Getting sshd to start as early as possible

In FreeBSD, sshd by default gets started quite late in the boot process, about the same time a console will show the login prompt. There’s quite a few services that can make trouble and hang before that. Annoyingly, you can’t fix a stuck system via ssh, since it’s not started yet. But as it turns out, sshd can be started quite a bit earlier than FreeBSD does by default.

The rcorder keywords in /etc/rc.d/sshd normally look like this:

# PROVIDE: sshd
# REQUIRE: LOGIN cleanvar
# KEYWORD: shutdown

Change the rcorder keywords like so:

# PROVIDE: sshd
# REQUIRE: NETWORKING cleanvar
# BEFORE: mountcritremote
# KEYWORD: shutdown

 

Now sshd will be started right after the network has been configured.

Note that starting sshd before certain parts of the system are ready might give you temporary or permanent errors. For example, starting sshd before the user home directories are mounted might cause problems with logins. However, if your machine has all critical filesystems on local disks, making these changes should not pose any problems, and will allow you to log in while the rc scripts are still running, giving you the opportunity to fix any misbehaving services.

Running bash as root’s shell only when it’s not broken

I like bash, mostly for its interactive features over FreeBSD’s standard Bourne-compatible shell, ash.

Setting bash as the default shell for the root user however has a big downside: if you ever break bash or any of the libraries it depends on, you can’t log in as root anymore to fix it. I’ve tried quite a few ways to work around this, and I think I’ve finally figured out a good solution: leave the root shell as /bin/sh, and add this snippet at the end of /root/.profile:

[ -z "$BASH" ] && /usr/local/bin/bash -c 'true' && exec /usr/local/bin/bash

This will start bash, but only if the shell sourcing .profile isn’t bash, and bash can actually successfully be executed.

In FreeBSD 9, ash has apparently grown command name completion. Together with the editing functions (already available in FreeBSD 7), this might allow me to switch to ash as the default shell.

 

FreeBSD, CUPS and iPad printing

For the longest time, I couldn’t get CUPS configured on my FreeBSD server successfully. Between CUPS access rules, foomatic drivers and avahi announcements, I had terrible trouble making heads or tails of the nondescript error messages I was getting.

Spurned on by the arrival of an iPad, I finally sat down and worked through configuring CUPS and avahi. So I don’t have to go through all the fiddling again, here’s a recipe of what I did.

sudo per Wählscheibe

Netter Hack: wie man eine alte Wählscheibe als Eingabegerät für PAM und sudo umfunktionieren kann. Wenn jetzt Andreas endlich mal seine Stromschleifenschnittstelle bauen würde, würde ich auch den passenden Treiber für den Fernschreiber fertig machen…

http://hackaday.com/2011/02/01/rotary-dial-authenticates-sudo-commands/

Prepaid Mobile Data in France

For a recent two-week vacation in France, I wanted to get the netbook and the iPhones (SIM-locked) online, without having to hunt down hotel wifi or other hotspots. Unfortunately, the situation is not quite as simple as in Germany, where there’s many reasonable priced options. Here’s what I managed to find out.

Orange offers a prepaid data plan (“journée Internet max”) for 3 Euros a day, but by various accounts, it is limited to web access only (no email etc.), and might even have restrictions on the sites you can browse to. I didn’t try that. Orange also offers an iPad option.

SFR offers a special “iPhone 3G” tariff that seemed quite interesting at first: full web access as well as email, in multiple packages up to 20 euros for 20 days and 500MB. They specifically claim that it only can be used with an iPhone. To get it, you buy a pre-paid SIM card (SFR La Carte) from any of the SFR stores, and one of the iPhone 3G recharges (see the bottom of that page). The recharge is a long number that you can punch in at a voice prompt after dialling 952. I had a French speaker help me with that. At least in Paris, most of the SFR store people I’ve encountered speak passable or very good English, and they were all friendly and helpful, and did help with the activation. You then configure your device to use APN “wapsfr”, and off you go.

With the iPhone package, data connections are indeed limited, but a lot more that I originally thought: surfing was limited to the SFR mobile portal (m.sfr.fr). Whether this was due to the fact that I was using a Mifi to establish the data connection, or due to some real limitation on the part of SFR, I’m not sure, but I’ve read elsewhere that others have encountered this block as well.

Even when accessing the mobile portal, you must use Safari on your iPhone, or make your other browser appear as an iPhone. For Safari, enable the Developer menu, and change the User Agent to one of the Mobile Safari entries. I believe there’s a number of Firefox Add-ons that allow you to change the User Agent.

The good news is that email access via IMAP and SMTP worked just fine, with all our accounts configured.

To get full internet access, I used OpenVPN from the netbook to connect to my server running on one of the ports usually used for email. This way, I could move all the internet traffic through the VPN, and have full internet access from the laptop.

Finally, to be able to browse from the iPhones as well, I used tinyproxy on the netbook to enable the iPhones to use the netbook as a proxy that connects through the VPN. This gave us full internet access throughout our journey.

Getting things purchased and activated was a bit of an adventure, but was fairly straightforward in the end. I was positively surprised by the coverage (minimum EDGE, mostly HSPA), even though we went to some slightly remote places (small villages on the Loire, Mont Saint Michel). All the descriptions claimed that services were limited to “France métropolitaine”. Also, I was surprised that we seemingly didn’t exceed the 500MB limit, even though the traffic counter on the Mifi claimed we had.

I can recommend this only to people very familiar with networking technology and the willingness to spend a couple of hours in the hotel room fiddling, instead of on the streets of Paris. So plan to bring your favorite geek along for the ride 🙂

Where’s the doctor now?

The oldest, still running science fiction TV series, Doctor Who, has the Doctor jumping through time and space. A lot.

Now David McCandless has collected all of them in a huge dataset on his blog, waiting for someone to visualize them. As David writes in the Guardian,

I really wanted to do a mega-visualisation of all of the Time Lord’s journeys. But faced the cosmic task of trawling through well over 200 episodes, logging every time TARDIS was hurled through time and space.

Can’t wait for the results to show up!

Panorama movie of Texas Stadium demolition

Texas Stadium, previous home of the Dallas Cowboys, was demolished on April 11th. Immersive Media recorded the demolition of the main structure using a 360° high speed video camera, so you can pan and zoom around while the stadium is collapsing around you. I don’t know if this is the first such recording, but it certainly is a nice application of panoramic photo and video recording, so that you can experience something from a position you would not want to be in personally. Too bad the camera got knocked out about halfway through the sequence.

Texas Stadium demolition

Screenshot of Immersive Media's flash viewer, displaying the demolition of Texas Stadium

via BoingBoing

Identifying and reparing broken MP3s

I only recently learned about iTunes being able to transcode music into 128kbit/s AAC on the fly, while syncing to the iPhone. Quite useful, since I’m keeping my music in 256 or 320 kbit/s MP3. Using the lower bitrate AAC on the iPhone still gives me decent quality on the go, while saving space for more music and apps.

Only one annoying problem: over the years and moving the music library from machine to machine, some files got corrupted. When I come across one during playback and I’m sufficiently annoyed by the problem, I’ll simply delete it and re-rip it, or buy a copy from the store. However, when iTunes tries to transcode all the files I want synced to my iPhone, it stumbles over files with encoding problems, and stops syncing. And the error message doesn’t even identify the file it’s having problems with, only the song title. Bummer.

iTunes does not appear to have a way to check and mark files with encoding problems, so you have to rely on identifying problematic files by playing them. Not very convenient. Luckily, I found MP3 Scan+Repair, a Mac program that will check a batch of files, identify broken ones, and even try to repair them.

You can drag files from the Finder or iTunes into MP3sar’s main window, and it will immediately start scanning them. Using the display filter buttons in the toolbar, you can show only the problematics files, select them, and let the program try and repair them. In my limited testing so far, M3SAR does a good job of identifying and repairing the files, even if some problems will only fix the file format, but not remove audible errors. But for being able to quickly see which of the twelve different versions of My Funny Valentine is stopping iTunes from syncing my iPhone is absolutely worth it.