Commit 73923da4 authored by Tobias Frost's avatar Tobias Frost

Import Upstream version 3.8.3

parent d99ab330
3.8.2 -> 3.8.3
- Fixed setting "size" bigger than 4GB on 32bit architectures
- Do not overwrite mode set by "create" option when using ACL. "create"
directive is now not mixed up with ACLs. If you use "create" in config
file and log file has some ACLs set, ACLs are not kept and are
overwritten by the mode set in "create" directive.
- Mode argument in "create" directive can be omitted. Only owner and group
is set in this case. Check man page for more info.
3.8.1 -> 3.8.2
- show error and ignore config if '{' is not present after log files
declaration
......
......@@ -581,7 +581,7 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
char foo;
off_t length;
int lineNum = 1;
int multiplier;
unsigned long long multiplier;
int i, k;
char *scriptStart = NULL;
char **scriptDest = NULL;
......@@ -848,6 +848,17 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
rc = sscanf(key, "%o %200s %200s%c", &createMode,
createOwner, createGroup, &foo);
/* We support 'create <owner> <group> notation now */
if (rc == 0) {
rc = sscanf(key, "%200s %200s%c",
createOwner, createGroup, &foo);
/* Simulate that we have read createMode and se it
* to NO_MODE. */
if (rc > 0) {
createMode = NO_MODE;
rc += 1;
}
}
if (rc == 4) {
message(MESS_ERROR, "%s:%d extra arguments for "
"create\n", configFile, lineNum);
......
......@@ -178,7 +178,8 @@ command.
.TP
\fBcompressoptions\fR
Command line options may be passed to the compression program, if one is
in use. The default, for \fBgzip\fR(1), is "-9" (maximum compression).
in use. The default, for \fBgzip\fR(1), is "-6" (biased towards high
compression at the expense of speed).
.TP
\fBcopy\fR
......@@ -200,7 +201,7 @@ When this option is used, the \fBcreate\fR option will have no effect,
as the old log file stays in place.
.TP
\fBcreate \fImode\fR \fIowner\fR \fIgroup\fR
\fBcreate \fImode\fR \fIowner\fR \fIgroup\fR, \fBcreate \fIowner\fR \fIgroup\fR
Immediately after rotation (before the \fBpostrotate\fR script is run)
the log file is created (with the same name as the log file just rotated).
\fImode\fR specifies the mode for the log file in octal (the same
......@@ -217,7 +218,7 @@ Log files are rotated every day.
.TP
\fBdateext\fR
Archive old versions of log files adding a daily extension like YYYYMMDD
Archive old versions of log files adding a date extension like YYYYMMDD
instead of simply adding a number. The extension may be configured using
the \fBdateformat\fR and \fBdateyesterday\fR options.
......
......@@ -34,9 +34,13 @@ int selinux_enforce = 0;
#ifdef WITH_ACL
#include "sys/acl.h"
static acl_t prev_acl = NULL;
#define acl_type acl_t
#else
#define acl_type void *
#endif
static acl_type prev_acl = NULL;
#include "basenames.h"
#include "log.h"
#include "logrotate.h"
......@@ -289,7 +293,7 @@ static int runScript(struct logInfo *log, char *logfn, char *script)
return rc;
}
int createOutputFile(char *fileName, int flags, struct stat *sb)
int createOutputFile(char *fileName, int flags, struct stat *sb, acl_type acl, int force_mode)
{
int fd;
struct stat sb_create;
......@@ -322,12 +326,27 @@ int createOutputFile(char *fileName, int flags, struct stat *sb)
close(fd);
return -1;
}
if (fchmod(fd, sb->st_mode)) {
message(MESS_ERROR, "error setting mode of %s: %s\n",
fileName, strerror(errno));
close(fd);
return -1;
}
#ifdef WITH_ACL
if (!force_mode && acl) {
if (acl_set_fd(fd, acl) == -1) {
if (errno != ENOTSUP) {
message(MESS_ERROR, "setting ACL for %s: %s\n",
fileName, strerror(errno));
close(fd);
return 1;
}
}
}
#endif
return fd;
}
......@@ -439,39 +458,29 @@ static int compressLogFile(char *name, struct logInfo *log, struct stat *sb)
return 1;
}
outFile =
createOutputFile(compressedName, O_RDWR | O_CREAT, sb);
if (outFile < 0) {
close(inFile);
return 1;
}
#ifdef WITH_ACL
if ((prev_acl = acl_get_fd(inFile)) == NULL) {
if (errno != ENOTSUP) {
message(MESS_ERROR, "getting file ACL %s: %s\n",
name, strerror(errno));
close(inFile);
close(outFile);
return 1;
}
}
#endif
outFile =
createOutputFile(compressedName, O_RDWR | O_CREAT, sb, prev_acl, 0);
#ifdef WITH_ACL
if (prev_acl) {
if (acl_set_fd(outFile, prev_acl) == -1) {
if (errno != ENOTSUP) {
message(MESS_ERROR, "setting ACL for %s: %s\n",
compressedName, strerror(errno));
acl_free(prev_acl);
prev_acl = NULL;
close(inFile);
close(outFile);
return 1;
}
}
acl_free(prev_acl);
prev_acl = NULL;
}
#endif /* WITH_ACL */
#endif
if (outFile < 0) {
close(inFile);
return 1;
}
if (!fork()) {
dup2(inFile, 0);
......@@ -671,7 +680,7 @@ static int copyTruncate(char *currLog, char *saveLog, struct stat *sb,
}
#endif /* WITH_ACL */
fdsave =
createOutputFile(saveLog, O_WRONLY | O_CREAT, sb);
createOutputFile(saveLog, O_WRONLY | O_CREAT, sb, prev_acl, 0);
#ifdef WITH_SELINUX
if (selinux_enabled) {
setfscreatecon_raw(prev_context);
......@@ -679,33 +688,16 @@ static int copyTruncate(char *currLog, char *saveLog, struct stat *sb,
prev_context = NULL;
}
#endif
if (fdsave < 0) {
close(fdcurr);
#ifdef WITH_ACL
if (prev_acl) {
acl_free(prev_acl);
prev_acl = NULL;
}
#endif /* WITH_ACL */
return 1;
}
#ifdef WITH_ACL
if (prev_acl) {
if (acl_set_fd(fdsave, prev_acl) == -1) {
if (errno != ENOTSUP) {
message(MESS_ERROR, "setting ACL for %s: %s\n",
saveLog, strerror(errno));
acl_free(prev_acl);
prev_acl = NULL;
close(fdsave);
close(fdcurr);
return 1;
}
}
acl_free(prev_acl);
prev_acl = NULL;
}
#endif /* WITH_ACL */
#endif
if (fdsave < 0) {
close(fdcurr);
return 1;
}
while ((cnt = read(fdcurr, buf, sizeof(buf))) > 0) {
if (write(fdsave, buf, cnt) != cnt) {
......@@ -1392,10 +1384,13 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
else
sb.st_gid = log->createGid;
int have_create_mode = 0;
if (log->createMode == NO_MODE)
sb.st_mode = state->sb.st_mode & 0777;
else
else {
sb.st_mode = log->createMode;
have_create_mode = 1;
}
message(MESS_DEBUG, "creating new %s mode = 0%o uid = %d "
"gid = %d\n", log->files[logNum], (unsigned int) sb.st_mode,
......@@ -1404,23 +1399,16 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
if (!debug) {
if (!hasErrors) {
fd = createOutputFile(log->files[logNum], O_CREAT | O_RDWR,
&sb);
&sb, prev_acl, have_create_mode);
#ifdef WITH_ACL
if (prev_acl) {
acl_free(prev_acl);
prev_acl = NULL;
}
#endif
if (fd < 0)
hasErrors = 1;
else {
#ifdef WITH_ACL
if (prev_acl) {
if (acl_set_fd(fd, prev_acl) == -1) {
if (errno != ENOTSUP) {
message(MESS_ERROR, "setting ACL for %s: %s\n",
log->files[logNum], strerror(errno));
hasErrors = 1;
}
}
acl_free(prev_acl);
prev_acl = NULL;
}
#endif /* WITH_ACL */
close(fd);
}
}
......
Summary: Rotates, compresses, removes and mails system log files
Name: logrotate
Version: 3.8.2
Version: 3.8.3
Release: 1
License: GPL+
Group: System Environment/Base
......@@ -52,6 +52,9 @@ rm -rf $RPM_BUILD_ROOT
%attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status
%changelog
* Thu Oct 04 2012 Jan Kaluza <jkaluza@redhat.com> 3.8.3-1
- new upstream version
* Thu Jul 19 2012 Jan Kaluza <jkaluza@redhat.com> 3.8.2-1
- new upstream version
......
......@@ -16,7 +16,9 @@ cleanup() {
genconfig() {
input=test-config.$1.in
output=test-config.$1
sed "s,&DIR&,$PWD,g" < $input > $output
user=$(id -u -n)
group=$(id -g -n)
sed "s,&DIR&,$PWD,g" < $input | sed "s,&USER&,$user,g" | sed "s,&GROUP&,$group,g" > $output
config_crc=$(md5sum $output)
}
......@@ -665,4 +667,123 @@ test.log 0 zero
test.log-$DATESTRING 0 one
EOF
cleanup 31
# ------------------------------- Test 31 ------------------------------------
# Test mode in create option
preptest test.log 31 1 0
$RLR test-config.31 --force
stat -c %f test.log|grep 8180 >/dev/null
if [ $? != 0 ]; then
echo "Bad mode of test.log, should be 0600"
exit 3
fi
checkoutput <<EOF
test.log 0
test.log.1 0 zero
EOF
cleanup 32
# ------------------------------- Test 32 ------------------------------------
# Without mode in 'create' directive, ACLs should be respected
preptest test.log 32 1 0
setfacl -m u:nobody:rwx test.log
$RLR test-config.32 --force
getfacl test.log|grep "user:nobody:rwx" >/dev/null
if [ $? != 0 ]; then
echo "test.log must contain user:nobody:rwx"
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"
exit 3
fi
checkoutput <<EOF
test.log 0
test.log.1 0 zero
EOF
cleanup 33
# ------------------------------- Test 33 ------------------------------------
# With mode in 'create' directive, ACLs are overwriten by chmod
preptest test.log 33 1 0
setfacl -m u:nobody:rwx test.log
$RLR test-config.33 --force
getfacl test.log|grep "user:nobody:rwx" >/dev/null
if [ $? == 0 ]; then
echo "test.log must not contain user:nobody:rwx"
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"
exit 3
fi
checkoutput <<EOF
test.log 0
test.log.1 0 zero
EOF
cleanup 34
# ------------------------------- Test 34 ------------------------------------
# We support changing user/mode without setting mode in create directive now
# We can't change user/group as normal user, so this test uses debug mode and
# checks the logrotate -d output.
preptest test.log 34 1 0
$RLR test-config.34 -d -f 2>&1|grep "uid = 0 gid = 0" > /dev/null
if [ $? != 0 ]; then
echo "logrotate output must contain 'uid = 0 gid = 0'"
exit 3
fi
checkoutput <<EOF
test.log 0 zero
EOF
cleanup 35
# ------------------------------- Test 35 ------------------------------------
# Test 'create' directive without mode but with user/group with ACLs. ACLs should
# be respected.
preptest test.log 35 1 0
setfacl -m u:nobody:rwx test.log
$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"
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"
exit 3
fi
checkoutput <<EOF
test.log 0
test.log.1 0 zero
EOF
cleanup
create 0600 &USER& &GROUP&
&DIR&/test.log {
daily
rotate 999
}
create
&DIR&/test.log {
daily
rotate 999
}
create 0600
&DIR&/test.log {
daily
rotate 999
}
create root root
&DIR&/test.log {
daily
rotate 1
}
create &USER& &GROUP&
&DIR&/test.log {
daily
rotate 1
}
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