Skip to content
Permalink
Browse files

Fix 'olddir' usage with wildcard in the middle of path in the pattern…

… definition when the pattern did not match any log file.
  • Loading branch information...
Jan Kaluza
Jan Kaluza committed Jan 26, 2016
1 parent 4c08e0a commit 73493ec38c5e806fa66d8c3f13259775da6282d9
Showing with 49 additions and 6 deletions.
  1. +18 −6 config.c
  2. +21 −0 test/test
  3. +10 −0 test/test-config.69.in
@@ -1464,12 +1464,24 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
int rv;
dirName = ourDirName(newlog->files[i]);
if (stat(dirName, &sb2)) {
message(MESS_ERROR,
"%s:%d error verifying log file "
"path %s: %s\n", configFile, lineNum,
dirName, strerror(errno));
free(dirName);
goto error;
if (!(newlog->flags & LOG_FLAG_MISSINGOK)) {
message(MESS_ERROR,
"%s:%d error verifying log file "
"path %s: %s\n", configFile, lineNum,
dirName, strerror(errno));
free(dirName);
goto error;
}
else {
message(MESS_DEBUG,
"%s:%d verifying log file "
"path failed %s: %s, log is probably missing, "
"but missingok is set, so this is not an error.\n",
configFile, lineNum,
dirName, strerror(errno));
free(dirName);
continue;
}
}
ld = alloca(strlen(dirName) + strlen(newlog->oldDir) + 2);
sprintf(ld, "%s/%s", dirName, newlog->oldDir);
@@ -1753,4 +1753,25 @@ if [ $? = 0 ]; then
exit 3
fi

cleanup 69

# ------------------------------- Test 69 ------------------------------------
# Test olddir with wildcard in the pattern
preptest test.log 69 1 0
rm -rf testdir adir bdir
mkdir adir
mkdir bdir
cp test.log adir
cp test.log bdir
$RLR test-config.69 --force -v

checkoutput <<EOF
adir/test.log 0
testdir/test.log.1 0 zero
EOF

rm -rf testdir adir
rm -rf testdir bdir

cleanup

@@ -0,0 +1,10 @@
create

&DIR&/*/test.log
&DIR&/*/test.lo3 {
monthly
rotate 1
olddir &DIR&/testdir
createolddir 700 &USER& &GROUP&
missingok
}

1 comment on commit 73493ec

@sastorsl

This comment has been minimized.

Copy link

sastorsl commented on 73493ec Mar 30, 2016

What version of logrotate will we see this in?

Please sign in to comment.
You can’t perform that action at this time.