]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
reload: if quiet, suppress rule reload output
authorJason Ish <jason.ish@oisf.net>
Fri, 28 Mar 2025 22:30:36 +0000 (16:30 -0600)
committerJason Ish <jason.ish@oisf.net>
Tue, 8 Apr 2025 22:16:09 +0000 (16:16 -0600)
If successful, and the quiet flag was provided, don't output the
return from the suricatasc socket command, or whatever the rule reload
command returns.

If there was an error, the output will be logged as an error.

Ticket: https://redmine.openinfosecfoundation.org/issues/7494

suricata/update/main.py

index 6b3d16dc3f141370877a06c9ba2aea00dd55e79a..8b893f2da55b2c862ec4a7185f3eff572c2df392 100644 (file)
@@ -1399,10 +1399,17 @@ def _main():
         return 1
 
     if not config.args().no_reload and config.get("reload-command"):
-        logger.info("Running %s." % (config.get("reload-command")))
-        rc = subprocess.Popen(config.get("reload-command"), shell=True).wait()
-        if rc != 0:
-            logger.error("Reload command exited with error: {}".format(rc))
+        reload_command = config.get("reload-command")
+        logger.info("Running {}.".format(reload_command))
+        try:
+            output = subprocess.check_output(
+                reload_command, shell=True, stderr=subprocess.STDOUT)
+            if reload_command.find("suricatasc") > -1 and output.decode("utf-8").find("NOK") > -1:
+                logger.error("Reload command was not successful: {}".format(output))
+            else:
+                logger.info("Reload command returned: {}".format(output.decode("utf-8")))
+        except Exception as err:
+            logger.error("Reload command failed: {}".format(err.output))
 
     logger.info("Done.")