<?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>Penguins in a Strange Land &#187; Unix</title>
	<atom:link href="http://strange.nsk.pt/category/unix/feed/" rel="self" type="application/rss+xml" />
	<link>http://strange.nsk.pt</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 26 Jul 2010 12:29:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fedora 12 on Compaq/HP Mini 311</title>
		<link>http://strange.nsk.pt/2010/01/fedora-12-on-compaqhp-mini-311/</link>
		<comments>http://strange.nsk.pt/2010/01/fedora-12-on-compaqhp-mini-311/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 20:07:22 +0000</pubDate>
		<dc:creator>luciano</dc:creator>
				<category><![CDATA[Unix]]></category>
		<category><![CDATA[311]]></category>
		<category><![CDATA[compaq]]></category>
		<category><![CDATA[f12]]></category>
		<category><![CDATA[fedora12]]></category>
		<category><![CDATA[hp]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://strange.nsk.pt/?p=85</guid>
		<description><![CDATA[I&#8217;ve been late to update to Fedora 12, and I&#8217;ve kept my installation at Fedora 11. Oh, but I couldn&#8217;t update my kernel either. It seems the following module is to blame:

$ modinfo ssb
filename:       /lib/modules/2.6.29.4-167.fc11.i586/kernel/drivers/ssb/ssb.ko
license:        GPL
description:    Sonics Silicon Backplane [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been late to update to Fedora 12, and I&#8217;ve kept my installation at Fedora 11. Oh, but I couldn&#8217;t update my kernel either. It seems the following module is to blame:<br />
<code><br />
$ modinfo ssb<br />
filename:       /lib/modules/2.6.29.4-167.fc11.i586/kernel/drivers/ssb/ssb.ko<br />
license:        GPL<br />
description:    Sonics Silicon Backplane driver<br />
srcversion:     A3AE34BE4010797EEEB08AF<br />
....<br />
</code></p>
<p>What is <code>ssb.ko</code>? Well, according to <code>Kconfig</code> in the corresponding source directory, it&#8217;s probably related to some Broadcom device.</p>
<p>Now that I know the culprit, I can continue the installation. Oh, I installed Fedora 12 by <code>dd(1)</code>ing the ext4 filesystem in <code>LiveOS/ext3fs.img</code> (that itself is in <code>LiveOS/squashfs.img</code> in the LiveCD image) under my old installation of Fedora 11. That allowed me to download and compile the wireless driver (in package kmod-wl) without requiring a cabled network.</p>
<p>So, how to disable the module? In the installed system, just add a line in <code>/etc/modprobe.d/blacklist.conf</code>. As for when booting, LiveCD or system? Well, by <code>grep(1)</code>ing the contents of the initrd, it&#8217;s by using the following parameter: <code>rdblacklist=ssb</code>.</p>
<p>And how did I found out this module was the culprit? Booting with the arguments: <code>udevtrace udevlog init=/bin/bash</code></p>
<p>I was booted directly to bash, then did: <code>strace -f -e open /sbin/start_udev</code></p>
<p><code>udevd</code> will start, serializing the events, and being a little slower, allowing me to see the point of failure.</p>
<p>Now, to migrate the configuration&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://strange.nsk.pt/2010/01/fedora-12-on-compaqhp-mini-311/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux guest account</title>
		<link>http://strange.nsk.pt/2009/12/linux-guest-account/</link>
		<comments>http://strange.nsk.pt/2009/12/linux-guest-account/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 17:20:51 +0000</pubDate>
		<dc:creator>luciano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[gdm]]></category>
		<category><![CDATA[guest]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://strange.nsk.pt/?p=77</guid>
		<description><![CDATA[So, you have a Linux system and want to show its hawtness to random stranges, but without having them mess with the system permanently? And use that account for those airport checks automatically? Well, it&#8217;s easy.

Disable remote login for the guest account:
echo DenyUsers guest &#62;&#62; /etc/ssh/sshd_config
service sshd condrestart

Create the guest account:
adduser guest
Make the guest account [...]]]></description>
			<content:encoded><![CDATA[<p>So, you have a Linux system and want to show its hawtness to random stranges, but without having them mess with the system permanently? And use that account for those airport checks automatically? Well, it&#8217;s easy.</p>
<ol>
<li>Disable remote login for the guest account:
<pre>echo DenyUsers guest &gt;&gt; /etc/ssh/sshd_config
service sshd condrestart
</pre>
<li>Create the guest account:
<pre>adduser guest</pre>
<li>Make the guest account home directory a filesystem in RAM:
<pre>echo "guest /home/guest tmpfs size=20%,
  mode=0700,uid=$(id -u guest),gid=$(id -g guest) 0 0" &gt;&gt; /etc/fstab
</pre>
<li>And finally configure the system to automatically login as guest:
<pre>
echo '
[daemon]
TimedLoginEnable=true
TimedLogin=guest
TimedLoginDelay=15
' >> /etc/gdm/custom.conf
</pre>
</ol>
<p>That&#8217;s it. On your next reboot, and if you do nothing, you&#8217;ll be logged in as <code>guest</code>. If you don&#8217;t like that the terminal for the guest user doesn&#8217;t include a pretty prompt, you may change the fstab entry, mounting the <code>tmpfs</code> somewhere else, like <code>/home/.guest</code>, and then have a <code>funionfs</code> mount for <code>~</code> with <code>/etc/skel</code> on top.</p>
<p>On boot, just make sure to cancel the automatic login, if you want to log in as another user.</p>
]]></content:encoded>
			<wfw:commentRss>http://strange.nsk.pt/2009/12/linux-guest-account/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encrypted home filesystem with pam_mount</title>
		<link>http://strange.nsk.pt/2009/12/encrypted-home-filesystem-with-pam_mount/</link>
		<comments>http://strange.nsk.pt/2009/12/encrypted-home-filesystem-with-pam_mount/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 17:02:41 +0000</pubDate>
		<dc:creator>luciano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[home]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[luks]]></category>
		<category><![CDATA[pam_mount]]></category>

		<guid isPermaLink="false">http://strange.nsk.pt/?p=64</guid>
		<description><![CDATA[There are several reasons for having an encrypted home partition. But usually, everyone should have it, if only for the reason that disks do go bad, and you don&#8217;t want to replace it and leave private data behind.
With that in mind, there are several options, depending in your operating system and security requirements. In this [...]]]></description>
			<content:encoded><![CDATA[<p>There are several reasons for having an encrypted home partition. But usually, everyone should have it, if only for the reason that disks do go bad, and you don&#8217;t want to replace it and leave private data behind.</p>
<p>With that in mind, there are several options, depending in your operating system and security requirements. In this howto I&#8217;ll be concentrating on <code>pam_mount</code>, using a LUKS encrypted partition. Probably limited to Linux, then. PAM works in many Unix systems, but LUKS may be restricted.</p>
<p>But before beginning, you have to choose between security and speed. By that, I mean choose an encryption and chaining algorithms. For the most security, I recommend <code>aes-xts-plain</code>, with <code>essiv:sha256</code> for IV calculation. For speed, though, on my netbook, I use <code>blowfish-ecb-plain</code>. Blowfish is slightly faster than AES, and not much less secure, but the ECB chaining mode is the fastest and very much insecure method. So choose wisely. Personally, my data isn&#8217;t that important, and if cryptanalysts are interested in it, there are better methods on getting the data: <a href="http://xkcd.com/538/">http://xkcd.com/538/</a></p>
<p>Now that you have chosen the algorithm, it&#8217;s time to encrypt your swap partition. That&#8217;s right, never forget the swap partition, where sensitive data may be swapped out to:</p>
<pre>echo 'swap /dev/sdaX /dev/urandom swap,cipher=blowfish-ecb-plain'
  &gt;&gt; /etc/crypttab
echo '/dev/mapper/swap    swap    swap    defaults    0 0' &gt;&gt; /etc/fstab</pre>
<p>Then reboot. Make sure you correct the swap device and replace the current entry in <code>/etc/fstab</code>.</p>
<p>Make a backup of your current home folder, or start from a clean state. Choose the partition you want your home to reside on, and format it as a LUKS device. First, however, you should zero the first megabyte or two, so that the detection code doesn&#8217;t mistake it as other filesystem:</p>
<pre>dd if=/dev/zero of=/dev/sdaY bs=16M count=1</pre>
<p>Take care to erase the correct device! And if it contained sensitive data, then remove the <code>count=1</code> and let it zero the full partition. Next, format it as LUKS. I&#8217;ll be using the less secure algorithm. When asked for a passphrase, enter your user&#8217;s.</p>
<pre>cryptsetup luksFormat /dev/sdaY --cipher blowfish-ecb-plain --key-size 128</pre>
<p>OK, you now have a device formated for encryption. Next step, activate it, and format a real filesystem on top:</p>
<pre>cryptsetup luksOpen /dev/sdaY enc</pre>
<p>This will create the device: <code>/dev/mapper/enc</code></p>
<p>For filesystem, choose what you will. I use <code>ext4</code>:</p>
<pre>mkfs.ext4 /dev/mapper/enc</pre>
<p>Then mount it, and restore your original data. Or start from scratch:</p>
<pre>mount /dev/mapper/enc /mnt
cp -a /etc/skell/.[[:alnum:]]* /mnt/
chown user: /mnt -R
umount /mnt</pre>
<p>Your home is ready! Unmount it, the job of mounting and unmounting will be done by <code>pam_mount</code>:</p>
<pre>umount /mnt
cryptsetup luksClose enc</pre>
<p>The preliminaries are done. You have your home in an encrypted device. Now, to configure <code>pajm_mount</code> for automatically mount and unmount it.</p>
<p>Make sure you have <code>pam_mount</code> installed in your system. The package is called like the name in Fedora, and <code>libpam-mount</code> in Debian/Ubuntu. The configuration file is <code>/etc/security/pam_mount.conf.xml</code>, read it, and disable any limitation you&#8217;re interested in. Add a line for your user:</p>
<pre>&lt;volume user="luciano" path="/dev/sdaY" mountpoint="~" options="" /&gt;</pre>
<p>Note the empty <code>options</code> key, otherwise some default options may get in your way. Try either way. If you didn&#8217;t zero the device, and it gets detected as something else than a LUKS device, then add <code>fstype="crypt_LUKS"</code> to the line. You can see what it is detected as with:</p>
<pre># blkid /dev/sdaY
/dev/sdaY: UUID=".." SEC_TYPE="ext2" TYPE="ext3"</pre>
<p>If it doesn&#8217;t say LUKS, then you must add the <code>fstype</code> definition.</p>
<p><code>pam_mount</code> is now set up. Next, configure PAM to use it. There are some particularities for <code>pam_mount</code>, especially because GDM may try to start daemons as your user before you get your home mounted. Created a configuration file that will be include by other PAM-aware services, defining <code>pam_mount</code></p>
<pre>echo '
auth	optional	pam_mount.so
session	optional	pam_mount.so
' &gt;&gt; /etc/pam.d/system-mount</pre>
<p>Now, depending on your current PAM configuration, you may get away with doing the following steps only to the <code>/etc/pam.d/system-auth</code> or other generic file, included by services&#8217; definitions. But that is not the case for Fedora 11, and do make sure all services include the generic file first.<br />
In my case, I changed the files:</p>
<ul>
<li><code>/etc/pam.d/sshd</code></li>
<li><code>/etc/pam.d/login</code></li>
<li><code>/etc/pam.d/gdm-password</code></li>
</ul>
<p>Now, add the following line as the first <strong>auth</strong> definition, or as the definition immediately after an <code>selinux</code> <strong>permit</strong> or <strong>close</strong> action:</p>
<pre>auth        include       system-mount</pre>
<p>Also, for <strong>session</strong>, respecting the <code>selinux</code> thingy:</p>
<pre>session     include       system-mount</pre>
<p>Now try logging in as the user in a console, or via ssh. You should see the prompt for password as: <code>pam_mount password:</code><br />
If it works, then try a graphical login. Console is easier, a graphical login may get <code>dbus</code> or <code>keyring</code> programs running before the pam_mount is run, but you&#8217;ll prevent that by having the <code>system-mount</code> lines as the first ones.</p>
]]></content:encoded>
			<wfw:commentRss>http://strange.nsk.pt/2009/12/encrypted-home-filesystem-with-pam_mount/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Remote access to VirtualIron Nodes</title>
		<link>http://strange.nsk.pt/2009/12/remote-access-to-virtualiron-nodes/</link>
		<comments>http://strange.nsk.pt/2009/12/remote-access-to-virtualiron-nodes/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 10:53:23 +0000</pubDate>
		<dc:creator>luciano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://strange.nsk.pt/?p=55</guid>
		<description><![CDATA[You can execute commands on VirtualIron nodes, using the supplied support_tools/testagent program, like this:
./support_tools/testagent 192.168.0.1 --exec="ls"
But this is cumbersome. Run the following commands to activate the ssh daemon:
ip=192.168.0.1
ag=./support_tools/testagent
$ag $ip --exec='ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -C "" -N ""'
$ag $ip --exec='
   echo sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
   &#62;&#62; /etc/passwd'
$ag $ip --exec='/usr/sbin/sshd'
$ag $ip --exec='echo r00t:FBx3ZpLywKVEk:0:0::/root:/bin/bash &#62;&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>You can execute commands on VirtualIron nodes, using the supplied <code>support_tools/testagent</code> program, like this:</p>
<pre>./support_tools/testagent 192.168.0.1 --exec="ls"</pre>
<p>But this is cumbersome. Run the following commands to activate the ssh daemon:</p>
<pre>ip=192.168.0.1
ag=./support_tools/testagent
$ag $ip --exec='ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -C "" -N ""'
$ag $ip --exec='
   echo sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
   &gt;&gt; /etc/passwd'
$ag $ip --exec='/usr/sbin/sshd'
$ag $ip --exec='echo r00t:FBx3ZpLywKVEk:0:0::/root:/bin/bash &gt;&gt; /etc/passwd'
</pre>
<p>The last command creates a user with login <code>r00t</code> and password <code>foobar</code>.</p>
<p>This is useful for when a node&#8217;s agent locks and you can&#8217;t use it in the Virtualization Manager Console. Usually, some SCSI scan process gets stuck in the <code>D</code> state. Search for the <code>storage_discover.py</code> process, kill it, and the node will be available once again.</p>
<p>But remember: with great power, comes great responsibility!</p>
]]></content:encoded>
			<wfw:commentRss>http://strange.nsk.pt/2009/12/remote-access-to-virtualiron-nodes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shell tip: remove directories from listings</title>
		<link>http://strange.nsk.pt/2009/09/shell-tip-remove-directories-from-listings/</link>
		<comments>http://strange.nsk.pt/2009/09/shell-tip-remove-directories-from-listings/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 14:27:23 +0000</pubDate>
		<dc:creator>luciano</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Unix]]></category>

		<guid isPermaLink="false">http://strange.nsk.pt/2009/09/shell-tip-remove-directories-from-listings/</guid>
		<description><![CDATA[With the output of a &#8216;find&#8217; command, or other, sorted list of entries:
(o=; while read f; do [ -n "$o" ] &#38;&#38; [ "${f#$o/}" == "$f" ] &#38;&#38; echo "$o"; o="$f"; done; echo "$o") &#60; list
Meaning: show a line only if next line doesn&#8217;t include this one (if last line is a directory, it still [...]]]></description>
			<content:encoded><![CDATA[<p>With the output of a &#8216;find&#8217; command, or other, sorted list of entries:<br />
<code>(o=; while read f; do [ -n "$o" ] &amp;&amp; [ "${f#$o/}" == "$f" ] &amp;&amp; echo "$o"; o="$f"; done; echo "$o") &lt; list</code></p>
<p>Meaning: show a line only if next line doesn&#8217;t include this one (if last line is a directory, it still shows).</p>
]]></content:encoded>
			<wfw:commentRss>http://strange.nsk.pt/2009/09/shell-tip-remove-directories-from-listings/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>shell tip: check if private key matches public certificate</title>
		<link>http://strange.nsk.pt/2009/09/shell-tip-check-if-private-key-matches-public-certificate/</link>
		<comments>http://strange.nsk.pt/2009/09/shell-tip-check-if-private-key-matches-public-certificate/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 14:22:23 +0000</pubDate>
		<dc:creator>luciano</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[tls]]></category>

		<guid isPermaLink="false">http://strange.nsk.pt/2009/09/shell-tip-check-if-private-key-matches-public-certificate/</guid>
		<description><![CDATA[Compare the output of the following two lines. They must match:
$ openssl x509 -noout -modulus -in server.pem &#124; openssl md5
$  openssl rsa -noout -modulus -in server.key &#124; openssl md5
]]></description>
			<content:encoded><![CDATA[<p>Compare the output of the following two lines. They must match:<br />
<code>$ openssl x509 -noout -modulus -in server.pem | openssl md5<br />
$  openssl rsa -noout -modulus -in server.key | openssl md5</code></p>
]]></content:encoded>
			<wfw:commentRss>http://strange.nsk.pt/2009/09/shell-tip-check-if-private-key-matches-public-certificate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shell tip: finding lines in file a not in file b</title>
		<link>http://strange.nsk.pt/2009/09/shell-tip-finding-lines-in-file-a-not-in-file-b/</link>
		<comments>http://strange.nsk.pt/2009/09/shell-tip-finding-lines-in-file-a-not-in-file-b/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 14:19:04 +0000</pubDate>
		<dc:creator>luciano</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://strange.nsk.pt/2009/09/shell-tip-finding-lines-in-file-a-not-in-file-b/</guid>
		<description><![CDATA[$ sort a &#60;(sed -e p b) &#124; uniq -u
Meaning: list unique lines in (contents of file &#8216;a&#8217; plus duplicated contents of file &#8216;b&#8217;). &#8217;sort&#8217; is required for &#8216;uniq&#8217; to work.
]]></description>
			<content:encoded><![CDATA[<p><code>$ sort a &lt;(sed -e p b) | uniq -u</code><br />
Meaning: list unique lines in (contents of file &#8216;a&#8217; plus duplicated contents of file &#8216;b&#8217;). &#8217;sort&#8217; is required for &#8216;uniq&#8217; to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://strange.nsk.pt/2009/09/shell-tip-finding-lines-in-file-a-not-in-file-b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
