[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wrong date format in syslog
From: |
SEKINE Tatsuo |
Subject: |
wrong date format in syslog |
Date: |
Tue, 25 Feb 2003 13:37:05 +0900 |
Hi all.
Accroding to RFC 3164(ftp://ftp.rfc-editor.org/in-notes/rfc3164.txt),
the timestamp should be in the format of "Mmm dd hh:mm:ss" (without
the quote marks). Where "Mmm" is the English language abbreviation for
the month of the year.
But glibc-2.3.1 implements it as "%h %e %T" (in strftime() format).
In non-English locale, syslog daemon incorrectly parse those message
generated by glibc.
Quick hacked patch is attached below.
I'm sorry, but I don't know how to write correct code in glibc.
Thus the patch is not tested, but the way of thinking may be correct.
------ cut here -- cut here -- cut here -- cut here -- cut here ------
--- glibc-2.3.1/misc/syslog.c.orig Tue Aug 27 06:15:54 2002
+++ glibc-2.3.1/misc/syslog.c Tue Feb 25 13:21:38 2003
@@ -165,16 +165,19 @@
}
else
{
+ char *ctimep;
prioff = fprintf (f, "<%d>", pri);
(void) time (&now);
+ ctimep = ctime (&now);
+ ctimep += 4; /* skip the days of the week */
#ifdef USE_IN_LIBIO
- f->_IO_write_ptr += strftime (f->_IO_write_ptr,
- f->_IO_write_end - f->_IO_write_ptr,
- "%h %e %T ",
- __localtime_r (&now, &now_tm));
+ f->_IO_write_ptr += __snprintf (f->_IO_write_ptr,
+ f->_IO_write_end - f->_IO_write_ptr,
+ "%s ",
+ ctimep);
#else
- f->__bufp += strftime (f->__bufp, f->__put_limit - f->__bufp,
- "%h %e %T ", __localtime_r (&now, &now_tm));
+ f->__bufp += __snprintf (f->__bufp, f->__put_limit - f->__bufp,
+ "%s ", ctimep);
#endif
msgoff = ftell (f);
if (LogTag == NULL)
------ cut here -- cut here -- cut here -- cut here -- cut here ------
--
SEKINE Tatsuo:
http://www.sdri.co.jp/~tsekine/
address@hidden(business) System Design & Research Institute Co.,Ltd.
address@hidden(private) Yokohama Linux Users Group
- wrong date format in syslog,
SEKINE Tatsuo <=