<?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>The Daily Build &#187; linux</title>
	<atom:link href="http://blog.bstpierre.org/category/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bstpierre.org</link>
	<description>Software Development, version 3.0</description>
	<lastBuildDate>Fri, 03 Feb 2012 02:59:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Turning Photos to a DVD Slideshow</title>
		<link>http://blog.bstpierre.org/photos-to-dvd-slideshow</link>
		<comments>http://blog.bstpierre.org/photos-to-dvd-slideshow#comments</comments>
		<pubDate>Tue, 24 Jan 2012 15:36:00 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=385</guid>
		<description><![CDATA[The task: take a bunch of photos from my digital camera and burn them to a DVD that would play the photos as a slideshow in any DVD player. (Actually, the task was to figure out how to do this in the simplest possible way, and make a set of instructions for an unsophisticated user [...]]]></description>
			<content:encoded><![CDATA[<p>The task: take a bunch of photos from my digital camera and burn them to a DVD that would play the photos as a slideshow in any DVD player. (Actually, the task was to figure out how to do this in the simplest possible way, and make a set of instructions for an unsophisticated user to follow.)</p>
<p>The result: several hours of fighting with a dozen different applications before I actually had photos displayed on my TV. And this post.</p>
<p>I don&#8217;t understand why what seems like a fairly simple task is so complicated.</p>
<p>This is what I found to be the easiest recipe on a stock Ubuntu 11.10 installation. Fair warning: this is quick &amp; dirty, you don&#8217;t get special effects, you don&#8217;t get music, etc.</p>
<ol>
<li>Required software (load through the software center, or via apt-get): imagination, devede, brasero.</li>
<li>Open Imagination. Click the import photos icon (it is a terrible choice of icon &#8212; there&#8217;s no clue that you should want to click on the black square to import photos) and choose your photos.</li>
<li>Export video. Choose DVD for output; to keep it organized, drop the video file in the Videos directory in your home directory. This can take a while if you have a slow computer and/or a lot of photos.</li>
<li>Open DeVeDe. Configure the title. Import the video you just generated.</li>
<li>Generate the DVD ISO image; again save the image to your Videos folder.</li>
<li>Insert a DVD in the drive. Open your Videos folder. Right click on the ISO image and choose Write to Disc.</li>
</ol>
<p>Some notes, in no particular order:</p>
<ul>
<li>If you want to tweak the slideshow, imagination will let you play around with transitions, slide duration, etc.</li>
<li>If you want to import video clips, use Openshot instead of Imagination. It&#8217;s harder to use (and overkill) compared to Imagination if all you want to do is produce a static photo slideshow. But if you want to do any video editing, it&#8217;s a good combination of power and ease of use.</li>
<li>If you want music, Openshot might also be your best bet. I didn&#8217;t look at adding music via Imagination or DeVeDe.</li>
<li>Don&#8217;t try to use the Brasero application directly. I experienced crashes/lockups while using it, but it worked well when all I did was right click the ISO and choose Write to Disc. (It&#8217;s also an ugly, hard to use piece of junk.)</li>
</ul>
<p>Things I tried and rejected:</p>
<ul>
<li>K3b: After Brasero failed miserably twice, I tried K3b. Rejected it in favor of not pulling in a bunch of KDE infrastructure that I wasn&#8217;t using anyway, and also in favor of the simplicity of just directly burning the file without having to explicitly open a separate app.</li>
<li>dvd-slideshow: This command line app does appeal to my inner geek, but I can&#8217;t recommend it for users who want a GUI. (Even the inner geek appeal isn&#8217;t enough to make me want to use it when the combination outlined above works well.)</li>
<li>Mistelix: As good as Imagination, and I would have selected it if I had quickly found a way to rotate a photo from within Mistelix. Photos that showed up auto-rotated in other apps showed up sideways in Mistelix and I didn&#8217;t see an obvious rotate button. Imagination did the right thing.</li>
<li>Bombono: Junk. Don&#8217;t bother with it. I opened it, saw that the tabs were overlapping the menus, couldn&#8217;t figure out how to import any photos, and purged it from my system.</li>
<li>Videoporama: Development is dead. It wasn&#8217;t immediately obvious that it was going to be easy to use for the simple task of creating a DVD from a set of photos.</li>
</ul>
<p>The software stack above 10x better if Imagination implemented a feature to export a DVD ISO. It would be 100x better if it had a &#8220;Burn DVD&#8221; button that spit out a shiny disc that I could drop into a DVD player.</p>
<p>(To be fair, the whole video situation is 1000x easier than it was 5 or 6 years ago when I tried to do something similar, realized how much work it was going to be, and walked away in frustration. The tools have come a long way.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/photos-to-dvd-slideshow/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tightening UFW Firewall Rules to Limit SSH Access</title>
		<link>http://blog.bstpierre.org/ufw-firewall-limit-ssh</link>
		<comments>http://blog.bstpierre.org/ufw-firewall-limit-ssh#comments</comments>
		<pubDate>Thu, 08 Dec 2011 23:54:21 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=371</guid>
		<description><![CDATA[The auth.log on one of my servers (really, on all of the servers I have access to) is full of stuff like this: Dec 8 03:19:33 localhost sshd[4718]: User root from 10.1.2.3 not allowed [...] Dec 8 03:19:35 localhost sshd[4721]: Invalid user db2inst1 from 10.1.2.3 Dec 8 03:19:38 localhost sshd[4723]: User root from 10.1.2.3 not [...]]]></description>
			<content:encoded><![CDATA[<p>The auth.log on one of my servers (really, on <em>all</em> of the servers I have access to) is full of stuff like this:</p>
<pre><code>Dec  8 03:19:33 localhost sshd[4718]: User root from 10.1.2.3 not allowed [...]
Dec  8 03:19:35 localhost sshd[4721]: Invalid user db2inst1 from 10.1.2.3
Dec  8 03:19:38 localhost sshd[4723]: User root from 10.1.2.3 not allowed [...]</code>
</pre>
<p>fail2ban is configured to (temporarily) block these after a certain number of attempts, but they keep coming back. One particular IP address was hitting ssh constantly (except for the ban periods) for several days, so I added a rule to drop everything from that address &#8212; but this strategy isn&#8217;t scalable.</p>
<p>The simple, obvious solution is to only allow access from known hosts. It would be very rare that I need to access this server from anywhere except a small number of addresses. I started with a ufw (Ubuntu&#8217;s &#8220;uncomplicated firewall&#8221;) ruleset like this:</p>
<pre><code>% sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
Anywhere                   DENY        10.1.2.3
Anywhere                   DENY        172.16.99.88
22                         ALLOW       Anywhere</code>
</pre>
<p>To avoid getting locked out, I added (temporarily) a crontab entry for root:</p>
<pre><code>*/15 * * * * /usr/sbin/ufw allow ssh</code></pre>
<p>This will allow access to ssh from any un-banned IP address (the current policy) every 15 minutes. Then I inserted a rule that allows access to ssh from my home ISPs netblock. (You can figure out the netblock by doing a whois lookup on your external IP address; you may need to add multiple netblocks if your ISP has several allocated. Be careful: it&#8217;s no fun to get locked out!) This action is safe because I have not yet removed global ssh access. Note that I&#8217;m using &#8220;insert 3&#8243; to add this rule at a specific position in the list.</p>
<pre><code>sudo ufw insert 3 allow proto tcp from 10.9.8.0/18 to any port 22</code></pre>
<p>And I added a rule to permit access from another server with a fixed IP I have access to (for the rare case where I need to access this server when I&#8217;m not at home):</p>
<p><code>sudo ufw insert 3 allow proto tcp from 172.17.101.102 to any port 22</code></p>
<p>Now my ruleset looks like:</p>
<pre><code>Status: active

To                         Action      From
--                         ------      ----
Anywhere                   DENY        10.1.2.3
Anywhere                   DENY        172.16.99.88
22/tcp                     ALLOW       172.17.101.102
22/tcp                     ALLOW       10.9.8.0/18
22                         ALLOW       Anywhere
</code></pre>
<p>So far, so good, but ssh access is still permitted from anywhere &#8212; because of that last rule. This is the dangerous part&#8230; you could get locked out if you haven&#8217;t set the rules correctly. (You set up that crontab entry, right?)</p>
<pre><code>sudo ufw delete allow ssh</code></pre>
<p>Wait for the prompt&#8230; hooray, I&#8217;m still connected! After checking that I can access ssh from home and the other server, I know it&#8217;s safe to remove the crontab job. (If the cron job has already fired, you&#8217;ll need to rerun the <code>ufw delete allow ssh</code> command.)</p>
<p>At this point I can delete the first two rules that ban specific IPs, since they&#8217;re outside my netblock and won&#8217;t be allowed anyway.</p>
<p>Now I can enjoy quieter logs without all those access attempts from China and Croatia!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/ufw-firewall-limit-ssh/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SSH for IPv6-enabled HTTP Proxying</title>
		<link>http://blog.bstpierre.org/using-ssh-for-ipv6-enabled-http-proxying</link>
		<comments>http://blog.bstpierre.org/using-ssh-for-ipv6-enabled-http-proxying#comments</comments>
		<pubDate>Fri, 11 Nov 2011 16:50:26 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=358</guid>
		<description><![CDATA[My ISP has apparently made no progress whatsoever with IPv6, but I&#8217;ve got an IPv6 enabled VPS. SSH makes it trivial to use that VPS as a SOCKS5 proxy. Just do: ssh -D 8080 myvps.example.com Then set your browser&#8217;s SOCKS proxy to localhost:8080. In Firefox on Linux, this is Edit &#62; Preferences &#62; Advanced &#62; [...]]]></description>
			<content:encoded><![CDATA[<p>My ISP has apparently made no progress whatsoever with IPv6, but I&#8217;ve got an IPv6 enabled VPS.</p>
<p>SSH makes it trivial to use that VPS as a SOCKS5 proxy. Just do:</p>
<p><code>ssh -D 8080 myvps.example.com</code></p>
<p>Then set your browser&#8217;s SOCKS proxy to localhost:8080. In Firefox on Linux, this is Edit &gt; Preferences &gt; Advanced &gt; Network tab &gt; (Connection) Settings &gt; Manual Proxy Configuration. Leave <em>all fields blank</em> except for SOCKS Host and Port &#8212; localhost and 8080, respectively. Choose SOCKS5. Then browse to about:config and change <code>change network.proxy.socks_remote_dns</code> to true. This tells Firefox to ask the proxy to resolve names instead of trying to resolve them using your ISP. Chrome worked for me without hassle.</p>
<p>Go to <a href="http://test-ipv6.com/">test-ipv6.com</a> to test that it works. If your results from test-ipv6.com indicate that IPv6 name lookups are failing, make sure you&#8217;ve got that about:config setting mentioned above changed.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/using-ssh-for-ipv6-enabled-http-proxying/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing Certificate Errors with Cisco AnyConnect</title>
		<link>http://blog.bstpierre.org/fixing-certificate-errors-with-cisco-anyconnect</link>
		<comments>http://blog.bstpierre.org/fixing-certificate-errors-with-cisco-anyconnect#comments</comments>
		<pubDate>Sun, 06 Nov 2011 15:50:20 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=351</guid>
		<description><![CDATA[&#8220;AnyConnect cannot confirm it is connected to your secure gateway. The local network may not be trustworthy. Please try another network.&#8221; There may be several reasons for this error, which you&#8217;ll find on other pages that hit for a search on this string. The reason that I encountered seems to be unique. What I found [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>&#8220;AnyConnect cannot confirm it is connected to your secure gateway. The local network may not be trustworthy. Please try another network.&#8221;</p></blockquote>
<p>There may be several reasons for this error, which you&#8217;ll find on other pages that hit for a search on this string.</p>
<p>The reason that I encountered seems to be unique. What I found by digging into a wireshark capture is that AnyConnect sends a TLS alert to the server, disconnecting the session. The alert message says &#8220;Unknown CA&#8221;.</p>
<p>It could have something to do with installing the firefox plugin  &#8220;Certificate Patrol&#8221; recently. AnyConnect apparently uses firefox&#8217;s  certificate store. Perhaps Certificate Patrol does something to the  store that makes it so that AnyConnect can no longer use it?</p>
<p>In case it matters, I&#8217;m on Ubuntu 10.04.</p>
<p>Whatever the cause, you can fix it by doing the following:</p>
<ol>
<li>Figure out the CA that signs your VPN server&#8217;s certificate. (Hat tip to <a href="http://blog.didierstevens.com/2007/12/23/quickpost-retrieving-an-ssl-certificate/">Didier Stevens</a> for the easy way to do this.)
<ol>
<li style="text-align: left;">Fill in your server, I&#8217;m going to use www.google.com.</li>
<li style="text-align: left;">openssl s_client -connect www.google.com:443 &gt;! /tmp/google</li>
<li style="text-align: left;">Hit ctrl-C.</li>
<li style="text-align: left;">You saw &#8220;Thawte Consulting (Pty) Ltd.&#8221;.</li>
</ol>
</li>
<li>Now search for &#8220;thawte root certificate&#8221;. (Obviously this will vary depending on who signs your server&#8217;s certificate.)</li>
<li>Go to the page where they list certificates. Download them all. (I tried downloading the one that looked like it matched the signature on my server&#8217;s certificate, but I think you need everything down to the root in order to fully verify it. It&#8217;s easier to just download everything than try to figure out exactly which ones are needed.)</li>
<li>Convert to PEM format. (Hat tip to <a href="http://moze.koze.net/?p=81">Mozekoze for this recipe</a>.)
<ol>
<li>openssl x509 -in input.crt -out input.der -outform DER ## (if the certs are in .crt format)</li>
<li>openssl x509 -in input.der -inform DER -out output.pem -outform PEM</li>
</ol>
</li>
<li>Copy all the PEM files to /opt/.cisco/certificates/ca. (Or to ~/.cisco/certificates/ca.)</li>
</ol>
<p>Alternatively, you could copy the certs out of the keystore on your machine, convert to PEM, and then copy the PEMs into the directory mentioned above. (On ubuntu, you can see the certificates in the package ca-certificates. You could copy just the thawte certs by doing something like &#8220;cp $(dpkg -L ca-certificates | grep -i thawte) /tmp/certificate-conversion/&#8221;.)</p>
<p>Three cheers for wireshark, strace, openssl, and google for help figuring out what was going on. Cisco <em>could</em> make things a little bit easier to figure out &#8212; a decent diagnostic message would have been great &#8212; just tell the user &#8220;Unknown CA&#8221;, it&#8217;s already buried in the wireshark trace.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/fixing-certificate-errors-with-cisco-anyconnect/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Use Linux to build win32 installers for Python apps</title>
		<link>http://blog.bstpierre.org/linux-win32-python-installer</link>
		<comments>http://blog.bstpierre.org/linux-win32-python-installer#comments</comments>
		<pubDate>Wed, 20 Jul 2011 15:00:36 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=319</guid>
		<description><![CDATA[A python-based project I&#8217;m working on has a win32 user that I need to support. Until yesterday I&#8217;ve been moving to a win32 laptop in order to run python setup.py bdist_wininst so I can produce a self-installing executable. Then I discovered how trivial it is to use wine to do the job: Install wine. (sudo [...]]]></description>
			<content:encoded><![CDATA[<p>A python-based project I&#8217;m working on has a win32 user that I need to support. Until yesterday I&#8217;ve been moving to a win32 laptop in order to run <code>python setup.py bdist_wininst</code> so I can produce a self-installing executable. Then I discovered how trivial it is to use wine to do the job:</p>
<ol>
<li>Install wine. (<code>sudo aptitude install wine</code>)</li>
<li>Install python into the wine environment. (Download an msi from python.org and run <code>msiexec /i python-x.x.x.msi</code>.)</li>
<li>Install whatever prerequisite packages you need (e.g. wxPython) using <code>wine</code> or <code>msiexec</code>.</li>
<li>When you&#8217;ve got everything ready to build, just do <code>wine c:/Python27/python.exe setup.py bdist_wininst</code> and look in ./dist/ for your exe!</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/linux-win32-python-installer/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An Interesting pid File Race</title>
		<link>http://blog.bstpierre.org/pid-file-race</link>
		<comments>http://blog.bstpierre.org/pid-file-race#comments</comments>
		<pubDate>Wed, 26 May 2010 16:08:50 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[software-engineering]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=305</guid>
		<description><![CDATA[ISC&#8217;s dhcpd uses this code to check for an already-running daemon: /* Read previous pid file. */ if ((i = open (path_dhcpd_pid, O_RDONLY)) &#62;= 0) { status = read (i, pbuf, (sizeof pbuf) - 1); close (i); if (status &#62; 0) { pbuf [status] = 0; pid = atoi (pbuf); /* If the previous server [...]]]></description>
			<content:encoded><![CDATA[<p>ISC&#8217;s dhcpd uses <a href="http://google.com/codesearch/p?hl=en#5KTrgOW2hXs/pub/nslu2/sources/dhcp-3.0.4.tar.gz|9nqObdv7Xcs/dhcp-3.0.4/server/dhcpd.c&amp;q=_PATH_DHCPD_CONF&amp;d=3&amp;l=539">this code</a> to check for an already-running daemon:</p>
<pre>/* Read previous pid file. */
if ((i = open (path_dhcpd_pid, O_RDONLY)) &gt;= 0) {
    status = read (i, pbuf, (sizeof pbuf) - 1);
    close (i);
    if (status &gt; 0) {
        pbuf [status] = 0;
        pid = atoi (pbuf);

        /* If the previous server process is not still running,
           write a new pid file immediately. */
        if (pid &amp;&amp; (pid == getpid() || kill (pid, 0) &lt; 0)) {
            unlink (path_dhcpd_pid);
            if ((i = open (path_dhcpd_pid,
                           O_WRONLY | O_CREAT, 0644)) &gt;= 0) {
                sprintf (pbuf, "%d\n", (int)getpid ());
                write (i, pbuf, strlen (pbuf));
                close (i);
                pidfilewritten = 1;
            }
        } else
            log_fatal ("There's already a DHCP server running.");
    }
}
</pre>
<p>The problem with this strategy is that, if the box dies, there&#8217;s a stale pid file left in /var/run/dhcpd.pid. This wouldn&#8217;t be so bad &#8212; the code above checks [using <code>kill(pid, 0)</code>] to see if there&#8217;s a process running with that pid. But when the box is restarting, there will be a bunch of processes all starting in similar sequence each time. So on one boot, you might see dhcpd with a pid of 1001 and ntpd with a pid of 1002. If the box dies violently (e.g. power cut), the dhcpd pid file will contain 1001. On the second boot, assume ntpd starts first and gets a pid of 1001 and dhcpd is 1002. Now, the <code>kill(pid, 0)</code> will succeed, making it appear that dhcpd is already running, and dhcpd will exit.</p>
<p>How to fix this?</p>
<ol>
<li>Explicitly put the pid file under /tmp. Getting this right is fussy &#8212; make sure you avoid the race conditions associated with creating temp files. Use dhcpd&#8217;s &#8220;-pf&#8221; flag to tell it where to use the pid file. This avoids spurious &#8220;already running&#8221; messages, because dhcpd will never read a pid from an existing pid file. [You could also just remove the /var/run/dhcpd.pid file, but I'd rather explicitly provide the path in my startup script in case some dim bulb decides to change the compiled-in default.]</li>
<li>Be careful in your restart code to kill any existing dhcpd (assuming you really want a new dhcpd), or avoid trying to start a new one (assuming you want to use an already running dhcpd). <code>pgrep(1)</code> and <code>pkill(1)</code> will be useful here.</li>
</ol>
<p>In researching this, I saw this <a href="http://openbsd.monkey.org/misc/200601/msg00735.html">bit of wisdom from Henning Brauer</a>: &#8220;pid files are useless.&#8221;.</p>
<p>I heartily agree&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/pid-file-race/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

