debian/changelog                         |    1 
 debian/patches/20_xdm_log_timestamp.diff |  147 +++++++------------------------
 debian/patches/21_xdm_log_append.diff    |   63 +++++--------
 debian/patches/series                    |    6 -
 4 files changed, 63 insertions(+), 154 deletions(-)

New commits:
commit 29c99d381187aa8ee0eaf02914335ad12b198808
Author: Julien Cristau <[email protected]>
Date:   Wed Dec 23 17:05:17 2009 +0100

    Update patches 20_xdm_log_timestamp.diff and 21_xdm_log_append.diff.

diff --git a/debian/changelog b/debian/changelog
index 0685131..15150ca 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,7 @@ xdm (1:1.1.9-1) UNRELEASED; urgency=low
   * xdm.postrm: remove /etc/X11/default-display-manager on purge if it exists
     and points to xdm.  Fixes piuparts failure.
   * xdm.prerm uses ps, add Depends on procps.
+  * Update patches 20_xdm_log_timestamp.diff and 21_xdm_log_append.diff.
 
   [ Brice Goglin ]
   * New upstream release.
diff --git a/debian/patches/20_xdm_log_timestamp.diff 
b/debian/patches/20_xdm_log_timestamp.diff
index 9cd1047..f109c5a 100644
--- a/debian/patches/20_xdm_log_timestamp.diff
+++ b/debian/patches/20_xdm_log_timestamp.diff
@@ -1,127 +1,48 @@
-From: Branden Robinson <[email protected]>
-Subject: Add timestamping to logging functions, except for LogOutOfMem()
+From 8eb75e620cca2d9c64682942e171a07b00a60749 Mon Sep 17 00:00:00 2001
+From: Julien Cristau <[email protected]>
+Date: Wed, 23 Dec 2009 16:51:22 +0100
+Subject: [PATCH] Add timestamping to logging functions
+
+Based on patch by Branden Robinson <[email protected]>
+---
+ error.c |   20 +++++++++++++++++---
+ 1 files changed, 17 insertions(+), 3 deletions(-)
 
 Index: xdm/error.c
 ===================================================================
 --- xdm.orig/error.c
 +++ xdm/error.c
-@@ -34,23 +34,41 @@
-  *
-  * error.c
-  *
-- * Log display manager errors to a file as
-- * we generally do not have a terminal to talk to
-+ * Log display manager errors to a file as we generally do not have a
-+ * terminal to talk to.
-+ *
-+ * Because we have child processes, and chatty things like X servers, we do
-+ * not use syslog().
-  */
- 
--# include <stdio.h>
--# include <stdarg.h>
-+#include <errno.h>
-+#include <stdio.h>
-+#include <stdarg.h>
-+#include <time.h>
- 
--# include "dm.h"
--# include "dm_error.h"
-+#include "dm.h"
-+#include "dm_error.h"
- 
- #define WRITES(fd, buf) write(fd, buf, strlen(buf))
- 
--void LogInfo(char * fmt, ...)
-+void
-+LogInfo(char * fmt, ...)
- {
-     char buf[1024];
- 
--    snprintf(buf, sizeof buf, "xdm info (pid %ld): ", (long)getpid());
-+    time_t seconds;
-+    struct tm *timestamp = NULL;
-+    char timebuf[256];
-+
-+    if (time(&seconds) > (time_t) -1)
-+      timestamp = localtime(&seconds);
-+
-+    strcpy(timebuf, "(time unavailable)");
-+
-+    if (timestamp != NULL)
-+      strftime(timebuf, 255, "%c", timestamp);
-+
-+    snprintf(buf, sizeof buf, "%s xdm info (pid %ld): ", timebuf, 
(long)getpid());
-     WRITES(STDERR_FILENO, buf);
-     {
-       va_list args;
-@@ -61,11 +79,24 @@
-     WRITES(STDERR_FILENO, buf);
+@@ -64,9 +64,6 @@
+       va_end(args);           \
+     } while(0)
+ 
+-#define LogHeader(type)               \
+-    LogAppend("xdm %s (pid %ld): ", type, (long)getpid())
+-
+ /* Append more text to the log without a new header, right after
+    having called LogInfo or LogError */
+ void
+@@ -75,6 +72,23 @@
+     LogVarArgsWrite(fmt);
  }
  
--void LogError (char * fmt, ...)
-+void
-+LogError (char * fmt, ...)
- {
-     char buf[1024];
- 
--    snprintf (buf, sizeof buf, "xdm error (pid %ld): ", (long)getpid());
++static void
++LogHeader(const char *type) {
 +    time_t seconds;
++    size_t rc = 0;
 +    struct tm *timestamp = NULL;
 +    char timebuf[256];
++    if (time(&seconds) != (time_t) -1)
++      timestamp = localtime(&seconds);
 +
-+    if (time(&seconds) > (time_t) -1)
-+      timestamp = localtime(&seconds);
-+
-+    strcpy(timebuf, "(time unavailable)");
-+
-+    if (timestamp != NULL)
-+      strftime(timebuf, 255, "%c", timestamp);
-+
-+    snprintf (buf, sizeof buf, "%s xdm error (pid %ld): ", timebuf, 
(long)getpid());
-     WRITES(STDERR_FILENO, buf);
-     {
-       va_list args;
-@@ -76,11 +107,24 @@
-     WRITES(STDERR_FILENO, buf);
- }
- 
--void LogPanic (char * fmt, ...)
-+void
-+LogPanic (char * fmt, ...)
- {
-     char buf[1024];
- 
--    snprintf (buf, sizeof buf, "xdm panic (pid %ld): ", (long)getpid());
-+    time_t seconds;
-+    struct tm *timestamp = NULL;
-+    char timebuf[256];
-+
-+    if (time(&seconds) > (time_t) -1)
-+      timestamp = localtime(&seconds);
-+
-+    strcpy(timebuf, "(time unavailable)");
++    if (timestamp)
++      rc = strftime(timebuf, 255, "%c", timestamp);
++    if (!rc)
++      strcpy(timebuf, "(time unavailable)");
 +
-+    if (timestamp != NULL)
-+      strftime(timebuf, 255, "%c", timestamp);
++    LogAppend("%s xdm %s (pid %ld): ", timebuf, type, (long)getpid());
++}
 +
-+    snprintf (buf, sizeof buf, "%s xdm panic (pid %ld): ", timebuf, 
(long)getpid());
-     WRITES(STDERR_FILENO, buf);
-     {
-       va_list args;
-@@ -92,8 +136,14 @@
-     _exit (1);
- }
- 
--void LogOutOfMem (char * fmt, ...)
-+void
-+LogOutOfMem (char * fmt, ...)
+ void
+ LogInfo(const char * fmt, ...)
  {
-+    /*
-+     * No point messing with allocation of timeval structs and static
-+     * buffers for the timestamp string if we're already out of memory...
-+     */
-+
-     fprintf (stderr, "xdm: out of memory in routine ");
-     {
-       va_list args;
diff --git a/debian/patches/21_xdm_log_append.diff 
b/debian/patches/21_xdm_log_append.diff
index 5ea022b..78f21fe 100644
--- a/debian/patches/21_xdm_log_append.diff
+++ b/debian/patches/21_xdm_log_append.diff
@@ -1,46 +1,33 @@
-From: Branden Robinson <[email protected]>
-Subject: Append to the log file if it already exists
+From: Julien Cristau <[email protected]>
+Subject: Append to the log file instead of truncating it
+
+Based on patch by Branden Robinson <[email protected]>
 
 Index: xdm/error.c
 ===================================================================
 --- xdm.orig/error.c
 +++ xdm/error.c
-@@ -168,17 +168,26 @@
-     }
- }
+@@ -38,6 +38,7 @@
  
--void InitErrorLog (void)
-+void
-+InitErrorLog (void)
+ #include <stdio.h>
+ #include <stdarg.h>
++#include <errno.h>
+ 
+ #include "dm.h"
+ #include "dm_error.h"
+@@ -140,13 +141,13 @@
  {
--      int     i;
--      if (errorLogFile[0]) {
--              i = creat (errorLogFile, 0666);
--              if (i != -1) {
--                      if (i != 2) {
--                              dup2 (i, 2);
--                              close (i);
--                      }
--              } else
--                      LogError ("Cannot open errorLogFile %s\n", 
errorLogFile);
--      }
-+    int fd;
-+
-+    if (errorLogFile[0]) {
-+      /* create the log file if it doesn't already exist */
-+      fd = open (errorLogFile, O_WRONLY|O_CREAT|O_EXCL, 0666);
-+      if (fd == -1)
-+          if (errno == EEXIST)
-+              /* log file already exists; append to it */
-+              fd = open (errorLogFile, O_WRONLY|O_APPEND);
-+      if (fd != -1) {
-+          /* redirect stderr to the log file */
-+          if (fd != 2) {
-+              dup2 (fd, 2);
-+              close (fd);
-+          }
-+      } else
-+          fprintf (stderr, "cannot open log file %s: %s\n", errorLogFile,
-+                   _SysErrorMsg (errno));
-+    }
+     int       i;
+     if (errorLogFile[0]) {
+-      i = creat (errorLogFile, 0666);
++      i = open (errorLogFile, O_WRONLY|O_CREAT|O_APPEND, 0666);
+       if (i != -1) {
+           if (i != STDERR_FILENO) {
+               dup2 (i, STDERR_FILENO);
+               close (i);
+           }
+       } else
+-          LogError ("Cannot open errorLogFile %s\n", errorLogFile);
++          LogError ("Cannot open errorLogFile %s: %s\n", errorLogFile, 
_SysErrorMsg (errno));
+     }
  }
diff --git a/debian/patches/series b/debian/patches/series
index 9d7f63e..1927a27 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -8,9 +8,9 @@
 # not sure this one is still relevant now we use mkstemp
 15_xdm_openfiles.diff
 
-# painful merge
-#XXX 20_xdm_log_timestamp.diff
-#XXX 21_xdm_log_append.diff
+# should get forwarded upstream
+20_xdm_log_timestamp.diff
+21_xdm_log_append.diff
 
 90_xdm_write_dummy_auth.diff
 # depends on patch 90


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to