Commit 255177a1 authored by Tobias Frost's avatar Tobias Frost

Import Upstream version 3.9.1

parent cebf3dd2
3.9.0 -> 3.9.1
- Fix off-by-one error which can lead to crash when copytruncate is used.
3.8.9 -> 3.9.0
- Fix crash when using long dateformat. [nmerdan]
- Add support for %H dateformat. [czchen]
- Fix regression introduced in 3.8.9 when when rotating multiple
logs when one of them is missing.
- In the debug mode, do not skip the code-path which handles the case when
the last rotation does not exist. [Sergey Vidishev]
- Show more precise description when "log does not need rotating".\
- Add new -l option to log verbose output to file. The file is overwritten
on every logrotate execution.
- Allow rotation of sparse files with copytruncate.
3.8.8 -> 3.8.9
- Add new directive "createolddir" and "nocreateolddir". These directives
can be used to create the directory specified by olddir with particular
"mode", "owner" and "group".
- Continue with rotation even when first log from logset is removed
during the rotation.
- Fix crash on BSD systems introduced in 3.8.8 caused by different qsort_r
function. Function qsort is now used instead.
- Fix potential buffer overflow in usage of strncat function.
- Fix compilation with musl-libc.
- Add experimental 'renamecopy' directive to allow 'olddir' on different
physical device. See the "man logrotate" for more information.
3.8.7 -> 3.8.8
- Add support for building using autotools/automake. Using "./autogen.sh",
"./configure" and "make" is now preferred way how to build logrotate.
Old Makefile remains available, but it is deprecated and will be removed
in the future. Please report any problem related to new build system.
- Add support for systems which do not support fork (use vfork instead)
and madvise.
- Fix bug when wrong log file has been removed in case of dateext and
dateformat %d-%m-%Y.
- Do not expect that the name of root account is 'root'.
- Do not stop rotation with an error when olddir and log file
are on different devices and copy or copytruncate is used.
- Return an error code when parent directory of log does not exist,
"su" directive is not used, logrotate is running as root and missingok
is not specified. [vcizek]
- Prepend error printed by compression program with the log name even when
the compression program exits with zero exit code.
3.8.6 -> 3.8.7
- Fixed --force/-f option handling together with "size" directive
(3.8.5 regression).
......
......@@ -2,25 +2,22 @@ The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code
2. Type `make' to compile the package.
2. Configure logrotate using `./autogen.sh' and `./configure'.
3. Optionally, type `make test' to run any self-tests that come with
3. Type `make' to compile the package.
4. Optionally, type `make test' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
5. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'.
If you want to add the Access Control List (ACL) support to the program
use `make WITH_ACL=yes' at the point 2 and `make test WITH_ACL=yes' at
the point 3.
use `./configure --with-acl=yes' at the point 2.
If you want to add the NSA Security-Enhanced Linux (SELinux) support to
the program use `make WITH_SELINUX=yes' at the point 2.
If you want to add both the ACL and SELinux supports to the program use
`make WITH_ACL=yes WITH_SELINUX=yes' at the point 2 and
`make test WITH_ACL=yes' at the point 3.
the program use `./configure --with-selinux=yes' at the point 2.
VERSION = $(shell awk '/Version:/ { print $$2 }' logrotate.spec)
OS_NAME = $(shell uname -s)
LFS = $(shell echo `getconf LFS_CFLAGS 2>/dev/null`)
CFLAGS = -Wall -D_GNU_SOURCE -D$(OS_NAME) -DVERSION=\"$(VERSION)\" $(RPM_OPT_FLAGS) $(LFS)
CFLAGS = -Wall -D_GNU_SOURCE -D$(OS_NAME) -DVERSION=\"$(VERSION)\" -DHAVE_STRPTIME=1 -DHAVE_QSORT -DHAVE_STRUCT_STAT_ST_BLOCKS -DHAVE_STRUCT_STAT_ST_BLKSIZE $(RPM_OPT_FLAGS) $(LFS)
PROG = logrotate
MAN = logrotate.8
MAN5 = logrotate.conf.5
......@@ -114,7 +114,14 @@ endif
RCSVERSION = $(subst .,-,$(VERSION))
all: $(TARGET) pretest
all: show_warning $(TARGET) pretest
show_warning:
@echo ""
@echo "Building using this Makefile is DEPRECATED."
@echo "Use './autogen.sh', './configure' and 'make' instead."
@echo "Some new features will not be enabled when building using this Makefile."
@echo ""
$(PROG): $(OBJS)
......
MAN = logrotate.8
MAN5 = logrotate.conf.5
AM_CFLAGS = -Wall -Werror
sbin_PROGRAMS = logrotate
logrotate_SOURCES = logrotate.c log.c config.c basenames.c
install-data-local:
$(AM_V_at)$(INSTALL) -d $(DESTDIR)$(mandir)/man8
$(AM_V_at)$(INSTALL) -d $(DESTDIR)$(mandir)/man5
$(AM_V_at)$(INSTALL) -m 644 @srcdir@/logrotate.8 $(DESTDIR)$(mandir)/man8
$(AM_V_at)$(INSTALL) -m 644 @srcdir@/logrotate.conf.5 $(DESTDIR)$(mandir)/man5
uninstall-local:
$(AM_V_at)rm -f $(DESTDIR)$(mandir)/man8/logrotate.8
$(AM_V_at)rm -f $(DESTDIR)$(mandir)/man5/logrotate.conf.5
SUBDIRS = test
This diff is collapsed.
This diff is collapsed.
AC_INIT([logrotate],[3.9.1])
AM_INIT_AUTOMAKE
AC_DEFINE(_GNU_SOURCE)
AM_EXTRA_RECURSIVE_TARGETS([test])
AC_PROG_CC
AC_PROG_CC_STDC
AC_STRUCT_ST_BLKSIZE
AC_STRUCT_ST_BLOCKS
AC_CHECK_LIB([popt],[poptParseArgvString],,
AC_MSG_ERROR([libpopt required but not found]))
AC_ARG_WITH([selinux],
[AS_HELP_STRING([--with-selinux],
[support handling SELinux contexts (yes,no,check) @<:@default=check@:>@])],
[],
[with_selinux=check])
AS_CASE(["$with_selinux"],
[yes], [AC_CHECK_LIB([selinux],[getfscreatecon_raw])],
[no], [],
[AC_CHECK_LIB([selinux],[getfscreatecon_raw])])
AS_IF([test "$ac_cv_lib_selinux_getfscreatecon_raw" = yes],
echo "1" > ./test/test.SELINUX;, echo "0" > ./test/test.SELINUX;)
AC_ARG_WITH([acl],
[AS_HELP_STRING([--with-acl],
[support handling ACL (yes,no,check) @<:@default=check@:>@])],
[],
[with_acl=check])
AS_CASE(["$with_acl"],
[yes], [AC_CHECK_LIB([acl],[acl_get_file])],
[no], [],
[AC_CHECK_LIB([acl],[acl_get_file])])
AS_IF([test "$ac_cv_lib_acl_acl_get_file" = yes],
echo "1" > ./test/test.ACL;, echo "0" > ./test/test.ACL;)
AC_CHECK_FUNCS([strptime qsort fork vfork madvise])
AC_CONFIG_FILES([Makefile test/Makefile])
AC_OUTPUT
......@@ -21,7 +21,7 @@ include /etc/logrotate.d
/var/log/wtmp {
monthly
create 0664 root utmp
minsize 1M
minsize 1M
rotate 1
}
......
......@@ -37,75 +37,48 @@ void logClearFlags(int newFlags)
flags &= ~newFlags;
}
#if 0
void log(int fd, char *format, ...)
static void log_once(FILE *where, int level, char *format, va_list args)
{
int i = 0;
char *buf = NULL;
va_list args;
int size;
va_start(args, format);
do {
i += 1000;
if (buf)
free(buf);
buf = malloc(i);
size = vsnprintf(buf, i, format, args);
} while (size >= i);
write(fd, buf, size);
free(buf);
va_end(args);
}
#endif
void message(int level, char *format, ...)
{
va_list args;
FILE *where = NULL;
int showTime = 0;
if (errorFile == NULL)
errorFile = stderr;
if (messageFile == NULL)
messageFile = stderr;
where = errorFile;
if (level >= logLevel) {
va_start(args, format);
int showTime = 0;
switch (level) {
case MESS_DEBUG:
where = messageFile;
showTime = 1;
break;
showTime = 1;
break;
case MESS_NORMAL:
case MESS_VERBOSE:
where = messageFile;
break;
break;
default:
if (flags & LOG_TIMES)
if (flags & LOG_TIMES)
fprintf(where, "%ld: ", (long) time(NULL));
fprintf(errorFile, "error: ");
break;
fprintf(where, "error: ");
break;
}
if (showTime && (flags & LOG_TIMES)) {
fprintf(where, "%ld:", (long) time(NULL));
fprintf(where, "%ld:", (long) time(NULL));
}
vfprintf(where, format, args);
fflush(where);
va_end(args);
if (level == MESS_FATAL)
exit(1);
exit(1);
}
void message(int level, char *format, ...)
{
va_list args;
if (level >= logLevel) {
va_start(args, format);
log_once(stderr, level, format, args);
va_end(args);
}
if (messageFile != NULL) {
va_start(args, format);
log_once(messageFile, level, format, args);
va_end(args);
}
}
......@@ -18,9 +18,6 @@ void message(int level, char *format, ...)
#else
;
#endif
#if 0
void log(int fd, char *format, ...);
#endif
void logSetErrorFile(FILE * f);
void logSetMessageFile(FILE * f);
void logSetFlags(int flags);
......
......@@ -11,8 +11,8 @@ removal, and mailing of log files. Each log file may be handled daily,
weekly, monthly, or when it grows too large.
.P
Normally, \fBlogrotate\fR is run as a daily cron job. It will not modify
a log multiple times in one day unless the criterion for that log is
based on the log's size and \fBlogrotate\fR is being run multiple times
a log more than once in one day unless the criterion for that log is
based on the log's size and \fBlogrotate\fR is being run more than once
each day, or unless the \fB\-f\fR or \fB\-\-force\fR option is used.
.P
Any number of config files may be given on the command line. Later config
......@@ -47,6 +47,12 @@ a \fBlogrotate\fR config file, or if old log files have been removed
by hand, as the new files will be created, and logging will continue
correctly.
.TP
\fB\-l <log_file>\fR
Tells \fBlogrotate\fR to log verbose output into the log_file. The verbose
output logged to that file is the same as when running \fBlogrotate\fR with
\fB-v\fR switch. The log file is overwritten on every logrotate execution.
.TP
\fB\-m\fR, \fB\-\-mail <command>\fR
Tells \fBlogrotate\fR which command to use when mailing logs. This
......@@ -67,7 +73,7 @@ Prints a short usage message.
.TP
+\fB\-v\fR, \fB\-\-verbose\fR
Turns on verbose mode.
Turns on verbose mode, ie. display messages during rotation.
.SH CONFIGURATION FILE
......@@ -119,9 +125,9 @@ compress
The first few lines set global options; in the example, logs are
compressed after they are rotated. Note that comments may appear
anywhere in the config file as long as the first non-whitespace
character on the line is a #.
character on the line is a \fB#\fR.
The next section of the config files defined how to handle the log file
The next section of the config file defines how to handle the log file
\fI/var/log/messages\fR. The log will go through five weekly rotations before
being removed. After the log file has been rotated (but before the old
version of the log has been compressed), the command
......@@ -129,14 +135,15 @@ version of the log has been compressed), the command
The next section defines the parameters for both
\fI/var/log/httpd/access.log\fR and \fI/var/log/httpd/error.log\fR.
They are rotated whenever it grows over 100k in size, and the old logs
Each is rotated whenever it grows over 100k in size, and the old logs
files are mailed (uncompressed) to www@my.org after going through 5
rotations, rather than being removed. The \fBsharedscripts\fR means that
the \fBpostrotate\fR script will only be run once (after the old logs have
been compressed), not once for each log which is rotated. Note that the double
quotes around the first filename at the beginning of this section allows
logrotate to rotate logs with spaces in the name. Normal shell quoting rules
apply, with ', ", and \\ characters supported.
been compressed), not once for each log which is rotated.
Note that log file names may be enclosed in
quotes (and that quotes are required if the name contains spaces).
Normal shell quoting rules apply, with \fB'\fR, \fB"\fR, and \fB\\\fR
characters supported.
The next section defines the parameters for all of the files in
\fI/var/log/news\fR. Each file is rotated on a monthly basis. This is
......@@ -162,12 +169,12 @@ Old versions of log files are compressed with \fBgzip\fR(1) by default. See also
.TP
\fBcompresscmd\fR
Specifies which command to use to compress log files. The default is
\fBgzip\fR. See also \fBcompress\fR.
\fBgzip\fR(1). See also \fBcompress\fR.
.TP
\fBuncompresscmd\fR
Specifies which command to use to uncompress log files. The default is
\fBgunzip\fR.
\fBgunzip\fR(1).
.TP
\fBcompressext\fR
......@@ -194,7 +201,7 @@ as the old log file stays in place.
.TP
\fBcopytruncate\fR
Truncate the original log file in place after creating a copy,
Truncate the original log file to zero size in place after creating a copy,
instead of moving the old log file and optionally creating a new one.
It can be used when some program cannot be told to close its logfile
and thus might continue writing (appending) to the previous log file forever.
......@@ -215,6 +222,16 @@ attributes for the new file will use the same values as the original log
file for the omitted attributes. This option can be disabled using the
\fBnocreate\fR option.
.TP
\fBcreateolddir \fImode\fR \fIowner\fR \fIgroup\fR
If the directory specified by \fBolddir\fR directive does not exist, it is
created. \fImode\fR specifies the mode for the \fBolddir\fR directory
in octal (the same as \fBchmod\fR(2)), \fIowner\fR specifies the user name
who will own the \fBolddir\fR directory, and \fIgroup\fR specifies the group
the \fBolddir\fR directory will belong to. This option can be disabled using the
\fBnocreateolddir\fR option.
.TP
\fBdaily\fR
Log files are rotated every day.
......@@ -228,10 +245,11 @@ the \fBdateformat\fR and \fBdateyesterday\fR options.
.TP
\fBdateformat\fR \fIformat_string\fR
Specify the extension for \fBdateext\fR using the notation similar to
\fBstrftime\fR(3) function. Only %Y %m %d and %s specifiers are allowed.
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.
\fBstrftime\fR(3) function. Only %Y %m %d %H and %s specifiers are allowed.
The default value is \-%Y%m%d except hourly, which uses \-%Y%m%d%H as default
value. 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).
......@@ -254,7 +272,7 @@ and thus might continue writing to the previous log file for some time.
.TP
\fBextension \fIext\fR
Log files with \fIext\fR extension can keep it after the rotation.
If compression is used, the compression extension (normally \fB.gz\fR)
If compression is used, the compression extension (normally \fI.gz\fR)
appears after \fIext\fR. For example you have a logfile named mylog.foo
and want to rotate it to mylog.1.foo.gz instead of mylog.foo.1.gz.
......@@ -281,7 +299,7 @@ the taboo extensions, as specified by the \fBtabooext\fR directive.
.TP
\fBmail \fIaddress\fR
When a log is rotated out-of-existence, it is mailed to \fIaddress\fR. If
When a log is rotated out of existence, it is mailed to \fIaddress\fR. If
no mail should be generated by a particular log, the \fBnomail\fR directive
may be used.
......@@ -349,6 +367,10 @@ Do not truncate the original log file in place after creating a copy
\fBnocreate\fR
New log files are not created (this overrides the \fBcreate\fR option).
.TP
\fBnocreateolddir\fR
\fBolddir\fR directory is not created by logrotate when it does not exist.
.TP
\fBnodelaycompress\fR
Do not postpone compression of the previous log file to the next rotation cycle
......@@ -361,7 +383,7 @@ Do not archive old versions of log files with date extension
.TP
\fBnomail\fR
Don't mail old log files to any address.
Do not mail old log files to any address.
.TP
\fBnomissingok\fR
......@@ -369,7 +391,7 @@ If a log file does not exist, issue an error. This is the default.
.TP
\fBnoolddir\fR
Logs are rotated in the same directory the log normally resides in (this
Logs are rotated in the directory they normally reside in (this
overrides the \fBolddir\fR option).
.TP
......@@ -390,9 +412,10 @@ Do not rotate the log if it is empty (this overrides the \fBifempty\fR option).
.TP
\fBolddir \fIdirectory\fR
Logs are moved into \fIdirectory\fR for rotation. The \fIdirectory\fR
must be on the same physical device as the log file being rotated,
and is assumed to be relative to the directory holding the log file
Logs are moved into \fIdirectory\fR for rotation. The \fIdirectory\fR must be
on the same physical device as the log file being rotated, unless \fBcopy\fR,
\fBcopytruncate\fR or \fBrenamecopy\fR option is used. The \fIdirectory\fR
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
overridden by the \fBnoolddir\fR option.
......@@ -453,6 +476,14 @@ Log files are rotated \fIcount\fR times before being removed or mailed to the
address specified in a \fBmail\fR directive. If \fIcount\fR is 0, old versions
are removed rather than rotated.
.TP
\fBrenamecopy\fR
Log file is renamed to temporary filename in the same directory by adding
".tmp" extension to it. After that, \fBpostrotate\fR script is run
and log file is copied from temporary filename to final filename. This allows
storing rotated log files on the different devices using \fBolddir\fR
directive. In the end, temporary filename is removed.
.TP
\fBsize \fIsize\fR
Log files are rotated only if they grow bigger then \fIsize\fR bytes. If
......@@ -498,7 +529,10 @@ number of times specified with the \fBrotate\fR directive.
\fBsu \fIuser\fR \fIgroup\fR
Rotate log files set under this user and group instead of using default
user/group (usually root). \fIuser\fR specifies the user name used for
rotation and \fIgroup\fR specifies the group used for rotation.
rotation and \fIgroup\fR specifies the group used for rotation. If the
user/group you specify here does not have sufficient privilege to make
files with the ownership you've specified in a \fIcreate\fR instruction,
it will cause an error.
.TP
\fBtabooext\fR [+] \fIlist\fR
......@@ -539,5 +573,6 @@ Configuration options.
Erik Troan, Preston Brown, Jan Kaluza.
<logrotate-owner@fedoraproject.org>
<http://fedorahosted.org/logrotate/>
.fi
This diff is collapsed.
......@@ -2,7 +2,7 @@
#define H_LOGROTATE
#include <sys/types.h>
#include <sys/queue.h>
#include "queue.h"
#include <glob.h>
#include "config.h"
......@@ -20,6 +20,8 @@
#define LOG_FLAG_SHRED (1 << 10)
#define LOG_FLAG_SU (1 << 11)
#define LOG_FLAG_DATEYESTERDAY (1 << 12)
#define LOG_FLAG_OLDDIRCREATE (1 << 13)
#define LOG_FLAG_TMPFILENAME (1 << 14)
#define NO_MODE ((mode_t) -1)
#define NO_UID ((uid_t) -1)
......@@ -28,6 +30,14 @@
#define NO_FORCE_ROTATE 0
#define FORCE_ROTATE 1
#ifdef HAVE_LIBSELINUX
#define WITH_SELINUX 1
#endif
#ifdef HAVE_LIBACL
#define WITH_ACL 1
#endif
struct logInfo {
char *pattern;
char **files;
......@@ -55,6 +65,9 @@ struct logInfo {
gid_t createGid;
uid_t suUid; /* switch user to this uid and group to this gid */
gid_t suGid;
mode_t olddirMode;
uid_t olddirUid;
uid_t olddirGid;
/* these are at the end so they end up nil */
const char **compress_options_list;
int compress_options_count;
......
Summary: Rotates, compresses, removes and mails system log files
Name: logrotate
Version: 3.8.7
Version: 3.9.1
Release: 1
License: GPL+
Group: System Environment/Base
......@@ -52,6 +52,18 @@ rm -rf $RPM_BUILD_ROOT
%attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status
%changelog
* Fri Apr 03 2015 Jan Kaluza <jkaluza@redhat.com> 3.9.1-1
- new upstream version
* Fri Apr 03 2015 Jan Kaluza <jkaluza@redhat.com> 3.9.0-1
- new upstream version
* Fri Feb 13 2015 Jan Kaluza <jkaluza@redhat.com> 3.8.9-1
- new upstream version
* Thu Oct 16 2014 Jan Kaluza <jkaluza@redhat.com> 3.8.8-1
- new upstream version
* Thu Oct 10 2013 Jan Kaluza <jkaluza@redhat.com> 3.8.7-1
- new upstream version
......
This diff is collapsed.
test:
(./test)
#!/bin/bash
echo "compression error" 1>&2
gzip $*
\ No newline at end of file
......@@ -464,9 +464,15 @@ cleanup 13
# ------------------------------- Test 13 ------------------------------------
preptest test.log 13 1 0
rm -rf testdir
mkdir testdir
$RLR test-config.13 --force
ls -l|grep testdir|grep "drwx------." 2>/dev/null >/dev/null
if [ $? != 0 ]; then
echo "testdir should have mode 2700, but it has:"
ls -l|grep testdir
exit 3
fi
checkoutput <<EOF
test.log 0
testdir/test.log.1 0 zero
......@@ -533,7 +539,7 @@ cleanup 17
# ------------------------------- Test 17 ------------------------------------
preptest test.log 17 1 0
# log with 1 byte should not be rotated
$RLR test-config.17 2>error.log
$RLR test-config.17 -l logrotate.log 2>error.log
grep "unexpected } (missing previous '{')" error.log >/dev/null
if [ $? != 0 ]; then
......@@ -543,6 +549,14 @@ fi
rm error.log
grep "reading config file test-config.17" logrotate.log >/dev/null
if [ $? != 0 ]; then
echo "There is no log output in logrotate.log"
exit 3
fi
rm -f logrotate.log
checkoutput <<EOF
test.log 0 zero
EOF
......@@ -803,24 +817,28 @@ $RLR test-config.32 --force
getfacl test.log|grep "user:nobody:rwx" >/dev/null
if [ $? != 0 ]; then
echo "test.log must have user:nobody:rwx ACL"
getfacl test.log
exit 3
fi
getfacl test.log|grep "group::---" >/dev/null
if [ $? != 0 ]; then
echo "test.log must have group::--- ACL"
getfacl test.log
exit 3
fi
getfacl test.log.1|grep "user:nobody:rwx" >/dev/null
if [ $? != 0 ]; then
echo "test.log.1 must have user:nobody:rwx ACL"
getfacl test.log.1
exit 3
fi
getfacl test.log.1|grep "group::---" >/dev/null
if [ $? != 0 ]; then
echo "test.log.1 must have group::--- ACL"
getfacl test.log.1
exit 3
fi
......@@ -899,13 +917,15 @@ $RLR test-config.35 --force
getfacl test.log|grep "user:nobody:rwx" >/dev/null
if [ $? != 0 ]; then
echo "test.log must not contain user:nobody:rwx"
echo "test.log must contain user:nobody:rwx"
getfacl test.log
exit 3
fi
getfacl test.log.1|grep "user:nobody:rwx" >/dev/null
if [ $? != 0 ]; then
echo "test.log.1 must contain user:nobody:rwx"
getfacl test.log.1
exit 3
fi
......@@ -1358,4 +1378,238 @@ test.log 0
test.log.1 0 zero
EOF
cleanup 54
# ------------------------------- Test 54 ------------------------------------
# removing last log file when using %Y-%m-%d
rm -f *test.log*
preptest test.log 54 1 0
DATE=""
for i in {1..60}
do
DATE=$(/bin/date "+%Y-%m-%d" --date "$i day ago" 2>/dev/null)
echo "x" > test.log-$DATE
done
$RLR test-config.54 --force
if [ -e test.log-$DATE ]; then
echo "File test.log-$DATE should not exist (it should be deleted)"
exit 3
fi
rm -f *test.log*
cleanup 55
# ------------------------------- Test 55 ------------------------------------
# removing last log file when using %s and hourly
rm -f *test.log*
preptest test.log 55 1 0
DATE=""
for i in {1..60}
do
DATE=$(/bin/date "+%s" --date "$i hour ago" 2>/dev/null)
echo "x" > test.log-$DATE.gz
done
$RLR test-config.55 --force
if [ -e test.log-$DATE.gz ]; then
echo "File test.log-$DATE.gz should not exist (it should be deleted)"
exit 3
fi
rm -f *test.log*
cleanup 56
# ------------------------------- Test 56 ------------------------------------
# removing last log file when using %d-%m-%Y
rm -f *test.log*
preptest test.log 56 1 0
DATE=""
for i in {1..60}
do
DATE=$(/bin/date "+%d-%m-%Y" --date "$i day ago" 2>/dev/null)
echo "x" > test.log-$DATE
done
$RLR test-config.56 --force
if [ -e test.log-$DATE ]; then
echo "File test.log-$DATE should not exist (it should be deleted)"
exit 3
fi
rm -f *test.log*
cleanup 57
# ------------------------------- Test 57 ------------------------------------
# When compressing program prints something to stderr, we should prepend it
# with the log name.
preptest test.log 57 1
$RLR test-config.57 --force 2>error.log
grep "error: Compressing" error.log >/dev/null
if [ $? != 0 ]; then
echo "No error printed, but there should be one."
exit 3
fi
grep "compression error" error.log >/dev/null
if [ $? != 0 ]; then
echo "No error printed, but there should be one."
exit 3
fi
rm -f error.log
checkoutput <<EOF
test.log 0
test.log.1.gz 1 zero
EOF
cleanup 58
# ------------------------------- Test 58 ------------------------------------
# Test renamecopy
preptest test.log 58 1 0
$RLR test-config.58 --force
checkoutput <<EOF
test.log 0
test.log.1 0 zero
EOF
cleanup 59
# ------------------------------- Test 59 ------------------------------------
# Test renamecopy in debug mode, nothing should happen
preptest test.log 58 1 0