Monday 17 March 2014

Keep files secure and edit GPG Files easily with Vim



Its important to ensure any sensitive data is encrypted in files. That being said I was surprised by how easy it is to be able to use vim to edit gpg files. gnupg.vim is a Plugin for transparent editing of gpg encrypted files.

On Arch Linux I just :
  • Created a plugin directory for Vim as one did not already exist
$ sudo mkdir ~/.vim/plugin/
  • Copied the gnupg.vim script to the plugin folder
  • Then I was easily able to edit and save the gpg files :)
  • Version wise I was using gpg2 with vim 7.4.
 Useful information on the plugin :
  • The filename must have a ".gpg", ".pgp" or ".asc" suffix
  • The script turns off viminfo and swapfile to increase security.
  • When opening such a file the content is decrypted
     
  • When opening a new file the script will ask for the recipients of the encrypted file
  • The file content will be encrypted to all recipients before it is written

Hopefully this will make it easier for you to keep sensitive data private. 

Tuesday 11 March 2014

Troubleshooting DHCP Network issues on Arch Linux



Its a major issue if DHCP stops working on your Arch Linux setup. If you are using Network Manager and dhcpcd (DHCP client) these steps should hopefully get your back on the network.

Check the logs :

$ sudo journalctl -b | egrep -i "dhclient|dhcpd"


If you do not see traffic similar to :

Mar 11 21:17:20 arch dhclient[4083]: DHCPDISCOVER on wlp1s0 to 255.255.255.255 port 67 interval 6
Mar 11 21:17:22 arch dhclient[4083]: DHCPREQUEST on wlp1s0 to 255.255.255.255 port 67
Mar 11 21:17:22 arch dhclient[4083]: DHCPOFFER from 192.168.0.1
Mar 11 21:17:22 arch dhclient[4083]: DHCPACK from 192.168.0.1


Then there is a good chance that the Network Manager is not configured for DHCP.

Check :

$ sudo vi /etc/NetworkManager/NetworkManager.conf

Contains :

[main]
plugins=keyfile
managed=true
dhcp=dhcpcd


Once updated restart the service

$ sudo systemctl restart NetworkManager

You should now hopefully have a network connection!

Monday 3 March 2014

get_iplayer - RTMP_ReadPacket, failed to read RTMP packet header

If you use the excellent application get_iplayer to download content from the BBC's iPlayer service you may from early June 2013 find issues downloading content.

ERROR: RTMP_ReadPacket
  • The following is a typical error :
WARNING: ffmpeg does not exist - not converting flv file
INFO: File name prefix =
History_of_Scotland_

Street_b022ff9g_default
RTMPDump v2.4
(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
Connecting ...
INFO: Connected...
Caught signal: 13, cleaning up, just a second...
ERROR: WriteN, RTMP send error 32 (42 bytes)
ERROR: RTMP_ReadPacket, failed to read RTMP packet header
INFO: Command exit code 1 (raw code = 256)


Solution
  •  Run the following command :

$ get_iplayer --prefs-add --rtmp-tv-opts="--swfVfy http://www.bbc.co.uk/emp/releases/iplayer/revisions/617463_618125_4/617463_618125_4_emp.swf" 

  • This updates your options file :

$ cat ~/.get_iplayer/options
output /home/cwishaw/iplayer
rtmptvopts --swfVfy http://www.bbc.co.uk/emp/releases/iplayer/revisions/617463_618125_4/617463_618125_4_emp.swf


  •  Note : I also use the options file to set my default download folder which is really useful
Background
  • The BBC iPlayer service uses SWF (Shockwave Flash) developed by Macromedia then purchased by Adobe
  • SWF Verification can protect access content by only allowing authorized software to access it
  • Content is accessed only by specific SWF files and is controlled by using an authorization key
  • The video download will fail without the authorization key
  • A Real-Time Messaging Protocol (RTMP) client is used by Flash for streaming video
  • The RTMP client used for get_iplayer is rtmpdump
  • The iPlayer media servers require SWF Verification with an authorized flash file e.g. 617463_618125_4_emp.swf
  • get_iplayer uses the SWF URL to provide to rtmpdump with the URL
  • The SWF verification file can be changed by the BBC which has occurred on this occasion
  • The default SWF file can be overwritten as detailed above in the options file

Further Information