]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
unix-socket: reset to ready state on startup
authorJason Ish <jason.ish@oisf.net>
Thu, 25 Feb 2021 17:16:28 +0000 (11:16 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 4 May 2021 08:31:29 +0000 (10:31 +0200)
As part of commit ea15282f47c6ff781533e3a063f9c903dd6f1afb,
some initialization was moved to happen even in unix socket mode,
however, this initialization does setup some loggers that can only have
one instance enabled (anomaly, drop, file-store).

This will cause these loggers to error out on the first pcap, but work
on subsequent runs of the pcap as some deinitialization is done after
each pcap.

This fix just runs the post pcap-file deinitialization routine to
reset some of the initialization done on startup, like is done after
running each pcap in unix socket mode.

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/4225

Additionally this prevents alerts from being logged two times
on the first run of a pcap through the unix socket:

Redmine issue:
https://redmine.openinfosecfoundation.org/issues/4434

src/suricata.c

index f6611987444e8233b6846a6ee5b5aa77794de652..1150b4861dff7dd41b3f25abfea5fcdfc6a903b4 100644 (file)
@@ -2027,8 +2027,14 @@ void PreRunPostPrivsDropInit(const int runmode)
     StatsSetupPostConfigPreOutput();
     RunModeInitializeOutputs();
 
-    if (runmode == RUNMODE_UNIX_SOCKET)
+    if (runmode == RUNMODE_UNIX_SOCKET) {
+        /* As the above did some necessary startup initialization, it
+         * also setup some outputs where only one is allowed, so
+         * deinitialize to the state that unix-mode does after every
+         * pcap. */
+        PostRunDeinit(RUNMODE_PCAP_FILE, NULL);
         return;
+    }
 
     StatsSetupPostConfigPostOutput();
 }