diff -up cups-2.1b1/scheduler/log.c.logrotate cups-2.1b1/scheduler/log.c --- cups-2.1b1/scheduler/log.c.logrotate 2015-06-04 20:00:31.000000000 +0200 +++ cups-2.1b1/scheduler/log.c 2015-06-29 13:25:09.623350218 +0200 @@ -26,6 +26,9 @@ # include #endif /* HAVE_ASL_H */ #include +#include +#include +#include /* @@ -135,12 +138,10 @@ cupsdCheckLogFile(cups_file_t **lf, /* I } /* - * 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... @@ -254,6 +255,34 @@ cupsdCheckLogFile(cups_file_t **lf, /* I /* * Change ownership and permissions of non-device logs... */ + + fchown(cupsFileNumber(*lf), RunUser, Group); + fchmod(cupsFileNumber(*lf), LogFilePerm); + } + } + + /* + * 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);