<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>About System Administration</title>
<link>http://mixinet.net/~sto/blog/sysadmin/</link>
<description>StoWiki</description>
<item>
	
	<title>Encrypting a Debian GNU/Linux installation (take 3)</title>
	
	<guid>http://mixinet.net/~sto/blog/sysadmin/20090226_macbook_cryptsetup_take_3/</guid>
	<link>http://mixinet.net/~sto/blog/sysadmin/20090226_macbook_cryptsetup_take_3/</link>
	
	<pubDate></pubDate>
	<description><![CDATA[<p>After my <a href="http://mixinet.net/~sto/blog/sysadmin/20090225_macbook_cryptsetup_followup/">followup</a> to the Tuesday 
<a href="http://mixinet.net/~sto/blog/sysadmin/20090222_macbook_cryptsetup/">post</a> I've received some additional comments
and I'm writing this entry to close the subject... ;)</p>

<p>One of the comments was from <a href="http://gwolf.org/">Gunnar</a> to tell me that the
<em>followup</em> setup was the same provided by the automatic partitioner of the
<a href="http://www.debian.org/devel/debian-installer/">Debian Installer</a> since 2007.</p>

<p>I was unaware of that because until some weeks ago I never tried to install a
system with encryption support and when I did it on my laptop I used the
manual setup because I wanted to keep the <strong>MacOS X</strong> partitions.</p>

<p>Anyway my <a href="http://mixinet.net/~sto/blog/sysadmin/20090225_macbook_cryptsetup_followup/">followup</a> blog entry made
sense anyway, as I just wanted to comment my thoughts about the advantages and
disadvantages of each partitioning schema.</p>

<p>I also received a couple of messages proposing the use of three layers to
keep the flexibility of the original setup and the simplicity of the second;
the setup is as follows:</p>

<ul>
<li><em>Layer 1</em>: use LVM on a physical volume,</li>
<li><em>Layer 2</em>: create a logical volume and format it as an encrypted volume,</li>
<li><em>Layer 3</em>: use LVM on top of the encrypted logical volume and put there the
file systems that you want encrypted.</li>
</ul>

<p>With the LVM at the lower level you get the advantages of my setup (mix
encrypted and unencrypted partitions, the crypted volume can use multiple
physical volumes, etc.) and the advantages of the second setup (only one key
for all the encrypted file systems).</p>

<p>I believe that this setup is a little too much for a laptop, but can be a good
option if you need encrypted file systems on a server.</p>
]]></description>
</item>
<item>
	
	<title>Encrypting a Debian GNU/Linux installation (followup)</title>
	
	<guid>http://mixinet.net/~sto/blog/sysadmin/20090225_macbook_cryptsetup_followup/</guid>
	<link>http://mixinet.net/~sto/blog/sysadmin/20090225_macbook_cryptsetup_followup/</link>
	
	<pubDate></pubDate>
	<description><![CDATA[<p>Yesterday I received a mail message from a Debian user called Ekrem Erdem
about my previous <a href="http://mixinet.net/~sto/blog/sysadmin/20090222_macbook_cryptsetup/">post</a>, proposing a different
partitioning schema that I found interesting.</p>

<p>The basic idea is to swap the order of the technologies, that is, use LVM on
top of an encrypted partition instead of encrypting logical volumes.</p>

<p>I never thought about this schema because I always use LVM on servers and that
is one of the fist things I setup (just after software RAID-1, if the machine
has two hard drives); when I was evaluating how to setup my system for
encryption I started with the LVM setup and never looked back.</p>

<p>The advantage of this setup is that there is only one pass phrase (the one used
to unlock the encrypted partition, <code>sda4</code> in my case), eliminating the need of
derived keys (i. e. my swap setup) or key files (I use them to mount snapshots
of the encrypted partition non interactively).</p>

<p>On the negative side I believe that this setup looses some flexibility:</p>

<ul>
<li><p>On my original model crypted and unencrypted partitions can coexist on the
same volume group, while the new setup requires a different volume group
for unencrypted volumes.</p></li>
<li><p>If the user wants to have multiple partitions each one can use a different
pass phrase or key file.</p></li>
<li><p>If a logical volume is expanded through multiple physical volumes the new
setup requires a key for each physical volume, while the original setup only
needs one key.</p></li>
</ul>

<p>Anyway if the plan is to encrypt all the file systems on a laptop the proposed
setup is simpler and, IMHO, as safe as my configuration (remember that my keys
are related).</p>

<p>I'm not going to change my setup now (it works great), but I'll probably try
this one in the future if I need an encrypted setup on a different machine.</p>
]]></description>
</item>
<item>
	
	<title>Encrypting a Debian GNU/Linux installation on a MacBook</title>
	
	<guid>http://mixinet.net/~sto/blog/sysadmin/20090222_macbook_cryptsetup/</guid>
	<link>http://mixinet.net/~sto/blog/sysadmin/20090222_macbook_cryptsetup/</link>
	
	<pubDate></pubDate>
	<description><![CDATA[<p>A couple of weeks ago I updated my <strong>Debian Sid</strong> setup on the <strong>MacBook</strong> to
use disk encryption; this post is to document what I did for later reference.</p>

<p>The system was configured for dual booting <strong>Debian</strong> or <strong>Mac OS X</strong> using
<code>refit</code> and <code>grub2</code> as documented on the <a href="http://wiki.debian.org/MacBook/">Debian
Wiki</a>; I don't use the <strong>Mac OS X</strong> system
much, but I left it there to be able to test things and be able to answer
questions of <strong>Mac OS X</strong> users when I have to.</p>

<p>The Debian installation was done using two primary partitions, one for <em>swap</em>
(I used a partition to be able to suspend to disk without troubles) and an
<code>ext3</code> file system used as the <em>root</em> file system.</p>

<p>The plan was to use the <strong>Debian Installer</strong> to do the disk setup and recover
the Sid installation from a backup once the encrypted setup was working OK.</p>

<h2>Backup for later recovery</h2>

<p>My first step was to install all the needed packages on the original system;
basically I verified that I had the <code>lvm2</code> and <code>cryptsetup</code> packages
installed.</p>

<p>The second step was to backup the root file system; to do it I changed to
run level 1 and copied the files to an external USB disk using <code>rsync</code>.</p>

<p>My third step was to boot into <strong>Mac OS X</strong> to reduce the space assigned to
it; I had a lot of free space that I didn't plan to use with <strong>Mac OS X</strong> and
I thought that this was the best occasion to reassign it to the Debian
file system.</p>

<h2>Encrypted Lenny installation</h2>

<p>Now the machine was ready for the installer. As I formatted the system a couple
of weeks ago I used a daily build of the <em>Lenny Debian Installer</em>, now that
<strong>Lenny</strong> is out I would have used the official version.</p>

<p>I booted the installer and on the partition disk step I selected the manual
method; I left <code>sda1</code> and <code>sda2</code> as they were (the <strong>Mac OS X</strong> installation
uses them) and set up <code>sda3</code> and <code>sda4</code> as follows:</p>

<ul>
<li><code>sda3</code>: 256 MB, use as <code>ext3</code>, mount point: <code>/boot</code></li>
<li><code>sda4</code>: 86 GB, use as physical volume for LVM</li>
</ul>

<p>Note that I decided to put <code>/boot</code> on a plain <code>ext3</code> partition to be able to
use <strong>grub2</strong> as the boot loader (if we put the kernel on an LVM logical volume
we need to use <code>lilo</code> as the boot loader).</p>

<p>Once <code>sda4</code> was adjusted as LVM I entered on the <code>LVM setup</code> and created a LVM
Volume Group (VG) with the name <code>debian</code>, using <code>sda4</code> as the physical volume.</p>

<p>Once the VG was defined I created a couple of Logical Volumes (LV):</p>

<ul>
<li><code>root</code>: 82 GB</li>
<li><code>swap</code>: 2  GB</li>
</ul>

<p>I left some space unallocated to be able to create LVM snapshots (I use them
to do backups, I'll post about it on the next days).</p>

<p>Once the LV were ready I finished with the LVM setup and went back to the
partitioner to configure the <em>Logical Volumes</em>:</p>

<ul>
<li>debian-root: use as physicals volume for encryption</li>
<li>debian-swap: use as pascal volume for encryption, encryption key: random</li>
</ul>

<p>Once both encrypted volumes were ready I entered on the <em>Configure the
encrypted volumes menu</em> and the installer formatted the volumes for encryption
and asked for the  <code>debian-root</code> pass phrase.</p>

<p>Back on the main partitioning menu I set up the <code>debian-root_crypt</code> encrypted
volume:</p>

<ul>
<li>debian-root_crypt: use as <code>ext3</code>, mount point: <code>/</code>.</li>
</ul>

<p>I didn't need to touch the <code>debian-swap_crypt</code>, it was configured
automatically as <em>swap</em> because I choose a random encryption key.</p>

<p>At this point I was finished with the partitioning; to finish I installed a
minimal system and rebooted to try the system.</p>

<p>As I had changed the disk layout I had to <em>re-sync</em> the partition tables from
<code>refit</code>; once that was done I was able to boot from the newly installed
system.</p>

<h2>Setting up suspend to disk</h2>

<p>I was using <code>s2disk</code> to suspend the system; to test if it still worked with
the new setup I installed the <code>uswsusp</code> package and adjusted the <code>resume
device</code> on the <code>/etc/uswsusp.conf</code> to <code>/dev/mapper/debian-swap_crypt</code>.</p>

<p>After my first try I noticed that the <em>resume</em> step failed with the encrypted
swap partition because it was using a random key, which means that the swap
contents are unrecoverable after a reboot.</p>

<p>Looking at the <code>cryptsetup</code> documentation I found that the solution was to use
a <em>derived key</em> for the swap partition instead of a <em>random</em> one.</p>

<p>The command sequence was as follows:</p>

<pre><code># disable swap
swapoff -a
# close encrypted volume
cryptsetup luksClose debian-swap_crypt
# change the swap partition setup on the /etc/crypttab file
sed -e -i 's%^debian-swap.*%debian-swap_crypt /dev/mapper/debian-swap debian-root_crypt cipher=aes-cbc-essiv:sha256,size=256,swap,hash=sha256,keyscript=/lib/cryptsetup/scripts/decrypt_derived,swap%' /etc/crypttab
# open the encrypted volumes with the new setup
/etc/init.d/cryptdisks start
# enable swap
swapon -a
# update the initrd image
update-initramfs -u
</code></pre>

<p>After executing all those commands the suspend to disk system worked as
expected.</p>

<h2>Recovering the original system</h2>

<p>If I were going to reinstall the system completely I would have finished here,
but in my case I wanted to recover my original system setup (except the
minimal changes required to use the encrypted passions, of course).</p>

<p>To recover my old installation I backed up some files (<code>/etc/fstab</code>,
<code>/etc/crypttab</code>, <code>/etc/uswsusp.conf</code> and the current <code>/boot</code> contents to be
able to boot in case of failure with my old kernel) from the current
installation, after that I recovered all the files from the initial backup
(except the ones just saved) using <code>rsync</code> again and regenerated the initrd
images of my old kernels:</p>

<pre><code>update-initramfs -u -k all
</code></pre>

<p>After that I rebooted and everything worked as on my original installation
(except for the disk encryption, of course).</p>
]]></description>
</item>
<item>
	
	<title>Redmine</title>
	
	<guid>http://mixinet.net/~sto/blog/sysadmin/20080301_redmine/</guid>
	<link>http://mixinet.net/~sto/blog/sysadmin/20080301_redmine/</link>
	
	<pubDate></pubDate>
	<description><![CDATA[<p>I've been using <a href="http://subversion.tigris.org/">Subversion</a> and
<a href="http://trac.edgewall.org/">Trac</a> for some years now, and I have encouraged
its use at work since the last couple of years, with the undesired effect of
having to maintain four different <code>Trac</code> installations with different database
systems (<code>SQLite3</code> and <code>PostgreSQL</code>), plugins (more than 15 on the big
servers), authentication systems (<code>htpass</code> files, <code>LDAP</code> and a database based
system) and tons of projects published (two internal servers have 64 and 16
projects, one of the client system has 33 projects and there is only one
single project installation, but it is living at a client's system).</p>

<p>Yesterday night, while reading <a href="http://planet.debian.org/">Planet Debian</a> I
found a <a href="http://changelog.complete.org/posts/694-Trac-Git.html">post</a> from
John Goerzen about tools to replace <a href="http://trac.edgewall.org/">Trac</a>,
including the option to use <a href="http://git.or.cz/">Git</a> as the project
<a href="http://en.wikipedia.org/wiki/Version_control_system">VCS</a>.</p>

<p>In the post he talks about different options, mainly projects that I would
categorize as <em>issue tracking systems</em> (<em>mantis</em>, <em>roundup</em>, etc.), but it
also talks about <a href="http://www.redmine.org/">Redmine</a>, a project management
system implemented using the <a href="http://www.rubyonrails.org/">Ruby on Rails</a>
framework that is similar to <code>Trac</code>.</p>

<p>As it looked interesting I downloaded, installed and executed an instance in
about 15 minutes (I love the systems that support
<a href="http://www.sqlite.org/">sqlite3</a> for this quick tests, not having to touch
real database servers speeds up simple tests a lot).</p>

<p>I played a little bit with the system and I believe that I will spend some
more time testing it at work next week, as it looks quite promising; the
standard version has almost all the features I'm interested in without the
need to install additional plugins and it can do most of the things I was
missing from <code>Trac</code> to do lightweight <em>project management</em>.</p>

<p>I evaluated <a href="http://project-open.org">]project-open[</a> to use it together with
<code>Trac</code> for our internal <em>project management</em> tasks, mainly because we miss
important features from <code>Trac</code>, like having clean systems to view the tasks of
a user in all projects or a clean way to do the project planning using
<em>tickets</em> and <em>gantt charts</em>. Of course there are ways to do it, but the
plugins I've tried are not as good and simple as I would like.</p>

<p>The problem with the use of <code>]project-open[</code> is that I don't really like it
for us, as it has tons of features that I feel we don't need nor will use and,
on a first try, the system seemed difficult to deploy and maintain, probably
because my lack of knowledge about <a href="http://openacs.org/">OpenACS</a> and
<a href="http://www.tcl.tk/">TCL</a>.</p>

<p>In fact we still don't have <code>]po[</code> running at work because I was unable to to
integrate the authentication system with our LDAP server on my first tries
and have had no time to investigate further since then.</p>

<p>The good thing about trying <code>Redmine</code> is that if we don't end up using it at
least I can take the most of this opportunity by looking at <code>Ruby on Rails</code>
and the <a href="http://www.ruby-lang.org/en/">Ruby Programming Language</a>, at least
from the administration side, as I have never looked at it seriously.</p>
]]></description>
</item>
<item>
	
	<title>Tips &amp;#x26; Tricks: plone, nginx and path rewriting</title>
	
	<guid>http://mixinet.net/~sto/blog/sysadmin/20080228_tandt_-_plone__nginx_and_path_rewriting/</guid>
	<link>http://mixinet.net/~sto/blog/sysadmin/20080228_tandt_-_plone__nginx_and_path_rewriting/</link>
	
	<pubDate></pubDate>
	<description><![CDATA[<h2>The problem</h2>

<p>On a couple of Debian Etch systems we have a
<a href="http://packages.debian.org/plone-site">plone-site</a> that is published using a
backport of the <a href="http://packages.debian.org/nginx">nginx</a> web server.</p>

<p>The <strong>Zope</strong> instance is running on the standard port and serves the <strong>Plone</strong>
contents under the <code>/plone</code> path.</p>

<p>Initially we were publishing the site to the external world using an https
site served by <code>nginx</code> using the following entry on the configuration:</p>

<pre><code>  location /plone/ {
    proxy_pass http://plone:9673;
    include    /etc/nginx/proxy.conf;
  }
</code></pre>

<p>The <code>proxy.conf</code> contents are quite standard:</p>

<pre><code>  # proxy.conf
  proxy_redirect                  off;
  proxy_set_header                Host &#036;host;
  proxy_set_header                X-Real-IP &#036;remote_addr;
  proxy_set_header                X-Forwarded-For &#036;proxy_add_x_forwarded_for;
  client_max_body_size            0;
  client_body_buffer_size         128k;
  proxy_connect_timeout           90;
  proxy_send_timeout              90;
  proxy_read_timeout              90;
  proxy_buffer_size               4k;
  proxy_buffers                   4 32k;
  proxy_busy_buffers_size         64k;
  proxy_temp_file_write_size      64k;
</code></pre>

<p>With this settings we see the <code>/plone</code> contents using the same path that is
used by the <em>Zope</em> instance, but after testing we have decided to change the
<code>/plone</code> path and server the contents under the <code>/web</code> path.</p>

<h2>The Wrong Solution</h2>

<p>The fist option I though about was quite simple, rename the <strong>Zope</strong>'s
<strong>plone</strong> object to <strong>web</strong>.</p>

<p>Seems reasonable and simple for someone without <strong>Zope</strong> experience (I don't
administer the internals of the <strong>Zope/Plone</strong> site), but now I know that it
is a very big mistake, because renaming objects in Zope in not cheap, as it
implies that the server has to modify all the contents of the renamed object
and the operation can take a very long time.</p>

<p>With my ignorance I tried to rename the plone object using the <code>Zope
administrative interface</code> and after a minute or so I cancelled the page
loading that was running on my browser, thinking that I had cancelled the
rename operation.</p>

<p>To make a long story short I'll tell you that the operation was still running
and after several hours the folder was renamed (in fact I noticed when the
good solution broke, as I had already solved the problem using the next
method), but something went wrong and part of the site functionality was
broken... the final solution to the debacle has been to recover a backup of
the Zope instance older than the rename operation and continue from that copy.</p>

<h2>The Right Solution (TM)</h2>

<p>It seems that <code>Zope</code> has a couple of systems to do <a href="http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/VirtualHosting.stx">Virtual
Hosting</a>
and the best option is the use of the product called <strong>Virtual Host Monster</strong>,
a weird and confusing system (IMHO, of course), that does the job once the
right configuration settings are in place.</p>

<p>The best solution to our problem was to modify the requests done by the
reverse proxy without touching anything on the <code>Plone</code> site (the original one
already had a <strong>Virtual Host Monster</strong> object installed and that was the only
thing that we needed to add).</p>

<p>The <code>nginx</code> configuration for the new <code>/web</code> path is the following:</p>

<pre><code>  location /web/ {
    proxy_pass http://plone:9673/plone/VirtualHostRoot/_vh_web/;
    include    /etc/nginx/proxy.conf;
  }
</code></pre>

<p>With this change, when the user asks for anything under the /web/ path the
<code>Zope</code> server gets the contents traversing the <code>/plone</code> object and adding to
it the elements that appear after the <code>VirtualHostRoot</code> component, ignoring
components that start with the <code>_vh_</code> prefix (the protocol and host name of
the requests are not modified, as we did not touched that).</p>

<p>Once the object is found, the server rewrites the URLs included on the HTML
files using the path components that appear after the <code>VirtualHostRoot</code> one,
including the suffix of the components that start with the prefix <code>_vh_</code>.</p>

<p>For example, when the <code>Zope</code> server receives a request for an URL like:</p>

<pre><code>  http://plone:9673/plone/VirtualHostRoot/_vh_web/home
</code></pre>

<p>it publishes the content found on:</p>

<pre><code>  http://plone:9673/plone/home
</code></pre>

<p>but the HTML files returned assume that their base URL is:</p>

<pre><code>  http://plone:9673/web/home
</code></pre>
]]></description>
</item>

</channel>
</rss>
