8d1f53
diff -up cups-2.1b1/scheduler/log.c.logrotate cups-2.1b1/scheduler/log.c
8d1f53
--- cups-2.1b1/scheduler/log.c.logrotate	2015-06-04 20:00:31.000000000 +0200
8d1f53
+++ cups-2.1b1/scheduler/log.c	2015-06-29 13:25:09.623350218 +0200
8d1f53
@@ -26,6 +26,9 @@
8d1f53
 #  include <systemd/sd-journal.h>
8d1f53
 #endif /* HAVE_ASL_H */
df5058
 #include <syslog.h>
df5058
+#include <sys/types.h>
df5058
+#include <sys/stat.h>
df5058
+#include <unistd.h>
df5058
 
df5058
 
df5058
 /*
8d1f53
@@ -135,12 +138,10 @@ cupsdCheckLogFile(cups_file_t **lf,	/* I
8d1f53
   }
df5058
 
df5058
  /*
df5058
-  * Format the filename as needed...
df5058
+  * Format the filename...
df5058
   */
df5058
 
df5058
-  if (!*lf ||
df5058
-      (strncmp(logname, "/dev/", 5) && cupsFileTell(*lf) > MaxLogSize &&
df5058
-       MaxLogSize > 0))
df5058
+  if (strncmp(logname, "/dev/", 5))
df5058
   {
df5058
    /*
df5058
     * Handle format strings...
8d1f53
@@ -254,6 +255,34 @@ cupsdCheckLogFile(cups_file_t **lf,	/* I
8d1f53
      /*
8d1f53
       * Change ownership and permissions of non-device logs...
8d1f53
       */
8d1f53
+
8d1f53
+      fchown(cupsFileNumber(*lf), RunUser, Group);
8d1f53
+      fchmod(cupsFileNumber(*lf), LogFilePerm);
8d1f53
+    }
8d1f53
+  }
8d1f53
+
8d1f53
+ /*
df5058
+  * Has someone else (i.e. logrotate) already rotated the log for us?
df5058
+  */
df5058
+  else if (strncmp(filename, "/dev/", 5))
df5058
+  {
df5058
+    struct stat st;
df5058
+    if (stat(filename, &st) || st.st_size == 0)
df5058
+    {
df5058
+      /* File is either missing or has zero size. */
df5058
+
df5058
+      cupsFileClose(*lf);
df5058
+      if ((*lf = cupsFileOpen(filename, "a")) == NULL)
df5058
+      {
df5058
+	syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename,
df5058
+             strerror(errno));
df5058
+
df5058
+	return (0);
df5058
+      }
df5058
+
df5058
+     /*
df5058
+      * Change ownership and permissions of non-device logs...
df5058
+      */
df5058
 
8d1f53
       fchown(cupsFileNumber(*lf), RunUser, Group);
8d1f53
       fchmod(cupsFileNumber(*lf), LogFilePerm);