From a201fc5e3dace5534e1a9d0e1fa7cda498d9c2a8 Mon Sep 17 00:00:00 2001 From: Alexey Gladkov Date: Sat, 25 Apr 2020 17:33:19 +0300 Subject: ALT: Improve messages about wrong file types Signed-off-by: Alexey Gladkov --- config.c | 4 ++-- logrotate.c | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config.c b/config.c index dd9eb04..9d196cc 100644 --- a/config.c +++ b/config.c @@ -1006,8 +1006,8 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig) } if (!S_ISREG(sb_config.st_mode)) { message(MESS_DEBUG, - "Ignoring %s because it's not a regular file.\n", - configFile); + "Ignoring %s because of unacceptable file type %#o.\n", + configFile, sb_config.st_mode & S_IFMT); close(fd); return 0; } diff --git a/logrotate.c b/logrotate.c index 2350672..27a864a 100644 --- a/logrotate.c +++ b/logrotate.c @@ -1400,6 +1400,12 @@ static int findNeedRotating(const struct logInfo *log, unsigned logNum, int forc return 1; } + if (!S_ISREG(sb.st_mode)) { + message(MESS_DEBUG, " log %s has unacceptable file type %#o, skipping.\n", + log->files[logNum], sb.st_mode & S_IFMT); + return 0; + } + state = findState(log->files[logNum]); if (!state) return 1; @@ -1408,13 +1414,6 @@ static int findNeedRotating(const struct logInfo *log, unsigned logNum, int forc state->sb = sb; state->isUsed = 1; - if ((sb.st_mode & S_IFMT) == S_IFLNK) { - message(MESS_DEBUG, " log %s is symbolic link. Rotation of symbolic" - " links is not allowed to avoid security issues -- skipping.\n", - log->files[logNum]); - return 0; - } - if (!(log->flags & LOG_FLAG_ALLOWHARDLINK) && sb.st_nlink != 1) { message(MESS_DEBUG, " log %s has multiple (%lu) hard links. Rotation of files" " with multiple hard links is not allowed for %s -- skipping.\n", -- 2.25.4