Thomas L. schrieb am 10.12.2022 19:53 (GMT +01:00):

> On Sat, 10 Dec 2022 19:03:23 +0100 (CET)
> "Nils" <o...@ffti.de> wrote:
>> And why does this problem occur in Linux, but *not* in OpenBSD?
>>
> 
> log_init calls tzset(3), which reads the timezone data early. not sure
> why this does not work on Linux.
> 
> 

After a short break of several months :-) I picked up this issue again.
I think I found the reason for the behaviour and a suitable workaround.

The chroot'ed processes can't access /etc/localtime and thus fall back
to UTC. This shall be prevented by the call of tzset(3) before the
chroot, and on OpenBSD this works. But in GNU libc the behaviour is - as
far as I understood it - different: If the environment variable TZ is
empty, then each call of a time-related function looks up the time
zone again, and this fails after the chroot because /etc/localtime isn't
accessible. This means that the tzset() call before is useless in case
of GNU libc.

If TZ is not empty and is set to a timezone string before starting smtpd
then all works as expected: Mail headers and log entries have the times
in the configured time zone. This also works when TZ is set to the
filespec format (see tzset(3)).

So the workaround is as simple as setting TZ before starting smtpd:

# TZ=/etc/localtime smtpd

This is just for the records, in case someone stumbles over this problem 
in future.


Best regards,
Nils

Reply via email to