From: Jason Ish Date: Fri, 28 Mar 2025 22:30:36 +0000 (-0600) Subject: reload: if quiet, suppress rule reload output X-Git-Tag: 1.3.5~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4ce59579b1cc74c1f4f1e73974721e6dfa635fb;p=thirdparty%2Fsuricata-update.git reload: if quiet, suppress rule reload output 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 --- diff --git a/suricata/update/main.py b/suricata/update/main.py index 6b3d16d..8b893f2 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -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.")