[Bug 7966] syslogd/logger wrong timestamps 1.22.x , 1.23.x

bugzilla at busybox.net bugzilla at busybox.net
Fri May 5 15:09:34 UTC 2017


https://bugs.busybox.net/show_bug.cgi?id=7966

Denys Vlasenko <vda.linux at googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #1 from Denys Vlasenko <vda.linux at googlemail.com> ---
Unfortunately, most clients of /dev/log socket generate their own timestamp -
they send a message which already has time/date prefix.

Current syslog.c code tries to detect it and not generate its own timestamp
prefix:

static void timestamp_and_log(int pri, char *msg, int len)
{
        char *timestamp;
        time_t now;

        /* Jan 18 00:11:22 msg... */
        /* 01234567890123456 */
        if (len < 16 || msg[3] != ' ' || msg[6] != ' '
         || msg[9] != ':' || msg[12] != ':' || msg[15] != ' '
        ) {
                time(&now);
                timestamp = ctime(&now) + 4; /* skip day of week */
        } else {
                now = 0;
                timestamp = msg;
                msg += 16;
        }
        timestamp[15] = '\0';

Thus, the bug is not in syslogd.c.

root at hbm-000eef(NFS):/$ date | logger
root at hbm-000eef(NFS):/$ date | logger
root at hbm-000eef(NFS):/$ date | logger

[PC]:$ nc -u -l -p 1514
<13>Dec 31 23:59:59 root: Sat Jan  1 00:24:59 UTC 2000
<13>Dec 31 23:59:59 root: Sat Jan  1 00:31:47 UTC 2000
<13>Dec 31 23:59:59 root: Sat Jan  1 00:31:50 UTC 2000

I ran a similar setup and can't reproduce it: strace shows that logger does
this:

send(3, "<13>May  5 16:59:17 root: Fri May  5 16:59:17 CEST 2017\n\0", 57,
MSG_NOSIGNAL) = 57

And this is done by syslog(i, "%s", strbuf) libc call: the date/time prefix is
generated in libc, not by logger.c code.

I'd hazard to guess "Poky-1.5.1" (whatever that is) is not doing it right.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list