Search Results: "enrico"

31 July 2008

Enrico Zini: Introducing the Humongous Merged Packages File From Hell

Introducing the Humongous Merged Packages File From Hell Suppose you want to build some service that requires information about all packages in all architectures. Like, for example, the debtags web tagging interface. If that is the case, then you may be interested in the Humongous Merged Packages File From Hell. It contains a merge of all Packages and Source files of etch, lenny, sid and experimental, for main, contrib and non-free, in all architectures. The merge is done according to completely arbitrary criteria of mine: It's there in case anyone other than me may find it useful.

12 July 2008

Petr Rockai: fast forward

Lucy left for England yesterday (OK, now it’s two days ago — last Friday). That means that I have unusual amount of free time at my hands, and yet even more things that could be done with it. But I suppose it’s time to update this little blog. It’s probably pointless to enumerate what happened, or what changed. Everything is fine and smooth over here — the wrinkles get worked out over time (with Lucy, without Lucy). Hobbies still take time and I still haven’t given up. My latest determination is to get myself a bassoon for next Christmas. (Now, that will be a year since we got Lucy a Marigaux 901, used, in great condition for a great price, lo and behold, on Austrian ebay. World is so weird sometimes…) And in the land of [LVM], I have finally started the process to merge code to improve LVM’s behaviour in presence of failed storage hardware (physical volumes gone missing). In the land of Adept, well… first things first. FOSSCamp I have visited Prague for the latest Ubuntu- (well, Canonical-) organised event, the FOSSCamp. I have met Johnatan (KUbuntu), Seli (KWin), Lidya (Amarok), Robert (Konsole), Jos (Strigi) and Inge (KOffice). See also Johnatan’s Blog (including a real blurry picture). So back to Adept — I had some hacking time over there in Prague, and I have almost brought Installer and Updater back to life for Adept 3. I unfortunately didn’t have as much time for it since then — but my current free time situation does open up some possibilities. First and foremost, I should really make a text interface to the underlying libraries for myself, maybe with fancy colourful UI, hopefully one that is comfortably close enough to apt-get and still offers advantages. Hmmmm… Intermezzo 1 Now zoom out and zoom in somewhere else, enough of coding matters. Our research group at the University had a (tool) paper accepted for ATVA 2008, meaning that I am not unlikely to visit Seoul, South Korea in October. Another piece of distant world to visit. FOSDEM Now, that reminds me… Since the last time, I have also been in Belgium — to visit FOSDEM — meeting Alasdair (of LVM) and Bart and Pino of Krita and Okular, respectively… although unfortunately, I didn’t spend nearly enough time with Pino… At least we have spend a day walking around Ghent with Bart (and Lucy, who visited Belgium with me, also having friends of her own there). Moreover, I have spent a lot of mostly productive time with Alasdair, discussing LVM2. And Belgium is nice and pretty, although I didn’t really get around to taste any beer. Maybe next time. And Antwerps were nice, too. Photos? Someday. LinuxTag And after that, I have visited Berlin again, for LinuxTag as usual — plus the accompanying LVM discussions, with Milan, Kabi and Mikul (Blek) of the Czech part of the team, and Heinz, John and of course Alasdair for the rest of the world… Also as usual, we walked around, had dinners, discussed non-work stuff, etc… a good event all in all. At LinuxTag, I have briefly seen Lidya again, as well as Ossi (whom I nearly didn’t recognise…) and Aaron who (for a change) didn’t recognise me (but to be fair, I didn’t quite stop by to chat and he’s been busy…) and Sebas, cordial as ever (and always a pleasure to meet)… reminds me of Paris two years ago, too. Intermezzo 2 Less than a month ago, I have finished my first semester of master’s study — two or three more to go (I have completed bachelor’s the semester before). Yes, I am a bachelor of computer science, or something like that, anyway, now. Or so I hope. I did not attend the whatever ceremony and I don’t really have the diploma (or maybe I do, but gods know where it is…). A short note on Debian with best intentions I am now sponsoring Trent Buck’s ?darcs packages, contributing a little on the go (making me wish that alpha buildd would make a little more progress…). With Enrico, we have uploaded new versions of wibble and libept, both of which I think make both of us fairly happy. (Although we again managed to hit a way strange compiler issue (only manifested on arm… what have I done that the gods punish me so?), as documented in Debian bug 487406…) I have packaged dzen2 and taken over haskell-mode (I am losing track of my own packages again — I really need to set up reliable watch files so I don’t miss out too many releases… apparently neither has new upstream versions, so I can sleep peacefully for a little longer). Intermezzo 3 I am not going to DebConf nor Akademy this year. That makes me a little sad, but it’s all my own fault (and laziness). Next time folks, next time. I haven’t seen K vin in aeons and he probably removed me from his memory by now… No matter, I’ll try a little harder next year, promise (oh, how many have I made to date?). Finale Nothing grandiose, just best wishes to everyone, I have to land in bed now it seems, as I am ever so sleepy. (Just So Stories, anyone?) There I go.

2 July 2008

Enrico Zini: Using OpenStreetMap maps with gpsdrive

Using OpenStreetMap maps with gpsdrive Here's how I made it:
  1. wget http://download.geofabrik.de/osm/europe/italy.osm.bz2
  2. bunzip2 italy.osm.bz2 (this might not be needed)
  3. setup mapnik; the instructions for sid worked on my lenny/testing system.
  4. osm2pgsql -c /store/italy.osm (you should not use -m with gpsdrive)
  5. start gpsdrive and turn on mapnik mode. Originally it did not work for me, until I deleted ~/.gpsdrive/osm.xml.
This makes gpsdrive not only more useful, but also completely Free.

17 June 2008

Enrico Zini: Joys of schroot

Joys of schroot Schroot is good! Try schroot. You have LVM set up and some free extents in a vg? Try this:
# Create a new logical volume for a sid chroot
lvcreate -n schroot-sid -L1G YOUR-VG-NAME
mke2fs -j /dev/YOUR-VG-NAME/schroot-sid
# Debootstrap sid into it
mount /dev/YOUR-VG-NAME/schroot-sid /mnt
debootstrap --keyring=/etc/apt/trusted.gpg sid /mnt http://ftp.uk.debian.org/debian
umount /mnt
Then apt-get install schroot and put this in your /etc/schroot/schroot.conf:
[sid]
type=lvm-snapshot
device=/dev/YOUR-VG-NAME/schroot-sid
description=Debian sid
priority=5
users=YOUR-USER-NAME
root-users=YOUR-USER-NAME
source-root-users=root
aliases=unstable
lvm-snapshot-options=--size 2G
Now, schroot -c sid will make a LVM snapshot of /dev/YOUR-VG-NAME/schroot-sid, mount it, set it up as a nice working system, and chroot into it running a shell. Have a look around: resolv.conf is set up, your home directory is bind mounted, /proc and /sys are mounted. When you exit the chroot, the LVM snapshot disappears, and /dev/YOUR-VG-NAME/schroot-sid is unchanged. If you want to modify /dev/YOUR-VG-NAME/schroot-sid, you just schroot -c sid-source. In my laptop, I did this:
# schroot -c sid-source
(sid)# echo APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/50enrico
(sid)# apt-get install build-essential, pbuilder, devscripts, fakeroot
(sid)# apt-get clean
At this point, to build a debian package like if I were using pbuilder, I do this:
pkgdir$ schroot -c sid
(sid)pkgdir$ su -c /usr/lib/pbuilder/pbuilder-satisfydepends
(sid)pkgdir$ debuild -us -uc
You can repeat this whole process with lenny and etch, for example, and if you are on an amd64 system, you can also do sid32, lenny32 and etch32. If you don't want to redownload packages all the time, install approx and configure the -source chroots to use it. This also allows you to easily switch all systems from one mirror to another if, for example, you are traveling abroad. If you want to do the same as pbuilder update, you can do this:
# schroot -c sid-source
(sid)# apt-get update
(sid)# apt-get dist-upgrade
(sid)# apt-get autoremove
(sid)# apt-get clean
You can use schroot -c sid-source for all sorts of permanent maintenance works. You can also create persistent named snapshots:
$ schroot -b -c sid -n playground
This will only disappear when you do:
$ schroot -c playground -e
And you can enter the schroot as many time as you want with:
$ schroot -r -c playground
You can also enter a temporary snapshot as many times as you want, by using the random name that schroot generated for it (you can see it, for example, when running df or mount). You fear that lvm snapshots are a little fragile and a little slow at the moment? It's not a problem: your home is bind-mounted inside the chroot, so you can do all the work in your normal home filesystem, without stressing the snapshot. This is good not only to build packages. For example, now that svk is broken in sid and lenny, I just did schroot -b -c etch -n svk, installed svk on it, and then every time I need svk, I can do schroot -r -c svk and have it ready.

Enrico Zini: Passing values to turbogears widgets at display time (the general case)

Passing values to turbogears widgets at display time (the general case) Last time I dug this up I was not clear enough in documenting my findings, so I had to find them again. Here is the second attempt. In Turbogears, in order to pass parameters to arbitrary widgets in a compound widget, the syntax is:
form.display(PARAMNAME=dict(WIDGETNAME=VALUE))
And if you have more complex nested widgets and would like to know what goes on, this monkey patch is good for inspecting the params lookup functions:
import turbogears.widgets.forms
old_rpbp = turbogears.widgets.forms.retrieve_params_by_path
def inspect_rpbp(params, path):
    print "RPBP", repr(params), repr(path)
    res = old_rpbp(params, path)
    print "RPBP RES", res
    return res
turbogears.widgets.forms.retrieve_params_by_path = inspect_rpbp
The code for the lookup itself is, as the name suggests, in the retrieve_params_by_path function in the file widgets/forms.py in the Turbogears source code.

14 June 2008

Enrico Zini: Saving waypoints with Holux M-241

Saving waypoints with Holux M-241 The Holux M-241 is a nice unit, but it looks like it cannot store waypoints while you're recording a track. In fact, if you set it to display latitude and longitude, every time you press enter it stores a track point with the current location. However, after downloading the data with gpsbabel, they are indistinguishable from all the other track points. If you are not taking a track, this is sufficient: your track will be made by all the waypoints you recorded. Together with Riccio, another M-241 user, we noticed that if you are taking a track, with one trackpoint per second, then when you press enter in the lat/lon screen you get two track points in the same second: one from the logger, and one from your keypress. The duplicate timestamp is just enough information to be able to distinguish a waypoint. Here is a little python script that will add a waypoint every time there are two trackpoints with the same timestamp.
#!/usr/bin/python
import xml.dom.minidom
from xml.dom.minidom import Node
import sys
def get_text(node):
    res = ""
    for n in node.childNodes:
        if n.nodeType == Node.TEXT_NODE:
            res += n.data
    return res.strip()
def get_val(node, name):
    for n in node.childNodes:
        if n.nodeName == name:
            return get_text(n)
    return None
doc = xml.dom.minidom.parse(sys.argv[1])
# Scan the document looking for duplicate timestamps
wpt = []
last_ts = None
for node in doc.getElementsByTagName("trkpt"):
    ts = get_val(node, "time")
    if last_ts != None and last_ts == ts:
        wpt.append(node)
    last_ts = ts
# Add the nodes with duplicate timestamps as waypoints
if len(wpt) > 0:
    for i in wpt:
        node = doc.createElement("wpt")
        for a in i.attributes.values():
            node.setAttribute(a.name, a.value)
        for n in i.childNodes:
            node.appendChild(n.cloneNode(True))
        doc.documentElement.appendChild(node)
doc.writexml(sys.stdout)

13 June 2008

Enrico Zini: Send a fax from the laptop

Send a fax from the laptop My bank sent me a PDF form via e-mail. I needed to fill it in, then send it back via fax. Send it back via e-mail would not work because it's not secure. The bank agrees that this is fantastically silly, but apparently this requirement is not their fault. Step 1: send a fax with the laptop
  1. apt-get source sl-modem-daemon efax-gtk
  2. patch as instructed in the Debian BTS
  3. pbuilder-satisfydepends, debuild, dpkg -i
  4. slmodemd -c ITALY --alsa hw:0,6
  5. echo ATDmymobilenumber > /dev/ttySL0 and my mobile phone rung
  6. efax-gtk
Believe it or not, at this point I managed to successfully send a test fax. Background: the laptop's modem is actually a sound card, and is ashamed to admit that it can also work as a modem:
$ lspci
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 03)

But the sound card actually has its own bus, which you can query with aplay -l:
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC861VD Analog [ALC861VD Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 6: Si3054 Modem [Si3054 Modem]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Then you learn that sl-modem-daemon can drive it both on i386 and on amd64, but you get period size 48 is not supported by playback (64) when trying to dial. But then you find the patch to get rid of that, and it works. The modem was the last device in the new laptop that I had not yet attempted to use. I can now claim that every single piece of hardware on my ASUS F9E-2P119E laptop can be made to work with Debian. Oh, yes! Step 2: fill in the form Much to my surprise, evince allowed me to just click in the form fields and type text. Even checkboxes worked. "Save a copy", however, did not retain the field contents: I had to print to file to get another PDF with the fields filled in. Update: this could be a limitation of that specific PDF, see this thread on the Adobe forums (thanks to Tomas Weber). However, evince did not allow me to import an image with my signature and paste it in the right place. Inkscape, however, successfully managed to import the PDF as an editable vector drawing that I could change at will. Again, that was impressive. From there, it was just a matter of pasting the signature in the right place, save as PostScript, give it to efax-gtk and phone the bank to learn that, in fact, the fax was received and was perfectly readable.

12 June 2008

Enrico Zini: How to autologin X without a display manager

How to autologin X without a display manager Problem: configure a custom Debian box used to drive some industrial machinery. The system should boot directly into the GUI control application, that runs full screen, with root privileges. Everything should respawn if X is killed or the control application dies. In theory, you'd run an X display manager with autologin, then run matchbox-window-manager and the control application as the X session. You wish. At the end of the post is an explanation of why this way failed. So, here is how to get the whole thing to work, without a display manager. Use init to drive the whole thing:
6:23:respawn:/sbin/getty -L -n -l /usr/local/sbin/autologin

This will respawn everything if it dies, stop respawning if it dies all the time, avoid starting it in single user mode, and not ask for a username. /usr/local/sbin/autologin contains:
#!/bin/sh
/bin/login -f root MAINAPP=true

This will autologin as root, setting an extra env variable. Then comes root's ~/.bash_profile, that just starts X if we are doing autologin:
if [ "$MAINAPP" = "true" ]
then
    startx
    logout
fi

If the application was running as a special user, we could have made things simpler and just used startx as the shell for that user; however, we still want root to have bash as the shell, and the above hack does it. Finally, root's ~/.xsession:
#!/bin/sh
matchbox-window-manager &
# If the touch screen is not calibrated, run the calibration
while [ ! -f /etc/touchscreen-calibration ]
do
        calibrate-touchscreen
done
# Run the main application: if it ends, the session ends
main-application

And there we go, no dependencies at all. Why not using a display manager gdm and kdm seem to do autologin, but their dependency list is not acceptable for something that should just respawn an X server in an industrial system that must be kept simple. xdm on the other hand has a small set of dependencies, but its developers seem to have decided that autologin is a ""glitz", and there is no need for it in such a bare-bones display manager". Dict for "glitz" gives "tasteless showiness". What one has to bear... wdm seems however even more disconcerting, as it "doesn't actually support autologin but you can set the default user and default password in /etc/X11/wdm/wdm-config. Now, [...] you only need to press Enter twice [...] to login". Figure how this would look in the manual: "After powering up the unit, attach a USB keyboard and press enter twice to start the system". And this is why we are not using a display manager.

Enrico Zini: Miscellaneous bash tips

Miscellaneous bash tips A few useful configuration bits:
# Don't put duplicate lines in the history
export HISTCONTROL=ignoredups
# When you use history expansion (the !something), allows to edit the
# expanded line before executing it
shopt -s histverify
# Correct spelling mistakes when using 'cd'
shopt -s cdspell
# Do not attempt completion on an empty line
shopt -s no_empty_cmd_completion

A few useful keystrokes: For more useful keystrokes, run man bash, look for "Commands for Manipulating the History" and read down from there.

Enrico Zini: How to resize a luks partition

How to resize a luks partition After things-not-to-do.mdwn I want to be careful when resizing a luks partition: here's a note with the right procedure. As explained in this bug report, the way to resize a luks partition is:
# lvresize -L+100M /dev/vg00/test 
  Extending logical volume test to 400.00 MB
  Logical volume test successfully resized
# cryptsetup resize test1 
# resize2fs /dev/mapper/test1

9 June 2008

Stefano Zacchiroli: debian weather is back

What's the weather like in Debian? One of the cool things developed during EDOS (now Mancoosi) has been edos-debcheck. Using it it is possible to check (incredibly quickly) whether some package in a given distribution cannot be installed according to its dependencies. When there are such packages it usually means that the distro is buggy s it is shipping uninstallable packages (there are some corner cases, but they are rare). In fact, edos-debcheck has been run daily (as a service maintained by Ralf) on Debian's main suites and some derivatives for years now. The resulting list of uninstallable packages is linked from http://edos.debian.net and is being used by the QA team; I've no idea if it is being used by the Release Managers too, but it probably should be. A cool toy built on top of edos-debcheck was the Debian weather (part of a more generic service called Anla, I'll blog about it sooner or later ...). Debian weather basically used to present the status of a given Debian-based distro in term of how many uninstallable packages were shipped using the weather metaphor: the fewer the uninstallable packages, the better the weather. I wrote "used to" because Anla was stopped about 1 year ago, and is being re-engineered these days. In the meantime it was a pity not to have the Debian weather (as Enrico pointed out with me), so I spent some time to resurrect it on top of edos-debcheck daily runs: Debian weather is back, enjoy!

6 June 2008

Enrico Zini: Italian weather agencies

Italian weather agencies Most Italian regions have agencies providing good regional weather forecast. However, I could not find a useful national index of all their weather forecast pages. So I made one, tweaking an image map found on wikipedia. Abruzzo Basilicata Calabria Campania Emilia-Romagna Friuli-Venezia Giulia Lazio Liguria Lombardia Marche Molise Piemonte Puglia Sardegna Sicilia Toscana Trentino-Alto Adige Umbria Valle d'Aosta Veneto Italia suddivisa per regioni I only filled in those regions that I was checking to organise a specific trip. With time, if I'll keep using this map I'll add more regions. Of course, if you now of a weather forecast page of a regional, public funded agency that is missing here, send me an e-mail.

1 June 2008

Enrico Zini: Playing with a Holux M-241

Playing with a Holux M-241 Here is how to download tracks from the Holux M-241:
gpsbabel -t -r -w -i m241 -f /dev/ttyUSB0 -o gpx -F  date +'%Y-%m-%d-%H%M%S' .gpx

It might work also via bluetooth, but I have not tried yet. Now, until M-241 support will be released in a stable version of gpsbabel, here is how to compile the version from CVS. Get the sources:
cvs -d:pserver:anonymous@gpsbabel.cvs.sourceforge.net:/cvsroot/gpsbabel login
cvs -z3 -d:pserver:anonymous@gpsbabel.cvs.sourceforge.net:/cvsroot/gpsbabel co -P gpsbabel

Untar this to debianise the sources. If it does to compile because of some errors in lmx.c, apply this patch. Then you can install the resulting package and (hopefully) be happy. Note, after downloading the logs, gpsbabel currently turns on logging. Here is a patch to disable that behaviour. Finally, if you want to hack around a little on the unit, you can play with mtkbabel: the source code is simple, and most of the MTK protocol is implemented, so you can easily feed your own commands to the MTK. Documentation about the commands can be found here: The links are taken from a post in the GPSPasSion forum. For a source of ideas of what commands you can send, you can look into the source code of BT747. For example, to set the M-241 to 2Hz fix, you can add this to mtkbabel:
packet_send('PMTK300,500,0,0,0.0,0.0');
$ret = packet_wait('PMTK001,300,3');

And if you want to set the MTK to an insane 5Hz fix rate, to take really fine grained gpx traces with your laptop, you can use this:
packet_send('PMTK300,200,0,0,0.0,0.0');
$ret = packet_wait('PMTK001,300,3');

26 May 2008

Joerg Jaspert: Mountainbike

[Non-Debian and even non-IT related post ahead, in case you want to skip them] Since some time I try to regularly take some time off of the PC and actually use my bike again. (Those pictures are old, some things have changed since then. Like, I have a different, larger, set of brakes now). After a break of more than a year (more like 1.5 - 2 years, I think), it was a pain. The first few rides haven’t been much fun, and after some 10 til 15km I was exhausted and felt bad. But now, where I found a semi-regular schedule and do the torture two or three times a week I actually feel better. And get away with longer rides. A few days after I started I bought myself a nice “Bicycle computer”, a Garmin Edge 305 - “Garmin’s GPS-enabled personal trainer and cycle computer.” Im not doing any kind of special training with it, but its still nice to see heartrate, pedal cadence and all the other information it offers (which is a lot). And to see how you improve over time. Still, my main motivation to carry it with me is really to be able to see where I went (I only made some of my entries public :) ). And maybe, at some time, somewhere, load waypoints to it and then follow those. The included GPS chip is pretty good, keeping a good signal accuracy even in terrain where you just wouldn’t expect it to have any signal. Now, if google maps would have recent images, not ones that are years old, some tracks wouldn’t look that weird. On other news - I’ve lost 10kg weight since February. Damnit. Update: If you are from (around) Fulda and also like that OpenStreetMap thing, Enrico just uploaded my tracks there. Now it needs someone doing the post-processing to make them useful, and Enrico says you should go here and have fun. So if you have time, know the roads, feel free to look there. I guess Enrico keeps uploading new tracks from me, whenever there are some. Comments: 2

25 May 2008

Enrico Zini: LDAP user database errors

LDAP user database errors In case your machine uses an external LDAP server for the user database, and you see this error:
id: ldap-nss.c:1376: do_init: Assertion  cfg->ldc_uris[__session.ls_current_uri] != ((void *)0)' failed.

The solution is to check that you have no passwords in /etc/libnss-ldap.conf and make it world readable, because software needs to access it in order to access the user database. This is apparently "normal" folk knowledge. Already in the BTS. Now, why is /etc/libnss-ldap.conf not world readable by default? Because a debconf question offers it to be that way. Why does it do so? I have no idea, since passwords should go in the not world readable /etc/libnss-ldap.secret anyway. Why do we get that assertion instead of something like cannot read /etc/libnss-ldap.conf? These sort of obscure errors or behaviours happen so often that I start to believe it's an intentional coding style. Maybe LDAP needs to be something for lite sysadmins with a painful initiation path, so that only the Worth and Pure of Spirit can use the only sane way to have a central user database in Linux. I almost feel like if I disclose these tricky bits one day I will be tied to a rock with an eagle eating my liver.

23 May 2008

Enrico Zini: Conditional partitioning in debian installer

Conditional partitioning in debian installer I needed to create an automatic, unattended installer that would repartition the whole disk, but keep an existing home partition if it is already existing. The idea is to replace the operating system, but keep the user's home files. If the home partition does not exist, however, we need to create it. The starting point for this is in Holger's website, which does everything except create the partition if it's missing. The technique I used is to create a udeb that would scan the partitions using /usr/lib/partconf/find-partitions and then load the right preseeding for partman-auto, the automatic partitioner. Here you find the udeb source. I'll comment the most important bits: First, the two partman-auto recipes that we are going to preseed. The format is documented in the debian-installer documentation. This will create /home if missing:
        d-i partman-auto/expert_recipe string                           \
                condpart ::                                             \
                2048 2048 2048 ext3                                     \
                        $primary    $bootable                           \
                        method  format   format                         \
                        use_filesystem    filesystem  ext3              \
                        mountpoint  /                                   \
                .                                                       \
                1024 1024 1024 linux-swap                               \
                        method  swap   format                           \
                .                                                       \
                1024 4096 10000000 ext3                                 \
                        method  format   format                         \
                        use_filesystem    filesystem  ext3              \
                        mountpoint  /home                               \
                .
And this will keep /home if it exists:
        d-i partman-auto/expert_recipe string                           \
                condpart ::                                             \
                2048 2048 2048 ext3                                     \
                        $primary    $bootable                           \
                        method  format   format                         \
                        use_filesystem    filesystem  ext3              \
                        mountpoint  /                                   \
                .                                                       \
                1024 1024 1024 linux-swap                               \
                        method  swap   format                           \
                .                                                       \
                1024 4096 10000000 ext3                                 \
                        method  keep                                    \
                        use_filesystem    filesystem  ext3              \
                        mountpoint  /home                               \
                .
Then the postinst file of the package, where the logic is. Otavio and Daniel on #debian-boot have taught me that udebs are, simply put, just big postinsts (installer wise, apart from shipping binaries). Postinst is where the logic is done, or applications are started.
#!/bin/sh
# Copyright 2008 Enrico Zini <enrico@truelite.it>
# Licensed under the terms of the GNU General Public License,
# version 3 or any later version.
set -e
FINDPARTS="/usr/lib/partconf/find-partitions"
notice ()  
    logger -t condpart "$@"
 
error ()  
    logger -t condpart "error: $@"
 
# load debconf
. /usr/share/debconf/confmodule
notice "Checking if we need to recreate /home"
if [ ! -x $FINDPARTS ]
then
    error "$FINDPARTS not found"
    exit 1
fi
if $FINDPARTS   grep -q part6
then
    # Keep
    notice "/home exists: we keep it"
    debconf-set-selections /usr/lib/condpart/part-keep.preseed
else
    # Format
    notice "/home does not exist: we create it"
    debconf-set-selections /usr/lib/condpart/part-create.preseed
fi
notice "Finished special handling of /home"
#DEBHELPER#
exit 0
Finally, debian/control. The basic bits about creating a d-i udeb are to put it in Section: debian-installer and to use XC-Package-Type: udeb. Then there is XB-Installer-Menu-Item, that defines the order of execution of postinsts. The d-i documentation lists the numbers that are currently assigned.
Source: condpart
Section: debian-installer
Priority: optional
Maintainer: Enrico Zini <enrico@debian.org>
Build-Depends: debhelper (>= 4.0.0), cdbs
Standards-Version: 3.7.2.1
Package: condpart
Architecture: any
XC-Package-Type: udeb
XB-Installer-Menu-Item: 38
Description: Conditional partitioning
 Tells partman-auto to create /home if it's missing, or if it exists, to keep
 it.
I am using 38 rather than 3800 because I'm targeting etch d-i. After etch, "numbers have been multiplied by 100 from what they were before to give us more space". This is it. debian/rules is just boilerplate, except installing the preseed files in the right place. CDBS is useful to make this self-evident:
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
install/condpart::
  install -o root -g root -m 0644 *.preseed debian/$(cdbs_curpkg)/usr/lib/condpart/
To build the installer CD with this d-i, I'm using simple-cdd; here are the profile files I'm using at the moment, with the main preseeding for fully unattended install (it is designed to trash your hard disk if you boot it, so only test it in an emulated environment) and the inclusion of the custom udeb.

18 May 2008

Russell Coker: Debian SSH Problems

It has recently been announced that Debian had a serious bug in the OpenSSL code [1], the most visible affect of this is compromising SSH keys - but it can also affect VPN and HTTPS keys. Erich Schubert was one of the first people to point out the true horror of the problem, only 2^15 different keys can be created [2]. It should not be difficult for an attacker to generate 2^15 host keys to try all combinations for decrypting a login session. It should also be possible to make up to 2^15 attempts to login to a session remotely if an attacker believes that an authorized key was being used - that would take less than an hour at a rate of 10 attempts per second (which is possible with modern net connections) and could be done in a day if the server was connected to the net by a modem. John Goerzen has some insightful thoughts about the issue [3]. I recommend reading his post. One point he makes is that the person who made the mistake in question should not be lynched. One thing I think we should keep in mind is the fact that people tend to be more careful after they have made mistakes, I expect that anyone who makes a mistake in such a public way which impacts so many people will be very careful for a long time… Steinar H. Gunderson analyses the maths in relation to DSA keys, it seems that if a DSA key is ever used with a bad RNG then it can be cracked by someone who sniffs the network [4]. It seems that it is safest to just not use DSA to avoid this risk. Another issue is that if a client supports multiple host keys (ssh version 2 can use three different key types, one for the ssh1 protocol, one for ssh2 with RSA, and one for ssh2 with DSA) then a man in the middle attack can be implemented by forcing a client to use a different key type - see Stealth’s article in Phrack for the details [5]. So it seems that we should remove support for anything other than SSHv2 with RSA keys. To remove such support from the ssh server edit /etc/ssh/sshd_config and make sure it has a line with “Protocol 2“, and that the only HostKey line references an RSA key. To remove it from the ssh client (the important thing) edit /etc/ssh/ssh_config and make sure that it has something like the following: Host *
Protocol 2
HostKeyAlgorithms ssh-rsa
ForwardX11 no
ForwardX11Trusted no You can override this for different machines. So if you have a machine that uses DSA only then it would be easy to add a section: Host strange-machine
Protocol 2
HostKeyAlgorithms ssh-dsa So making the default configuration of the ssh client on all machines you manage has the potential to dramatically reduce the incidence of MITM attacks from the less knowledgable users. When skilled users who do not have root access need to change things they can always edit the file ~/.ssh/config (which has the same syntax as /etc/ssh/ssh_config) or they can use command-line options to override it. The command ssh -o “HostKeyAlgorithms ssh-dsa” user@server will force the use of DSA encryption even if the configuration file requests RSA. Enrico Zini describes how to use ssh-keygen to get the fingerprint of the host key [6]. One thing I have learned from comments on this post is how to get a fingerprint from a known hosts file. A common situation is that machine A has a known hosts file with an entry for machine B. I want to get the right key in machine C and there is no way of directly communicating between machine A and machine C (EG they are in different locations with no network access). In that situation the command “ssh-keygen -l -f ~/.ssh/known_hosts” can be used to display all the fingerprints of hosts that you have connected to in the past, then it’s a simple matter of grepping the output. Docunext has an interesting post about ways of mitigating such problems [7]. One thing that they suggest is using fail2ban to block IP addresses that appear to be trying to do brute-force attacks. It’s unfortunate that the version of fail2ban in Debian uses /tmp/fail2ban.sock for it’s Unix domain socket for talking to the server (the version in Unstable uses /var/run/fail2ban/fail2ban.sock). They also mention patching network drivers to add entropy to the kernel random number generator. One thing that seems interesting is the package randomsound (currently in Debian/Unstable) which takes ALSA sound input as a source of entropy, note that you don’t need to have any sound input device connected. When considering fail2ban and similar things, it’s probably best to start by restricting the number of machines which can connect to your SSH server. Firstly if you put it on a non-default port then it’ll take some brute-force to find it. This will waste some of the attacker’s time and also make the less persistent attackers go elsewhere. One thing that I am considering is having a few unused ports configured such that any IP address which connects to them gets added to my NetFilter configuration - if you connect to such ports then you can’t connect to any other ports for a week (or until the list becomes too full). So if for example I had port N configured in such a manner and port N+100 used for ssh listening then it’s likely that someone who port-scans my server would be blocked before they even discovered the SSH server. Does anyone know of free software to do this? The next thing to consider is which IP addresses may connect. If you were to allow all the IP addresses from all the major ISPs in your country to connect to your server then it would still be a small fraction of the IP address space. Sure attackers could use machines that they already cracked in your country to launch their attacks, but they would have to guess that you had such a defense in place, and even so it would be an inconvenience for them. You don’t necessarily need to have a perfect defense, you only need to make the effort to reward ratio be worse for attacking you than for attacking someone else. Note that I am not advocating taking a minimalist approach to security, merely noting that even a small increment in the strength of your defenses can make a significant difference to the risk you face. Update: based on comments I’m now considering knockd to open ports on demand. The upstream site for knockd is here [8], and some documentation on setting it up in Debian is here [9]. The concept of knockd is that you make connections to a series of ports which act as a password for changing the firewall rules. An attacker who doesn’t know those port numbers won’t be able to connect. Of course anyone who can sniff your network will discover the ports soon enough, but I guess you can always login and change the port numbers once knockd has let you in. Also thanks to Helmut for advice on ssh-keygen.

17 May 2008

Enrico Zini: How to view the fingerprint of the ssh host key

How to view the fingerprint of the ssh host key This way, ready to copy and paste:
ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key

Background: It already takes a lot of resources to recall that to see the host key fingerprint you need to run something called 'keygen'. Then ssh-keygen doesn't support --help: it will try to generate a new key instead. We're in 2008. There should be a law against this sort of behaviour. To figure out how to see the host key, you need to dig through a long manpage with no examples section. ssh-keygen does have commandline help, but does not implement any switch to invoke it (check the getopt invocation in the source code if you don't believe me). It will however show commandline help when given an unrecognised option, so it will mutter but at least give you love if you ask for it:
$ ssh-keygen - 
ssh-keygen: illegal option -- 
Usage: ssh-keygen [options]
Options:
  [...]

After figuring out that it's -l -f, you still have to go and fish the file wherever it is. And luckily we had the recent Debian openssh problems, so now I can get the fingerprint of the RSA file only and be done with it. But thanks to this blog entry, no more of that, at last.

13 May 2008

Enrico Zini: How to generate bootable USB keys with simple-cdd

How to generate bootable USB keys with simple-cdd simple-cdd is a lovely piece of software that builds a custom D-I image with the package selection and preseeding of your choice. Today I was asked to build a bootable USB key with the simple-cdd image. Here is how; the general case is described in the d-i manual: General USB key preparation:
  1. download vmlinuz and initrd.img from hd-media
  2. apt-get install syslinux mtools mbr
  3. Partition the USB key as needed (from now on, I'll assume the usb key is in the device /dev/sdb1)
  4. Format it as FAT: mkdosfs /dev/sdb1
  5. Put the boot loader in it: syslinux /dev/sdb1
  6. Put the MBR in it: install-mbr /dev/sdb
  7. Mount it: mount /dev/sdb1 /mnt
  8. Copy kernel and initrd: cp vmlinuz initrd.img /mnt/
simple-cdd specific part:
  1. Run build-simple-cdd as usual
  2. Copy the ISO file generated by build-simple-cdd in the USB key. Any name will do, as long as it ends in .iso the installer will find it
  3. Configure the boot loader, fetching the kernel command line out of the cdrom boot loader generated by simple-cdd:
    • echo default vmlinuz > /mnt/syslinux.cfg
    • grep append tmp/cd-build/etch/boot1/isolinux/isolinux.cfg head -1 sed -e 's/^\t//' -e 's/ initrd=[^ ]*/ initrd=initrd.gz/' >> /mnt/syslinux.cfg
This is it, it works nicely, perfectly scriptable, tested today.

Enrico Zini: Setting environment variables at X login

Setting environment variables at X login I've been asked how to set a variable after gdm has done login. ~/.bashrc is not an option, as it's only run by shells, but we want the variable to be set in every X application that is started. The answer is: Forget about ~/.xinitrc. ~/.xsession and ~/.Xsession: at least in gnome-session, they do not work. Update: * On IRC, I've been told that ~/.xsessionrc should be used since xorg 1:7.3+9

Next.

Previous.