Commit f8f1380f authored by Tobias Frost's avatar Tobias Frost

Import Upstream version 3.7.9

parent 5895930e
3.7.8 -> 3.7.9
- fix building on Solaris (patch by András Szilárd)
- don't copy config files on the stack -- mmap them instead
(fixes segfaults with too large/invalid config files)
- symlinked conf file man page as requested by Fedora guidelines
(thanks to Ivana Hutarova Varekova)
- cron script logrotate.cron redirects output to /dev/null
- added rotating (copying) non-writable, readable files
(patch by Henrique Martins)
- fixed missingok problem with globs
(taken from the Debian patches by Ted Percival
<ted@midg3t.net>)
- fixed bug when log files could be removed even there was
some error in rotation process.
- allow setting size greater than 4.2GB in configuration file
- pass currently rotated file to postrotate/prerotate script
in nosharedscripts mode
- added new TabooExts: ".disabled", ".dpkg-old", ".dpkg-dist",
".dpkg-new", ".cfsaved", ".ucf-old", ".ucf-dist", ".ucf-new"
(taken from the Debian patches by Paul Martin <pm@debian.org>)
- Don't change utime atime/mtime when compressing files
(taken from the Debian patches by Paul Martin <pm@debian.org>)
- Better *rotate scripts parser. (taken from the Debian patches)
- Allow 'include' directive in log file definitions
3.7.7 -> 3.7.8
- do not exit on status file errors
- limit config file inclusion nesting
......
......@@ -4,6 +4,7 @@ LFS = $(shell echo `getconf LFS_CFLAGS 2>/dev/null`)
CFLAGS = -Wall -D_GNU_SOURCE -D$(OS_NAME) -DVERSION=\"$(VERSION)\" $(RPM_OPT_FLAGS) $(LFS)
PROG = logrotate
MAN = logrotate.8
MAN5 = logrotate.conf.5
LOADLIBES = -lpopt
SVNURL= svn+ssh://svn.fedorahosted.org/svn/logrotate
SVNPUBURL = http://svn.fedorahosted.org/svn/logrotate
......@@ -11,7 +12,7 @@ SVNTAG = r$(subst .,-,$(VERSION))
ifeq ($(WITH_SELINUX),yes)
CFLAGS += -DWITH_SELINUX
LOADLIBES += -lselinux
LOADLIBES += -lselinux
endif
# HP-UX using GCC
......@@ -40,6 +41,7 @@ ifeq ($(OS_NAME),SunOS)
endif
CC = gcc
INSTALL = install
LOADLIBES += -lasprintf
ifeq ($(BASEDIR),)
BASEDIR = /usr/local
endif
......@@ -99,13 +101,16 @@ install:
[ -d $(PREFIX)/$(BINDIR) ] || mkdir -p $(PREFIX)/$(BINDIR)
[ -d $(PREFIX)/$(MANDIR) ] || mkdir -p $(PREFIX)/$(MANDIR)
[ -d $(PREFIX)/$(MANDIR)/man8 ] || mkdir -p $(PREFIX)/$(MANDIR)/man8
[ -d $(PREFIX)/$(MANDIR)/man5 ] || mkdir -p $(PREFIX)/$(MANDIR)/man5
if [ "$(OS_NAME)" = HP-UX ]; then \
$(INSTALL) $(PROG) $(PREFIX)/$(BINDIR) 0755 bin bin; \
$(INSTALL) $(MAN) $(PREFIX)/$(MANDIR)/man`echo $(MAN) | sed "s/.*\.//"` 0644 bin bin; \
$(INSTALL) $(MAN5) $(PREFIX)/$(MANDIR)/man`echo $(MAN5) | sed "s/.*\.//"` 0644 bin bin; \
else \
$(INSTALL) -m 755 $(PROG) $(PREFIX)/$(BINDIR); \
$(INSTALL) -m 644 $(MAN) $(PREFIX)/$(MANDIR)/man`echo $(MAN) | sed "s/.*\.//"`/$(MAN); \
$(INSTALL) -m 644 $(MAN5) $(PREFIX)/$(MANDIR)/man`echo $(MAN5) | sed "s/.*\.//"`/$(MAN5); \
fi
co:
......
This diff is collapsed.
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf
/usr/sbin/logrotate /etc/logrotate.conf >/dev/null 2>&1
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
......
......@@ -217,6 +217,11 @@ Specify the extension for \fBdateext\fR using the notation similar to
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
......@@ -246,8 +251,6 @@ before processing of the including file continues. The only files
which are ignored are files which are not regular files (such as
directories and named pipes) and files whose names end with one of
the taboo extensions, as specified by the \fBtabooext\fR directive.
The \fBinclude\fR directive may not appear inside a log file
definition.
.TP
\fBmail \fIaddress\fR
......@@ -336,7 +339,8 @@ overrides the \fBolddir\fR option).
\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). If the scripts exit with error, the remaining actions will
option). The absolute path to the log file is passed as first argument
to the script. If the scripts exit with error, the remaining actions will
not be executed for the affected log only.
.TP
......@@ -359,36 +363,44 @@ overridden by the \fBnoolddir\fR option.
.TP
\fBpostrotate\fR/\fBendscript\fR
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 a log file definition.
must appear on lines by themselves) are executed (using \fB/bin/sh\fR)
after the log file is rotated. These directives may only appear inside
a log file definition. Normally, the absolute path to the log file is
passed as first argument to the script. If \fBsharedscripts\fR is specified,
whole pattern is passed to the script.
See also \fBprerotate\fR. See \fBsharedscripts\fR and \fBnosharedscripts\fR
for error handling.
.TP
\fBprerotate\fR/\fBendscript\fR
The lines between \fBprerotate\fR and \fBendscript\fR (both of which
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 a log file definition. See also \fBpostrotate\fR.
must appear on lines by themselves) are executed (using \fB/bin/sh\fR) before
the log file is rotated and only if the log will actually be rotated. These
directives may only appear inside a log file definition. Normally,
the absolute path to the log file is passed as first argument to the script.
If \fBsharedscripts\fR is specified, whole pattern is passed to the script.
See also \fBpostrotate\fR.
See \fBsharedscripts\fR and \fBnosharedscripts\fR for error handling.
.TP
\fBfirstaction\fR/\fBendscript\fR
The lines between \fBfirstaction\fR and \fBendscript\fR (both of which
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 a log file definition. If the script exits
with error, no further processing is done. See also \fBlastaction\fR.
must appear on lines by themselves) are executed (using \fB/bin/sh\fR) 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 a log file definition. Whole pattern is
passed to the script as first argument. If the script exits with error,
no further processing is done. See also \fBlastaction\fR.
.TP
\fBlastaction\fR/\fBendscript\fR
The lines between \fBlastaction\fR and \fBendscript\fR (both of which
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 a log file definition. If the script exits with
error, just an error message is shown (as this is the last
must appear on lines by themselves) are executed (using \fB/bin/sh\fR) 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 a log file definition. Whole pattern is
passed to the script as first argument. If the script exits
with error, just an error message is shown (as this is the last
action). See also \fBfirstaction\fR.
.TP
......@@ -408,10 +420,12 @@ size is in gigabytes. So \fBsize 100\fR, \fIsize 100k\fR, \fIsize 100M\fR and
.TP
\fBsharedscripts\fR
Normally, \fBprerotate\fR and \fBpostrotate\fR scripts are run for each
log which is rotated, meaning that a single script may be run multiple
log which is rotated and the absolute path to the log file is passed as first
argument to the script. That means a single script may be run multiple
times for log file entries which match multiple files (such as the
\fI/var/log/news/*\fR example). If \fBsharedscript\fR is specified, the scripts
are only run once, no matter how many logs match the wildcarded pattern.
\fI/var/log/news/*\fR example). If \fBsharedscripts\fR is specified, the scripts
are only run once, no matter how many logs match the wildcarded pattern,
and whole pattern is passed to them.
However, if none of the logs in the pattern require rotating, the scripts
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
......@@ -442,7 +456,7 @@ The current taboo extension list is changed (see the \fBinclude\fR directive
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 .rpmorig, .rpmsave, ,v, .swp, .rpmnew, ~, .cfsaved and .rhn-cfg-tmp-*.
contains .rpmsave, .rpmorig, ~, .disabled, .dpkg-old, .dpkg-dist, .dpkg-new, .cfsaved, .ucf-old, .ucf-dist, .ucf-new, .rpmnew, .swp, .cfsaved, .rhn-cfg-tmp-*
.TP
\fBweekly\fR
......
......@@ -14,6 +14,12 @@
#include <unistd.h>
#include <glob.h>
#include <locale.h>
#include <sys/types.h>
#include <utime.h>
#if defined(SunOS)
#include <syslimits.h>
#endif
#ifdef WITH_SELINUX
#include <selinux/selinux.h>
......@@ -275,6 +281,7 @@ static int compressLogFile(char *name, struct logInfo *log, struct stat *sb)
{
char *compressedName;
const char **fullCommand;
struct utimbuf utim;
int inFile;
int outFile;
int i;
......@@ -326,6 +333,12 @@ static int compressLogFile(char *name, struct logInfo *log, struct stat *sb)
return 1;
}
utim.actime = sb->st_atime;
utim.modtime = sb->st_mtime;
utime(compressedName,&utim);
/* If we can't change atime/mtime, it's not a disaster.
It might possibly fail under SELinux. */
shred_file(name, log);
return 0;
......@@ -432,7 +445,7 @@ static int copyTruncate(char *currLog, char *saveLog, struct stat *sb,
message(MESS_DEBUG, "copying %s to %s\n", currLog, saveLog);
if (!debug) {
if ((fdcurr = open(currLog, O_RDWR)) < 0) {
if ((fdcurr = open(currLog, (flags & LOG_FLAG_COPY) ? O_RDONLY : O_RDWR)) < 0) {
message(MESS_ERROR, "error opening %s: %s\n", currLog,
strerror(errno));
return 1;
......@@ -844,9 +857,10 @@ int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
mailLogWrapper(mailFilename,
mailCommand, logNum,
log);
if (!hasErrors)
if (!hasErrors) {
message(MESS_DEBUG, "removing %s\n", mailFilename);
hasErrors = removeLogFile(mailFilename, log);
}
}
mail_out = i;
}
......@@ -1075,6 +1089,7 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
message(MESS_ERROR, "failed to rename %s to %s: %s\n",
log->files[logNum], rotNames->finalName,
strerror(errno));
hasErrors = 1;
}
if (!log->rotateCount) {
......@@ -1194,7 +1209,7 @@ int rotateLogSet(struct logInfo *log, int force)
message(MESS_DEBUG, "\nrotating pattern: %s ", log->pattern);
switch (log->criterium) {
case ROT_DAYS:
message(MESS_DEBUG, "after %d days ", log->threshhold);
message(MESS_DEBUG, "after %llu days ", log->threshhold);
break;
case ROT_WEEKLY:
message(MESS_DEBUG, "weekly ");
......@@ -1206,7 +1221,7 @@ int rotateLogSet(struct logInfo *log, int force)
message(MESS_DEBUG, "yearly ");
break;
case ROT_SIZE:
message(MESS_DEBUG, "%d bytes ", log->threshhold);
message(MESS_DEBUG, "%llu bytes ", log->threshhold);
break;
case ROT_FORCE:
message(MESS_DEBUG, "forced from command line ");
......@@ -1227,7 +1242,7 @@ int rotateLogSet(struct logInfo *log, int force)
message(MESS_DEBUG, "empty log files are not rotated, ");
if (log->minsize)
message(MESS_DEBUG, "only log files >= %d bytes are rotated, ", log->minsize);
message(MESS_DEBUG, "only log files >= %llu bytes are rotated, ", log->minsize);
if (log->logAddress) {
message(MESS_DEBUG, "old logs mailed to %s\n", log->logAddress);
......@@ -1288,7 +1303,7 @@ int rotateLogSet(struct logInfo *log, int force)
"since no logs will be rotated\n");
} else {
message(MESS_DEBUG, "running prerotate script\n");
if (runScript(log->pattern, log->pre)) {
if (runScript(log->flags & LOG_FLAG_SHAREDSCRIPTS ? log->pattern : log->files[j], log->pre)) {
if (log->flags & LOG_FLAG_SHAREDSCRIPTS)
message(MESS_ERROR,
"error running shared prerotate script "
......@@ -1323,7 +1338,7 @@ int rotateLogSet(struct logInfo *log, int force)
"since no logs were rotated\n");
} else {
message(MESS_DEBUG, "running postrotate script\n");
if (runScript(log->pattern, log->post)) {
if (runScript(log->flags & LOG_FLAG_SHAREDSCRIPTS ? log->pattern : log->files[j], log->post)) {
if (log->flags & LOG_FLAG_SHAREDSCRIPTS)
message(MESS_ERROR,
"error running shared postrotate script "
......
.so man8/logrotate.8
......@@ -33,8 +33,8 @@ struct logInfo {
char *oldDir;
enum { ROT_DAYS, ROT_WEEKLY, ROT_MONTHLY, ROT_YEARLY, ROT_SIZE,
ROT_FORCE } criterium;
unsigned int threshhold;
unsigned int minsize;
unsigned long long threshhold;
unsigned long long minsize;
int rotateCount;
int rotateAge;
int logStart;
......
Summary: Rotates, compresses, removes and mails system log files
Name: logrotate
Version: 3.7.8
Version: 3.7.9
Release: 1
License: GPL+
Group: System Environment/Base
......@@ -45,12 +45,16 @@ rm -rf $RPM_BUILD_ROOT
%doc CHANGES COPYING
%attr(0755, root, root) %{_sbindir}/logrotate
%attr(0644, root, root) %{_mandir}/man8/logrotate.8*
%attr(0644, root, root) %{_mandir}/man5/logrotate.conf.5*
%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
* Mon Jun 28 2010 Jan Kaluza <jkaluza@redhat.com> 3.7.9-1
- new upstream version
* Wed Jan 28 2009 Tomas Smetana <tsmetana@redhat.com> 3.7.8-1
- new upstream version
......
......@@ -17,6 +17,7 @@ genconfig() {
input=test-config.$1.in
output=test-config.$1
sed "s,&DIR&,$PWD,g" < $input > $output
config_crc=$(md5sum $output)
}
createlog() {
......@@ -117,6 +118,11 @@ checkoutput() {
echo expected: \'$expected\'
exit 2
fi
echo "$config_crc" | md5sum -c - 2>&1 > /dev/null
if [ $? != 0 ]; then
echo "config file $output has been altered: MD5 sum mismatch"
exit 3
fi
done
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment