...
 
Commits (2)
Index: logrotate-3.7.9/config.c
===================================================================
--- logrotate-3.7.9.orig/config.c 2011-06-22 15:40:42.727459027 +0100
+++ logrotate-3.7.9/config.c 2011-06-22 15:50:46.047374110 +0100
@@ -165,7 +165,7 @@
static int checkFile(const char *fname)
{
int i;
- char pattern[PATH_MAX];
+ char *pattern;
/* Check if fname is '.' or '..'; if so, return false */
if (fname[0] == '.' && (!fname[1] || (fname[1] == '.' && !fname[2])))
@@ -173,15 +173,17 @@
/* Check if fname is ending in a taboo-extension; if so, return false */
for (i = 0; i < tabooCount; i++) {
- snprintf(pattern, sizeof(pattern), "*%s", tabooExts[i]);
+ asprintf(&pattern, "*%s", tabooExts[i]);
if (!fnmatch(pattern, fname, 0))
{
message(MESS_DEBUG, "Ignoring %s, because of %s ending\n",
fname, tabooExts[i]);
+ free(pattern);
return 0;
}
}
+ free(pattern);
/* All checks have been passed; return true */
return 1;
}
Index: logrotate.git/logrotate.c
===================================================================
--- logrotate.git.orig/logrotate.c 2016-12-29 02:36:21.851158797 +0100
+++ logrotate.git/logrotate.c 2016-12-29 02:36:21.848158800 +0100
@@ -496,8 +496,12 @@
if (fchmod(fd, (S_IRUSR | S_IWUSR) & sb->st_mode)) {
message(MESS_ERROR, "error setting mode of %s: %s\n",
fileName, strerror(errno));
- close(fd);
- return -1;
+ if (geteuid() == 0) {
+ /* If run as non-root, we may not be able to duplicate
+ the ownership of the file. Warn but don't fail. */
+ close(fd);
+ return -1;
+ }
}
if (fstat(fd, &sb_create)) {
# Loosens the config syntax checking to allow more flexibility.
# (Closes: #95617,#95630)
Index: logrotate-3.8.3/config.c
===================================================================
--- logrotate-3.8.3.orig/config.c 2012-10-15 14:18:29.117724327 +0100
+++ logrotate-3.8.3/config.c 2012-10-15 14:18:32.089780981 +0100
@@ -1110,7 +1110,7 @@
while (*endtag) {
chptr = endtag;
- while (!isspace(*chptr) && *chptr != ',' && *chptr)
+ while (!isspace(*chptr) && /* *chptr != ',' && */ *chptr)
chptr++;
tabooExts = realloc(tabooExts, sizeof(*tabooExts) *
@@ -1122,8 +1122,10 @@
tabooCount++;
endtag = chptr;
+ /*
if (*endtag == ',')
- start++;
+ endtag++;
+ */
while (isspace(*endtag) && *endtag)
endtag++;
}
Closes: #284040
Patch from: NIIBE Yutaka <gniibe@fsij.org>
Cross-building logrotate with dpkg-cross, I encountered a problem.
dpkg-cross sets CPP variable, and compilation failures, because
the executable 'cpp' does not accept multiple input files.
Index: logrotate.git/Makefile.legacy
===================================================================
--- logrotate.git.orig/Makefile.legacy 2016-12-29 02:36:21.631158971 +0100
+++ logrotate.git/Makefile.legacy 2016-12-29 02:36:21.628158973 +0100
@@ -130,7 +130,7 @@
rm -f ./test/test.ACL ./test/test.SELINUX ./test/error.log
depend:
- $(CPP) $(CFLAGS) -M $(SOURCES) > .depend
+ $(CC) -E $(CFLAGS) -M $(SOURCES) > .depend
# pretest create the file ./test/test.ACL with
# 0 or 1 according to the WITH_ACL=yes presence.
Close #388608.
In the extremely unlikely event that a log file to be rotated is going
to be created group readable or writable, and the current group of the
to-be-truncated logfile or the current user's group (for creation of the
new logfile) is not the intended one, guard against the logfile being
briefly readable or writable by the current user's group, or the group
the logfile already had (and probably will have after the operation).
Thanks to Florian Zumbiehl <florz@gmx.de> for being zealously persistent.
Index: logrotate-3.7.9/logrotate.c
===================================================================
--- logrotate-3.7.9.orig/logrotate.c 2011-06-22 15:15:29.087530649 +0100
+++ logrotate-3.7.9/logrotate.c 2011-06-22 15:15:37.963764798 +0100
@@ -233,7 +233,7 @@
{
int fd;
- fd = open(fileName, flags, sb->st_mode);
+ fd = open(fileName, flags, (S_IRUSR | S_IWUSR) & sb->st_mode);
if (fd < 0) {
message(MESS_ERROR, "error creating output file %s: %s\n",
fileName, strerror(errno));
Fix locations of STATEFILE and DEFAULT_MAIL_COMMAND for Debian.
--- a/config.h
+++ b/config.h
@@ -32,7 +32,7 @@
* Default settings (mainly for Linux) - leave these last.
*/
#ifndef DEFAULT_MAIL_COMMAND
-#define DEFAULT_MAIL_COMMAND "/bin/mail"
+#define DEFAULT_MAIL_COMMAND "/usr/bin/mail"
#endif
#ifndef COMPRESS_COMMAND
--- a/configure.ac
+++ b/configure.ac
@@ -48,7 +48,7 @@
AC_ARG_WITH([state-file-path],
AC_HELP_STRING([--with-state-file-path=PATH],
- [path to state file (/var/lib/logrotate.status by default)]),
+ [path to state file (/var/lib/logrotate/status by default)]),
[
case "$withval" in
yes|no)
@@ -60,7 +60,7 @@
esac
],
[
- STATE_FILE_PATH="/var/lib/logrotate.status"
+ STATE_FILE_PATH="/var/lib/logrotate/status"
])
AC_DEFINE_UNQUOTED([STATEFILE], "$STATE_FILE_PATH")
AC_SUBST(STATE_FILE_PATH)
--- a/logrotate.8.in
+++ b/logrotate.8.in
@@ -65,7 +65,7 @@
\fB\-s\fR, \fB\-\-state <statefile>\fR
Tells \fBlogrotate\fR to use an alternate state file. This is useful
if logrotate is being run as a different user for various sets of
-log files. The default state file is \fI/var/lib/logrotate.status\fR.
+log files. The default state file is \fI/var/lib/logrotate/status\fR.
.TP
\fB\-\-usage\fR
Subject: Fix broken test suite runner
Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Forwarded: No
That line appearently got lost between 3.8.7 and 3.11.0 but is
required to make the tests run.
--- a/test/test
+++ b/test/test
@@ -3,6 +3,7 @@
ACL_TESTS=1
SELINUX_TESTS=0
SYSLOG_TESTS=0
+LOGROTATE=../logrotate
M="-m ./mailer"
S="-s state"
RLR="$LOGROTATE $M $S"
Subject: Make expect value in test 62 depend on page size
Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Bug:
https://buildd.debian.org/status/fetch.php?pkg=logrotate&arch=powerpc&ver=3.11.0-0.1~exp2&stamp=1483609625
https://buildd.debian.org/status/fetch.php?pkg=logrotate&arch=ppc64el&ver=3.11.0-0.1~exp2&stamp=1483609707
The Debian buildds, at least those running ppc64el (they also build
for powerpc) put the source tree into a tmpfs. A tmpfs allocates
memory per page, and with an unusually huge page size of 64Ki, the
two pages needed for a sparse file with some content as created in
test 62, 128Ki are actually allocated - which is more than the limit
of 100 in the test.
So get the actual pagesize and raise the limits if it's 32Ki or
more. The second limit is wild-guessed, in the failing test the
value was 10304 (= 131 pages).
On a 4Ki-page system (amd64), the observed values were 8 (= two
pages), and 12 (= three pages).
Reproducer:
printf zero > test.log ; truncate -s 10M test.log ; echo x >> test.log ; du test.log
--- a/test/test
+++ b/test/test
@@ -1597,7 +1597,15 @@
exit 3
fi
-if [ $SIZE_SPARSE_OLD -gt 100 ] || [ $SIZE_SPARSE_NEW -gt 100 ]; then
+PAGESIZE="$(getconf PAGESIZE)"
+if [ -z "$PAGESIZE" ] || [ "$PAGESIZE" -lt 32768 ] ; then
+ LIMIT1=100
+ LIMIT2=100
+else
+ LIMIT1=200
+ LIMIT2=20000
+fi
+if [ $SIZE_SPARSE_OLD -gt $LIMIT1 ] || [ $SIZE_SPARSE_NEW -gt $LIMIT2 ]; then
echo "Bad size of sparse logs"
echo "test.log: $SIZE_SPARSE_OLD"
echo "test.log.1: $SIZE_SPARSE_NEW"
Fix location of killall in the examples. (Closes: #189243)
--- /home/pm/deb/logrotate/logrotate-3.7/logrotate.8 2004-02-11 21:18:23.000000000 +0000
+++ logrotate-3.7/logrotate.8 2004-02-11 21:18:54.000000000 +0000
@@ -83,7 +83,7 @@
rotate 5
weekly
postrotate
- /sbin/killall -HUP syslogd
+ /usr/bin/killall -HUP syslogd
endscript
}
@@ -93,7 +93,7 @@
size=100k
sharedscripts
postrotate
- /sbin/killall -HUP httpd
+ /usr/bin/killall -HUP httpd
endscript
}
Index: logrotate-3.7.8/logrotate.8
===================================================================
--- logrotate-3.7.8.orig/logrotate.8 2010-05-03 12:25:04.013761517 +0200
+++ logrotate-3.7.8/logrotate.8 2010-05-03 13:38:33.861513873 +0200
@@ -222,6 +222,11 @@
The default value is -%Y%m%d. Note that also the character separating log
name from the extension is part of the dateformat string. The system clock
must be set past Sep 9th 2001 for %s to work correctly.
+Note that the datestamps generated by this format must be lexically sortable
+(i.e., first the year, then the month then the day. e.g., 2001/12/01 is ok,
+but 01/12/2001 is not, since 01/11/2002 would sort lower while it is later).
+This is because when using the \fBrotate\fR option, logrotate sorts all
+rotated filenames to find out which logfiles are older and should be removed.
.TP
\fBdelaycompress\fR
Fix manpage typo (Closes: #310337)
Index: logrotate-3.7.7/logrotate.8
===================================================================
--- logrotate-3.7.7.orig/logrotate.8 2008-11-07 01:32:45.079556409 +0000
+++ logrotate-3.7.7/logrotate.8 2008-11-07 01:33:47.551555931 +0000
@@ -358,7 +358,7 @@
and is assumed to be relative to the directory holding the log file
unless an absolute path name is specified. When this option is used all
old versions of the log end up in \fIdirectory\fR. This option may be
-overriden by the \fBnoolddir\fR option.
+overridden by the \fBnoolddir\fR option.
.TP
\fBpostrotate\fR/\fBendscript\fR
Fix manpage typo in the size example.
--- /home/pm/deb/logrotate/logrotate-3.7/logrotate.8 2004-09-13 22:50:08.000000000 +0100
+++ logrotate-3.7/logrotate.8 2004-09-13 22:50:25.000000000 +0100
@@ -90,7 +90,7 @@
"/var/log/httpd/access.log" /var/log/httpd/error.log {
rotate 5
mail www@my.org
- size=100k
+ size 100k
sharedscripts
postrotate
/usr/bin/killall -HUP httpd
Index: logrotate-3.7.9/logrotate.c
===================================================================
--- logrotate-3.7.9.orig/logrotate.c 2011-06-22 15:15:37.000000000 +0100
+++ logrotate-3.7.9/logrotate.c 2011-06-22 15:20:33.987573622 +0100
@@ -343,7 +343,7 @@
compressedName = alloca(strlen(name) + strlen(log->compress_ext) + 2);
sprintf(compressedName, "%s%s", name, log->compress_ext);
- if ((inFile = open(name, O_RDONLY)) < 0) {
+ if ((inFile = open(name, O_RDONLY | O_NOFOLLOW)) < 0) {
message(MESS_ERROR, "unable to open %s for compression\n", name);
return 1;
}
@@ -396,7 +396,7 @@
char *mailArgv[] = { mailCommand, "-s", subject, address, NULL };
int rc = 0;
- if ((mailInput = open(logFile, O_RDONLY)) < 0) {
+ if ((mailInput = open(logFile, O_RDONLY | O_NOFOLLOW)) < 0) {
message(MESS_ERROR, "failed to open %s for mailing: %s\n", logFile,
strerror(errno));
return 1;
@@ -487,7 +487,7 @@
message(MESS_DEBUG, "copying %s to %s\n", currLog, saveLog);
if (!debug) {
- if ((fdcurr = open(currLog, (flags & LOG_FLAG_COPY) ? O_RDONLY : O_RDWR)) < 0) {
+ if ((fdcurr = open(currLog, ((flags & LOG_FLAG_COPY) ? O_RDONLY : O_RDWR) | O_NOFOLLOW)) < 0) {
message(MESS_ERROR, "error opening %s: %s\n", currLog,
strerror(errno));
return 1;
@@ -1074,7 +1074,7 @@
security_context_t oldContext = NULL;
int fdcurr = -1;
- if ((fdcurr = open(log->files[logNum], O_RDWR)) < 0) {
+ if ((fdcurr = open(log->files[logNum], O_RDWR | O_NOFOLLOW)) < 0) {
message(MESS_ERROR, "error opening %s: %s\n",
log->files[logNum],
strerror(errno));
Index: logrotate-3.7.9/logrotate.c
===================================================================
--- logrotate-3.7.9.orig/logrotate.c 2011-06-22 15:20:33.987573622 +0100
+++ logrotate-3.7.9/logrotate.c 2011-06-22 15:20:41.311766830 +0100
@@ -233,7 +233,14 @@
{
int fd;
- fd = open(fileName, flags, (S_IRUSR | S_IWUSR) & sb->st_mode);
+ /*
+ * Protect against malicious linking or symlinking.
+ * This function only ever creates new files.
+ */
+ unlink(fileName);
+
+ fd = open(fileName, (flags | O_EXCL | O_NOFOLLOW),
+ (S_IRUSR | S_IWUSR) & sb->st_mode);
if (fd < 0) {
message(MESS_ERROR, "error creating output file %s: %s\n",
fileName, strerror(errno));
@@ -349,7 +356,7 @@
}
outFile =
- createOutputFile(compressedName, O_RDWR | O_CREAT | O_TRUNC, sb);
+ createOutputFile(compressedName, O_RDWR | O_CREAT, sb);
if (outFile < 0) {
close(inFile);
return 1;
@@ -528,7 +535,7 @@
}
#endif
fdsave =
- createOutputFile(saveLog, O_WRONLY | O_CREAT | O_TRUNC, sb);
+ createOutputFile(saveLog, O_WRONLY | O_CREAT, sb);
#ifdef WITH_SELINUX
if (selinux_enabled) {
setfscreatecon_raw(prev_context);
Index: logrotate-3.8.3/logrotate.c
===================================================================
--- logrotate-3.8.3.orig/logrotate.c 2013-04-24 12:29:24.009997692 +0100
+++ logrotate-3.8.3/logrotate.c 2013-04-24 13:53:14.562163828 +0100
@@ -295,6 +295,42 @@
return rc;
}
+static int runScriptMultiple(char *logfn, char *script, struct logNames **rotNames, int numFiles)
+{
+ int rc,i;
+ char **argv;
+
+ if (debug) {
+ message(MESS_DEBUG, "running script (multiple) with arg %s: \"%s\"\n",
+ logfn, script);
+ return 0;
+ }
+
+ argv = calloc(numFiles+5,sizeof(char*));
+ if (NULL == argv) {
+ message(MESS_ERROR,"error allocating memory to runScriptMultiple\n");
+ return -1;
+ }
+
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = script;
+ argv[3] = "logrotate_script";
+
+ for (i = 0; i<numFiles; i++) {
+ argv[i+4] = rotNames[i]->finalName;
+ }
+ argv[i+4] = NULL;
+
+ if (!fork()) {
+ execv("/bin/sh",argv);
+ exit(1);
+ }
+
+ wait(&rc);
+ return rc;
+}
+
int createOutputFile(char *fileName, int flags, struct stat *sb, acl_type acl, int force_mode)
{
int fd;
@@ -1604,18 +1640,22 @@
"since no logs will be rotated\n");
} else {
message(MESS_DEBUG, "running prerotate script\n");
- if (runScript(log, log->flags & LOG_FLAG_SHAREDSCRIPTS ? log->pattern : log->files[j], log->pre)) {
- if (log->flags & LOG_FLAG_SHAREDSCRIPTS)
+ if (log->flags & LOG_FLAG_SHAREDSCRIPTS) {
+ if (runScriptMultiple(log->pattern, log->pre, rotNames, log->numFiles)) {
message(MESS_ERROR,
"error running shared prerotate script "
"for '%s'\n", log->pattern);
- else {
+ logHasErrors[j] = 1;
+ hasErrors = 1;
+ }
+ } else {
+ if (runScript(log, log->files[j], log->pre)) {
message(MESS_ERROR,
"error running non-shared prerotate script "
"for %s of '%s'\n", log->files[j], log->pattern);
+ logHasErrors[j] = 1;
+ hasErrors = 1;
}
- logHasErrors[j] = 1;
- hasErrors = 1;
}
}
}
@@ -1639,18 +1679,22 @@
"since no logs were rotated\n");
} else {
message(MESS_DEBUG, "running postrotate script\n");
- if (runScript(log, log->flags & LOG_FLAG_SHAREDSCRIPTS ? log->pattern : log->files[j], log->post)) {
- if (log->flags & LOG_FLAG_SHAREDSCRIPTS)
+ if (log->flags & LOG_FLAG_SHAREDSCRIPTS) {
+ if (runScriptMultiple(log->pattern, log->post, rotNames, log->numFiles)) {
message(MESS_ERROR,
"error running shared postrotate script "
"for '%s'\n", log->pattern);
- else {
+ logHasErrors[j] = 1;
+ hasErrors = 1;
+ }
+ } else {
+ if (runScript(log, log->files[j], log->post)) {
message(MESS_ERROR,
"error running non-shared postrotate script "
"for %s of '%s'\n", log->files[j], log->pattern);
+ logHasErrors[j] = 1;
+ hasErrors = 1;
}
- logHasErrors[j] = 1;
- hasErrors = 1;
}
}
}
Index: logrotate.git/config.c
===================================================================
--- logrotate.git.orig/config.c 2016-12-29 02:36:22.065158629 +0100
+++ logrotate.git/config.c 2016-12-29 02:36:22.060158633 +0100
@@ -128,6 +128,7 @@
static char *defTabooExts[] = { ".rpmsave", ".rpmorig", "~", ",v",
".disabled", ".dpkg-old", ".dpkg-dist", ".dpkg-new", ".cfsaved",
".ucf-old", ".ucf-dist", ".ucf-new",
+ ".dpkg-bak", ".dpkg-del",
".rpmnew", ".swp", ".cfsaved", ".rhn-cfg-tmp-*"
};
static int defTabooCount = sizeof(defTabooExts) / sizeof(char *);
Index: logrotate.git/logrotate.8
===================================================================
--- logrotate.git.orig/logrotate.8 2016-12-29 02:36:22.065158629 +0100
+++ logrotate.git/logrotate.8 2016-12-29 02:36:22.061158632 +0100
@@ -559,7 +559,7 @@
for information on the taboo extensions). If a + precedes the list of
extensions, the current taboo extension list is augmented, otherwise it
is replaced. At startup, the taboo extension list
-contains .rpmsave, .rpmorig, ~, .disabled, .dpkg\-old, .dpkg\-dist, .dpkg\-new, .cfsaved, .ucf\-old, .ucf\-dist, .ucf\-new, .rpmnew, .swp, .cfsaved, .rhn\-cfg\-tmp\-*
+contains .rpmsave, .rpmorig, ~, .disabled, .dpkg\-old, .dpkg\-dist, .dpkg\-new, .dpkg-bak, .dpkg-del, .cfsaved, .ucf\-old, .ucf\-dist, .ucf\-new, .rpmnew, .swp, .cfsaved, .rhn\-cfg\-tmp\-*
.TP
\fBtaboopat\fR [+] \fIlist\fR
Index: logrotate-3.7.7/logrotate.c
===================================================================
--- logrotate-3.7.7.orig/logrotate.c 2008-12-17 13:03:40.451635277 +0000
+++ logrotate-3.7.7/logrotate.c 2008-12-17 13:03:41.355635555 +0000
@@ -289,7 +289,7 @@
char *uncompressCommand, char *address, char *subject)
{
int mailInput;
- pid_t mailChild, uncompressChild;
+ pid_t mailChild, uncompressChild=-1;
int mailStatus, uncompressStatus;
int uncompressPipe[2];
char *mailArgv[] = { mailCommand, "-s", subject, address, NULL };
# lintian doesn't seem to know about kfreebsd-amd64 yet.
logrotate source: invalid-arch-string-in-source-relation kfreebsd-amd64 [build-depends: libselinux1-dev [!hurd-i386 !kfreebsd-i386 !kfreebsd-amd64]]
Name: logrotate
Repository: https://github.com/logrotate/logrotate/
Repository-Browse: https://github.com/logrotate/logrotate/
Contact: https://github.com/logrotate/logrotate/issues