]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
Copy environment before modify when running Suricata.
authorJason Ish <jason.ish@oisf.net>
Fri, 11 Oct 2019 16:52:27 +0000 (10:52 -0600)
committerJason Ish <jason.ish@oisf.net>
Fri, 11 Oct 2019 16:54:29 +0000 (10:54 -0600)
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.

suricata/update/engine.py

index 8d9512930a38e40f0bbf2b2a95ac63baadae9f75..dd996d36164ae75a673279b139707e06cc1396c1 100644 (file)
@@ -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