rpms/cups/FC-6 cups-logrotate.patch,NONE,1.1 cups.spec,1.319,1.320

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Tue Mar 6 19:05:31 UTC 2007


Author: twaugh

Update of /cvs/dist/rpms/cups/FC-6
In directory cvs.devel.redhat.com:/tmp/cvs-serv5241

Modified Files:
	cups.spec 
Added Files:
	cups-logrotate.patch 
Log Message:
* Tue Mar  6 2007 Tim Waugh <twaugh at redhat.com> 1:1.2.8-4
- Use new log file if logrotate rotate the logs (bug #215023).
- Resolves: rhbz#215023


cups-logrotate.patch:
 log.c |  111 ++++++++++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 68 insertions(+), 43 deletions(-)

--- NEW FILE cups-logrotate.patch ---
--- cups-1.2.8/scheduler/log.c.logrotate	2006-10-11 22:04:58.000000000 +0100
+++ cups-1.2.8/scheduler/log.c	2007-03-06 18:46:25.000000000 +0000
@@ -37,6 +37,9 @@
 #include "cupsd.h"
 #include <stdarg.h>
 #include <syslog.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 
 
 /*
@@ -427,60 +430,51 @@
     return (1);
 
  /*
-  * Format the filename as needed...
+  * Handle format strings...
   */
 
-  if (!*lf ||
-      (strncmp(logname, "/dev/", 5) && cupsFileTell(*lf) > MaxLogSize &&
-       MaxLogSize > 0))
-  {
-   /*
-    * Handle format strings...
-    */
+  filename[sizeof(filename) - 1] = '\0';
 
-    filename[sizeof(filename) - 1] = '\0';
+  if (logname[0] != '/')
+  {
+    strlcpy(filename, ServerRoot, sizeof(filename));
+    strlcat(filename, "/", sizeof(filename));
+  }
+  else
+    filename[0] = '\0';
 
-    if (logname[0] != '/')
+  for (ptr = filename + strlen(filename);
+       *logname && ptr < (filename + sizeof(filename) - 1);
+       logname ++)
+    if (*logname == '%')
     {
-      strlcpy(filename, ServerRoot, sizeof(filename));
-      strlcat(filename, "/", sizeof(filename));
-    }
-    else
-      filename[0] = '\0';
+      /*
+       * Format spec...
+       */
 
-    for (ptr = filename + strlen(filename);
-         *logname && ptr < (filename + sizeof(filename) - 1);
-	 logname ++)
-      if (*logname == '%')
+      logname ++;
+      if (*logname == 's')
       {
-       /*
-        * Format spec...
-	*/
+	/*
+	 * Insert the server name...
+	 */
 
-        logname ++;
-	if (*logname == 's')
-	{
-	 /*
-	  * Insert the server name...
-	  */
-
-	  strlcpy(ptr, ServerName, sizeof(filename) - (ptr - filename));
-	  ptr += strlen(ptr);
-	}
-        else
-	{
-	 /*
-	  * Otherwise just insert the character...
-	  */
-
-	  *ptr++ = *logname;
-	}
+	strlcpy(ptr, ServerName, sizeof(filename) - (ptr - filename));
+	ptr += strlen(ptr);
       }
       else
+      {
+	/*
+	 * Otherwise just insert the character...
+	 */
+
 	*ptr++ = *logname;
+      }
+    }
+    else
+      *ptr++ = *logname;
 
-    *ptr = '\0';
-  }
+  *ptr = '\0';
 
  /*
   * See if the log file is open...
@@ -512,10 +506,41 @@
   }
 
  /*
+  * Has someone else (i.e. logrotate) already rotated the log for us?
+  */
+  else if (strncmp(filename, "/dev/", 5))
+  {
+    struct stat st;
+    if (stat(filename, &st) || st.st_size == 0)
+    {
+      /* File is either missing or has zero size. */
+
+      cupsFileClose(*lf);
+      if ((*lf = cupsFileOpen(filename, "a")) == NULL)
+      {
+	syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename,
+             strerror(errno));
+
+	return (0);
+      }
+
+      if (strncmp(logname, "/dev/", 5))
+      {
+       /*
+	* Change ownership and permissions of non-device logs...
+	*/
+
+	fchown(cupsFileNumber(*lf), RunUser, Group);
+	fchmod(cupsFileNumber(*lf), LogFilePerm);
+      }
+    }
+  }
+
+ /*
   * Do we need to rotate the log?
   */
 
-  if (strncmp(logname, "/dev/", 5) && cupsFileTell(*lf) > MaxLogSize &&
+  if (strncmp(filename, "/dev/", 5) && cupsFileTell(*lf) > MaxLogSize &&
       MaxLogSize > 0)
   {
    /*


Index: cups.spec
===================================================================
RCS file: /cvs/dist/rpms/cups/FC-6/cups.spec,v
retrieving revision 1.319
retrieving revision 1.320
diff -u -r1.319 -r1.320
--- cups.spec	2 Mar 2007 14:58:40 -0000	1.319
+++ cups.spec	6 Mar 2007 19:05:28 -0000	1.320
@@ -6,7 +6,7 @@
 Summary: Common Unix Printing System
 Name: cups
 Version: 1.2.8
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: GPL
 Group: System Environment/Daemons
 Source: ftp://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -46,6 +46,7 @@
 Patch20: cups-getpass.patch
 Patch21: cups-driverd-timeout.patch
 Patch22: cups-options.patch
+Patch23: cups-logrotate.patch
 Patch100: cups-lspp.patch
 Epoch: 1
 Url: http://www.cups.org/
@@ -153,6 +154,7 @@
 %patch20 -p1 -b .getpass
 %patch21 -p1 -b .driverd-timeout
 %patch22 -p1 -b .options
+%patch23 -p1 -b .logrotate
 
 %if %lspp
 %patch100 -p1 -b .lspp
@@ -436,6 +438,9 @@
 %{cups_serverbin}/daemon/cups-lpd
 
 %changelog
+* Tue Mar  6 2007 Tim Waugh <twaugh at redhat.com> 1:1.2.8-4
+- Use new log file if logrotate rotate the logs (bug #215023).
+
 * Fri Mar  2 2007 Tim Waugh <twaugh at redhat.com> 1:1.2.8-3
 - Updated LSPP patch (bug #229673).
 




More information about the fedora-cvs-commits mailing list