[syslog-ng] TZ DST offset problem in 1.6.8 syslog-ng using $TZOFFSET or $ISODATE....

Peter Valdemar Mørch swp5jhu02 at sneakemail.com
Mon Oct 31 14:37:49 CET 2005


Hi,

I've seen the "ISODATE offset?" thread, and I seem to be seeing the 
exact same thing:
https://lists.balabit.hu/pipermail/syslog-ng/2004-November/006633.html

The problem appears only during Daylight Savings Time ("summer time"), 
not during standard/non-DST/"Winter" time. We just entered non-DST time 
this weekend (and hence the bug "stopped").

During DST the TZ offset does not include the offset due to DST. So TZ 
is off-by-one during DST.

About this section

#if HAVE_GLOBAL_TIMEZONE
         length = snprintf(dest, left - 1, "%c%02ld%02ld",
                           timezone > 0 ? '-' : '+',
                           (timezone < 0 ? -timezone : timezone) / 3600,
                           (timezone % 3600) / 60);
#else

Bazsi writes in the thread:
> Thanks. Either the value in timezone is not set properly, or it does not
> contain the daylight-saving offset, or my code has an error.
> 
> I'll check (I've checked DST before, and timezone should reflect it, so
> it _might_ be a problem in libc) I'll see what I can do.

Has there been any progress on this? After typing up this report I 
notice the 1.9.6 NEWS and see: "Fixes in local timezone detection, it 
should properly detect DSTs on Linux, Solaris and probably BSDs". Is 
this the same bug? Any chance of this fix being back-ported into a 1.6 
maintenance release to show up automagically in debian?

(There are no TZ environment variables set on this machine. Also what 
should it be set to? Following GNUs docs doesn't help. See below.)

************ environment *************
 > cat /etc/timezone
Europe/Copenhagen
 > ls -l /etc/localtime
lrwxrwxrwx  1 root root 37 2005-10-25 07:13 /etc/localtime -> 
/usr/share/zoneinfo/Europe/Copenhagen
syslog-ng       1.6.8-1
 > set | grep -i TZ
(no output - se below under "Tried setting TZ env")
# I'm using 1.6.8-1 on debian (==newest in testing+unstable),
# and the poster in the thread from Nov 2004 was using 1.6.4-1.
 > dpkg-query -W 'syslog-ng'
 > dpkg-query -W libc6
libc6   2.3.5-6


************ syslog-ng.conf snippet *************

destination d_template {
   file("/tmp/syslog-template.log"
 
template("\"DATE'$ISODATE'TZOFFSET'$TZOFFSET'FULLDATE'$FULLDATE'MSG'$MSG\n")
   template_escape(yes));
};

log { source(s_all); destination(d_template); };

************ non-DST example - works ************
# date, perl and syslog-ng all agree with the truth that
# we're +0100 during "wintertime" - non-DST.
 > date --rfc-2822
Mon, 31 Oct 2005 00:00:06 +0100
 > perl -le 'use POSIX; print strftime ("%a,  %d  %b %Y %H:%M:%S %z", 
localtime);'
Mon,  31  Oct 2005 00:00:08 +0100
 > logger 'A message'
 > sudo tail /tmp/syslog-template.log | grep 'A message'
"DATE'2005-10-31T00:00:11+0100'TZOFFSET'+0100'FULLDATE'2005 Oct 31 
00:00:11'MSG'pvm: A message

************ DST example - fails     ************
# Date and perl agree with the truth that
# we're +0200 during "summertime" - dst.
 > date --rfc-2822
Tue, 25 Oct 2005 00:14:13 +0200
 > perl -le 'use POSIX; print strftime ("%a,  %d  %b %Y %H:%M:%S %z", 
localtime);'
Tue,  25  Oct 2005 00:14:15 +0200
# syslog-ng seems to think we're +0100
 > logger 'A message'
 > sudo tail /tmp/syslog-template.log | grep 'A message'
"DATE'2005-10-25T00:14:17+0100'TZOFFSET'+0100'FULLDATE'2005 Oct 25 
00:14:17'MSG'pvm: A message

*********** Tried setting TZ env ****************
I tried setting the TZ environment variable as pr.
http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

And notice that perl (or rather the POSIX implementation of strftime()) 
adheres to it:
 > TZ=:/usr/share/zoneinfo/Asia/Tokyo perl -le 'use POSIX; print 
strftime ("%a,  %d  %b %Y %H:%M:%S %z", localtime);'
Tue,  25  Oct 2005 07:03:32 +0900
 > TZ=:/usr/share/zoneinfo/Europe/Copenhagen perl -le 'use POSIX; print 
strftime ("%a,  %d  %b %Y %H:%M:%S %z", localtime);'
Tue,  25  Oct 2005 00:03:39 +0200

Using Asia/Tokyo or Europe/Copenhagen does affect syslog-ng, but it 
still has a offset-by-one error during DST!

# Not my real timezone
# export TZ=:/usr/share/zoneinfo/Asia/Tokyo
# /etc/init.d/syslog-ng restart
# logger 'A message'
# tail /tmp/syslog-template.log | grep 'A message'
"DATE'2005-10-25T07:06:14+0900'TZOFFSET'+0900'FULLDATE'2005 Oct 25 
07:06:14'MSG'pvm: A message

# My real timezone - should be +0200 on oct 25 in
# Copenhagen as strftime also knows.
#
# export TZ=:/usr/share/zoneinfo/Europe/Copenhagen
# /etc/init.d/syslog-ng restart
# logger 'A message'
# tail /tmp/syslog-template.log | grep 'A message'
"DATE'2005-10-25T00:06:57+0100'TZOFFSET'+0100'FULLDATE'2005 Oct 25 
00:06:57'MSG'pvm: A message

-- 
Peter Valdemar Mørch
http://www.morch.com


More information about the syslog-ng mailing list