From df50584cdae1c0ee8e7fd5d5a04cc41acec7ef26 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Thu, 14 Feb 2008 12:49:40 +0000 Subject: [PATCH] - Try out logrotate again (bug #432730). --- cups-logrotate.patch | 63 ++++++++++++++++++++++++++++++++++++++++++++ cups.spec | 10 ++++++- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 cups-logrotate.patch diff --git a/cups-logrotate.patch b/cups-logrotate.patch new file mode 100644 index 0000000..559cbdc --- /dev/null +++ b/cups-logrotate.patch @@ -0,0 +1,63 @@ +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 + #include ++#include ++#include ++#include + + + /* +@@ -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? + */ + diff --git a/cups.spec b/cups.spec index a2a283e..2affe2b 100644 --- a/cups.spec +++ b/cups.spec @@ -18,6 +18,7 @@ Source5: cups-lpd Source6: pstoraster Source7: pstoraster.convs Source8: postscript.ppd.gz +Source9: cups.logrotate Source10: ncp.backend Source11: cups.conf Source12: cups.cron @@ -47,6 +48,7 @@ Patch19: cups-eggcups.patch Patch20: cups-getpass.patch Patch21: cups-driverd-timeout.patch Patch22: cups-strict-ppd-line-length.patch +Patch23: cups-logrotate.patch Patch25: cups-usb-paperout.patch Patch100: cups-lspp.patch Epoch: 1 @@ -162,6 +164,7 @@ lpd emulation. %patch20 -p1 -b .getpass %patch21 -p1 -b .driverd-timeout %patch22 -p1 -b .strict-ppd-line-length +%patch23 -p1 -b .logrotate %patch25 -p1 -b .usb-paperout %if %lspp @@ -222,9 +225,10 @@ mv lpc.8 lpc-cups.8 popd %endif -mkdir -p $RPM_BUILD_ROOT%{_datadir}/pixmaps $RPM_BUILD_ROOT%{_sysconfdir}/X11/sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/X11/applnk/System $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily +mkdir -p $RPM_BUILD_ROOT%{_datadir}/pixmaps $RPM_BUILD_ROOT%{_sysconfdir}/X11/sysconfig $RPM_BUILD_ROOT%{_sysconfdir}/X11/applnk/System $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily install -c -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_datadir}/pixmaps install -c -m 644 cups-lpd.real $RPM_BUILD_ROOT%{_sysconfdir}/xinetd.d/cups-lpd +install -c -m 644 %{SOURCE9} $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/cups install -c -m 755 %{SOURCE10} $RPM_BUILD_ROOT%{cups_serverbin}/backend/ncp install -c -m 755 %{SOURCE12} $RPM_BUILD_ROOT%{_sysconfdir}/cron.daily/cups install -c -m 644 %{SOURCE13} $RPM_BUILD_ROOT%{_sysconfdir}/cups/pdftops.conf @@ -377,6 +381,7 @@ rm -rf $RPM_BUILD_ROOT %dir %attr(0700,root,lp) /etc/cups/ssl /etc/cups/pstoraster.convs %config(noreplace) /etc/pam.d/cups +%config(noreplace) %{_sysconfdir}/logrotate.d/cups %dir %{_docdir}/cups-%{version} %{_docdir}/cups-%{version}/favicon.* %{_docdir}/cups-%{version}/images @@ -454,6 +459,9 @@ rm -rf $RPM_BUILD_ROOT %{cups_serverbin}/daemon/cups-lpd %changelog +* Thu Feb 14 2008 Tim Waugh +- Try out logrotate again (bug #432730). + * Tue Feb 12 2008 Tim Waugh 1:1.3.5-5 - Fixed admin.cgi handling of DefaultAuthType (bug #432478, STR #2703).