logrotate/logrotate-fail_if_ENOENT_and_nomissingok.patch

16 lines
725 B
Diff
Raw Normal View History

Index: logrotate-3.8.7/logrotate.c
===================================================================
--- logrotate-3.8.7.orig/logrotate.c 2014-04-01 18:39:14.294635014 +0200
+++ logrotate-3.8.7/logrotate.c 2014-04-01 18:40:29.613496763 +0200
@@ -795,8 +795,9 @@ int findNeedRotating(struct logInfo *log
char *ld = ourDirName(log->files[logNum]);
if (stat(ld, &sb)) {
/* If parent directory doesn't exist, it's not real error
+ (unless nomissingok is specified)
and rotation is not needed */
- if (errno != ENOENT) {
+ if (errno != ENOENT || (errno == ENOENT && (log->flags & LOG_FLAG_MISSINGOK) == 0)) {
message(MESS_ERROR, "stat of %s failed: %s\n", ld,
strerror(errno));
free(ld);