<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>KennyNet</title>
	
	<link>http://www.kennynet.co.uk</link>
	<description>Ramblings of a PHP developer</description>
	<lastBuildDate>Thu, 08 Oct 2009 12:15:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/KennyNet" type="application/rss+xml" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">KennyNet</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Resetting unix passwords from a webpage</title>
		<link>http://www.kennynet.co.uk/2009/10/08/resetting-unix-passwords-from-a-webpage/</link>
		<comments>http://www.kennynet.co.uk/2009/10/08/resetting-unix-passwords-from-a-webpage/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 12:12:32 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[password reset]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=107</guid>
		<description><![CDATA[Been a while since my last post due to being extremely busy here over the past few months.
Recently we came across a little problem where one of our customers had a dedicated mailserver (courier, exim4) but had no ability to change their own passwords.
So I came up with two scripts, one bash (to do the [...]]]></description>
			<content:encoded><![CDATA[<p>Been a while since my last post due to being extremely busy here over the past few months.</p>
<p>Recently we came across a little problem where one of our customers had a dedicated mailserver (courier, exim4) but had no ability to change their own passwords.</p>
<p>So I came up with two scripts, one bash (to do the actual password reset) and one php (as a front-end to the bash script). These two scripts are designed to be used in tandem to provide adequate input validation and security. </p>
<p>You can find these two scripts here: <a href="http://www.kennynet.co.uk/misc/chpasswd.sh">chpasswd.sh</a> (backend bash script) and <a href="http://www.kennynet.co.uk/misc/chpasswd.txt">chpasswd.txt</a> (frontend php script).</p>
<p>Please note these are simple scripts, in both the lack of error reporting and lack of styling / CSS however they should be functional and with the use of su&#8217;ing to the user and avoidance of a setuid root script they should be secure. </p>
<p>If you implement these you are <strong>strongly advised</strong> to also implement some anti-bruteforce code or in the very least restrict access to internal use only.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2009/10/08/resetting-unix-passwords-from-a-webpage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu jaunty upgrade: Encrypted home not mounting</title>
		<link>http://www.kennynet.co.uk/2009/04/27/ubuntu-jaunty-upgrade-encrypted-home-not-mounting/</link>
		<comments>http://www.kennynet.co.uk/2009/04/27/ubuntu-jaunty-upgrade-encrypted-home-not-mounting/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 08:34:35 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[encrypted]]></category>
		<category><![CDATA[intrepid]]></category>
		<category><![CDATA[jaunty]]></category>
		<category><![CDATA[libpam-mount]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=98</guid>
		<description><![CDATA[The Problem
I took the plunge to upgrade my laptop to Jaunty yesterday and upon reboot the first thing I noticed was that my encrypted home partition was no longer being mounted. After enabling pam_mount&#8217;s debug option and tracing through the problem it turned out to be that mount.crypt was now unable to mount my encrypted [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The Problem</strong><br />
I took the plunge to upgrade my laptop to Jaunty yesterday and upon reboot the first thing I noticed was that my encrypted home partition was no longer being mounted. After enabling pam_mount&#8217;s debug option and tracing through the problem it turned out to be that mount.crypt was now unable to mount my encrypted partition.</p>
<p>mount.crypt fails to mount the partition because when it calls cryptsetup it fails to pass the keysize parameter so cryptsetup uses the default (256), which is fine if you used a 256 bit encryption key, but unfortunately I&#8217;d used a 128-bit encryption key so therefore cryptsetup fails to setup the encrypted volume correctly thus causing the subsequent call to mount to fail.</p>
<p><strong>The Solution</strong><br />
Fortunately I don&#8217;t let little things like that stop me from getting things working. Firstly I created a <a href="https://launchpad.net/~kmdm/+archive/ppa">patched libpam-mount package</a>  (LP: <a href="https://bugs.launchpad.net/bugs/367577">#367577</a>) that does pass the -s option through to cryptsetup, this then allows mount.crypt to successfully mount the encrypted volume.</p>
<p>However, pam_mount was still not able to mount the volume when I logged in, thankfully it only required a config tweak to match the new options that are now passed to mount.crypt, so my new pam_mount.conf.xml <volume...> config block now looks like this:-</p>
<pre>
&lt;volume
    user="kenny"
    fstype="crypt"
    path="/dev/sda3"
    mountpoint="/home/kenny"
    options="cipher=aes,hash=ripemd160,fsk_cipher=aes-128-ecb,fsk_hash=md5,
keyfile=/home/kenny.key"
/&gt;
</pre>
<p>(Annoyingly hash=ripemd160 has to be passed because cryptsetup defaults to that but mount.crypt defaults to and passes through &#8220;plain&#8221; unless told otherwise.)</p>
<p>Once this change was made (and the fixed packages installed), pam_mount was once again able to mount my encrypted home directory when I log in.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2009/04/27/ubuntu-jaunty-upgrade-encrypted-home-not-mounting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu, lirc and the Antec Black Fusion (15c2:0038)</title>
		<link>http://www.kennynet.co.uk/2009/03/30/ubuntu-lirc-and-the-antec-black-fusion-152c0038/</link>
		<comments>http://www.kennynet.co.uk/2009/03/30/ubuntu-lirc-and-the-antec-black-fusion-152c0038/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 20:12:40 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[antec]]></category>
		<category><![CDATA[imon]]></category>
		<category><![CDATA[lirc]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=89</guid>
		<description><![CDATA[After getting my Antec Black Fusion, I just couldn&#8217;t get it to work in Ubuntu with lirc 0.8.4a, so I went ahead and created some simple packages for lirc 0.8.5pre1 which do appear to work with this case / device.
Notice: Please note in preparing these lirc 0.8.5pre1 packages I&#8217;ve dropped a fair few of the [...]]]></description>
			<content:encoded><![CDATA[<p>After getting my Antec Black Fusion, I just couldn&#8217;t get it to work in Ubuntu with lirc 0.8.4a, so I went ahead and created some simple packages for lirc 0.8.5pre1 which do appear to work with this case / device.</p>
<p><strong>Notice: Please note in preparing these lirc 0.8.5pre1 packages I&#8217;ve dropped a fair few of the Ubuntu specific enhancements to lirc since this is intended as a fix solely for adding support for this device. Debdiffs welcome. <img src='http://www.kennynet.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </strong></p>
<p>Firstly add my repository key to apt so that the packages authenticate:</p>
<pre>
$ wget -O - http://packages.kennynet.co.uk/repository.key | sudo apt-key
add -
</pre>
<p>(note: trailing dash)</p>
<p>Next grab the sources.list entries for my repository so you can download the 0.8.5pre1 packages:</p>
<pre>
$ sudo wget -O /etc/apt/sources.list.d/kennynet-testing.list
 http://packages.kennynet.co.uk/intrepid-testing.list
</pre>
<p>Now we&#8217;re ready to install the packages as follows:</p>
<pre>
$ sudo apt-get update
$ sudo apt-get install lirc lirc-modules-source
</pre>
<p>With these packages installed, you only need the following line in /etc/lircd.conf:-</p>
<pre>
include "/usr/share/lirc/remotes/imon/lircd.conf.imon-antec-veris"
</pre>
<p>I&#8217;ve also made a custom (somewhat hacky) startup script which&#8217;ll launch the required two lircd daemons for the two lirc devices created under /dev.</p>
<p>You can download the script here, just put it in /etc/init.d/: <a href="http://www.kennynet.co.uk/misc/lirc-imon">lirc-imon</a></p>
<p>Now make it executable and set it to run on startup:</p>
<pre>
$ sudo chmod +x /etc/init.d/lirc-imon
$ sudo update-rc.d -f lirc remove
$ sudo update-rc.d lirc-imon defaults 51
</pre>
<p>This&#8217;ll disable the default lirc init.d script and enable the lirc-imon one that I&#8217;ve created.</p>
<p>From then on I&#8217;d make sure it&#8217;s loaded the new modules / started lirc as follows then test it out using irw:-</p>
<pre>
$ sudo /etc/init.d/lirc stop
$ sudo modprobe -r lirc_dev lirc_imon
$ sudo /etc/init.d/lirc-imon start
$ irw
</pre>
<p>Press some buttons, they should now show up.</p>
<p>All works for me, let me know how it goes&#8230; there are numerous debug steps at each stage if it doesn&#8217;t work but I&#8217;ve left these out to try and keep the e-mail relatively short. We can go through those if you still experience problems. Please leave comments if you have any questions.</p>
<p>I&#8217;ll package the very latest imonlcd patch for lcdproc and upload that to my testing repositories soon and make another quick post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2009/03/30/ubuntu-lirc-and-the-antec-black-fusion-152c0038/feed/</wfw:commentRss>
		<slash:comments>59</slash:comments>
		</item>
		<item>
		<title>Iomega StorCenter Pro 200rl root access</title>
		<link>http://www.kennynet.co.uk/2009/03/13/iomega-storcenter-pro-200rl-root-access/</link>
		<comments>http://www.kennynet.co.uk/2009/03/13/iomega-storcenter-pro-200rl-root-access/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 21:29:41 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[root]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=86</guid>
		<description><![CDATA[So we got one of these NAS boxes at work and like all self respecting sysadmins we wanted root access on the box ideally with SSH, unfortunately the NAS server doesn&#8217;t support this. However it is trivial to obtain root access by using an Ubuntu live CD as follows.
Firstly boot off the live CD and [...]]]></description>
			<content:encoded><![CDATA[<p>So we got one of these NAS boxes at work and like all self respecting sysadmins we wanted root access on the box ideally with SSH, unfortunately the NAS server doesn&#8217;t support this. However it is trivial to obtain root access by using an Ubuntu live CD as follows.</p>
<p>Firstly boot off the live CD and once you have your live CD desktop open up a terminal window, we now need access to the system drive on the NAS box which we can acquire as follows:-</p>
<pre>$ sudo apt-get install mdadm
$ sudo mdadm --assemble --scan
$ sudo mount /dev/md3 /mnt</pre>
<p>Next we need to make sure we&#8217;re working on the NAS system drive for all our commands so let&#8217;s chroot into it:-</p>
<pre>$ sudo chroot /mnt</pre>
<p>To reset the root password we need to run:-</p>
<pre> # passwd</pre>
<p>To enable SSH (which is already installed) on startup we need to run:-</p>
<pre># update-rc.d ssh defaults 16</pre>
<p>Finally we cleanup and reboot the NAS server:-</p>
<pre># exit
$ sudo umount /mnt
$ sudo reboot</pre>
<p>Don&#8217;t forget to remove/eject the CD when the Ubuntu live CD prompts you to.</p>
<p>Now once the NAS reboots into its native OS (which happens to be Debian) you&#8217;ll find you&#8217;ll be able to login to the box as root with all the power that comes with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2009/03/13/iomega-storcenter-pro-200rl-root-access/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP app Licensing Faux-pas</title>
		<link>http://www.kennynet.co.uk/2009/03/10/php-app-licensing-faux-pas/</link>
		<comments>http://www.kennynet.co.uk/2009/03/10/php-app-licensing-faux-pas/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 13:48:00 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[licensing]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=82</guid>
		<description><![CDATA[One of the php web applications we use in the office requires a license to work, it locks its license to the hostname and ip address of the server on which it&#8217;s run.  When the license key is first entered it phones home to set the hostname and ip address on the licensing server and [...]]]></description>
			<content:encoded><![CDATA[<p>One of the php web applications we use in the office requires a license to work, it locks its license to the hostname and ip address of the server on which it&#8217;s run.  When the license key is first entered it phones home to set the hostname and ip address on the licensing server and then stores a valid hash of the license.</p>
<p>We recently restructured our network and changed the ip address thus causing the app to complain the license was invalid, deleting the licensing file caused it to talk with the licensing server again but it was no use the licensing server still held the old ip address which was no longer correct. At this point I sent an e-mail off to their customer support team to get the information changed.</p>
<p>However, I couldn&#8217;t resist  taking a quick peek under the hood. To their credit the app is largely open source and readable except for the code that manages the license which is encrypted.  I removed the license file, fired up wireshark which logged the following conversation to their license server (anonymised to protect the guilty):-</p>
<pre>GET /XXXXXX.php?license_key=Base64String&#038;host_name=?Base64String&#038;
host_ip=Base64String</pre>
<p>Which generated the following reply:-</p>
<pre>license-key|host-name|old-ip-address</pre>
<p>On the face of it this seems quite easy to attack given it sends the current hostname/ip to the licensing server it&#8217;d be a trivial PHP script to send back what we assume the app would want to see:-</p>
<pre>$key = base64_decode(urldecode($_GET['license_key']));
$host = base64_decode(urldecode($_GET['host_name']));
$ip = base64_decode(urldecode($_GET['host_ip']));

echo "$key|$host|$ip";</pre>
<p>All that remains to do is set the script up on our server, and add an entry into our /etc/hosts file so that the licensing server domain name now points at our server. Once done after removing the license file I hit refresh and surprise surprise the app accepted the license response and things continued as normal.</p>
<p>This is particularly weak scheme since it doesn&#8217;t even run over SSL so capturing with wireshark is trivial. The other fundamental problem is that the class which converses with the licensing server is not encrypted so that would represent another point of attack which wouldn&#8217;t require setting up a fake licensing server &#8211; just hijack the response methods.</p>
<p>To their credit the license key itself is validated using a hash to determine what level of features you have access to but once you&#8217;ve bought one key you are then able to apply the methods above to copy the key to as many different locations as you wish.</p>
<p>Any comments identifying the application in question will be removed or censored, this is not an aid to bypassing licensing requirements more a discussion of the security implications of how this particular method was implemented.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2009/03/10/php-app-licensing-faux-pas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web App config files</title>
		<link>http://www.kennynet.co.uk/2009/01/21/web-app-config-files/</link>
		<comments>http://www.kennynet.co.uk/2009/01/21/web-app-config-files/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 21:14:44 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[config file]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web app]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=78</guid>
		<description><![CDATA[So like most people when I write my web applications I create a config.inc.php of some description and put that in the directory with the application. However, when it comes to roll out the app this causes problems due to the config differences between the live and development environments so the config file needs to [...]]]></description>
			<content:encoded><![CDATA[<p>So like most people when I write my web applications I create a config.inc.php of some description and put that in the directory with the application. However, when it comes to roll out the app this causes problems due to the config differences between the live and development environments so the config file needs to be changed once the new version has been put live.</p>
<p>This isn&#8217;t ideal so the first obvious thing to do is to move the config file out of the web application directory to somewhere else (for example: /etc/webapp.conf). Now when a version of the web app is released you simply just have to untar the web app tarball into the correct place and everything will just work without any post-install manual tweaking.</p>
<p>The problem with this approach is that it doesn&#8217;t work for multi-developer environments where a developer might need to tweak the config file for a new feature they&#8217;re testing, but the web app is now looking at the /etc/webapp.conf file no matter what developer it is. </p>
<p>The solution I then came up with was another config file, say called .dev-config.inc.php which is (optionally) kept in the same directory as the web app but excluded from your version control software so it&#8217;s never checked in. Then you simple change the web app to check for this file and if it doesn&#8217;t exist load the main config file so now a developer can create a config file for just their tree. For example:-</p>
<pre>
if(file_exists(dirname(__FILE__)."/.dev-config.inc.php")) {
    require_once(dirname(__FILE__)."/.dev-config.inc.php);
} else {
    require("/etc/webapp.conf");
}
</pre>
<p>Now once we have this setup everything works and developers can change the config files if they need too (e.g. database dsn&#8217;s) and the live system can be deployed by simply untar&#8217;ing a tarball.</p>
<p>The next thing I noticed was if I need to add a new config file option I need to add it in all the config files, even if it&#8217;s just a system config option that won&#8217;t change no matter what environment it&#8217;s in. This is a bit of chore given I&#8217;m just a lazy developer&#8230;</p>
<p>So the next change I make to the config file system is to reinstate the config.inc.php in the web app directory with one key difference, it now has the following design pattern and it is responsible for including our main config file:-</p>
<pre>
if(file_exists(dirname(__FILE__)."/.dev-config.inc.php")) {
    require_once(dirname(__FILE__)."/.dev-config.inc.php);
} else {
    require("/etc/webapp.conf");
}

$config = array(
    "A_CONFIG_OPTION"=>TRUE,
    "IS_THIS_OVERKILL"=>"MAYBE"
);

foreach($config as $const=>$value)
    if(!defined($const))
        DEFINE($const, $value);
</pre>
<p>Now this config file will first load our main web app config file (either /etc/webapp.conf or .dev-config.inc.php) and fill in all the missing (default/system) config options that weren&#8217;t needed to be changed in the per-environment config settings. Should that need change, simply just define them and this config file will not set them.</p>
<p><strong>Questions</strong><br />
1. Is this over the top?<br />
2. How does everyone else handle config files?<br />
3. Do their methods solve the issues presented above?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2009/01/21/web-app-config-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dead Space with Arrow Keys!</title>
		<link>http://www.kennynet.co.uk/2008/12/22/dead-space-with-arrow-keys/</link>
		<comments>http://www.kennynet.co.uk/2008/12/22/dead-space-with-arrow-keys/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 23:23:29 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[arrow keys]]></category>
		<category><![CDATA[controls.rmp]]></category>
		<category><![CDATA[dead space]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=68</guid>
		<description><![CDATA[Having received Dead Space for my Birthday I was disappointed to find that there was no way to use the arrow keys to play especially since I&#8217;m left handed and that is far more natural to me.
However, not being one to give up at the first hurdle Google lead me this page which gives instructions [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_69" class="wp-caption alignright" style="width: 310px"><a href="http://www.kennynet.co.uk/wp-content/uploads/2008/12/deadspace.png"><img class="size-medium wp-image-69" title="Dead Space with Arrow Keys" src="http://www.kennynet.co.uk/wp-content/uploads/2008/12/deadspace-300x242.png" alt="Dead Space with Arrow Keys" width="300" height="242" /></a><p class="wp-caption-text">Dead Space with Arrow Keys</p></div>
<p>Having received Dead Space for my Birthday I was disappointed to find that there was no way to use the arrow keys to play especially since I&#8217;m left handed and that is far more natural to me.</p>
<p>However, not being one to give up at the first hurdle Google lead me <a href="http://my.opera.com/rejzor/blog/how-to-play-dead-space-with-arrow-keys">this page</a> which gives instructions for playing Dead Space with arrow keys using GlovePIE to remap the keys as you press them. It&#8217;s a good workaround but it&#8217;s simply not ideal.</p>
<p>The file responsible for storing your key mappings is controls.rmp located under &#8220;C:\Documents and Settings\&lt;your username&gt;\Local Settings\Application Data\Electronic Arts\Dead Space&#8221;, so I began examing this file, how it changed depending what the keys were set to and after an hour or two of playing about I discovered not only the offsets storing the Up/Down/Left/Right key mappings but also the correct values for the arrow keys &#8211; AND THEY WORK.</p>
<p>To make these changes for yourself you&#8217;ll need a hex editor like <a href="http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm">XVI32</a>, set the following values at the following offsets in the controls.rmp file (OFFSET:VALUE):-</p>
<pre>5C: CB
AC: D0
14C: C8
23C: CD</pre>
<p>Now save the file and load up Dead Space, you should find you&#8217;re now able to use the arrow keys to move around. Alternatively if that&#8217;s too much like hard work you can download my pre-modified controls.rmp file below which is set to use the arrow keys &#8211; simply customise the other keys how you would like.</p>
<p><strong>Download: </strong><a href="http://www.kennynet.co.uk/misc/controls.rmp">controls.rmp</a>.</p>
<p><strong>Update:</strong><br />
If you&#8217;d like to use the Enter/Return key as your reload key, make the following change using XVI32:-</p>
<pre>
E8: 1C
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2008/12/22/dead-space-with-arrow-keys/feed/</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
		<item>
		<title>IWF “block” Virgin Killer wikipedia page</title>
		<link>http://www.kennynet.co.uk/2008/12/08/iwf-block-virgin-killer-wikipedia-page/</link>
		<comments>http://www.kennynet.co.uk/2008/12/08/iwf-block-virgin-killer-wikipedia-page/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 13:05:02 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[Incompetence]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[iwf]]></category>
		<category><![CDATA[scorpions]]></category>
		<category><![CDATA[wikipedia]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=59</guid>
		<description><![CDATA[So I just read that the IWF have decided to block the Virgin Killer wikipedia page for what they claim is indecent coverart. Whether it is or is not, is out of scope for this posting.
The problem is they seem to be exclusively targeting wikipedia with this block since the image is easily available from [...]]]></description>
			<content:encoded><![CDATA[<p>So I <a href="http://www.theregister.co.uk/2008/12/07/brit_isps_censor_wikipedia/">just read</a> that the IWF have decided to block the <a href="http://en.wikipedia.org/wiki/Virgin_Killer">Virgin Killer</a> wikipedia page for what they claim is indecent coverart. Whether it is or is not, is out of scope for this posting.</p>
<p>The problem is they seem to be exclusively targeting wikipedia with this block since the image is easily available from <a href="http://www.amazon.com/Virgin-Killer-Scorpions/dp/B0000073NL">other</a> <a href="http://images.google.co.uk/images?gbv=2&amp;hl=en&amp;safe=off&amp;sa=X&amp;oi=spell&amp;resnum=0&amp;ct=result&amp;cd=1&amp;q=virgin+killer">locations</a> not to mention peoples&#8217; homes.</p>
<p>The result of the block is that due most of UK&#8217;s traffic going via the <a href="http://en.wikipedia.org/wiki/Cleanfeed_(content_blocking_system)">Cleanfeed content blocking system</a> wikipedia has been forced to <a href="https://bugzilla.wikimedia.org/show_bug.cgi?id=16569">prevent editing articles</a> to UK contributors because they now effectively share a few IP addresses and do not pass on the real IP address as most proxies should.</p>
<p>The other problem is that they have only blocked the article text and not the <a href="http://upload.wikimedia.org/wikipedia/en/3/33/Virgin_Killer.jpg">actual image</a> which is still accessible from wikipedia&#8217;s servers. Infact, had they blocked the actual image to start with the editing problem may never have existed. It&#8217;s still possible to view the article text without resorting to technology like <a href="http://www.torproject.org/">tor</a> by using the <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Virgin_Killer">https:// version</a> of the site instead which ofcourse cannot be transparently filtered. The irony here is that that site renders the full article + the actual image since the actual image hasn&#8217;t been blocked.</p>
<p>Far more people have now seen this image on the wikipedia page than would have if this block was never attempted, this block has attracted alot of media attention causing the views to that wikipedia page to <a href="http://stats.grok.se/en/200812/Virgin_Killer">sky rocket </a>in the past 24-48 hours.</p>
<p>All in all I don&#8217;t think they&#8217;ve accomplished a great deal besides drawing attention to the very image they tried to prevent people seeing by raising the profile of that image.</p>
<p><strong>Update: </strong>It appears that the image on Amazon (linked above) has now been removed.</p>
<p><strong>Update 2:</strong> The IWF have now decided to remove this page from their block list:-</p>
<blockquote><p>Following representations from Wikipedia, IWF invoked its <a href="http://www.iwf.org.uk/public/page.148.341.htm">Appeals Procedure</a> and has given careful consideration to the issues involved in this case. The procedure is now complete and has confirmed that the image in question is potentially in breach of the Protection of Children Act 1978. However, the IWF Board has today (9 December 2008) considered these findings and the contextual issues involved in this specific case and, in light of the length of time the image has existed and its wide availability, the decision has been taken to remove this webpage from our list.</p>
<p>IWF’s overriding objective is to minimise the availability of indecent images of children on the internet, however, on this occasion our efforts have had the opposite effect. We regret the unintended consequences for Wikipedia and its users. Wikipedia have been informed of the outcome of this procedure and IWF Board’s subsequent decision.</p></blockquote>
<p>- <a href="http://www.iwf.org.uk/media/news.251.htm">http://www.iwf.org.uk/media/news.251.htm</a></p>
<p>I suppose that&#8217;s one way to backtrack without entirely admitting you were wrong in the first place, may they carefully consider their blocks in the future lest they repeat the same mistake.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2008/12/08/iwf-block-virgin-killer-wikipedia-page/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>asterisk cdr_mysql on Ubuntu 8.04 (Hardy)</title>
		<link>http://www.kennynet.co.uk/2008/12/08/asterisk-cdr_mysql-on-ubuntu-804-hardy/</link>
		<comments>http://www.kennynet.co.uk/2008/12/08/asterisk-cdr_mysql-on-ubuntu-804-hardy/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 08:56:15 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[cdr]]></category>
		<category><![CDATA[hardy]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[uniqueid]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=53</guid>
		<description><![CDATA[After a successful asterisk installation I was asked to also add call recording so that calls could be monitored and reviewed.To allow easy browsing of recorded calls it&#8217;s also handy to setup CDR to store call records in a database and since MixMonitor() by records calls named after the UNIQUEID of the call it&#8217;s important [...]]]></description>
			<content:encoded><![CDATA[<p>After a successful asterisk installation I was asked to also add call recording so that calls could be monitored and reviewed.To allow easy browsing of recorded calls it&#8217;s also handy to setup CDR to store call records in a database and since MixMonitor() by records calls named after the UNIQUEID of the call it&#8217;s important this ID is recorded as well.</p>
<p>Unfortunately after some simple testing it seems that cdr_mysql in the asterisk-mysql package has not been compiled to log this important ID.Fortunately we can fix this ourselves using the Ubuntu packaging tools. Firstly we need to install the packages needed to edit the package:-</p>
<pre>sudo apt-get install devscripts debhelper fakeroot pbuilder dpatch</pre>
<p>Next we should download the source package:-</p>
<pre>apt-get source asterisk-mysql</pre>
<p>Now we can set about editing the package, a quick look in debian/patches tells us that this package uses dpatch to maintain its patches &#8211; so we should too:-</p>
<pre>cd asterisk-addons-1.4.5/
dpatch-edit-patch loguniqueid</pre>
<p>This will drop us into a sub-shell where we can make our code changes for dpatch to record for us in a patch file. All we need to do is edit the file cdr_addon_mysql.c and at around line 52 near the #define DATE_FORMAT line we should add:-</p>
<pre>#define MYSQL_LOGUNIQUEID 1</pre>
<p>Save the file and quit out of the sub-shell created by dpatch, dpatch will now create our patch file under debian/patches/. All that&#8217;s left for us to do is edit debian/patches/00list and insert our new patch file into the list of patch files, I put mine first so the 00list file now looks like this:-</p>
<pre>loguniqueid.dpatch
nomarch.dpatch
include_asterisk</pre>
<p>With that done we should bump the changelog to reflect our changes:-</p>
<pre>dch -i</pre>
<p>Add a description after the top blank * indent like &#8220;Added logging of uniqueid&#8221;, also, it&#8217;s advisable to append ~uniqueid1 (or anything you like really, the ~ is important) so that our package doesn&#8217;t conflict with any new package versions Ubuntu might release in future (Make sure that the Ubuntu codename still says &#8220;hardy&#8221; and not &#8220;intrepid&#8221; or indeed &#8220;jaunty&#8221; too). Save the changelog. </p>
<p>We are now ready to build our new package:-</p>
<pre>debuild -S -uc -us</pre>
<p>If all went well our new dsc file has been created in the parent directory, so all that remains is to get pbuilder building the package. If you&#8217;ve never used pbuilder before you need to run:-</p>
<pre>sudo pbuilder create</pre>
<p>If you have run pbuilder before you should check everything is up to date by running:-</p>
<pre>sudo pbuilder update</pre>
<p>With pbuilder up to date, let&#8217;s build our new package:-</p>
<pre>sudo pbuilder build ../asterisk-addons_1.4.5~uniqueid1.dsc</pre>
<p>After a bit of compiling if all was successful pbuilder will report it has successfully built the package, so let&#8217;s install it:-</p>
<pre>sudo dpkg -i /var/cache/pbuilder/result/asterisk-mysql*.deb</pre>
<p>Once the package is installed all that remains is to restart asterisk to pickup the new module:-</p>
<pre>sudo asterisk -rx 'restart when convenient'</pre>
<p>Now test your cdr_mysql logging again, you should find the uniqueid is being logged.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2008/12/08/asterisk-cdr_mysql-on-ubuntu-804-hardy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP, PDO &amp; Nested Transactions</title>
		<link>http://www.kennynet.co.uk/2008/12/02/php-pdo-nested-transactions/</link>
		<comments>http://www.kennynet.co.uk/2008/12/02/php-pdo-nested-transactions/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 13:09:43 +0000</pubDate>
		<dc:creator>Kenny Millington</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[pdo]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[transactions]]></category>

		<guid isPermaLink="false">http://www.kennynet.co.uk/?p=38</guid>
		<description><![CDATA[I&#8217;ve been using PDO as my database library and it works reasonably well (as long as you remember it&#8217;s not a full blown database abstraction library), however recently I needed to use nested transactions to ensure that the database remains consistent while doing a series of SQL statements.
Unfortunately PDO does not support nested transactions although [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using <a href="http://www.php.net/pdo">PDO</a> as my database library and it works reasonably well (as long as you remember it&#8217;s not a full blown database abstraction library), however recently I needed to use nested transactions to ensure that the database remains consistent while doing a series of SQL statements.</p>
<p>Unfortunately PDO does not support nested transactions although <a href="http://www.postgresql.org">PostgreSQL</a> and <a href="http://www.mysql.com">MySQL</a> do. I decided to extend the PDO class to support nested transactions while also using PDO to keep track of the first transaction. I came up with the following class (released under the <a href="http://www.gnu.org/licenses/gpl-3.0-standalone.html">GNU General Public License, Version 3</a>):-</p>
<pre>class MyPDO extends PDO {
    // Database drivers that support SAVEPOINTs.
    protected static $savepointTransactions = array("pgsql", "mysql");

    // The current transaction level.
    protected $transLevel = 0;

    protected function nestable() {
        return in_array($this-&gt;getAttribute(PDO::ATTR_DRIVER_NAME),
                        self::$savepointTransactions);
    }

    public function beginTransaction() {
        if(!$this-&gt;nestable() || $this-&gt;transLevel == 0) {
            parent::beginTransaction();
        } else {
            $this-&gt;exec("SAVEPOINT LEVEL{$this-&gt;transLevel}");
        }

        $this-&gt;transLevel++;
    }

    public function commit() {
        $this-&gt;transLevel--;

        if(!$this-&gt;nestable() || $this-&gt;transLevel == 0) {
            parent::commit();
        } else {
            $this-&gt;exec("RELEASE SAVEPOINT LEVEL{$this-&gt;transLevel}");
        }
    }

    public function rollBack() {
        $this-&gt;transLevel--;

        if(!$this-&gt;nestable() || $this-&gt;transLevel == 0) {
            parent::rollBack();
        } else {
            $this-&gt;exec("ROLLBACK TO SAVEPOINT LEVEL{$this-&gt;transLevel}");
        }
    }
}</pre>
<p>This  code will only attempt to use the SAVEPOINT code if you&#8217;re using a database driver that supports it (it should probably version check the database server) this then means that in your code you can do things like:-</p>
<pre>$pdo = new MyPDO(DB_DSN, DB_USER, DB_PASS);
$pdo-&gt;beginTransaction();
try {
    $pdo-&gt;exec(...);
    $pdo-&gt;exec(...);

    $pdo-&gt;beginTransaction();
    try {
        $pdo-&gt;exec(...);
        $pdo-&gt;exec(...);
        $pdo-&gt;exec(...);
        $pdo-&gt;commit();
    } catch(PDOException $e) {
        // If this statement fails, rollback...
        // NOTE: This will only rollback statements made in the
        //       inner try { block and not the outer one.
        $pdo-&gt;rollBack();
    }

    $pdo-&gt;commit();
} catch (PDOException $e) {
    $pdo-&gt;rollBack();
}</pre>
<p><strong>NB:</strong> I&#8217;ve tweaked the code slightly when transferring it to my blog and I haven&#8217;t tested it, so there could be some minor errors &#8211; please leave comments if you spot any. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kennynet.co.uk/2008/12/02/php-pdo-nested-transactions/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
