summaryrefslogtreecommitdiffstats
path: root/cups-logrotate.patch
diff options
context:
space:
mode:
Diffstat (limited to 'cups-logrotate.patch')
-rw-r--r--cups-logrotate.patch63
1 files changed, 63 insertions, 0 deletions
diff --git a/cups-logrotate.patch b/cups-logrotate.patch
new file mode 100644
index 0000000..a6485a9
--- /dev/null
+++ b/cups-logrotate.patch
@@ -0,0 +1,63 @@
+diff -up cups-1.5b1/scheduler/log.c.logrotate cups-1.5b1/scheduler/log.c
+--- cups-1.5b1/scheduler/log.c.logrotate 2011-05-14 01:04:16.000000000 +0200
++++ cups-1.5b1/scheduler/log.c 2011-05-24 15:47:20.000000000 +0200
+@@ -32,6 +32,9 @@
+ #include "cupsd.h"
+ #include <stdarg.h>
+ #include <syslog.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <unistd.h>
+
+
+ /*
+@@ -71,12 +74,10 @@ cupsdCheckLogFile(cups_file_t **lf, /* I
+ return (1);
+
+ /*
+- * Format the filename as needed...
++ * Format the filename...
+ */
+
+- if (!*lf ||
+- (strncmp(logname, "/dev/", 5) && cupsFileTell(*lf) > MaxLogSize &&
+- MaxLogSize > 0))
++ if (strncmp(logname, "/dev/", 5))
+ {
+ /*
+ * Handle format strings...
+@@ -186,6 +187,34 @@ cupsdCheckLogFile(cups_file_t **lf, /* I
+ }
+
+ /*
++ * 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);
++ }
++
++ /*
++ * Change ownership and permissions of non-device logs...
++ */
++
++ fchown(cupsFileNumber(*lf), RunUser, Group);
++ fchmod(cupsFileNumber(*lf), LogFilePerm);
++ }
++ }
++
++ /*
+ * Do we need to rotate the log?
+ */
+