<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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"
	>

<channel>
	<title>Inode Ltd</title>
	<atom:link href="http://inode.co.nz/feed" rel="self" type="application/rss+xml" />
	<link>http://inode.co.nz</link>
	<description>Internet, Linux, Security Consultancy &#38; Services</description>
	<pubDate>Sun, 25 Jul 2010 22:26:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Wifi &#8216;Hole 196&#8242; opens WPA2</title>
		<link>http://inode.co.nz/wifi-hole-196-opens-wpa2</link>
		<comments>http://inode.co.nz/wifi-hole-196-opens-wpa2#comments</comments>
		<pubDate>Sun, 25 Jul 2010 22:26:07 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=56</guid>
		<description><![CDATA[It looks like a active attack of an underlying protocol vulnerability in WPA2 has just been announced, by Md. Sohail Ahmad of AirTight Networks. This represents a real risk to people relying on WPA2 (in any flavour) for their data communications security.
This affects WPA2 itself, and although full details won&#8217;t be announced for a few [...]]]></description>
			<content:encoded><![CDATA[<p>It looks like a active attack of an underlying protocol vulnerability in WPA2 has <a href="http://www.airtightnetworks.com/WPA2-Hole196">just been announced</a>, by Md. Sohail Ahmad of AirTight Networks. This represents a real risk to people relying on WPA2 (in any flavour) for their data communications security.</p>
<p>This affects WPA2 itself, and although full details won&#8217;t be announced for a few days it just serves as a reminder that the security landscape is constantly changing. Vulnerabilities are a fact of life, and upgrades to your security software are essential. If you cannot upgrade, you need to have another layer of protection.</p>
<p>Many people provide their wireless access points from dedicated hardware devices, for example the Linksys WRT54GL or increasingly directly from their ADSL modem. These devices are usually the simplest to configure and support, but they are probably the hardest to upgrade.</p>
<p>In a case such as this, its the whole protocol that has been declared faulty, allowing an attacker to bypass network encryption completely by demanding copies of each device&#8217;s PTKs (the transient encryption keys), and the only way around that is for <em>every</em> device on the wireless network to upgrade to a different protocol &#8212; and we don&#8217;t have one available right now. In practice I&#8217;d expect a &#8220;WPA3&#8243; to come up, with the specific vulnerability around group keys to be mitigated in some way. This will be delivered to PCs through your operating system updates, but that&#8217;s no use if you can&#8217;t upgrade your access points; and even though it&#8217;s often technically possible to turn up a new firmware for an old device, most hardware vendors would prefer if you just went out and bought a new unit &#8230;</p>
<p>So your workaround is to consider your wireless network to be as open as the old hub-based wired networks, or possibly even as dangerous as the raw Internet. Use a firewall to prevent applications on your PC from using the network without your approval, and make sure that every protocol you use with private data is software encrypted; HTTPS (use the EFF&#8217;s <a href="https://www.eff.org/https-everywhere">HTTPS-Everywhere</a> plugin for Firefox as a minimum), IMAPS|POPS for email &#8230; or perhaps run a VPN between wireless devices and the access point or server beyond.</p>
<p>In fact, for corporates it may make sense to <em>require</em> the use of a VPN over all wireless networks, after all they are already managing the PCs in question and can keep credentials/keys updated.</p>
<p>This isn&#8217;t a new message; this is an old message. The security problems of wireless are not new, and indeed aren&#8217;t even specific to wireless technology at all &#8212; it&#8217;s more an issue of the way that the security software is implemented in firmware, and is therefore difficult to manage by most users. There will be vulnerabilities in the software VPNs; but the fix/upgrade timescales for these will be far faster and more achievable.</p>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/wifi-hole-196-opens-wpa2/feed</wfw:commentRss>
		</item>
		<item>
		<title>CloudCamp Dunedin</title>
		<link>http://inode.co.nz/cloudcamp-dunedin</link>
		<comments>http://inode.co.nz/cloudcamp-dunedin#comments</comments>
		<pubDate>Thu, 22 Jul 2010 22:11:55 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[cloud]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=55</guid>
		<description><![CDATA[I went to CloudCamp Dunedin yesterday, which I think went very well. Ben Kepes did a great job of encouraging people through the Unconvention structure, and our lightning talk speakers covered a wide range of ideas between them. Just a shame that I had to leave before the wrapup (&#038; pizza!).
There were a lot of [...]]]></description>
			<content:encoded><![CDATA[<p>I went to <a href="http://cloudcamp.org/">CloudCamp</a> <a href="http://cloudcamp.org/dunedin/2010-07-22">Dunedin</a> yesterday, which I think went very well. Ben Kepes did a great job of encouraging people through the Unconvention structure, and our lightning talk speakers covered a wide range of ideas between them. Just a shame that I had to leave before the wrapup (&#038; pizza!).</p>
<p>There were a lot of different people present, and &#8220;the cloud&#8221; means some very different things to all of them. I tend to see the system architectural view first, where I worry about how to marshall the resources that go into the cloud, and how software has to be structured to make best use of this different type of environment. But it&#8217;s interesting to see how cloud <em>services</em> rather than cloud machines are empowering developers to be able to cut out the middleman of system administrators.</p>
<p>An analogy for that was voiced at the time; currently we&#8217;re all like factories running our own power generators, doing our own maintenance and finding our own fuel. But the cloud services move us to just grabbing electricity from the grid. We might still worry about the cost and service level of our power supply, but we don&#8217;t employ our own engineers &#8230;</p>
<p>(Personal input &#8212; my father had a long career as a mechanical engineer for factory power systems, and my father-in-law is a high-voltage electrical engineer)</p>
<p>With a long term background in system administration, I might feel a little threatened by this, but on the whole I can see that its a good thing to be able to move on. With my security hat on, I&#8217;m worried about developers exposing their code directly to large-scale on the Internet without the benefit of actually having it evaluated or engineered correctly, but then again that&#8217;s part of the free market &#8212; if they do a bad job their apps won&#8217;t succeed, if they do a good job all will be well.</p>
<p>The economics of cloud services are also interesting; your first hit is free, and for at least one established NZ web-based application provider I know, their entire target market&#8217;s usage is low enough to let them run systems with zero infrastructure cost. Think about that for a minute &#8212; they can prove their platform in an NZ marketplace, and only have to pay for staff time. That&#8217;s a tremendous economic advantage for a small business &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/cloudcamp-dunedin/feed</wfw:commentRss>
		</item>
		<item>
		<title>Ubuntu&#8217;s gnome-panel instability workaround</title>
		<link>http://inode.co.nz/ubuntus-gnome-panel-instability-workaround</link>
		<comments>http://inode.co.nz/ubuntus-gnome-panel-instability-workaround#comments</comments>
		<pubDate>Thu, 15 Jul 2010 02:18:26 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[gnome]]></category>

		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=53</guid>
		<description><![CDATA[I&#8217;ve been running Ubuntu 10.04 on my desktop since it came out, and about the only real annoyance I have is that occasionally the gnome-panel scrambles the order of my icons and applets. This is possibly because I keep switching the screen layout between a pair of external screens and the laptop screen itself, just [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been running Ubuntu 10.04 on my desktop since it came out, and about the only real annoyance I have is that occasionally the gnome-panel scrambles the order of my icons and applets. This is possibly because I keep switching the screen layout between a pair of external screens and the laptop screen itself, just using some scripts that invoke xrandr directly &#8230; but it still shouldn&#8217;t happen.</p>
<p>My workaround for this is to find the files that are modified when the panel attributes are changed, and put the old ones back! So, I sat in a shell finding current files in ~/.gconf using <code>find -mtime 0</code> until I&#8217;d identified the ~/.gconf/apps/panel directory (not ~/.gconf/apps/panel/applets as I initially thought) as being the place to look. I created a bzr repository in that directory and checked in all the files, and in my .bashrc I just run a quick status check to see if anything has been modified &#8230; if it has, I can run <code>bzr revert</code> to put it back!</p>
<p>Sadly just killing and restarting the gnome-panel doesn&#8217;t do enough to reset the session, you&#8217;ll have to log out completely to get the panel re-organised. Unless gnome-panel listens to a signal like HUP &#8230; and I&#8217;m not going to test that today!</p>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/ubuntus-gnome-panel-instability-workaround/feed</wfw:commentRss>
		</item>
		<item>
		<title>VoIP under pfSense</title>
		<link>http://inode.co.nz/voip-under-pfsense</link>
		<comments>http://inode.co.nz/voip-under-pfsense#comments</comments>
		<pubDate>Tue, 13 Jul 2010 06:05:13 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[pfSense]]></category>

		<category><![CDATA[VoIP]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=52</guid>
		<description><![CDATA[I used to have a Linksys WRT54GL at the edge of the network, running the Tomato firmware, and things were nice. Then I decided to switch to pfSense on a PC Engines ALIX 2C10 (see my earlier post), and &#8230;
Well, VoIP behaves very differently in this new regime, by which I mean SIP and RTP [...]]]></description>
			<content:encoded><![CDATA[<p>I used to have a Linksys WRT54GL at the edge of the network, running the <a href="http://www.polarcloud.com/tomato">Tomato firmware</a>, and things were nice. Then I decided to switch to <a href="http://pfsense.org/">pfSense</a> on a PC Engines ALIX 2C10 (see <a href="http://inode.co.nz/installing-pfsense-on-an-alix-board">my earlier post</a>), and &#8230;</p>
<p>Well, VoIP behaves very differently in this new regime, by which I mean SIP and RTP of course. I&#8217;ve spent far too long reading pages of badly-stated problems and non-helpful answers, and trying to get my head around just how badly NAT screws things up. And far too long changing settings trying to get improved behaviour &#8230;</p>
<p>Ultimately of course pfSense should behave the same way that Linux/Tomato does &#8212; things should just work without having to do any specific setup. But the timeout seems to be far more aggressive, and I think that was the real issue that started me down a long road &#8230;</p>
<p>I&#8217;ve been using a SIP proxy (<a href="http://siproxd.sf.net/">siproxd</a>), I&#8217;ve been NATting RTP &#038; SIP down to a single device, I&#8217;ve been using STUN servers &#8230; The siproxd seemed to be working perfectly but at the same time there was an upstream problem that prevented me receiving calls on one of my accounts, so that solution got ripped out. The NATting worked fine but was only appropriate for one device at a time, so I started trying to move SIP to a different source port. At one stage I was seeing non-NATted traffic on my firewall&#8217;s external interface, which was rumoured to be a specific SIP (UDP port 5060) exclusion in the codebase &#8230; but I can&#8217;t replicate that any more!</p>
<p>Thanks to a fair bit of handholding from Chris MacGreggor at VentureVoIP, I&#8217;ve finished up with a very clean setup &#8212; no STUN, no mention of NAT on the phones, anything like that. I have decreased the Registration timeouts to 500 seconds (that&#8217;s just over 8 minutes), and put in a couple of rules matching the VoIP destination networks to increase the firewall state timeout to 1800 seconds (30 minutes). This seems to be working well &#8230;</p>
<p>For the record, I&#8217;ve got a number of SIP devices here :-</p>
<ul>
<li>Snom 300
<ul>
<li>Inode Ltd account at VentureVoIP</li>
<li>Home account at VentureVoIP</li>
<li>Test account on 2talk</li>
</ul>
</li>
<li>Linksys SPA3102 (used as an ATA)
<ul>
<li>Home account at VentureVoIP</li>
</ul>
</li>
<li>Grandstream HT486, currently not configured</li>
<li>Nokia n900 mobile, currently not working
<ul>
<li>Inode Ltd account at VentureVoIP</li>
</ul>
</li>
</ul>
<p>So I still have a couple of steps left to take; the n900 thinks everyone is offline when it tries to call them, but then again I&#8217;ve never had this working yet so perhaps it&#8217;s not my changes that have caused this! And the old HT486 is just plugged backwards into the house phone wiring, but I no longer have any phones connected around the place (just a triplet of DECT phones connected to the Linksys SPA3102) so it&#8217;s not much of a priority.</p>
<p>But the basic lesson in migrating from a Linux-based working firewall into a BSD-based one seems to be &#8220;check the state table timeouts&#8221;!</p>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/voip-under-pfsense/feed</wfw:commentRss>
		</item>
		<item>
		<title>Installing pfSense on an ALIX board</title>
		<link>http://inode.co.nz/installing-pfsense-on-an-alix-board</link>
		<comments>http://inode.co.nz/installing-pfsense-on-an-alix-board#comments</comments>
		<pubDate>Thu, 08 Jul 2010 10:14:07 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[ALIX]]></category>

		<category><![CDATA[pfSense]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=51</guid>
		<description><![CDATA[The PC Engines ALIX single-board computers don&#8217;t have much in the way of interfaces, just ethernet, USB and a serial port, so if you&#8217;re not used to dealing with these things it can seem a little daunting to get an OS installed.
Here&#8217;s the procedure I use to get the pfSense firewall OS installed on something [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.pcengines.ch/alix.htm">PC Engines ALIX</a> single-board computers don&#8217;t have much in the way of interfaces, just ethernet, USB and a serial port, so if you&#8217;re not used to dealing with these things it can seem a little daunting to get an OS installed.</p>
<p>Here&#8217;s the procedure I use to get the <a href="http://pfsense.org/">pfSense</a> firewall OS installed on something like an ALIX 2D3. Note that I&#8217;m putting the full live distribution on a CF card, which may not be a good choice for you &#8212; CF cards have a limited write lifetime. You&#8217;ll need the following equipment :-</p>
<ul>
<li>ALIX system board</li>
<li>Power Supply of course</li>
<li>CF card, I&#8217;m using 1GB</li>
<li>CF card reader on your desktop machine</li>
<li>Null modem 9DB cable</li>
<li>A serial port on your desktop (I use a USB/Serial converter)</li>
<li>Serial port communications software (minicom works fine; on Ubuntu remember to make sure you have permission to read the /dev file &#8212; you may need to join the dialout group)</li>
<li>UTP Ethernet cable</li>
</ul>
<h2>Configure the ALIX board</h2>
<p>First, check that your ALIX machine is working and do a little setup. Don&#8217;t put the board into its case at this stage, as that usually blocks access to the CF card we&#8217;ll be using later. Be careful to keep the board on a non-conductive surface. Connect the serial cable to your PC, get the serial port communications software configured for 38400 baud, 8N1. Power on the ALIX machine and you should see this :-</p>
<blockquote>
<pre>PC Engines ALIX.2 v0.99h
640 KB Base Memory
261120 KB Extended Memory

01F0 - no drive found !
No boot device available, press Enter to continue.</pre>
</blockquote>
<p>If you don&#8217;t get something like that, look for the green lights on the ALIX board and check your comms settings. Once you get that working, it&#8217;s time to reboot the ALIX and change the baud rate. Take out the power (remember that PC Engines don&#8217;t recommend un/plugging the PSU connector at their end due to the risk of arcing, so do it at the mains end), and this time as the machine reboots press the &#8220;s&#8221; key while the memory check is counting up.</p>
<blockquote>
<pre>PC Engines ALIX.2 v0.99h
640 KB Base Memory
261120 KB Extended Memory

01F0 - no drive found !

BIOS setup:

(9) 9600 baud (2) 19200 baud *3* 38400 baud (5) 57600 baud (1) 115200 baud
*C* CHS mode (L) LBA mode (W) HDD wait (V) HDD slave (U) UDMA enable
(M) MFGPT workaround
(P) late PCI init
*R* Serial console enable
(E) PXE boot enable
(X) Xmodem upload
(Q) Quit</pre>
</blockquote>
<p>Press &#8220;9&#8243;, then &#8220;q&#8221;, then &#8220;y&#8221; to save &#8230; at which point you may as well power off again while you change the communication settings on your terminal down to 9600 baud!</p>
<blockquote>
<pre>*9* 9600 baud (2) 19200 baud (3) 38400 baud (5) 57600 baud (1) 115200 baud
*C* CHS mode (L) LBA mode (W) HDD wait (V) HDD slave (U) UDMA enable
(M) MFGPT workaround
(P) late PCI init
*R* Serial console enable
(E) PXE boot enable
(X) Xmodem upload
(Q) Quit

Save changes Y/N ?
Writing setup to flash... OK
x����x&lt;�������x������x������x���x���x</pre>
</blockquote>
<p>Confirm you can talk to the device once again, then power off and leave it alone for a little while.</p>
<h2>Configure the CF card</h2>
<p>Now we&#8217;re ready to install pfSense onto the CF card. I don&#8217;t want to boot my desktop from the pfSense LiveCD, I&#8217;m going to do this via a VM under <a href="http://virtualbox.org/">VirtualBox</a>. First, we need to identify how the CF card shows up in your normal desktop machine, so plug it in. If a filesystem is automounted (most CF cards come with a FAT32 filesystem on them by default) then unmount it. Have a look with dmesg to find out which device it has been connected as &#8212; mine comes in as /dev/sdc</p>
<blockquote><pre>$ dmesg|tail
[45748.609374] sd 3:0:0:0: [sdb] Attached SCSI removable disk
[45748.610134] sd 3:0:0:1: [sdc] Write Protect is off
[45748.610141] sd 3:0:0:1: [sdc] Mode Sense: 03 00 00 00
[45748.610146] sd 3:0:0:1: [sdc] Assuming drive cache: write through
[45748.613126] sd 3:0:0:1: [sdc] Assuming drive cache: write through
[45748.613136]  sdc: sdc1
[45748.615125]  sdc1: <bsd:bad subpartition - ignored
[45748.615131]  sdc5 >
[45748.618619] sd 3:0:0:1: [sdc] Assuming drive cache: write through
[45748.618629] sd 3:0:0:1: [sdc] Attached SCSI removable disk</pre>
</blockquote>
<p>Now you need to create a passthrough disk that will allow a VM guest machine to talk directly to /dev/sdc. This isn&#8217;t well covered through Google searches, but it is out there, and it&#8217;s in the VirtualBox documentation too &#8230;</p>
<blockquote><pre>$ sudo VboxManage internalcommands createrawvmdk \
-filename passthroughsdc.vmdk -rawdisk /dev/sdc -register</pre>
</blockquote>
<p>Make sure you create that passthroughsdc.vmdk in the correct directory, ~/.VirtualBox/HardDisks on my setup. You need to be root in order to connect to /dev/sdc, but once the disk file has been created you can chown it back to your ownership.</p>
<p>Now set up a VM guest for FreeBSD, giving it the passthroughsdc.vmdk as the hard drive, and the pfSense LiveCD on the CD drive. Start it up. When pfSense boots, select &#8220;i&#8221; for the Installer, choose &#8220;Easy Install&#8221; and let it rip through, copying files onto your CF drive. At the end, choose the &#8220;Embedded kernel&#8221;, and shutdown normally.</p>
<h2>Booting pfSense on the ALIX</h2>
<p>Now you can take the CF card and install it into the ALIX, carefully. Switch back to the serial console and power up &#8230;</p>
<blockquote><pre>PC Engines ALIX.2 v0.99h
640 KB Base Memory
261120 KB Extended Memory

01F0 Master 044A CF 2GB
Phys C/H/S 3933/16/63 Log C/H/S 983/64/63

F1   FreeBSD

Boot:   F1</pre>
</blockquote>
<p>pfSense should then boot, leaving you with the serial console options :-</p>
<blockquote><pre>Bootup complete

FreeBSD/i386 (pfSense.local) (console)

*** Welcome to pfSense 1.2.3-RELEASE-pfSense on pfSense ***

  LAN                      ->   vr0     ->      192.168.1.1
  WAN                      ->   vr1     ->      NONE(DHCP)

 pfSense console setup
***************************
 0)  Logout (SSH only)
 1)  Assign Interfaces
 2)  Set LAN IP address
 3)  Reset webConfigurator password
 4)  Reset to factory defaults
 5)  Reboot system
 6)  Halt system
 7)  Ping host
 <img src='http://inode.co.nz/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' />  Shell
 9)  PFtop
10)  Filter Logs
11)  Restart webConfigurator
12)  pfSense Developer Shell
13)  Upgrade from console
14)  Enable Secure Shell (sshd)

Enter an option: </pre>
</blockquote>
<p>Now you should be able to connect a UTP Ethernet cable to the LAN interface (vr0 will probably be the interface closest to the power connector) and the other end to your PC &#8212; note that this should provide an address (<em>and default route/DNS config &#8212; be careful if you thought your PC was supposed to be working via a different interface at the same time</em>) for you automatically. Point your web browser to http://192.168.1.1 and enjoy your pfSense firewall!</p>
<p>By the way, all my PC Engine hardware comes from <a href="http://nicegear.co.nz/">Nicegear</a>, NZ&#8217;s VoIP and Open Source Hardware specialists.</p>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/installing-pfsense-on-an-alix-board/feed</wfw:commentRss>
		</item>
		<item>
		<title>Running Nagios3 under Nginx &#038; FastCGI</title>
		<link>http://inode.co.nz/running-nagios3-under-nginx-fastcgi</link>
		<comments>http://inode.co.nz/running-nagios3-under-nginx-fastcgi#comments</comments>
		<pubDate>Wed, 07 Jul 2010 02:00:19 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[fastcgi]]></category>

		<category><![CDATA[nagios]]></category>

		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=50</guid>
		<description><![CDATA[It is quite possible to run Nagios3&#8217;s web interface directly from Nginx and a FastCGI server, rather than having to involve a web application server like Apache. This is useful if you want to preserve memory on your machine, for example.
First of all, we ask Nginx to serve the static files for the Nagios web [...]]]></description>
			<content:encoded><![CDATA[<p>It is quite possible to run Nagios3&#8217;s web interface directly from Nginx and a FastCGI server, rather than having to involve a web application server like Apache. This is useful if you want to preserve memory on your machine, for example.</p>
<p>First of all, we ask Nginx to serve the static files for the Nagios web interface. In Debian/Ubuntu, these live in /usr/share/nagios3/htdocs and /usr/share/nagios3/stylesheets, which is a little awkward, but just the sort of thing that the rewrite command is for &#8230;</p>
<blockquote><pre>    location / {
        root /usr/share/nagios3/htdocs;
        index index.html;

        rewrite ^/nagios3/stylesheets/(.*)$ /../stylesheets/$1 break;
        rewrite ^/nagios3/(.*)$ /$1 break;
    }
</pre>
</blockquote>
<p>Next, we tell Nginx to send requests for CGI pages down to a FastCGI server :-</p>
<blockquote><pre>    location ~ \.cgi$ {
        root /usr/lib/cgi-bin/nagios3;
        include /etc/nginx/fastcgi_params;

        rewrite ^/cgi-bin/nagios3/(.*)$ /$1;

        auth_basic "Nagios";
        auth_basic_user_file /etc/nagios3/htpasswd.users;

        fastcgi_pass 127.0.1.1:8998;
        fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/nagios3$fastcgi_script_name;
        fastcgi_param AUTH_USER       $remote_user;
        fastcgi_param REMOTE_USER     $remote_user;
    }
</pre>
</blockquote>
<p>We need to make sure that these requests are under authentication, and that we pass the authenticated username to the CGI script properly, hence the <code>auth_basic</code> and <code>fastcgi_param AUTH_USER</code> lines.</p>
<p>That&#8217;s Nginx taken care of, but we also need to make sure there&#8217;s a generic FastCGI server running on the specified address/port. No configuration is necessary, as we&#8217;re passing everything we need, including the script name. fcgiwrap comes recommended on the <a href="http://nginx.localdomain.pl/wiki/FcgiWrap">Nginx wiki</a>.</p>
<blockquote><pre>/usr/bin/spawn-fcgi -a 127.0.1.1 -p 8998 \
-u www-data -g www-data \
-f /usr/local/bin/fcgiwrap -P /var/run/fcgiwrap.pid</pre>
</blockquote>
<p>And that&#8217;s all you need!</p>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/running-nagios3-under-nginx-fastcgi/feed</wfw:commentRss>
		</item>
		<item>
		<title>Testing a FastCGI service</title>
		<link>http://inode.co.nz/testing-a-fastcgi-service</link>
		<comments>http://inode.co.nz/testing-a-fastcgi-service#comments</comments>
		<pubDate>Wed, 07 Jul 2010 01:37:55 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[fastcgi]]></category>

		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=49</guid>
		<description><![CDATA[If you have a FastCGI service running, normally you just talk to it through the front-end web server. However, for testing purposes you should send requests directly to the fastcgi server.
Getting this done isn&#8217;t terribly obvious, as the FastCGI protocol is not in plain text you can&#8217;t just telnet to the server and enter commands, [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a FastCGI service running, normally you just talk to it through the front-end web server. However, for testing purposes you should send requests directly to the fastcgi server.</p>
<p>Getting this done isn&#8217;t terribly obvious, as the FastCGI protocol is not in plain text you can&#8217;t just telnet to the server and enter commands, the way you can with HTTP. There is a useful command, <code>cgi-fcgi</code> that comes from the libfcgi package on Debian/Ubuntu (and probably in similar packages in other distros), but the man page assumes you already know a lot more about FastCGI than you probably needed to set something up in the first place!</p>
<p>From <a href="http://gist.github.com/mpasternacki">http://gist.github.com/mpasternacki</a> comes a short wrapper script to invoke cgi-fcgi to send a simple request - <a href="http://gist.github.com/209446">http://gist.github.com/209446</a>. This script sets a bunch of environment variables that the fcgi script may require up front.</p>
<p>Here&#8217;s a simpler example. I have a FastCGI server running on 127.0.1.1 port 8998. I used lighttpd&#8217;s spawn-fcgi to start up an instance of fcgiwrap, a minimal fcgi processor recommended on the <a href="http://nginx.localdomain.pl/wiki/FcgiWrap">Nginx wiki</a>.</p>
<blockquote><pre>/usr/bin/spawn-fcgi -a 127.0.1.1 -p 8998 \
-u www-data -g www-data \
-f /usr/local/bin/fcgiwrap -P /var/run/fcgiwrap.pid</pre>
</blockquote>
<p>Then, I use cgi-fcgi to connect to the port, and see what I get back.</p>
<blockquote><pre>$ cgi-fcgi -bind -connect 127.0.1.1:8998
Cannot get script name, are DOCUMENT_ROOT and SCRIPT_NAME (or SCRIPT_FILENAME) set and is the script executable?
Status: 403 Forbidden
Content-type: text/plain

403</pre>
</blockquote>
<p>This is enough to confirm that fcgiwrap is running OK, but doesn&#8217;t tell us if it can actually carry out any work. I&#8217;ll ask it to run a Nagios CGI command :-</p>
<blockquote><pre>$ DOCUMENT_ROOT=/var/www \
SCRIPT_FILENAME=/usr/lib/cgi-bin/nagios3/tac.cgi \
cgi-fcgi -bind -connect 127.0.1.1:8998
getcgivars(): Unsupported REQUEST_METHOD -> ''

I'm guessing you're trying to execute the CGI from a command line.
In order to do that, you need to set the REQUEST_METHOD environment
variable to either "GET", "HEAD", or "POST".  When using the
GET and HEAD methods, arguments can be passed to the CGI
by setting the "QUERY_STRING" environment variable.  If you're
using the POST method, data is read from standard input.  Also of
note: if you've enabled authentication in the CGIs, you must set the
"REMOTE_USER" environment variable to be the name of the user you're
"authenticated" as.</pre>
</blockquote>
<p>Excellent, this error message looks like it has come from the actual CGI command itself. Let&#8217;s set a couple more variables to help it work &#8230; let&#8217;s add REQUEST_METHOD as the error message suggested.</p>
<blockquote><pre>$ REQUEST_METHOD=GET DOCUMENT_ROOT=/var/www \
SCRIPT_FILENAME=/usr/lib/cgi-bin/nagios3/tac.cgi \
cgi-fcgi -bind -connect 127.0.1.1:8998

Cache-Control: no-store
Pragma: no-cache
Refresh: 90
Last-Modified: Wed, 07 Jul 2010 01:27:16 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-type: text/html

...</pre>
</blockquote>
<p>I&#8217;ll spare you the rest of the HTML output. This shows us a way of using a simple command-line test to verify that a FastCGI service is running correctly, without involving any front-end webserver. This is useful if you&#8217;re getting stuck setting up the front-end webserver, or if you like to have intelligent service dependency monitoring that can diagnose problems more precisely.</p>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/testing-a-fastcgi-service/feed</wfw:commentRss>
		</item>
		<item>
		<title>VirtualBox and an openSUSE 11.2 guest</title>
		<link>http://inode.co.nz/virtualbox-and-an-opensuse-112-guest</link>
		<comments>http://inode.co.nz/virtualbox-and-an-opensuse-112-guest#comments</comments>
		<pubDate>Thu, 10 Jun 2010 07:51:44 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[openSUSE]]></category>

		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=47</guid>
		<description><![CDATA[I had an odd need to run an openSUSE 11.2 machine recently, so I installed one under VirtualBox. It worked very well out of the box, with the screen nicely resizing to the VBox window.
However, when I tried to add a shared folder to copy files from the host machine, things started going wrong &#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>I had an odd need to run an openSUSE 11.2 machine recently, so I installed one under VirtualBox. It worked very well out of the box, with the screen nicely resizing to the VBox window.</p>
<p>However, when I tried to add a shared folder to copy files from the host machine, things started going wrong &#8230; <img src='http://inode.co.nz/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>I have a Shared Folder called &#8220;hometmp&#8221; that shares my ~/tmp directory. Normally this can be easily added to a guest with</p>
<pre>
$ sudo mount -t vboxsf hometmp ~/tmp
</pre>
<p>But for some off reason that was failing with a &#8220;Protocol error&#8221; every time &#8230; so I had to do a little digging. It seems that there&#8217;s something wrong with the way &#8220;mount -t&#8221; operates in this case, I&#8217;m not interested in openSUSE enough to dig further, but the workaround is to invoke &#8220;mount.vboxsf&#8221; directly instead. /sbin isn&#8217;t on the user path, BTW &#8230;</p>
<pre>
$ sudo /sbin/mount.vboxsf hometmp ~/tmp
</pre>
<p>And the strangest bit of all &#8212; when I went back to my VBox openSUSE to reproduce the error message in order to write this post &#8230; the original normal mount option worked just fine!</p>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/virtualbox-and-an-opensuse-112-guest/feed</wfw:commentRss>
		</item>
		<item>
		<title>Thunderbird &#038; Ubuntu 10.04</title>
		<link>http://inode.co.nz/thunderbird-ubuntu-1004</link>
		<comments>http://inode.co.nz/thunderbird-ubuntu-1004#comments</comments>
		<pubDate>Tue, 04 May 2010 10:37:36 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[10.04]]></category>

		<category><![CDATA[thunderbird]]></category>

		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=45</guid>
		<description><![CDATA[Thunderbird 3 comes with Ubuntu 10.04, but sadly it doesn&#8217;t integrate with the default desktop as well as it could &#8212; it doesn&#8217;t link to the envelope icon in the Indicator Applet, and it uses its own popups instead of the libnotify mechanism Ubuntu prefers.
These are easily fixed, however &#8230;
http://ubuntuforums.org/showpost.php?p=9150987 tells us how to add [...]]]></description>
			<content:encoded><![CDATA[<p>Thunderbird 3 comes with Ubuntu 10.04, but sadly it doesn&#8217;t integrate with the default desktop as well as it could &#8212; it doesn&#8217;t link to the envelope icon in the Indicator Applet, and it uses its own popups instead of the libnotify mechanism Ubuntu prefers.</p>
<p>These are easily fixed, however &#8230;</p>
<p><a href="http://ubuntuforums.org/showpost.php?p=9150987">http://ubuntuforums.org/showpost.php?p=9150987</a> tells us how to add Thunderbird to the menu, along with actions such as Compose New Message and Contacts (read the whole thread to see how Calendar would work if you had Lightning installed); but it doesn&#8217;t address how to get notifications working.</p>
<p>The experimental libnotify-mozilla XPI for Thunderbird itself, on the other hand, provides the notification of new mail &#8212; but if Thunderbird is not running, or if there are no new messages, nothing will be visible in the Indicator.<br />
<a href="http://ubublogger.wordpress.com/2010/02/02/how-to-install-the-experimental-version-of-libnotify-mozilla/">http://ubublogger.wordpress.com/2010/02/02/how-to-install-the-experimental-version-of-libnotify-mozilla/</a></p>
<p>A combination of these two still doesn&#8217;t produce a perfect solution, but it&#8217;s good enough until Ubuntu &#038; Mozilla sort themselves out and get Thunderbird capable of replacing Evolution on the desktop fully.</p>
<p><a href='http://inode.co.nz/wp-uploads/thunderbird-indicator.png'><img src="http://inode.co.nz/wp-uploads/thunderbird-indicator-300x233.png" alt="The Indicator Applet showing Thunderbird status" title="Thunderbird Indicator" width="300" height="233" class="alignnone size-medium wp-image-46" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/thunderbird-ubuntu-1004/feed</wfw:commentRss>
		</item>
		<item>
		<title>Exim4 and authenticating from a database</title>
		<link>http://inode.co.nz/exim4-and-authenticating-from-a-database</link>
		<comments>http://inode.co.nz/exim4-and-authenticating-from-a-database#comments</comments>
		<pubDate>Tue, 27 Apr 2010 00:50:44 +0000</pubDate>
		<dc:creator>jim</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[exim4]]></category>

		<guid isPermaLink="false">http://inode.co.nz/?p=44</guid>
		<description><![CDATA[The exim authenticators take care of collecting a username/password from the user during the SMTP conversation, and are often used to check against a database to see if they are &#8216;correct&#8217;. The syntax for this check gets a few people confused, so here&#8217;s a description &#8230;
Your database is storing an encrypted password I hope; if [...]]]></description>
			<content:encoded><![CDATA[<p>The exim authenticators take care of collecting a username/password from the user during the SMTP conversation, and are often used to check against a database to see if they are &#8216;correct&#8217;. The syntax for this check gets a few people confused, so here&#8217;s a description &#8230;</p>
<p>Your database is storing an encrypted password I hope; if it is not you have other issues. You should <em>also</em> be following standards and prefixing the password with the name of the encryption scheme, so the DB value looks like :- <code>{md5}CY9rzUYh03PK3k6DJie09g==</code></p>
<p>However, if you are simply storing the encrypted data without the scheme name (as I was until I started writing this!) you need to stick to a single scheme and hard-code this into the exim authentication config, which is a big source of confusion.</p>
<p>How it all works :-</p>
<p>The authentication session provides an actual password (it was lightly encoded with base64 during the SMTP session, but this has been taken care of automatically). Under PLAIN authentication, for example, $3 will contain the actual user password.</p>
<p>A DB query such as <code>${lookup mysql{...}}</code> returns &#8220;encrypted-password&#8221; (not &#8220;{scheme}encrypted-password&#8221;)</p>
<p>Therefore in order to compare the password with the encrypted password, we have to say what encryption scheme the database is using &#8212; md5, sha1, whatever. We cannot decrypt what the database returns, so we must encrypt the password &#8212; but the difference is invisible to us, Exim does the right thing.</p>
<p>In order to encrypt the password, we need to tell crypteq which encryption scheme to use &#8212; &#8220;sha1&#8243; normally. We need to tell crypteq explicitly what scheme we&#8217;re using, it cannot guess by looking at the values. Exim is expecting &#8220;{scheme}data&#8221;, but our DB isn&#8217;t returning that &#8230;</p>
<p>Also, crypteq&#8217;s *syntax* is confusing because it doesn&#8217;t read like &#8220;encrypt the password with &#8217;sha1&#8242; and compare that to what&#8217;s in the database&#8221;, it reads &#8220;compare the password with the &#8217;sha1&#8242;-encrypted data from the database&#8221;. </p>
<p>And, for good measure, the way you say &#8220;sha1&#8243; demands curly brackets, which are *not* part of the command syntax, and therefore need to have backslashes in front of them &#8230;</p>
<p>crypteq takes two strings, the unencrypted password in one, and the encrypted password PLUS the encryption scheme name in the second. We need to explicitly say \{sha1\} in front of the SQL lookup.</p>
<p>crypteq {$3}{\{sha1\}${lookup &#8230;}}</p>
<p>${if} takes three values; the query (the entire crypteq thing from above), and the two results.</p>
<p>server_condition = ${if crypteq {$3}{\{sha1\}${lookup &#8230;}}{yes}{no}}</p>
<p>read more about crypteq: http://www.exim.org/exim-html-4.40/doc/html/spec_11.html</p>
<p>Here&#8217;s a full authenticator for PLAIN &#8230;</p>
<blockquote><pre>begin authenticators

plain:
    driver = plaintext
    public_name = PLAIN
    server_advertise_condition = ${if eq{$tls_cipher}{}{no}{yes}}
    server_condition = ${if crypteq {$3}{${lookup sqlite {DB \
        select password from users where username = '$2';}}}{yes}{no}}
    server_set_id = $2
</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://inode.co.nz/exim4-and-authenticating-from-a-database/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
