Project

General

Profile

Bug #3694

Timestamp on logfile entries is GMT on Alpine 3.x instead of local time on pre-3.x versions

Added by Yves Schumann over 4 years ago. Updated about 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
01/13/2015
Due date:
% Done:

0%

Estimated time:
Affected versions:
Security IDs:

Description

Timestamp of logfile entries uses GMT on Alpine Linux 3.x. This leads to confusing problems as other programs like Apache use local time.

History

#1 Updated by Natanael Copa over 4 years ago

this is actually a bit tricky because different users can have different timezones. So if one daemon runs as one user in one timezone, there is nothing that prevents another daemon run as other user in other timezone. I think this is the reason why musl decided to go for timezones as UTC only.

See http://www.openwall.com/lists/musl/2014/01/28/4

#2 Updated by Sören Tempel almost 3 years ago

I was annoyed by that too. Attached is a busybox 1.25 patch which always sets the log message timestamp from sysklogd. Maybe not ideal but good enough for me.

#3 Updated by Oleg Omelyusik almost 2 years ago

Timestamp adjusting feature (custom -Z option for syslogd) is broken on x86.

sysklogd/syslogd.c with applied 0009-sysklogd-add-Z-option-to-adjust-message-timezones.patch:

833                if (G.adjustTimezone && strptime(msg, "%b %e %T", &nowtm)) {
834                        now = mktime(&nowtm) - timezone;
835                        timestamp = ctime(&now) + 4; /* skip day of week */
836                }

  • strptime() does not set tm_year field in nowtm structure since there is no year in the timestamp string and template
  • mktime() fails to create time_t value with EOVERFLOW and returns -1 with tm_year=0
  • mktime() works OK if tm_year field is set to valid value (e.g. 117)

I have GMT+3 timezone and have always the same timestamp in logs (excluding syslog messages): "Jan 1 05:59:59"

Even if this code works on the other platforms it is necessary to take into account year value otherwise syslogd will report (I guess) wrong date in leap years (e.g. adjusting Feb 28 23:00:00 UTC to GMT+2).

#4 Updated by Oleg Omelyusik almost 2 years ago

Forgot to mention the version: Alpine Linux 3.6.2.

#5 Updated by Valery Kartel almost 2 years ago

I had the same problem with busybox-syslogd. I setted up timezone via 'setup-timezone' to Europe/Kiev but log entries still were with UTC time. When I setted the same value to /etc/TZ (echo Europe/Kiev > /etc/TZ) - problem dissapeared.

#6 Updated by Justin Forest about 1 year ago

I have the same issue on Alpine 3.7. Unless I remove -Z from syslog, all entries are timestamped with "Jan 1 05:59:59".

Also available in: Atom PDF