]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blame - cups/patches/cups-logrotate.patch
Move all packages to root.
[people/arne_f/ipfire-3.x.git] / cups / patches / cups-logrotate.patch
CommitLineData
f92713d3
SS
1diff -up cups-1.3.5/scheduler/log.c.logrotate cups-1.3.5/scheduler/log.c
2--- cups-1.3.5/scheduler/log.c.logrotate 2008-02-14 12:21:25.000000000 +0000
3+++ cups-1.3.5/scheduler/log.c 2008-02-14 12:24:16.000000000 +0000
4@@ -29,6 +29,9 @@
5 #include "cupsd.h"
6 #include <stdarg.h>
7 #include <syslog.h>
8+#include <sys/types.h>
9+#include <sys/stat.h>
10+#include <unistd.h>
11
12
13 /*
14@@ -467,12 +470,10 @@ check_log_file(cups_file_t **lf, /* IO -
15 return (1);
16
17 /*
18- * Format the filename as needed...
19+ * Format the filename...
20 */
21
22- if (!*lf ||
23- (strncmp(logname, "/dev/", 5) && cupsFileTell(*lf) > MaxLogSize &&
24- MaxLogSize > 0))
25+ if (strncmp(logname, "/dev/", 5))
26 {
27 /*
28 * Handle format strings...
29@@ -565,6 +566,34 @@ check_log_file(cups_file_t **lf, /* IO -
30 }
31
32 /*
33+ * Has someone else (i.e. logrotate) already rotated the log for us?
34+ */
35+ else if (strncmp(filename, "/dev/", 5))
36+ {
37+ struct stat st;
38+ if (stat(filename, &st) || st.st_size == 0)
39+ {
40+ /* File is either missing or has zero size. */
41+
42+ cupsFileClose(*lf);
43+ if ((*lf = cupsFileOpen(filename, "a")) == NULL)
44+ {
45+ syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename,
46+ strerror(errno));
47+
48+ return (0);
49+ }
50+
51+ /*
52+ * Change ownership and permissions of non-device logs...
53+ */
54+
55+ fchown(cupsFileNumber(*lf), RunUser, Group);
56+ fchmod(cupsFileNumber(*lf), LogFilePerm);
57+ }
58+ }
59+
60+ /*
61 * Do we need to rotate the log?
62 */
63