]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
When re-opening a log file on HUP, always append.
authorJason Ish <ish@unx.ca>
Fri, 27 Feb 2015 17:30:47 +0000 (11:30 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 11 Mar 2015 14:46:20 +0000 (15:46 +0100)
This will prevent log files that have not been rotated by some
external tool from being deleted, but log files that were
rotated (moved out of the way) will be re-opened.

This is a better default behaviour, especially when not all
log files are rotated at the same time.

Thanks to iro on IRC.

src/util-logopenfile.c

index 4e42ceef402f9c8e57955397decaff46033e8d53..fcef26d623e204d39d31dd1ea2edb008c365b76a 100644 (file)
@@ -251,9 +251,10 @@ int SCConfLogReopen(LogFileCtx *log_ctx)
 
     fclose(log_ctx->fp);
 
-    /* Reopen the file.  In this case do not append like may have been
-     * done on the initial opening of the file. */
-    log_ctx->fp = SCLogOpenFileFp(log_ctx->filename, "no");
+    /* Reopen the file. Append is forced in case the file was not
+     * moved as part of a rotation process. */
+    SCLogDebug("Reopening log file %s.", log_ctx->filename);
+    log_ctx->fp = SCLogOpenFileFp(log_ctx->filename, "yes");
     if (log_ctx->fp == NULL) {
         return -1; // Already logged by Open..Fp routine.
     }