From 77feb3e1315ec5bc47ec851b2ee3b72f1ace63f5 Mon Sep 17 00:00:00 2001 From: Daniel Novotny Date: Tue, 6 Apr 2010 10:01:15 +0000 Subject: [PATCH] fix #578115 - missingok problem with globs --- logrotate-3.7.8-missingok.patch | 74 +++++++++++++++++++++++++++++++++ logrotate.spec | 7 +++- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 logrotate-3.7.8-missingok.patch diff --git a/logrotate-3.7.8-missingok.patch b/logrotate-3.7.8-missingok.patch new file mode 100644 index 0000000..bd19697 --- /dev/null +++ b/logrotate-3.7.8-missingok.patch @@ -0,0 +1,74 @@ +diff -up logrotate-3.7.8/config.c.missingok logrotate-3.7.8/config.c +--- logrotate-3.7.8/config.c.missingok 2010-04-06 11:35:11.000000000 +0200 ++++ logrotate-3.7.8/config.c 2010-04-06 11:43:37.000000000 +0200 +@@ -41,6 +41,7 @@ static int defTabooCount = sizeof(defTab + /* I shouldn't use globals here :-( */ + static char **tabooExts = NULL; + int tabooCount = 0; ++static int glob_errno = 0; + + static int readConfigFile(const char *configFile, struct logInfo *defConfig); + static int globerr(const char *pathname, int theerr); +@@ -461,8 +462,7 @@ int readAllConfigPaths(const char **path + + static int globerr(const char *pathname, int theerr) + { +- message(MESS_ERROR, "error accessing %s: %s\n", pathname, +- strerror(theerr)); ++ glob_errno = theerr; + + /* We want the glob operation to abort on error, so return 1 */ + return 1; +@@ -501,6 +501,7 @@ static int readConfigFile(const char *co + int logerror = 0; + struct logInfo *log; + static unsigned recursion_depth = 0U; ++ char *globerr_msg = NULL; + + /* FIXME: createOwner and createGroup probably shouldn't be fixed + length arrays -- of course, if we aren't run setuid it doesn't +@@ -1346,16 +1347,25 @@ static int readConfigFile(const char *co + newlog->files = NULL; + newlog->numFiles = 0; + for (argNum = 0; argNum < argc && logerror != 1; argNum++) { ++ if (globerr_msg) { ++ free(globerr_msg); ++ globerr_msg = NULL; ++ } ++ + rc = glob(argv[argNum], GLOB_NOCHECK, globerr, + &globResult); + if (rc == GLOB_ABORTED) { + if (newlog->flags & LOG_FLAG_MISSINGOK) + continue; + +- message(MESS_ERROR, "%s:%d glob failed for %s\n", +- configFile, lineNum, argv[argNum]); +- logerror = 1; +- break; ++ /* We don't yet know whether this stanza has "missingok" ++ * set, so store the error message for later. */ ++ rc = asprintf(&globerr_msg, "%s:%d glob failed for %s: %s\n", ++ configFile, lineNum, argv[argNum], strerror(glob_errno)); ++ if (rc == -1) ++ globerr_msg = NULL; ++ ++ globResult.gl_pathc = 0; + } + + newlog->files = +@@ -1407,6 +1417,14 @@ duperror: + lineNum); + return 1; + } ++ if (globerr_msg) { ++ if (!(newlog->flags & LOG_FLAG_MISSINGOK)) ++ message(MESS_ERROR, globerr_msg); ++ free(globerr_msg); ++ globerr_msg = NULL; ++ if (!(newlog->flags & LOG_FLAG_MISSINGOK)) ++ return 1; ++ } + + if (newlog->oldDir) { + for (i = 0; i < newlog->numFiles; i++) { diff --git a/logrotate.spec b/logrotate.spec index f091e08..fd4b5a2 100644 --- a/logrotate.spec +++ b/logrotate.spec @@ -1,7 +1,7 @@ Summary: Rotates, compresses, removes and mails system log files Name: logrotate Version: 3.7.8 -Release: 7%{?dist} +Release: 8%{?dist} License: GPL+ Group: System Environment/Base Source: https://fedorahosted.org/releases/l/o/logrotate/logrotate-%{version}.tar.gz @@ -11,6 +11,7 @@ Patch3: logrotate-3.7.8-devnull.patch Patch4: logrotate-3.7.8-man5.patch Patch5: logrotate-3.7.8-readonly.patch Patch6: logrotate-3.7.8-perm.patch +Patch7: logrotate-3.7.8-missingok.patch Requires: coreutils >= 5.92 libsepol libselinux popt BuildRequires: libselinux-devel popt-devel @@ -35,6 +36,7 @@ log files on your system. %patch4 -p1 -b .man5 %patch5 -p1 -b .readonly %patch6 -p1 -b .perm +%patch7 -p1 -b .missingok %build make %{?_smp_mflags} RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes @@ -65,6 +67,9 @@ rm -rf $RPM_BUILD_ROOT %attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status %changelog +* Tue Apr 06 2010 Daniel Novotny 3.7.8-8 +- fix #578115 - missingok problem with globs + * Mon Jan 11 2010 Daniel Novotny 3.7.8-7 - fix #489038 - RFE: useful permissions on log files