]>
Commit | Line | Data |
---|---|---|
b3b50933 AM |
1 | diff -up cups-2.1b1/scheduler/log.c.logrotate cups-2.1b1/scheduler/log.c |
2 | --- cups-2.1b1/scheduler/log.c.logrotate 2015-06-04 20:00:31.000000000 +0200 | |
3 | +++ cups-2.1b1/scheduler/log.c 2015-06-29 13:25:09.623350218 +0200 | |
4 | @@ -26,6 +26,9 @@ | |
5 | # include <systemd/sd-journal.h> | |
6 | #endif /* HAVE_ASL_H */ | |
7 | #include <syslog.h> | |
8 | +#include <sys/types.h> | |
9 | +#include <sys/stat.h> | |
10 | +#include <unistd.h> | |
11 | ||
12 | ||
13 | /* | |
14 | @@ -135,12 +138,10 @@ cupsdCheckLogFile(cups_file_t **lf, /* I | |
15 | } | |
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 | @@ -254,6 +255,34 @@ cupsdCheckLogFile(cups_file_t **lf, /* I | |
30 | /* | |
31 | * Change ownership and permissions of non-device logs... | |
32 | */ | |
33 | + | |
34 | + fchown(cupsFileNumber(*lf), RunUser, Group); | |
35 | + fchmod(cupsFileNumber(*lf), LogFilePerm); | |
36 | + } | |
37 | + } | |
38 | + | |
39 | + /* | |
40 | + * Has someone else (i.e. logrotate) already rotated the log for us? | |
41 | + */ | |
42 | + else if (strncmp(filename, "/dev/", 5)) | |
43 | + { | |
44 | + struct stat st; | |
45 | + if (stat(filename, &st) || st.st_size == 0) | |
46 | + { | |
47 | + /* File is either missing or has zero size. */ | |
48 | + | |
49 | + cupsFileClose(*lf); | |
50 | + if ((*lf = cupsFileOpen(filename, "a")) == NULL) | |
51 | + { | |
52 | + syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename, | |
53 | + strerror(errno)); | |
54 | + | |
55 | + return (0); | |
56 | + } | |
57 | + | |
58 | + /* | |
59 | + * Change ownership and permissions of non-device logs... | |
60 | + */ | |
61 | ||
62 | fchown(cupsFileNumber(*lf), RunUser, Group); | |
63 | fchmod(cupsFileNumber(*lf), LogFilePerm); |