From: Jason Ish Date: Fri, 11 Oct 2019 16:52:27 +0000 (-0600) Subject: Copy environment before modify when running Suricata. X-Git-Tag: 1.1.0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e735821adfa709779c23e15db1c07e099f6084fd;p=thirdparty%2Fsuricata-update.git Copy environment before modify when running Suricata. Related issue: https://redmine.openinfosecfoundation.org/issues/2669 LD_LIBRARY_PATH wasn't being passed through to the environment used to run Suricata. Fix this by copying the parent environment than adding the vars that we need instead of using a clean environment. --- diff --git a/suricata/update/engine.py b/suricata/update/engine.py index 8d95129..dd996d3 100644 --- a/suricata/update/engine.py +++ b/suricata/update/engine.py @@ -92,11 +92,8 @@ class Configuration: @classmethod def load(cls, config_filename, suricata_path=None): - env = { - "SC_LOG_FORMAT": "%t - <%d> -- ", - "SC_LOG_LEVEL": "Error", - "ASAN_OPTIONS": "detect_leaks=0", - } + env = build_env() + env["SC_LOG_LEVEL"] = "Error" if not suricata_path: suricata_path = get_path() if not suricata_path: @@ -176,16 +173,18 @@ def test_configuration(suricata_path, suricata_conf=None, rule_filename=None): if rule_filename: test_command += ["-S", rule_filename] - # This makes the Suricata output look just like suricata-update - # output. - env = { - "SC_LOG_FORMAT": "%t - <%d> -- ", - "SC_LOG_LEVEL": "Warning", - "ASAN_OPTIONS": "detect_leaks=0", - } + env = build_env() + env["SC_LOG_LEVEL"] = "Warning" logger.debug("Running %s; env=%s", " ".join(test_command), str(env)) rc = subprocess.Popen(test_command, env=env).wait() if rc == 0: return True return False + +def build_env(): + env = os.environ.copy() + env["SC_LOG_FORMAT"] = "%t - <%d> -- " + env["SC_LOG_LEVEL"] = "Error" + env["ASAN_OPTIONS"] = "detect_leaks=0" + return env