Don’t mess with my /dev/null
*BSD, Open Source January 25th, 2006One of the members of our LUG was having an odd problem starting PostgreSQL on a NetBSD 3.0 alpha machine. The error was as follows:
alpha:~# /etc/rc.d/pgsql start
Initializing PostgreSQL databases.
fgets failure: Undefined error: 0
The program "postgres" is needed by initdb but was not found in the same directory as "/usr/pkg/bin/initdb".
Check your installation.
alpha:~# which postgres
/usr/pkg/bin/postgres
My first few suggestions (check the rc script is up to date, etc) were not too helpful, so he asked me if I wanted to log in and investigate. Being the public spirited chap I am (and loving a good challenge), I jumped at the chance. After checking the obvious (the rc script was up to date, no libraries were missing, PostgreSQL permissions looked OK), I spotted something odd – /tmp’s permissions were 755 instead of 1777. Checking a few other obvious binaries (/usr/bin/su, for example), I spotted that the permissions on the system were pretty messed up (looks like the sets were extracted without using tar’s “p” parameter). Still, the PostgreSQL permissions looked OK, so something else had to be broken.
I fired up ktrace(1) to see if I could get any further. The trace didn’t reveal anything, so I fired up my next troubleshooting tool: Google. A few hits suggested checking the permissions on /dev/null, which I did. It was writeable only by the owner, root! A quick chmod 666 /dev/null and PostgreSQL started up.
And so an interesting hour’s troubleshooting ended.

Recent Comments