Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37733353
en ru br
ALT Linux repositórios
S:2.38.0.23.0e1ef6779a-alt1
5.0: 2.9-alt5
4.1: 2.5.1-alt4.M41.2
4.0: 2.5-alt4.M40.2
3.0: 2.3.5-alt5

Outros repositórios

Group :: Sistema/Base
RPM: glibc

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: glibc-2.5-mjt-owl-alt-syslog-timestamp.patch
Download


2005-05-08  Michael Tokarev <mjt@corpit.ru>
	    Dmitry V. Levin  <ldv@altlinux.org>
	Use ctime_r(3) instead of strftime_r(3) in syslog(3) so that month
	names will not depend on current locale settings.  This patch also
	cleans up syslog.c a bit as a result.  But see note in code below.
--- glibc-2.5.orig/misc/syslog.c
+++ glibc-2.5/misc/syslog.c
@@ -57,11 +57,8 @@
 #include <varargs.h>
 #endif
 
-#include <libio/iolibio.h>
 #include <math_ldbl_opt.h>
 
-#define ftell(s) INTUSE(_IO_ftell) (s)
-
 static int	LogType = SOCK_DGRAM;	/* type of socket connection */
 static int	LogFile = -1;		/* fd for log */
 static int	connected;		/* have done connect */
@@ -182,19 +179,22 @@
 void
 __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap)
 {
-	struct tm now_tm;
 	time_t now;
 	int fd;
 	FILE *f;
 	char *buf = 0;
 	size_t bufsize = 0;
-	size_t prioff, msgoff;
+	size_t msgoff;
 #ifndef NO_SIGPIPE
  	struct sigaction action, oldaction;
  	int sigpipe;
 #endif
 	int saved_errno = errno;
-	char failbuf[3 * sizeof (pid_t) + sizeof "out of memory []"];
+	/* we use failbuf for 2 things: to hold message in case of
+	 * OOM condition, and for ctime_r() buffer */
+#define FAILMSGSZ (3 * sizeof (pid_t) + sizeof "out of memory []")
+#define CTIMESZ 26
+	char failbuf[FAILMSGSZ > CTIMESZ ? FAILMSGSZ : CTIMESZ];
 
 #define	INTERNALLOG	LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID
 	/* Check for invalid bits. */
@@ -239,15 +239,21 @@ __vsyslog_chk(int pri, int flag, const char *fmt, va_list ap)
 	else
 	  {
 	    __fsetlocking (f, FSETLOCKING_BYCALLER);
-	    prioff = fprintf (f, "<%d>", pri);
+	    /*
+	     * XXX: syslogd may know better what the current time is.
+	     * User program may be running chrooted w/o proper localtime
+	     * description, or a user may prefer their own timezone.  syslogd
+	     * is able to construct timestamp if there is no timestamp given
+	     * in a message.  So it may be waay better to NOT construct ANY
+	     * timestamp here and allow syslogd to figure out proper time
+	     * for us.  When working with local syslogd (and it IS local
+	     * since we're using either /dev/log or localhost), message
+	     * should be picked up by syslogd very shortly.  And at least
+	     * timestamps in system logs will be in chronological order...
+	     * -- mjt.
+	     */
 	    (void) time (&now);
-	    f->_IO_write_ptr += __strftime_l (f->_IO_write_ptr,
-					      f->_IO_write_end
-					      - f->_IO_write_ptr,
-					      "%h %e %T ",
-					      __localtime_r (&now, &now_tm),
-					      _nl_C_locobj_ptr);
-	    msgoff = ftell (f);
+	    msgoff = fprintf (f, "<%d>%.15s ", pri, ctime_r(&now, failbuf) + 4);
 
 	    /* Protect against multiple users and cancellation.  */
 	    __libc_cleanup_push (cancel_handler, NULL);
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009