Hello community, here is the log from the commit of package logrotate checked in at Thu Aug 16 18:19:24 CEST 2007. -------- --- logrotate/logrotate.changes 2006-08-07 18:18:43.000000000 +0200 +++ /mounts/work_src_done/STABLE/logrotate/logrotate.changes 2007-08-16 15:33:59.802857000 +0200 @@ -1,0 +2,7 @@ +Thu Aug 16 15:33:29 CEST 2007 - ro@suse.de + +- update to 3.7.5 with some bugfixes containing: + - 251040 config option size not handled correctly +- added the current fedora patchkit which adds shred support + +------------------------------------------------------------------- Old: ---- logrotate-3.7.4.tar.bz2 New: ---- logrotate-3.7.5-cfengine.patch logrotate-3.7.5-date.patch logrotate-3.7.5-errorHandling.patch logrotate-3.7.5-logfn.patch logrotate-3.7.5-shred.patch logrotate-3.7.5.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ logrotate.spec ++++++ --- /var/tmp/diff_new_pack.i16228/_old 2007-08-16 18:19:05.000000000 +0200 +++ /var/tmp/diff_new_pack.i16228/_new 2007-08-16 18:19:05.000000000 +0200 @@ -1,7 +1,7 @@ # -# spec file for package logrotate (Version 3.7.4) +# spec file for package logrotate (Version 3.7.5) # -# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine # package are under the same license as the package itself. # @@ -13,25 +13,30 @@ Name: logrotate BuildRequires: popt-devel Summary: Rotate, Compress, Remove, and Mail System Log Files -Version: 3.7.4 -Release: 2 -License: GPL +Version: 3.7.5 +Release: 1 +License: GPL v2 or later Group: System/Base Source: ftp://people.redhat.com/sopwith/logrotate-%{version}.tar.bz2 Patch: logrotate-suse.dif Patch1: logrotate-conf.dif Patch2: logrotate-autoext.dif Patch3: logrotate-addextension.dif +Patch11: logrotate-3.7.5-errorHandling.patch +Patch12: logrotate-3.7.5-shred.patch +Patch13: logrotate-3.7.5-cfengine.patch +Patch14: logrotate-3.7.5-date.patch +Patch15: logrotate-3.7.5-logfn.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build PreReq: %fillup_prereq /bin/rm /bin/mv %description The logrotate utility is designed to simplify the administration of log files on a system that generates a lot of log files. Logrotate allows -for the automatic rotation, compression, removal, and mailing of log -files. Logrotate can be set to handle a log file daily, weekly, -monthly, or when the log file gets to a certain size. Normally, -logrotate runs as a daily cron job. +the automatic rotation, compression, removal, and mailing of log files. +Logrotate can be set to handle a log file daily, weekly, monthly, or +when the log file reaches a certain size. Normally, logrotate runs as a +daily cron job. @@ -47,6 +52,11 @@ %patch1 %patch2 %patch3 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 %build make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" @@ -79,13 +89,17 @@ %config /etc/logrotate.conf %config(noreplace)/etc/logrotate.d/wtmp -%changelog -n logrotate +%changelog +* Thu Aug 16 2007 - ro@suse.de +- update to 3.7.5 with some bugfixes containing: + - 251040 config option size not handled correctly +- added the current fedora patchkit which adds shred support * Mon Aug 07 2006 - ro@suse.de - try adding new option "addextension" which provides what some users expected the old "extension" keyword to do * Wed Jun 21 2006 - ro@suse.de - update to 3.7.4 -- adds the "minsize" option + - adds the "minsize" option - clean up comments in sample logrotate.conf (#183440) * Wed Jan 25 2006 - mls@suse.de - converted neededforbuild to BuildRequires ++++++ logrotate-3.7.5-cfengine.patch ++++++ --- logrotate-3.7.5/config.c.cfengine 2007-05-14 14:18:44.000000000 +0200 +++ logrotate-3.7.5/config.c 2007-05-14 14:19:06.000000000 +0200 @@ -31,7 +31,7 @@ #endif static char *defTabooExts[] = { ".rpmsave", ".rpmorig", "~", ",v", - ".rpmnew", ".swp" + ".rpmnew", ".swp", ".cfsaved" }; static int defTabooCount = sizeof(defTabooExts) / sizeof(char *); ++++++ logrotate-3.7.5-date.patch ++++++ --- logrotate-3.7.5/examples/logrotate-default.date 2007-05-16 16:36:06.000000000 +0200 +++ logrotate-3.7.5/examples/logrotate-default 2007-05-16 16:36:50.000000000 +0200 @@ -8,6 +8,9 @@ # create new (empty) log files after rotating old ones create +# use date as a suffix of rotated file +dateext + # uncomment this if you want your log files compressed #compress ++++++ logrotate-3.7.5-errorHandling.patch ++++++ --- logrotate-3.7.5/logrotate.c.errorHandling 2007-03-01 12:05:30.000000000 +0100 +++ logrotate-3.7.5/logrotate.c 2007-03-31 12:50:33.000000000 +0200 @@ -1043,6 +1043,8 @@ message(MESS_ERROR, "error running first action script " "for %s\n", log->pattern); hasErrors = 1; + /* finish early, firstaction failed, affects all logs in set */ + return hasErrors; } } } @@ -1067,16 +1069,25 @@ hasErrors |= logHasErrors[i]; } - if (log->pre) { + if (log->pre + && (! ( (logHasErrors[j] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS)) + || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) )) { if (!numRotated) { message(MESS_DEBUG, "not running prerotate script, " "since no logs will be rotated\n"); } else { message(MESS_DEBUG, "running prerotate script\n"); if (runScript(log->pattern, log->pre)) { - message(MESS_ERROR, - "error running shared prerotate script " - "for %s\n", log->pattern); + if (log->flags & LOG_FLAG_SHAREDSCRIPTS) + message(MESS_ERROR, + "error running shared prerotate script " + "for '%s'\n", log->pattern); + else { + message(MESS_ERROR, + "error running non-shared prerotate script " + "for %s of '%s'\n", log->files[j], log->pattern); + } + logHasErrors[j] = 1; hasErrors = 1; } } @@ -1085,22 +1096,33 @@ for (i = j; ((log->flags & LOG_FLAG_SHAREDSCRIPTS) && i < log->numFiles) || (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && i == j); i++) { - if (!logHasErrors[i]) { + if (! ( (logHasErrors[i] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS)) + || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) ) { logHasErrors[i] |= rotateSingleLog(log, i, state[i], rotNames[i]); hasErrors |= logHasErrors[i]; } } - if (log->post) { + if (log->post + && (! ( (logHasErrors[j] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS)) + || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) )) { if (!numRotated) { message(MESS_DEBUG, "not running postrotate script, " "since no logs were rotated\n"); } else { message(MESS_DEBUG, "running postrotate script\n"); if (runScript(log->pattern, log->post)) { - message(MESS_ERROR, "error running postrotate script " - "for %s\n", log->pattern); + if (log->flags & LOG_FLAG_SHAREDSCRIPTS) + message(MESS_ERROR, + "error running shared postrotate script " + "for '%s'\n", log->pattern); + else { + message(MESS_ERROR, + "error running non-shared postrotate script " + "for %s of '%s'\n", log->files[j], log->pattern); + } + logHasErrors[j] = 1; hasErrors = 1; } } @@ -1109,7 +1131,8 @@ for (i = j; ((log->flags & LOG_FLAG_SHAREDSCRIPTS) && i < log->numFiles) || (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && i == j); i++) { - if (!logHasErrors[i]) { + if (! ( (logHasErrors[i] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS)) + || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) ) { logHasErrors[i] |= postrotateSingleLog(log, i, state[i], rotNames[i]); hasErrors |= logHasErrors[i]; --- logrotate-3.7.5/logrotate.8.errorHandling 2006-05-17 16:46:51.000000000 +0200 +++ logrotate-3.7.5/logrotate.8 2007-03-31 12:37:06.000000000 +0200 @@ -326,7 +326,8 @@ \fBnosharedscripts\fR Run \fBprerotate\fR and \fBpostrotate\fR scripts for every log file which is rotated (this is the default, and overrides the \fBsharedscripts\fR -option). +option). If the scripts exit with error, the remaining actions will +not be executed for the affected log only. .TP \fBnotifempty\fR @@ -346,7 +347,8 @@ The lines between \fBpostrotate\fR and \fBendscript\fR (both of which must appear on lines by themselves) are executed after the log file is rotated. These directives may only appear inside of a log file definition. -See \fBprerotate\fR as well. +See \fBprerotate\fR as well. See \fBsharedscripts\fR and +\fBnosharedscripts\fR for error handling. .TP \fBprerotate\fR/\fBendscript\fR @@ -354,7 +356,8 @@ must appear on lines by themselves) are executed before the log file is rotated and only if the log will actually be rotated. These directives may only appear inside of a log file definition. See \fBpostrotate\fR -as well. +as well. See \fBsharedscripts\fR and \fBnosharedscripts\fR for error +handling. .TP \fBfirstaction\fR/\fBendscript\fR @@ -362,7 +365,8 @@ must appear on lines by themselves) are executed once before all log files that match the wildcarded pattern are rotated, before prerotate script is run and only if at least one log will actually be rotated. These directives -may only appear inside of a log file definition. See \fBlastaction\fR as well. +may only appear inside of a log file definition. If the script exits +with error, no further processing is done. See \fBlastaction\fR as well. .TP \fBlastaction\fR/\fBendscript\fR @@ -370,7 +374,9 @@ must appear on lines by themselves) are executed once after all log files that match the wildcarded pattern are rotated, after postrotate script is run and only if at least one log is rotated. These directives may only -appear inside of a log file definition. See \fBfirstaction\fR as well. +appear inside of a log file definition. If the script exits with +error, just an error message is shown (as this is the last +action). See \fBfirstaction\fR as well. .TP \fBrotate \fIcount\fR @@ -393,8 +399,10 @@ /var/log/news/* example). If \fBsharedscript\fR is specified, the scripts are only run once, no matter how many logs match the wildcarded pattern. However, if none of the logs in the pattern require rotating, the scripts -will not be run at all. This option overrides the \fBnosharedscripts\fR -option and implies \fBcreate\fR option. +will not be run at all. If the scripts exit with error, the remaining +actions will not be executed for any logs. This option overrides the +\fBnosharedscripts\fR option and implies \fBcreate\fR option. + .TP \fBstart \fIcount\fR ++++++ logrotate-3.7.5-logfn.patch ++++++ --- logrotate-3.7.5/logrotate.c.logfn 2007-05-30 14:52:21.000000000 +0200 +++ logrotate-3.7.5/logrotate.c 2007-05-30 14:53:08.000000000 +0200 @@ -151,7 +151,7 @@ } if (!fork()) { - execl("/bin/sh", "sh", "-c", script, NULL); + execl("/bin/sh", "sh", "-c", script, script, logfn, NULL); exit(1); } ++++++ logrotate-3.7.5-shred.patch ++++++ --- logrotate-3.7.5/logrotate.h.shred 2007-05-14 09:25:50.000000000 +0200 +++ logrotate-3.7.5/logrotate.h 2007-05-14 10:27:48.000000000 +0200 @@ -16,6 +16,7 @@ #define LOG_FLAG_SHAREDSCRIPTS (1 << 7) #define LOG_FLAG_COPY (1 << 8) #define LOG_FLAG_DATEEXT (1 << 9) +#define LOG_FLAG_SHRED (1 << 10) #define NO_MODE ((mode_t) -1) #define NO_UID ((uid_t) -1) @@ -44,6 +45,7 @@ char *uncompress_prog; char *compress_ext; int flags; + int shred_cycles; /* if !=0, pass -n shred_cycles to GNU shred */ mode_t createMode; /* if any/all of these are -1, we use the */ uid_t createUid; /* attributes from the log file just rotated */ gid_t createGid; --- logrotate-3.7.5/logrotate.c.shred 2007-05-14 09:25:30.000000000 +0200 +++ logrotate-3.7.5/logrotate.c 2007-05-14 10:35:41.000000000 +0200 @@ -53,6 +53,8 @@ char *mailCommand = DEFAULT_MAIL_COMMAND; time_t nowSecs = 0; +static int shred_file(char * filename, logInfo *log); + static int globerr(const char *pathname, int theerr) { message(MESS_ERROR, "error accessing %s: %s\n", pathname, @@ -188,11 +190,54 @@ return fd; } -static int removeLogFile(char *name) +#define SHRED_CALL "shred -u " +#define SHRED_COUNT_FLAG "-n " +#define DIGITS 10 +/* unlink, but try to call shred from GNU fileutils */ +static int shred_file(char * filename, logInfo *log) +{ + int len, ret; + char *cmd; + char count[DIGITS]; /* that's a lot of shredding :) */ + + if (!(log->flags & LOG_FLAG_SHRED)) { + return unlink(filename); + } + + len = strlen(filename) + strlen(SHRED_CALL); + len += strlen(SHRED_COUNT_FLAG) + DIGITS; + cmd = malloc(len); + + if (!cmd) { + message(MESS_ERROR, "malloc error while shredding"); + return unlink(filename); + } + strcpy(cmd, SHRED_CALL); + if (log->shred_cycles != 0) { + strcat(cmd, SHRED_COUNT_FLAG); + snprintf(count, DIGITS - 1, "%d", log->shred_cycles); + strcat(count, " "); + strcat(cmd, count); + } + strcat(cmd, filename); + ret = system(cmd); + free(cmd); + if (ret != 0) { + message(MESS_ERROR, "Failed to shred %s\n, trying unlink", filename); + if (ret != -1) { + message(MESS_NORMAL, "Shred returned %d\n", ret); + } + return unlink(filename); + } else { + return ret; + } +} + +static int removeLogFile(char *name, logInfo *log) { message(MESS_DEBUG, "removing old log %s\n", name); - if (!debug && unlink(name)) { + if (!debug && shred_file(name, log)) { message(MESS_ERROR, "Failed to remove old log %s: %s\n", name, strerror(errno)); return 1; @@ -255,7 +300,7 @@ return 1; } - unlink(name); + shred_file(name, log); return 0; } @@ -697,7 +742,7 @@ mailCommand, logNum, log); if (!hasErrors) - hasErrors = removeLogFile(mailFilename); + hasErrors = removeLogFile(mailFilename, log); } mail_out = i; } @@ -737,7 +782,7 @@ mailLogWrapper(mailFilename, mailCommand, logNum, log); if (!hasErrors) - hasErrors = removeLogFile(mailFilename); + hasErrors = removeLogFile(mailFilename, log); } } } @@ -954,7 +999,7 @@ } if (!hasErrors && rotNames->disposeName) - hasErrors = removeLogFile(rotNames->disposeName); + hasErrors = removeLogFile(rotNames->disposeName, log); #ifdef WITH_SELINUX if (selinux_enabled) { --- logrotate-3.7.5/logrotate.8.shred 2007-05-14 09:26:02.000000000 +0200 +++ logrotate-3.7.5/logrotate.8 2007-05-14 10:42:16.000000000 +0200 @@ -330,6 +330,10 @@ not be executed for the affected log only. .TP +\fBnoshred\fR +Do not use \fBshred\fR when deleting old log files. See also \fBshred\fR. + +.TP \fBnotifempty\fR Do not rotate the log if it is empty (this overrides the \fBifempty\fR option). @@ -403,6 +407,16 @@ actions will not be executed for any logs. This option overrides the \fBnosharedscripts\fR option and implies \fBcreate\fR option. +.TP +\fBshred\fR +Delete log files using \fBshred\fR -u instead of unlink(). This should +ensure that logs are not readable after their scheduled deletion; this is +off by default. See also \fBnoshred\fR. + +.TP +\fBshredcycles\fR \fIcount\fR +Asks GNU \fBshred\fR to overwite log files \fBcount\fR times before +deletion. Without this option, \fBshred\fR's default will be used. .TP \fBstart \fIcount\fR --- logrotate-3.7.5/config.c.shred 2007-05-14 09:26:42.000000000 +0200 +++ logrotate-3.7.5/config.c 2007-05-14 10:32:37.000000000 +0200 @@ -432,6 +432,7 @@ /* uncompress_prog */ NULL, /* compress_ext */ NULL, /* flags */ LOG_FLAG_IFEMPTY, + /* shred_cycles */ 0, /* createMode/Uid/Gid */ NO_MODE, NO_UID, NO_GID, /* compress_options_list/count */ NULL, 0 }; @@ -638,6 +639,14 @@ newlog->flags &= ~LOG_FLAG_DELAYCOMPRESS; *endtag = oldchar, start = endtag; + } else if (!strcmp(start, "shred")) { + newlog->flags |= LOG_FLAG_SHRED; + + *endtag = oldchar, start = endtag; + } else if (!strcmp(start, "noshred")) { + newlog->flags &= ~LOG_FLAG_SHRED; + + *endtag = oldchar, start = endtag; } else if (!strcmp(start, "sharedscripts")) { newlog->flags |= LOG_FLAG_SHAREDSCRIPTS; @@ -833,7 +842,22 @@ *endtag = oldchar, start = endtag; } #endif - } else if (!strcmp(start, "daily")) { + } else if (!strcmp(start, "shredcycles")) { + *endtag = oldchar, start = endtag; + + if (!isolateValue(configFile, lineNum, "shred cycles", + &start, &endtag)) { + oldchar = *endtag, *endtag = '\0'; + + newlog->shred_cycles = strtoul(start, &chptr, 0); + if (*chptr || newlog->shred_cycles < 0) { + message(MESS_ERROR, "%s:%d bad shred cycles '%s'\n", + configFile, lineNum, start); + return 1; + } + *endtag = oldchar, start = endtag; + } + } else if (!strcmp(start, "daily")) { *endtag = oldchar, start = endtag; newlog->criterium = ROT_DAYS; ++++++ logrotate-3.7.4.tar.bz2 -> logrotate-3.7.5.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/logrotate-3.7.4/config.c new/logrotate-3.7.5/config.c --- old/logrotate-3.7.4/config.c 2006-05-17 16:46:51.000000000 +0200 +++ new/logrotate-3.7.5/config.c 2007-03-01 12:05:30.000000000 +0100 @@ -14,6 +14,7 @@ #include <time.h> #include <unistd.h> #include <assert.h> +#include <wchar.h> #include "basenames.h" #include "log.h" @@ -82,13 +83,24 @@ char *start = *startPtr; char *path; + wchar_t pwc; + size_t len; + if (!isolateValue(configFile, lineNum, key, &start, &endtag)) { oldchar = *endtag, *endtag = '\0'; chptr = start; - /* this is technically too restrictive -- let's see if anyone - complains */ + while( (len = mbrtowc(&pwc, chptr, strlen(chptr), NULL)) != 0 ) { + if( len == (size_t)(-1) || len == (size_t)(-2) || !iswprint(pwc) || iswblank(pwc) ) { + message(MESS_ERROR, "%s:%d bad %s path %s\n", + configFile, lineNum, key, start); + return NULL; + } + chptr += len; + } + +/* while (*chptr && isprint(*chptr) && *chptr != ' ') chptr++; if (*chptr) { @@ -96,8 +108,11 @@ configFile, lineNum, key, start); return NULL; } +*/ + path = strdup(start); + *endtag = oldchar, start = endtag; *startPtr = start; @@ -151,7 +166,7 @@ for (i = 0; i < tabooCount; i++) { if (!strcmp(fname + strlen(fname) - strlen(tabooExts[i]), tabooExts[i])) { - message(MESS_ERROR, "Ignoring %s, because of %s " + message(MESS_DEBUG, "Ignoring %s, because of %s " "ending\n", fname, tabooExts[i]); return 0; @@ -177,12 +192,109 @@ free(array); } +static void copyLogInfo(logInfo * to, logInfo * from) +{ + int i; + + memset(to, 0, sizeof(*to)); + if (from->oldDir) + to->oldDir = strdup(from->oldDir); + to->criterium = from->criterium; + to->threshhold = from->threshhold; + to->minsize = from->minsize; + to->rotateCount = from->rotateCount; + to->rotateAge = from->rotateAge; + to->logStart = from->logStart; + if (from->pre) + to->pre = strdup(from->pre); + if (from->post) + to->post = strdup(from->post); + if (from->first) + to->first = strdup(from->first); + if (from->last) + to->last = strdup(from->last); + if (from->logAddress) + to->logAddress = strdup(from->logAddress); + if (from->extension) + to->extension = strdup(from->extension); + if (from->compress_prog) + to->compress_prog = strdup(from->compress_prog); + if (from->uncompress_prog) + to->uncompress_prog = strdup(from->uncompress_prog); + if (from->compress_ext) + to->compress_ext = strdup(from->compress_ext); + to->flags = from->flags; + to->createMode = from->createMode; + to->createUid = from->createUid; + to->createGid = from->createGid; + if (from->compress_options_count) { + poptDupArgv(from->compress_options_count, from->compress_options_list, + &to->compress_options_count, &to->compress_options_list); + } +} + +static void freeLogInfo(logInfo *log) +{ + if (log->pattern) + free(log->pattern); + if (log->files) + free_2d_array(log->files, log->numFiles); + if (log->oldDir) + free(log->oldDir); + if (log->pre) + free(log->pre); + if (log->post) + free(log->post); + if (log->first) + free(log->first); + if (log->last) + free(log->last); + if (log->logAddress) + free(log->logAddress); + if (log->extension) + free(log->extension); + if (log->compress_prog) + free(log->compress_prog); + if (log->uncompress_prog) + free(log->uncompress_prog); + if (log->compress_ext) + free(log->compress_ext); + if (log->compress_options_list) + free(log->compress_options_list); +} + +static void freeTailLogs(logInfo ** logsPtr, int *numLogsPtr, + int newNumLogs) +{ + int i; + + assert(newNumLogs <= *numLogsPtr); + + message(MESS_DEBUG, "removing last %d log configs\n", + *numLogsPtr - newNumLogs); + + if (newNumLogs == *numLogsPtr) + return; + + for (i = newNumLogs; i < *numLogsPtr; i++) + freeLogInfo(*logsPtr + i); + + if (newNumLogs == 0) { + free (*logsPtr); + *logsPtr = NULL; + } else { + *logsPtr = realloc(*logsPtr, sizeof(**logsPtr) * newNumLogs); + } + *numLogsPtr = newNumLogs; +} + static int readConfigPath(const char *path, logInfo * defConfig, logInfo ** logsPtr, int *numLogsPtr) { struct stat sb; - int here; + int here, oldnumlogs, result = 1; + logInfo defConfigBackup; if (stat(path, &sb)) { message(MESS_ERROR, "cannot stat %s: %s\n", path, strerror(errno)); @@ -264,30 +376,45 @@ for (i = 0; i < files_count; ++i) { assert(namelist[i] != NULL); - + oldnumlogs = *numLogsPtr; + copyLogInfo(&defConfigBackup, defConfig); if (readConfigFile(namelist[i], defConfig, logsPtr, - numLogsPtr)) { - fchdir(here); - close(here); - free_2d_array(namelist, files_count); - return 1; + numLogsPtr)) { + message(MESS_ERROR, "found error in file %s, skipping\n", namelist[i]); + freeTailLogs(logsPtr, numLogsPtr, oldnumlogs); + freeLogInfo(defConfig); + copyLogInfo(defConfig, &defConfigBackup); + freeLogInfo(&defConfigBackup); + continue; + } else { + result = 0; } + freeLogInfo(&defConfigBackup); } fchdir(here); close(here); free_2d_array(namelist, files_count); } else { - return readConfigFile(path, defConfig, logsPtr, numLogsPtr); + oldnumlogs = *numLogsPtr; + copyLogInfo(&defConfigBackup, defConfig); + if (readConfigFile(path, defConfig, logsPtr, numLogsPtr)) { + freeTailLogs(logsPtr, numLogsPtr, oldnumlogs); + freeLogInfo(defConfig); + copyLogInfo(defConfig, &defConfigBackup); + } else { + result = 0; + } + freeLogInfo(&defConfigBackup); } - return 0; + return result; } int readAllConfigPaths(const char **paths, logInfo ** logsPtr, int *numLogsPtr) { - int i; + int i, result = 0; const char **file; logInfo defConfig = { /* pattern */ NULL, /* files, numFiles */ NULL, 0, @@ -323,12 +450,13 @@ for (file = paths; *file; file++) { if (readConfigPath(*file, &defConfig, logsPtr, numLogsPtr)) { - free_2d_array(tabooExts, tabooCount); - return 1; + result = 1; + break; } } free_2d_array(tabooExts, tabooCount); - return 0; + freeLogInfo(&defConfig); + return result; } static int globerr(const char *pathname, int theerr) @@ -340,6 +468,12 @@ return 1; } +#define freeLogItem(what) \ + if (newlog->what) { \ + free(newlog->what); \ + newlog->what = NULL; \ + } + static int readConfigFile(const char *configFile, logInfo * defConfig, logInfo ** logsPtr, int *numLogsPtr) { @@ -364,6 +498,7 @@ glob_t globResult; const char **argv; int argc, argNum; + int logerror = 0; /* FIXME: createOwner and createGroup probably shouldn't be fixed length arrays -- of course, if we aren't run setuid it doesn't @@ -417,6 +552,28 @@ start = buf; while (*start) { + if (logerror) { + assert(newlog != defConfig); + + message(MESS_ERROR, "found error in %s, skipping\n", + newlog->pattern ? newlog->pattern : "log config"); + + while (*start != '}') { + if (*start == 0) { + message(MESS_ERROR, "%s:%d } expected \n", + configFile, lineNum); + return 1; + } else if (*start == '\n') { + lineNum++; + } + start++; + } + start++; + + freeTailLogs(logsPtr, numLogsPtr, (*numLogsPtr) - 1); + newlog = defConfig; + logerror = 0; + } while (isblank(*start) && (*start)) start++; if (*start == '#') { @@ -549,7 +706,13 @@ if (rc == 4) { message(MESS_ERROR, "%s:%d extra arguments for " "create\n", configFile, lineNum); - return 1; + if (newlog != defConfig) { + *endtag = oldchar, start = endtag; + logerror = 1; + continue; + } else { + return 1; + } } if (rc > 0) @@ -560,7 +723,13 @@ if (!pw) { message(MESS_ERROR, "%s:%d unknown user '%s'\n", configFile, lineNum, createOwner); - return 1; + if (newlog != defConfig) { + *endtag = oldchar, start = endtag; + logerror = 1; + continue; + } else { + return 1; + } } newlog->createUid = pw->pw_uid; endpwent(); @@ -570,7 +739,13 @@ if (!group) { message(MESS_ERROR, "%s:%d unknown group '%s'\n", configFile, lineNum, createGroup); - return 1; + if (newlog != defConfig) { + *endtag = oldchar, start = endtag; + logerror = 1; + continue; + } else { + return 1; + } } newlog->createGid = group->gr_gid; endgrent(); @@ -605,7 +780,13 @@ } else if (!isdigit(start[length])) { message(MESS_ERROR, "%s:%d unknown unit '%c'\n", configFile, lineNum, start[length]); - return 1; + if (newlog != defConfig) { + *endtag = oldchar, start = endtag; + logerror = 1; + continue; + } else { + return 1; + } } else { multiplier = 1; } @@ -614,10 +795,16 @@ if (*chptr) { message(MESS_ERROR, "%s:%d bad size '%s'\n", configFile, lineNum, start); - return 1; + if (newlog != defConfig) { + *endtag = oldchar, start = endtag; + logerror = 1; + continue; + } else { + return 1; + } } - if (!strcmp(opt, "size")) { + if (!strncmp(opt, "size", 4)) { newlog->criterium = ROT_SIZE; newlog->threshhold = size; } else @@ -676,7 +863,13 @@ message(MESS_ERROR, "%s:%d bad rotation count '%s'\n", configFile, lineNum, start); - return 1; + if (newlog != defConfig) { + *endtag = oldchar, start = endtag; + logerror = 1; + continue; + } else { + return 1; + } } *endtag = oldchar, start = endtag; } @@ -692,7 +885,13 @@ if (*chptr || newlog->logStart < 0) { message(MESS_ERROR, "%s:%d bad start count '%s'\n", configFile, lineNum, start); - return 1; + if (newlog != defConfig) { + *endtag = oldchar, start = endtag; + logerror = 1; + continue; + } else { + return 1; + } } *endtag = oldchar, start = endtag; } @@ -708,7 +907,13 @@ if (*chptr || newlog->rotateAge < 0) { message(MESS_ERROR, "%s:%d bad maximum age '%s'\n", configFile, lineNum, start); - return 1; + if (newlog != defConfig) { + *endtag = oldchar, start = endtag; + logerror = 1; + continue; + } else { + return 1; + } } *endtag = oldchar, start = endtag; } @@ -718,13 +923,18 @@ configFile, lineNum); } else if (!strcmp(start, "mail")) { *endtag = oldchar, start = endtag; + freeLogItem(logAddress); if (!(newlog->logAddress = readAddress(configFile, lineNum, "mail", &start))) { - return 1; + if (newlog != defConfig) { + logerror = 1; + continue; + } else { + return 1; + } } } else if (!strcmp(start, "nomail")) { - /* hmmm, we could lose memory here, but not much */ - newlog->logAddress = NULL; + freeLogItem(logAddress); *endtag = oldchar, start = endtag; } else if (!strcmp(start, "missingok")) { @@ -738,6 +948,8 @@ } else if (!strcmp(start, "prerotate")) { *endtag = oldchar, start = endtag; + freeLogItem (pre); + scriptStart = start; scriptDest = &newlog->pre; @@ -746,6 +958,8 @@ } else if (!strcmp(start, "firstaction")) { *endtag = oldchar, start = endtag; + freeLogItem (first); + scriptStart = start; scriptDest = &newlog->first; @@ -754,6 +968,8 @@ } else if (!strcmp(start, "postrotate")) { *endtag = oldchar, start = endtag; + freeLogItem (post); + scriptStart = start; scriptDest = &newlog->post; @@ -762,6 +978,8 @@ } else if (!strcmp(start, "lastaction")) { *endtag = oldchar, start = endtag; + freeLogItem (last); + scriptStart = start; scriptDest = &newlog->last; @@ -773,7 +991,9 @@ "%s:%d tabooext may not appear inside " "of log file definition\n", configFile, lineNum); - return 1; + *endtag = oldchar, start = endtag; + logerror = 1; + continue; } *endtag = oldchar, start = endtag; @@ -819,7 +1039,9 @@ "%s:%d include may not appear inside " "of log file definition\n", configFile, lineNum); - return 1; + *endtag = oldchar, start = endtag; + logerror = 1; + continue; } *endtag = oldchar, start = endtag; @@ -837,9 +1059,17 @@ } } else if (!strcmp(start, "olddir")) { *endtag = oldchar, start = endtag; + + freeLogItem (oldDir); + if (!(newlog->oldDir = readPath(configFile, lineNum, "olddir", &start))) { - return 1; + if (newlog != defConfig) { + logerror = 1; + continue; + } else { + return 1; + } } #if 0 if (stat(newlog->oldDir, &sb)) { @@ -868,6 +1098,7 @@ &endtag)) { oldchar = *endtag, *endtag = '\0'; + freeLogItem (extension); newlog->extension = strdup(start); *endtag = oldchar, start = endtag; @@ -878,18 +1109,30 @@ } else if (!strcmp(start, "compresscmd")) { *endtag = oldchar, start = endtag; + + freeLogItem (compress_prog); + if (! (newlog->compress_prog = readPath(configFile, lineNum, "compress", &start))) { - return 1; + if (newlog != defConfig) { + logerror = 1; + continue; + } else { + return 1; + } } if (access(newlog->compress_prog, X_OK)) { message(MESS_ERROR, "%s:%d compression program %s is not an executable file\n", configFile, lineNum, newlog->compress_prog); - free(newlog->compress_prog); - return 1; + if (newlog != defConfig) { + logerror = 1; + continue; + } else { + return 1; + } } message(MESS_DEBUG, "compress_prog is now %s\n", @@ -897,19 +1140,31 @@ } else if (!strcmp(start, "uncompresscmd")) { *endtag = oldchar, start = endtag; + + freeLogItem (uncompress_prog); + if (! (newlog->uncompress_prog = readPath(configFile, lineNum, "uncompress", &start))) { - return 1; + if (newlog != defConfig) { + logerror = 1; + continue; + } else { + return 1; + } } if (access(newlog->uncompress_prog, X_OK)) { message(MESS_ERROR, "%s:%d uncompression program %s is not an executable file\n", configFile, lineNum, newlog->uncompress_prog); - free(newlog->uncompress_prog); - return 1; + if (newlog != defConfig) { + logerror = 1; + continue; + } else { + return 1; + } } message(MESS_DEBUG, "uncompress_prog is now %s\n", @@ -918,12 +1173,23 @@ } else if (!strcmp(start, "compressoptions")) { char *options; + if (newlog->compress_options_list) { + free(newlog->compress_options_list); + newlog->compress_options_list = NULL; + newlog->compress_options_count = 0; + } + *endtag = oldchar, start = endtag; if (! (options = readPath(configFile, lineNum, "compressoptions", &start))) { - return 1; + if (newlog != defConfig) { + logerror = 1; + continue; + } else { + return 1; + } } if (poptParseArgvString(options, @@ -933,7 +1199,12 @@ "%s:%d invalid compression options\n", configFile, lineNum); free(options); - return 1; + if (newlog != defConfig) { + logerror = 1; + continue; + } else { + return 1; + } } message(MESS_DEBUG, "compress_options is now %s\n", @@ -941,11 +1212,19 @@ free(options); } else if (!strcmp(start, "compressext")) { *endtag = oldchar, start = endtag; + + freeLogItem (compress_ext); + if (! (newlog->compress_ext = readPath(configFile, lineNum, "compress-ext", &start))) { - return 1; + if (newlog != defConfig) { + logerror = 1; + continue; + } else { + return 1; + } } message(MESS_DEBUG, "compress_ext is now %s\n", @@ -973,7 +1252,8 @@ if (newlog != defConfig) { message(MESS_ERROR, "%s:%d unexpected log filename\n", configFile, lineNum); - return 1; + logerror = 1; + continue; } /* If no compression options were found in config file, @@ -989,7 +1269,7 @@ (*numLogsPtr)++; *logsPtr = realloc(*logsPtr, sizeof(**logsPtr) * *numLogsPtr); newlog = *logsPtr + *numLogsPtr - 1; - memcpy(newlog, defConfig, sizeof(*newlog)); + copyLogInfo(newlog, defConfig); endtag = start; while (*endtag != '{' && *endtag != '\0') @@ -1013,7 +1293,7 @@ newlog->files = NULL; newlog->numFiles = 0; - for (argNum = 0; argNum < argc; argNum++) { + for (argNum = 0; argNum < argc && logerror != 1; argNum++) { rc = glob(argv[argNum], GLOB_NOCHECK, globerr, &globResult); if (rc == GLOB_ABORTED) { @@ -1022,7 +1302,8 @@ message(MESS_ERROR, "%s:%d glob failed for %s\n", configFile, lineNum, argv[argNum]); - return 1; + logerror = 1; + break; } newlog->files = @@ -1045,8 +1326,8 @@ "%s:%d duplicate log entry for %s\n", configFile, lineNum, globResult.gl_pathv[i]); - globfree(&globResult); - return 1; + logerror = 1; + goto duperror; } } } @@ -1055,19 +1336,21 @@ strdup(globResult.gl_pathv[i]); newlog->numFiles++; } +duperror: globfree(&globResult); } newlog->pattern = strdup(start); - message(MESS_DEBUG, "reading config info for %s\n", start); + if (!logerror) + message(MESS_DEBUG, "reading config info for %s\n", start); free(argv); start = endtag + 1; } else if (*start == '}') { if (newlog == defConfig) { - message(MESS_ERROR, "%s:%d unxpected }\n", configFile, + message(MESS_ERROR, "%s:%d unexpected }\n", configFile, lineNum); return 1; } diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/logrotate-3.7.4/logrotate.c new/logrotate-3.7.5/logrotate.c --- old/logrotate-3.7.4/logrotate.c 2006-06-13 14:47:03.000000000 +0200 +++ new/logrotate-3.7.5/logrotate.c 2007-03-01 12:05:30.000000000 +0100 @@ -12,6 +12,7 @@ #include <time.h> #include <unistd.h> #include <glob.h> +#include <locale.h> #ifdef WITH_SELINUX #include <selinux/selinux.h> @@ -364,8 +365,8 @@ #ifdef WITH_SELINUX if (selinux_enabled) { security_context_t oldContext; - if (fgetfilecon(fdcurr, &oldContext) >= 0) { - if (getfscreatecon(&prev_context) < 0) { + if (fgetfilecon_raw(fdcurr, &oldContext) >= 0) { + if (getfscreatecon_raw(&prev_context) < 0) { message(MESS_ERROR, "getting default context: %s\n", strerror(errno)); @@ -374,7 +375,7 @@ return 1; } } - if (setfscreatecon(oldContext) < 0) { + if (setfscreatecon_raw(oldContext) < 0) { message(MESS_ERROR, "setting file context %s to %s: %s\n", saveLog, oldContext, strerror(errno)); @@ -399,7 +400,7 @@ createOutputFile(saveLog, O_WRONLY | O_CREAT | O_TRUNC, sb); #ifdef WITH_SELINUX if (selinux_enabled) { - setfscreatecon(prev_context); + setfscreatecon_raw(prev_context); if (prev_context != NULL) { freecon(prev_context); prev_context = NULL; @@ -755,8 +756,8 @@ #ifdef WITH_SELINUX if (selinux_enabled) { security_context_t oldContext = NULL; - if (getfilecon(log->files[logNum], &oldContext) > 0) { - if (getfscreatecon(&prev_context) < 0) { + if (getfilecon_raw(log->files[logNum], &oldContext) > 0) { + if (getfscreatecon_raw(&prev_context) < 0) { message(MESS_ERROR, "getting default context: %s\n", strerror(errno)); @@ -765,7 +766,7 @@ return 1; } } - if (setfscreatecon(oldContext) < 0) { + if (setfscreatecon_raw(oldContext) < 0) { message(MESS_ERROR, "setting file context %s to %s: %s\n", log->files[logNum], oldContext, @@ -911,6 +912,8 @@ &sb); if (fd < 0) hasErrors = 1; + else + close(fd); } } @@ -955,7 +958,7 @@ #ifdef WITH_SELINUX if (selinux_enabled) { - setfscreatecon(prev_context); + setfscreatecon_raw(prev_context); if (prev_context != NULL) { freecon(prev_context); prev_context = NULL; @@ -1342,6 +1345,7 @@ }; logSetLevel(MESS_NORMAL); + setlocale (LC_ALL, ""); optCon = poptGetContext("logrotate", argc, argv, options, 0); poptReadDefaultConfig(optCon, 1); diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/logrotate-3.7.4/logrotate.spec new/logrotate-3.7.5/logrotate.spec --- old/logrotate-3.7.4/logrotate.spec 2006-06-13 14:47:03.000000000 +0200 +++ new/logrotate-3.7.5/logrotate.spec 2007-03-01 12:05:30.000000000 +0100 @@ -1,15 +1,19 @@ -%if %{?WITH_SELINUX:0}%{!?WITH_SELINUX:1} -%define WITH_SELINUX 1 -BuildRequires: libselinux-devel -%endif -Summary: Rotates, compresses, removes and mails system log files. +Summary: Rotates, compresses, removes and mails system log files Name: logrotate -Version: 3.7.4 -Release: 3 +Version: 3.7.5 +Release: 1 License: GPL Group: System Environment/Base -Source: logrotate-%{PACKAGE_VERSION}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}.root +# The source for this package was pulled from cvs. +# Use the following commands to generate the tarball: +# export CVSROOT=:pserver:anonymous@rhlinux.redhat.com:/usr/local/CVS +# cvs login (hit return) +# cvs co logrotate +# cd logrotate +# make create-archive +Source: logrotate-%{version}.tar.gz +BuildRequires: libselinux-devel +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description The logrotate utility is designed to simplify the administration of @@ -23,39 +27,75 @@ log files on your system. %prep -%setup +%setup -q %build -make RPM_OPT_FLAGS="$RPM_OPT_FLAGS -g" \ -%if %{WITH_SELINUX} - WITH_SELINUX=yes -%endif +make %{?_smp_mflags} RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes %install rm -rf $RPM_BUILD_ROOT make PREFIX=$RPM_BUILD_ROOT MANDIR=%{_mandir} install -mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d -mkdir -p $RPM_BUILD_ROOT/etc/cron.daily -mkdir -p $RPM_BUILD_ROOT/var/lib - -install -m 644 examples/logrotate-default $RPM_BUILD_ROOT/etc/logrotate.conf -install -m 755 examples/logrotate.cron $RPM_BUILD_ROOT/etc/cron.daily/logrotate -touch $RPM_BUILD_ROOT/var/lib/logrotate.status +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d +mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily +mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib + +install -p -m 644 examples/logrotate-default $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.conf +install -p -m 755 examples/logrotate.cron $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily/logrotate +touch $RPM_BUILD_ROOT/%{_localstatedir}/lib/logrotate.status %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) -%doc CHANGES -%attr(0755, root, root) /usr/sbin/logrotate +%doc CHANGES COPYING +%attr(0755, root, root) %{_sbindir}/logrotate %attr(0644, root, root) %{_mandir}/man8/logrotate.8* -%attr(0755, root, root) /etc/cron.daily/logrotate -%attr(0644, root, root) %config(noreplace) /etc/logrotate.conf -%attr(0755, root, root) %dir /etc/logrotate.d -%attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) /var/lib/logrotate.status +%attr(0755, root, root) %{_sysconfdir}/cron.daily/logrotate +%attr(0644, root, root) %config(noreplace) %{_sysconfdir}/logrotate.conf +%attr(0755, root, root) %dir %{_sysconfdir}/logrotate.d +%attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status %changelog +* Thu Mar 01 2007 Peter Vrabec <pvrabec@redhat.com> 3.7.5-1 +- new upstream release. + +* Fri Feb 09 2007 Peter Vrabec <pvrabec@redhat.com> 3.7.4-13 +- another spec file fixes (#226104) + +* Thu Feb 08 2007 Peter Vrabec <pvrabec@redhat.com> 3.7.4-12 +- fix problem with compress_options_list (#227706) +- fix spec file to meet Fedora standards (#226104) + +* Tue Jan 23 2007 Peter Vrabec <pvrabec@redhat.com> 3.7.4-11 +- logrotate won't stop if there are some errors in configuration + or glob failures (#166510, #182062) + +* Wed Jan 10 2007 Peter Vrabec <pvrabec@redhat.com> 3.7.4-10 +- fix some rpmlint issues + +* Tue Jan 09 2007 Peter Vrabec <pvrabec@redhat.com> 3.7.4-9 +- allow multibyte characters in readPath() (#122145) + +* Fri Jan 05 2007 Peter Vrabec <pvrabec@redhat.com> 3.7.4-8 +- "size" option was ignored in config files (#221341) + +* Sun Oct 01 2006 Jesse Keating <jkeating@redhat.com> - 3.7.4-7 +- rebuilt for unwind info generation, broken in gcc-4.1.1-21 + +* Tue Sep 26 2006 Peter Vrabec <pvrabec@redhat.com> 3.7.4-6 +- fix leaking file descriptor (#205072) + +* Wed Aug 09 2006 Dan Walsh <dwalsh@redhat.com> 3.7.4-5 +- Use selinux raw functions + +* Mon Jul 24 2006 Peter Vrabec <pvrabec@redhat.com> 3.7.4-4 +- make error message, about ignoring certain config files, + a debug message instead (#196052) + +* Wed Jul 12 2006 Jesse Keating <jkeating@redhat.com> - 3.7.4-3.1 +- rebuild + * Tue Jun 13 2006 Peter Vrabec <pvrabec@redhat.com> 3.7.4-3 - rename ENOSUP to ENOTSUP @@ -63,11 +103,20 @@ - clean up a couple of SELinux problems. Patch from Daniel J. Walsh. * Wed May 17 2006 Peter Vrabec <pvrabec@redhat.com> 3.7.4-1 -- add new "minsize" option +- add new "minsize" option (#173088) -* Tue Mar 28 2005 Peter Vrabec <pvrabec@redhat.com> 3.7.3-3 +* Tue Mar 28 2006 Peter Vrabec <pvrabec@redhat.com> 3.7.3-3 - correct man page "extension" option description (#185318) +* Fri Feb 10 2006 Jesse Keating <jkeating@redhat.com> - 3.7.3-2.2.1 +- bump again for double-long bug on ppc(64) + +* Tue Feb 07 2006 Jesse Keating <jkeating@redhat.com> - 3.7.3-2.2 +- rebuilt for new gcc4.1 snapshot and glibc changes + +* Fri Dec 09 2005 Jesse Keating <jkeating@redhat.com> +- rebuilt + * Sun Nov 13 2005 Peter Vrabec <pvrabec@redhat.com> 3.7.3-2 - fix_free_segfaults (#172918) @@ -208,7 +257,7 @@ - Apply various bugfix patches from the openwall people * Tue Jan 29 2002 Elliot Lee <sopwith@redhat.com> 3.6.2-1 -- Fix bug #55809 (include logrotate.status in %files) +- Fix bug #55809 (include logrotate.status in "files") - Fix bug #58328 (incorrect error detection when reading state file) - Allow 'G' size specifier from bug #57242 diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/logrotate-3.7.4/Makefile new/logrotate-3.7.5/Makefile --- old/logrotate-3.7.4/Makefile 2003-10-09 22:05:07.000000000 +0200 +++ new/logrotate-3.7.5/Makefile 2007-03-01 12:05:30.000000000 +0100 @@ -114,7 +114,7 @@ cvstag: cvs tag -cF $(CVSTAG) . -archive: cvstag +create-archive: @rm -rf /tmp/logrotate-$(VERSION) /tmp/logrotate @cd /tmp; cvs -d $(CVSROOT) export -r$(CVSTAG) logrotate; mv logrotate logrotate-$(VERSION) @cd /tmp/logrotate-$(VERSION) @@ -125,6 +125,8 @@ @echo " " @echo "The final archive is ./logrotate-$(VERSION).tar.gz." +archive: clean cvstag create-archive + ifeq (.depend,$(wildcard .depend)) include .depend endif ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org