From: Jason Ish Date: Mon, 9 Jul 2018 16:57:26 +0000 (-0600) Subject: config: save the filename that was used for the config X-Git-Tag: 1.0.0rc1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c144900c791566fa9ac3db50adcf5eb3a38d6a66;p=thirdparty%2Fsuricata-update.git config: save the filename that was used for the config So it can be presented to the user in log messages, specifically when listing enabled sources that are in the main configuration file. Fixes issue: https://redmine.openinfosecfoundation.org/issues/2526 --- diff --git a/suricata/update/config.py b/suricata/update/config.py index 891e315..5a6f4de 100644 --- a/suricata/update/config.py +++ b/suricata/update/config.py @@ -89,6 +89,9 @@ DEFAULT_CONFIG = { _args = None _config = {} +# The filename the config was read from, if any. +filename = None + def set(key, value): """Set a configuration value.""" _config[key] = value @@ -143,6 +146,7 @@ def get_arg(key): def init(args): global _args + global filename _args = args _config.update(DEFAULT_CONFIG) @@ -153,12 +157,14 @@ def init(args): config = yaml.safe_load(fileobj) if config: _config.update(config) + filename = args.config elif os.path.exists(DEFAULT_UPDATE_YAML_PATH): logger.info("Loading %s", DEFAULT_UPDATE_YAML_PATH) with open(DEFAULT_UPDATE_YAML_PATH, "rb") as fileobj: config = yaml.safe_load(fileobj) if config: _config.update(config) + filename = DEFAULT_UPDATE_YAML_PATH # Apply command line arguments to the config.