Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Jun 2000 16:38:06 -0400
From:      Antoine Beaupre <abeaupre@chemcomp.com>
To:        freebsd-questions@freebsd.org
Subject:   Chroot'ed programs syslogs date problems
Message-ID:  <395127AE.802E6732@chemcomp.com>

next in thread | raw e-mail | index | archive | help
Hi folks.

The Problem:
============

I have a strange problem here. Postfix (the MTA suite) seems to have
problems logging syslog messages with correct dates.

I run postfix-19991231.04 on FreeBSD hostname.somewhere.com 4.0-RELEASE
FreeBSD 4.0-RELEASE #6: Thu Jun  8 13:15:46 EDT 2000.

An example seems to be like the best explanation:

Jun 21 00:00:00 sky newsyslog[669]: logfile turned over
Jun 21 06:05:08 sky postfix/pickup[696]: A751F5F: uid=0 from=<root>
Jun 21 02:05:09 sky postfix/cleanup[926]: A751F5F: message-id=<...>
Jun 21 06:05:09 sky postfix/qmgr[207]: A751F5F: from=<...
Jun 21 06:05:09 sky postfix/pickup[696]: 9747160: uid=...
Jun 21 02:05:09 sky postfix/cleanup[926]: 9747160: message-id=<...>
Jun 21 06:05:09 sky postfix/qmgr[207]: 9747160: from=<...
Jun 21 02:05:09 sky postfix/smtp[940]: A751F5F: to=<...
Jun 21 02:05:09 sky postfix/smtp[944]: 9747160: to=<...

These are all line that appear as is in the logs. That is, the sequence
is correct. I think the correct local time for the logs is around Jun 21
02:05, because this email is the one from the periodic(8) script. The
times at 6:05 are probably UTC. 

Why would one program log one time and the other log another time? This
is very confusing. 

The Explanation
===============

I'm trying to seek an answer in syslog's source code and I think the
problem's probably not from there. It would rather seems to be related
to the fact that some parts of the postfix system run chroot()'ed. In
the case of the machine here:

# service type  private unpriv  chroot  wakeup  maxproc command + args
pickup    fifo  n       n       -       60      1       pickup
cleanup   unix  -       -       n       -       0       cleanup
qmgr      fifo  n       -       -       300     1       qmgr
smtp      unix  -       -       n       -       -       smtp

... the ones that output correct times are the ones that _don't_ run
chrooted. Now what does this have to do with dates???

Here we are. My machine's CMOS clock is set to follow local time. That
means I have a file  /etc/wall_cmos_clock on the machine. When
chroot'ed, a program won't see this file. I guess that when the
necessary librairies load, they check for the existence of this file. Or
may it be another file?

The Workaround
==============

As advised in
/usr/ports/mail/postfix/work/postfix-19991231-pl04/examples/chroot-setup/FREEBSD3:

mkdir /var/spool/postfix/etc
chmod 755 /var/spool/postfix/etc
cd /etc ; cp host.conf localtime services resolv.conf
/var/spool/postfix/etc

tested and working. So the file is obviously /etc/localtime, which I
know nothing about. But it seems to me like this is a workaround, since
these files are subject to change and, with the advent of more programs
running chrooted (bind, etc), this will multiply in reach.

The Solution
============

This is part of the long-lasting problems of chroot'ed environnement. As
with many other issues, the best way would probably be to make a kernel
variable (sysctl?) or such device. Since I'm not yet a FBSD kernel guru,
I wouldn't know exactly what the best fix would be. And one must also
think of the effect that this would have on libc. 

I'm not sure exactly of what this email will bring but it helped me
solve my problem and I hope it will help others too. Heck, it might even
make it to the FAQ!?

Any comments are welcome.

-- 
Antoine Beaupre
System Administrator
Chemical Computing Group, Inc.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?395127AE.802E6732>