64 lines
1.5 KiB
Diff
64 lines
1.5 KiB
Diff
|
diff -up cups-1.3.5/scheduler/log.c.logrotate cups-1.3.5/scheduler/log.c
|
||
|
--- cups-1.3.5/scheduler/log.c.logrotate 2008-02-14 12:21:25.000000000 +0000
|
||
|
+++ cups-1.3.5/scheduler/log.c 2008-02-14 12:24:16.000000000 +0000
|
||
|
@@ -29,6 +29,9 @@
|
||
|
#include "cupsd.h"
|
||
|
#include <stdarg.h>
|
||
|
#include <syslog.h>
|
||
|
+#include <sys/types.h>
|
||
|
+#include <sys/stat.h>
|
||
|
+#include <unistd.h>
|
||
|
|
||
|
|
||
|
/*
|
||
|
@@ -467,12 +470,10 @@ check_log_file(cups_file_t **lf, /* IO -
|
||
|
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...
|
||
|
@@ -565,6 +566,34 @@ check_log_file(cups_file_t **lf, /* IO -
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
+ * 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?
|
||
|
*/
|
||
|
|