Eric's blog

Tuesday, September 13, 2005

Watch your double calls to ctime() and friends

I fell into this trap (again) today:


printf("%s%s", ctime(&t1), ctime(&t2);


Although the time_t variables t1 and t2 contain different values, the output of the printf() statement above is two similar date strings. Indeed, ctime() places the resulting date string in a static buffer, and returns a reference to this static buffer. Here, the same reference is placed twice on the stack.

iBook trackpad

Today I learned how to have tap-on-click working on my Ubuntu-powered iBook: sudo trackpad tap does the trick. Cool!

Monday, September 12, 2005

Breezy kernel on Hoary

My ibook/G3 runs Ubuntu Hoary, which comes with the Ubuntu kernel 2.6.10-5-powerpc on that hardware. I'm quite happy with that kernel except that resume-from-memory sometimes freezes, leaving me with the only option to hit the big red button. Argh.

I read from LWN that Ubuntu Breezy Preview is out, and ships a 2.6.12-8-powerpc kernel with enhanced suspend/resume support. So, I thought I should try out this kernel.

First I just said to myself: why not just upgrade to Breezy? Actually, it seems that postfix-tls, which I really need—see my previous post, isn't in Breezy at this point.

I therefore decided to try installing 2.6.12-8-powerpc without doing the full upgrade. Here is the steps I followed:


sudo cp /etc/apt/sources.list /etc/apt/sources.list.hoary

then changed "hoary" by "breezy" in the sources.list file, then

sudo apt-get update
sudo apt-get install linux-image-2.6.12-8-powerpc
sudo apt-get install glibc-doc linux-doc-2.6.12 linux-source-2.6.12
sudo cp /etc/apt/sources.list.hoary /etc/apt/sources.list
sudo apt-get update


and reboot...

During boot of the new kernel, I noticed two things: a sed error (sed: Unsupported Command I), and some udev/devfs related errors. Later, in GNOME, I couldn't launch a terminal due to fork/exec errors! Apparently things didn't go as smoothly as wished...

I rebooted on my old kernel—just to try—and everything was fine. I figured out that udev wasn't installed, so I installed it in the hope of getting rid of the udev errors I saw during boot, and possible others... That actually worked: except the stupid sed error that remains during boot, the rest seems all ok.

Now we'll see how wake-from-sleep goes...

Tuesday, September 06, 2005

Postfix TLS on a null client

I pretty much have always been using ssmtp as a mail agent. ssmtp is a lightweight, easy to configure, nullmailer that supports AUTH and TLS. (Other nullmailers are listed here and here.)

I recently happened to install Ubuntu Linux on my ibook G3. On Ubuntu, installing ssmtp requires removing the meta-package ubuntu-base. In Ubuntu's words (see apt-cache show ubuntu-base):
It is safe to remove this package if some of the base system packages are not desired. However, it is recommended that you keep it installed, because it is used to carry out certain upgrade transitions (such as adding new packages to the system).


So I decided not to uninstall ubuntu-base, and give postfix, the default mail agent in Ubuntu, a try.

Here was my need: using postfix as a null client to send emails through an SMTP server that uses AUTH and TLS. After having struggled a bit, I came up with the following working mail.cf configuration file:


# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# default host to send non-local mail
relayhost = my.smtp.server

# do not receive mails from outside
inet_interfaces = loopback-only

# do not deliver email locally
local_transport = error:local delivery is disabled

# use TLS when a remote SMTP server announces STARTTLS support
smtp_use_tls = yes

# log TLS handshake and certificate information
smtp_tls_loglevel = 1

# log the hostname of a remote SMTP server that offers STARTTLS
smtp_tls_note_starttls_offer = yes

# enable SASL authentication in the Postfix SMTP server
smtp_sasl_auth_enable = yes

# SMTP client lookup table is /etc/postfix/sasl/passwd (Berkeley DB)
smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd

# disallow methods that allow anonymous authentication
smtp_sasl_security_options = noanonymous



My login/password is stored in the Berkeley DB file /etc/postfix/sasl/passwd.db, which was created using the command postmap(1) with the flag -i. Using other databases is possible, but using the Berkeley DB turned up straightforward.