<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tridge's Corner</title>
	<atom:link href="http://blog.tridgell.net/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.tridgell.net</link>
	<description>Another Australian Hacker</description>
	<lastBuildDate>Wed, 28 Jul 2010 23:55:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>debugging startup problems on Ubuntu</title>
		<link>http://blog.tridgell.net/?p=57</link>
		<comments>http://blog.tridgell.net/?p=57#comments</comments>
		<pubDate>Wed, 28 Jul 2010 23:55:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=57</guid>
		<description><![CDATA[I recently upgraded my home server from Ubuntu Karmic to Lucid. It did not go well.
The actual apt-get dist-upgrade went fine, with only minor problems which were easy enough to fix. The problem came when I rebooted. The boot started fine, but then got
stuck at the purple boot page, which showed &#8220;Ubuntu 10.4&#8243; and 5 [...]]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded my home server from Ubuntu Karmic to Lucid. It did not go well.</p>
<p>The actual apt-get dist-upgrade went fine, with only minor problems which were easy enough to fix. The problem came when I rebooted. The boot started fine, but then got<br />
stuck at the purple boot page, which showed &#8220;Ubuntu 10.4&#8243; and 5 dots which cycled<br />
between white and red. It never got past that point.</p>
<p>The usual thing to do at this point is to reboot in single user mode and start debugging startup scripts. Unfortunately I found that single user mode with Ubuntu Lucid was not useful as it doesn&#8217;t start a shell until after a huge pile of other things are started. In my case a &#8217;single&#8217; boot got stuck at the same point. Getting rid of the quiet and splash options, and adding nomodeset also didn&#8217;t help.</p>
<p>I found that if I booted an older kernel (2.6.31-19) then the system came up OK. That pointed to a likely driver issue. I could have just settled for that older kernel, but part of the reason for going to Lucid was to get a newer ALSA with better support for HDMI audio, so I didn&#8217;t really want to stick to an older kernel. I also wanted to know why the problem was happening.</p>
<p>I was also able to get a shell using the latest kernel by using the init=/bin/bash trick, but that doesn&#8217;t help to actually debug the problem. To debug startup problems you need to be able to watch the startup process in action, to see what is waiting. This is much harder these days with the new upstart init system now used in Ubuntu, as startup is much more parallel than it used to be. Adding some echo lines to init scripts used to be a useful technique, but it is much harder to get anything sensible out of that when using upstart.</p>
<p>To try to debug the problem I initially had a look for any startup debugging options. I found some promising options in /etc/default/rcS, and tried setting VERBOSE=yes and SULOGIN=yes. I found that the VERBOSE=yes option was somewhat useful, as it gave me some information on what jobs were started/waiting, but it didn&#8217;t really allow me to pin down the problem. The parallelism in upstart again made interpreting the output hard. When it says that a job is waiting it doesn&#8217;t say what it is waiting on, so you have no idea what the underlying problem really is.</p>
<p>Despite the promising name, and the nice description in the rcS(5) manpage, the SULOGIN=yes option didn&#8217;t seem to do anything at all. A grep for SULOGIN in the startup scripts didn&#8217;t find any hits, so I suspect it isn&#8217;t actually implemented.</p>
<p>As usual, the real key to solving the problem was a hack. I added the following to /etc/default/rcS:</p>
<p><code>(<br />
/bin/sleep 10<br />
/sbin/ifconfig eth0 192.168.2.10 up<br />
/usr/sbin/sshd<br />
) > /dev/null 2>&#038;1 &#038;</code></p>
<p>The idea behind this hack was to allow me to login with ssh from my laptop during the startup process and watch what was going on. This worked really well and meant that I was finally able to debug the startup process with the most recent Lucid kernel.</p>
<p>I rebooted again, logged into the system with ssh from my laptop, and started poking around with ps and initctl to see what was going on. I had assumed that &#8220;initctl list&#8221; would give me the information I needed. It does show what jobs are waiting, but as with the VERBOSE=yes messages it doesn&#8217;t tell you what it is waiting on. </p>
<p>Poking around some more I saw 3 things that were suspicious:</p>
<p>1) cryptdisks-enable was shown as &#8220;waiting&#8221;. I don&#8217;t have any encrypted disks on this system, so why should it be waiting?</p>
<p>2) dmesg showed a segfault in plymouth, which is the process that asks for user input during startup (it also does splash screens). This could be linked to why cryptdisks was waiting, as its possible that cryptdisks wanted a passphrase (for what disk though? I don&#8217;t have any encrypted disks)</p>
<p>3) dmesg also showed a lot of warnings from the dvb-usb-cxusb driver</p>
<p>As I was running low on time I decided to try the triple whammy of removing the cryptsetup package, removing the dvb-usb and dvb-usb-cxusb drivers (by moving them out of /lib/modules and running depmod) and removing the plymouth-theme-ubuntu-text package to try to simplify plymouth. This did the trick and my system now boots fine.</p>
<p>I still have the puzzle as to what is really causing the problem (and thus which of the changes matter), but I can leave that for another day. I thought it would be worthwhile sharing the ssh debug hack in case other people are also trying to debug upstart startup problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=57</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Going solar</title>
		<link>http://blog.tridgell.net/?p=46</link>
		<comments>http://blog.tridgell.net/?p=46#comments</comments>
		<pubDate>Tue, 20 Jul 2010 12:31:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=46</guid>
		<description><![CDATA[I&#8217;ve just signed up for a 29.7kW grid connected solar system to be installed in August. We have a large north facing roof with almost no shade, and it really seemed like a shame to be wasting all that potential!
The system will consist of 132 Sunpower 225W panels, and 6 Xantrex GT5 inverters. It is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just signed up for a 29.7kW grid connected solar system to be installed in August. We have a large north facing roof with almost no shade, and it really seemed like a shame to be wasting all that potential!</p>
<p>The system will consist of 132 Sunpower 225W panels, and 6 Xantrex GT5 inverters. It is being installed on a colorbond roof, using a landscape layout of the panels:<br />
<a href='http://solar.tridgell.net/Sunpower225-horizontal-132panels-2.png'><img src='http://solar.tridgell.net/Sunpower225-horizontal-132panels-2-small.png'></a></p>
<p>I got quotes from a lot of installers, and found a big variance in the level of knowledge that the various installers showed when they quoted for the system. I ended up getting quotes from 2 good Canberra based installers (Armada and Enviro-Friendly) and one national installer (Clear Solar). The Clear Solar quote was the one I went with because of the really good mounting system they were able to show me. The rails are mounted vertically up the roof face, and the mounting brackets are shaped to the contours of the colorbond roofing, giving a strong mounting system that allows for airflow on the back of the panels which should keep them a bit cooler (the efficiency of PV panels drops quite quickly if they get too hot). It should also stop leaves and other rubbish from building up behind the rails, which would tend to happen if the rails were mounted horizontally.</p>
<p>I&#8217;m getting a data logger and Paul Wilson from Clear has sent me the manual for the protocol to talk to the inverters, so I should be able to write some python code pretty quickly to analyze the performance of the system and watch for any degradation.</p>
<p>It will be fun to be producing more electricity than I use!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=46</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>recovering kaddressbook entries</title>
		<link>http://blog.tridgell.net/?p=36</link>
		<comments>http://blog.tridgell.net/?p=36#comments</comments>
		<pubDate>Fri, 25 Jun 2010 05:36:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=36</guid>
		<description><![CDATA[I&#8217;ve been using kaddressbook for a long time, long after I switched from KDE to Gnome. It has worked well until now.
After returning from vacation I decided to update my laptop from Ubuntu Karmic to Lucid, and then found that kaddressbook wouldn&#8217;t start. Digging into it I found a maze of errors related to mysql [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using kaddressbook for a long time, long after I switched from KDE to Gnome. It has worked well until now.</p>
<p>After returning from vacation I decided to update my laptop from Ubuntu Karmic to Lucid, and then found that kaddressbook wouldn&#8217;t start. Digging into it I found a maze of errors related to mysql and innodb. I hadn&#8217;t even realized that kaddressbook was using mysql for my addressbook till now. It&#8217;s a bit of an overkill for my little home addressbook <img src='http://blog.tridgell.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>After spending some time tracing mysql and trying to work out why I was getting &#8220;InnoDB: No valid checkpoint found&#8221;, I realised there was an easier way. Inside that mysql database was just a set of binary VCARD records. So the quick fix was:</p>
<pre>mlgrep.py BEGIN:VCARD END:VCARD ~/.local/share/akonadi/db_data/ibdata1</pre>
<p>putting the result in a file. I then imported the file into the evolution contacts app and all was well. Of course, this assumes records aren&#8217;t split within the db, but it seems to work well enough for this quick fix.</p>
<p>See <a href="http://samba.org/ftp/unpacked/junkcode/mlgrep.py">http://samba.org/ftp/unpacked/junkcode/mlgrep.py</a> for mlgrep.</p>
<p>Cheers, Tridge</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=36</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>burned by a SIP attack</title>
		<link>http://blog.tridgell.net/?p=28</link>
		<comments>http://blog.tridgell.net/?p=28#comments</comments>
		<pubDate>Thu, 24 Jun 2010 07:47:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=28</guid>
		<description><![CDATA[I use an asterisk server at home to provide phone services over SIP. I have two SIP providers, internode (aka nodephone) and engin.
After I came back from a long vacation last week (long service leave is nice!) I got a message from internode telling me my SIP service had been suspended due to suspicious activity. [...]]]></description>
			<content:encoded><![CDATA[<p>I use an asterisk server at home to provide phone services over SIP. I have two SIP providers, internode (aka nodephone) and engin.</p>
<p>After I came back from a long vacation last week (long service leave is nice!) I got a message from internode telling me my SIP service had been suspended due to suspicious activity. I had a look at my asterisk logs, and found that while I had been away my asterisk box had been busy making calls to various unusual places, especially North Korea and Somalia. I do fair number a lot of overseas calls, especially to the US, Germany and Sweden, but this certainly didn&#8217;t look legit!</p>
<p>I looked a bit more into my logs and found that I&#8217;d been compromised twice &#8211; once on June 1st and another time on June 15th. The first attacker only made a couple of test calls to Romania, Sierra  Leone and Zimbabwe, plus one to North Korea. The second attacker took a lot more advantage of their ill-gotten SIP secret however, and made 151 calls, most of them to North Korea plus some to Somalia.</p>
<p>What the logs show is that the attacks both followed the same pattern. Both attackers first scanned extensions, trying all 1 digit extensions, then all 2 digit extensions then all 3 digit extensions etc. From that they found the list of five 4-digit extensions that were active on my asterisk box. Then they went back and brute-forced the SIP secrets on those extensions. Unfortunately I had chosen digit-only secrets when I first installed asterisk (thinking it may help with setup on keypad only devices) and I&#8217;d never changed them. Not a good idea! They needed a total of about 39k SIP auth requests to find the secrets.</p>
<p>Of course, this service was never intended to be exposed to the internet. The way it had become exposed was that I had been trying to track down a call dropout problem with engin, and thinking that they may be using a variant of the asterisk &#8220;try an OPTIONS request every few minutes to see if the other end is still there&#8221; approach, I temporarily had allowed UDP port 5060 through my firewall. Of course I then forgot to disable it again once I determined that wasn&#8217;t the problem. Darn!</p>
<p>Luckily whatever the people had to say to the person they were calling in North Korea wasn&#8217;t long &#8211; the calls were all about 5 minutes long (suspiciously close to 300 seconds actually &#8211; maybe they had dropouts too?). It still added up to a fair bit though &#8211; over $250 worth of calls. Ouch!</p>
<p>I contacted internode and they re-enabled my SIP account once I changed my internode SIP password (it wasn&#8217;t actually my internode SIP password that was compromised, but this was still a very reasonable precaution).  At the suggestion of Travis, a very helpful internode helpdesk person, I put in a feedback request describing what happened, and they very kindly agreed to credit me with the charges for the fraudulent calls. That was a very nice surprise! Internode do seem to be well ahead of the crowd in customer service. Of course, this was a one-off gesture of goodwill, so it would not be a good idea to rely on this sort of generosity.</p>
<p>The calls made via engin were a bit strange. They showed up in my asterisk logs, but didn&#8217;t show up in the engin web call log or billing interface. I rang and asked engin about that, and a helpful person called Erick assured me that the bill was correct, and I wasn&#8217;t going to receive a big bill later. Perhaps someone at engin had already stripped their logs of calls to North Korea after someone else was hit by this?</p>
<p>Meanwhile, I&#8217;ve now got long random passwords in asterisk, and I&#8217;ve fixed my firewall. I&#8217;ve also setup a little UDP logger on port 5060 to grab any future attempts anyone makes to brute force my SIP service (just for amusement value, I&#8217;m curious to see how often I get scanned).</p>
<p>I wonder who was at the receiving end of all those calls to North Korea?</p>
<p>Cheers, Tridge</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=28</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>samba.org joins Australian Internet Blackout</title>
		<link>http://blog.tridgell.net/?p=24</link>
		<comments>http://blog.tridgell.net/?p=24#comments</comments>
		<pubDate>Sun, 24 Jan 2010 20:38:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=24</guid>
		<description><![CDATA[This week many websites in Australia will be showing a &#8220;blackout&#8221; popup to protest the introduction of internet censorship in Australia. The Samba project, which has is roots in Australia, has joined in this protest on its website.
If you run a non-Australian site but you want to also show your support, then you might like [...]]]></description>
			<content:encoded><![CDATA[<p>This week many websites in Australia will be showing a &#8220;blackout&#8221; popup to protest the introduction of <a href="http://www.internetblackout.com.au/">internet censorship in Australia</a>. The Samba project, which has is roots in Australia, has joined in this protest on its <a href="http://samba.org/">website</a>.</p>
<p>If you run a non-Australian site but you want to also show your support, then you might like to grab the <a href="http://samba.org/tridge/blackout">hacked up popup code</a> I used on samba.org.</p>
<p>For Australian sites, please use the <a href="http://www.internetblackout.com.au/websites/">official code</a>. Hopefully something appropriate for non-au sites will be added there soon.</p>
<p>Cheers, Tridge</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Another brilliant LCA!</title>
		<link>http://blog.tridgell.net/?p=21</link>
		<comments>http://blog.tridgell.net/?p=21#comments</comments>
		<pubDate>Sun, 24 Jan 2010 01:04:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Conferences]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=21</guid>
		<description><![CDATA[The last week at LCA has been amazing. It was a heady combination of great technical talks, geek hackery, fantastic social events and fun discussions.
I think the key to LCA is the amazing volunteers who run it. The combination of moving the conference between cities each year along with enthusiastic volunteers from the FOSS community [...]]]></description>
			<content:encoded><![CDATA[<p>The last week at <a href="http://www.lca2010.org.nz/">LCA</a> has been amazing. It was a heady combination of great technical talks, geek hackery, fantastic social events and fun discussions.</p>
<p>I think the key to LCA is the amazing volunteers who run it. The combination of moving the conference between cities each year along with enthusiastic volunteers from the FOSS community makes for an incredible conference year after year.</p>
<p>Thank you to everyone who made LCA 2010 in Wellington such a success. If you missed it, then make sure you don&#8217;t miss next years <a href="http://followtheflow.org/">LCA in Brisbane</a>. The highlight of every year for me is LCA, and I am so grateful that we have such a great community of FOSS hackers in Australia and New Zealand to make it possible.</p>
<p>Cheers, Tridge</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=21</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Samba4 DRS replication</title>
		<link>http://blog.tridgell.net/?p=12</link>
		<comments>http://blog.tridgell.net/?p=12#comments</comments>
		<pubDate>Mon, 11 Jan 2010 03:04:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Samba]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=12</guid>
		<description><![CDATA[There has been a lot of progress recently in the development of the directory server capabilities of Samba4. I thought it would be worthwhile putting together a video that shows off some of those capabilities.
You can see the video here:
http://samba.org/tridge/DRS-demo/s4-DRS-demo.avi
(if you have a fast link and can play Ogg videos, there is a high quality [...]]]></description>
			<content:encoded><![CDATA[<p>There has been a lot of progress recently in the development of the directory server capabilities of Samba4. I thought it would be worthwhile putting together a video that shows off some of those capabilities.</p>
<p>You can see the video here:</p>
<p><a href="http://samba.org/tridge/DRS-demo/s4-DRS-demo.avi">http://samba.org/tridge/DRS-demo/s4-DRS-demo.avi</a></p>
<p>(if you have a fast link and can play Ogg videos, there is a <a href="http://samba.org/tridge/DRS-demo/s4-DRS-demo.ogv">high quality version</a> too)</p>
<p>The video shows a few things:</p>
<ul>
<li> provisioning a Samba4 domain controller</li>
<li> joining a Windows 2008 R2 machine as an additional domain controller for the Samba domain</li>
<li> joining an additional Samba domain controller to the same domain</li>
<li> adding a user and seeing changes to the user propogate between the domain controllers</li>
</ul>
<p>There is a lot <a href="http://wiki.samba.org/index.php/Samba4_DRS_TODO_List">more to do</a> in Samba4, but we are making <a href="http://git.samba.org/?p=samba.git;a=shortlog">very rapid progress</a> now. Thanks to everyone who has contributed to this effort!</p>
<p>Cheers, Tridge</p>
<p>PS: If you&#8217;ve having trouble playing the videos on windows, you may want to install the x264 codec. See <a href="http://sourceforge.net/projects/x264vfw/files/">http://sourceforge.net/projects/x264vfw/files/</a> for a downloadable codec pack for windows media player.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=12</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://samba.org/tridge/DRS-demo/s4-DRS-demo.mp4" length="17894521" type="video/mp4" />
<enclosure url="http://samba.org/tridge/DRS-demo/s4-DRS-demo.ogv" length="261286446" type="video/ogg" />
<enclosure url="http://samba.org/tridge/DRS-demo/s4-DRS-demo.avi" length="54289376" type="video/x-msvideo" />
		</item>
		<item>
		<title>chocolate truffles!</title>
		<link>http://blog.tridgell.net/?p=5</link>
		<comments>http://blog.tridgell.net/?p=5#comments</comments>
		<pubDate>Sun, 10 Jan 2010 02:12:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=5</guid>
		<description><![CDATA[After having some fun building a coffee roaster with automatic power control and a python UI, my wife asked if I could help her with chocolate tempering for making chocolate truffles.
The result is a new use for pyRoast, and some great &#8220;techno truffles&#8221; !
See http://coffeesnobs.com.au/YaBB.pl?num=1263085051 for all the details and a short movie.
Cheers, Tridge
]]></description>
			<content:encoded><![CDATA[<p>After having some fun building a <a href="http://coffeesnobs.com.au/YaBB.pl?num=1259627839">coffee roaster with automatic power control</a> and a <a href="http://samba.org/tridge/pyRoast">python UI</a>, my wife asked if I could help her with chocolate tempering for making chocolate truffles.</p>
<p>The result is a new use for pyRoast, and some great &#8220;techno truffles&#8221; !</p>
<p>See <a href="http://coffeesnobs.com.au/YaBB.pl?num=1263085051">http://coffeesnobs.com.au/YaBB.pl?num=1263085051</a> for all the details and a short movie.</p>
<p>Cheers, Tridge</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=5</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with gdb</title>
		<link>http://blog.tridgell.net/?p=4</link>
		<comments>http://blog.tridgell.net/?p=4#comments</comments>
		<pubDate>Thu, 23 Apr 2009 05:11:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hacks]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=4</guid>
		<description><![CDATA[Ben Elliston just gave a great lunchtime talk at OzLabs on gdb. Ben has actually read the gdb manual, and in doing so has discovered a lot of neat tricks!
One that he missed in his talk is some cute stuff you can do with the p command (the short form for &#8216;print&#8217;). For example, say [...]]]></description>
			<content:encoded><![CDATA[<p>Ben Elliston just gave a great lunchtime talk at OzLabs on gdb. Ben has actually read the gdb manual, and in doing so has discovered a lot of neat tricks!</p>
<p>One that he missed in his talk is some cute stuff you can do with the p command (the short form for &#8216;print&#8217;). For example, say you have some process that is sending its output to /dev/null, but you want to see that output. That can happen with long running daemons that were started without debugging enabled for example. What you need to do is tell that program to change file descriptor 1 to point to a file, instead of /dev/null.</p>
<p>Let&#8217;s look at an example:</p>
<pre><small>
 lsof -n |grep null|grep 1u
 gconfd-2  17243     tridge    1u      CHR                1,3              5961 /dev/null
</small></pre>
<p>We see from lsof that gconfd-2 has pid of 17243 and is redirecting stdout (fd 1) to /dev/null. Now let&#8217;s attach with gdb, close fd 1, and re-open it on a file in /tmp</p>
<pre><small>
 tridge@blu:~$ gdb --pid 17243
 GNU gdb 6.8-debian
 Copyright (C) 2008 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
 and "show warranty" for details.
 This GDB was configured as "x86_64-linux-gnu".
 Attaching to process 17243
</small></pre>
<p>ok, we&#8217;re attached, now the dirty work:</p>
<pre><small>
 (gdb) p close(1)
 $1 = 0
 (gdb) p fopen("/tmp/gconfd.log", "w")
 $2 = 27041792
 (gdb) p fileno($2)
 $6 = 1
 (gdb) quit
</small></pre>
<p>Now if we check with lsof, we see the fd is now open on a log file</p>
<pre><small>
 gconfd-2  17243     tridge    1u      REG                8,1        0 12277473 /tmp/gconfd.log
</small></pre>
<p>You may ask why I used fopen() and not open(). First off, &#8220;w&#8221; is easier than remembering the right flag bits to open. Secondly, open may in fact be open64 or some other symbol, whereas I&#8217;ve found that fopen() always seems to work.</p>
<p>Notice also that I checked that fopen() gave us the right file descriptor back by calling fileno() on the output of fopen(). It will always give you the lowest available fd, which is usually right. If it isn&#8217;t the right one then use p with dup2() to move it to the right one.</p>
<h2>Another use</h2>
<p>This type of hack can also be used to solve the problem of unmounting a filesystem that has a process running with a file open on the filesystem read-write. The kernel doesn&#8217;t allow that, and the usual approach is to kill off all those processes. But what if you don&#8217;t want one of those processes to die? You can use the above trick to move the fd to point at a different filesystem. By using lsof to find all the ones you need to move, you can eventually mount the filesystem read-only, or even unmount it. This allows you to swap filesystems with running processes using them. You can minimise the effect on the processes by using gdb -x to script it (so it isn&#8217;t paused waiting for nervous fingers to type the right commands).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=4</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FOSS development can be taught</title>
		<link>http://blog.tridgell.net/?p=3</link>
		<comments>http://blog.tridgell.net/?p=3#comments</comments>
		<pubDate>Wed, 22 Apr 2009 04:44:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Teaching]]></category>

		<guid isPermaLink="false">http://blog.tridgell.net/?p=3</guid>
		<description><![CDATA[Last week Bob Edwards and myself finished the intensive part of the COMP8440 course at ANU. It was a lot of fun teaching the course, but it also answers something that I have wondered about for a while. Can FOSS development be taught?
Most things can be taught of course, but free software development is rarely [...]]]></description>
			<content:encoded><![CDATA[<p>Last week Bob Edwards and myself finished the intensive part of the <a href="http://cs.anu.edu.au/students/comp8440">COMP8440 course</a> at ANU. It was a lot of fun teaching the course, but it also answers something that I have wondered about for a while. Can FOSS development be taught?</p>
<p>Most things can be taught of course, but free software development is rarely taught. Instead hundreds of thousands of people have learned it by slowly absorbing the culture and the development practices from other people who already develop free software. I wasn&#8217;t absolutely certain that it could be successfully taught using more traditional teaching techniques in a university environment.</p>
<p>Last week gave me the answer very clearly &#8211; FOSS development can be taught, and indeed it can be taught very quickly. Most of the 21 students who took the course started off with almost no knowledge of what free software is. Only 2 of the students had any previous involvement with free software development, and many of the others had never used a free operating system before. The first day and a half had me a bit worried, as it was clear that many of the students were struggling, but by the end of the 2nd day the students were starting to understand. By the start of the third day I was starting to see the glow of understanding in many of their faces as they did the lab work and contributed in the discussions during the lectures.</p>
<p>By the end of the week the students were really enjoying it, and many of them had successfully contributed to a free software project of their choice. It was amazing to see them interacting with other developers from all over the world, and it was fantastic that they found the experience so rewarding.</p>
<h3>Scaling it up</h3>
<p>So, FOSS development can be taught. Now how do we scale it up? Bob and I have released all our lecture and lab notes, plus videos of all of the lectures on the course website under a creative commons license. We will also soon be releasing the scripts we used to setup the lab machines. So now I am looking forward to some other universities from other parts of the world adopting the course material and offering their own courses in FOSS development.</p>
<p>If we can make this a standard part of CS curriculums around the world, then the next generation of free software developers will be a bit better prepared.</p>
<h3>Thanks!</h3>
<p>Many thanks to everyone who made it possible to run this course. Special thanks to Bob Edwards and Henry Gardner for suggesting the course, and to Deanne Drummond for helping to get it all organised.</p>
<p>I&#8217;d also like to thank <a href="http://case.org.au">CASE</a>, who were the official providers of the course. I love doing volunteer work for case, and this was the most enjoyable project I&#8217;ve done for them so far.</p>
<p>Finally, thanks to the students who took part. Taking a course like this when it hasn&#8217;t been offered before is always a bit of a stab in the dark. I hope you all got as much out of it as I did.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tridgell.net/?feed=rss2&amp;p=3</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
