Skip to content

Commit

Permalink
Copy environment before modify when running Suricata.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jasonish committed Oct 11, 2019
1 parent 6c52c04 commit e735821
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions suricata/update/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,8 @@ def is_true(self, key, truthy=[]):

@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:
Expand Down Expand Up @@ -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

0 comments on commit e735821

Please sign in to comment.