Red Hat Bugzilla – Bug 13188
initlog fails when starting syslogd on read-only root file system
Last modified: 2014-03-16 22:14:32 EDT
The initlog.c line 187 causes syslogd to fail
when the root file system is mounted read-only.
Removing the call to access ("/", W_OK) solves the problem.
We recently switched to a read-only root file
system on some of our boxes in order to have
very strict guarantees of integrity. We noticed
that syslog no longer worked after making / read-only.
That is, no log messages appeared in /var/log/messages. All the normal
places (/var/log, /dev, etc) are read-write.
We found that on our read-only root, minilogd would always be
in the background after runnning /etc/rc.d/init.d/syslog start.
This is odd because minilogd should exit as soon as syslogd starts.
Here's what we think happens. In the normal read-write case,
initlog forks off and execs minilogd. minilogd unlinks /dev/log
and waits for syslogd to start. Eventually syslogd unlinks /dev/log
which causes minilogd to exit its event loop. Everything works fine.
In the read-only case, it seems that minilogd starts *after*
syslogd (the argument to initlog -c) starts. So syslog unlinks
/dev/log, listens for DGRAMs, then minilogd unlinks /dev/log
and waits for syslogd to unlink /dev/log. So the problem is that
minilogd cannot start after syslogd, otherwise the programs get
confused. It appears that minilogd and syslogd are racing to
have control of /dev/log. In the normal case, minilogd
will win the race. But if syslogd should win the race, then
minilogd blindly unlinks /dev/log which syslogd is already accepting
We're not sure why you have the call to access ("/", W_OK) in the
first place. You're not writing to /. What is the purpose
of this call? Do you really mean to check access ("/dev/, W_OK)?
I had exactly the same problem and spent half a day tracking it down to the
line in initlog.c instead of looking into the bug database. :(
I agree with your theory, it looks like a race creating /dev/log.
Checking for access to /dev instead of / fixes the problem if /dev is a seperate
--- src/initlog.c.orig Sun Jul 16 19:40:23 2000
+++ src/initlog.c Sun Jul 16 19:40:38 2000
@@ -192,7 +192,7 @@
/* Don't log empty or null lines */
if (!logEnt->line || !strcmp(logEnt->line,"\n")) return 0;
- if ( ((stat(_PATH_LOG,&statbuf)==-1) ||(access("/",W_OK)==-1))
+ if ( ((stat(_PATH_LOG,&statbuf)==-1) ||(access("/dev/",W_OK)==-1))
DDEBUG("starting daemon failed, pooling entry %d\n",logEntries);
This is already fixed in the current minilogd.