]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rules: use primary default-rule-path if set on command line 10313/head 10323/head
authorJason Ish <jason.ish@oisf.net>
Wed, 4 May 2022 19:18:09 +0000 (13:18 -0600)
committerJeff Lucovsky <jlucovsky@oisf.net>
Mon, 5 Feb 2024 13:37:17 +0000 (08:37 -0500)
When reloading rules, respect `--set default-rule-path=...` from the
command line if set.

Previously the rule reload would always take the default-rule-path from
the configuration file, even if overrided on the command line.

Issue: #1911
(cherry picked from commit 3ea6572e22d9ffcb26d9d408a91a3c0a5291c847)

src/detect-engine-loader.c

index 99364a0a249ad78ccafde0ec44eb038872697297..f83dbc076f1f78e8e4843dff696b0760a0fc7b54 100644 (file)
@@ -68,11 +68,17 @@ char *DetectLoadCompleteSigPath(const DetectEngineCtx *de_ctx, const char *sig_f
         return NULL;
     }
 
-    if (strlen(de_ctx->config_prefix) > 0) {
+    /* If we have a configuration prefix, only use it if the primary configuration node
+     * is not marked as final, as that means it was provided on the command line with
+     * a --set. */
+    ConfNode *default_rule_path = ConfGetNode("default-rule-path");
+    if ((!default_rule_path || !default_rule_path->final) && strlen(de_ctx->config_prefix) > 0) {
         snprintf(varname, sizeof(varname), "%s.default-rule-path",
                 de_ctx->config_prefix);
-    } else {
-        snprintf(varname, sizeof(varname), "default-rule-path");
+        default_rule_path = ConfGetNode(varname);
+    }
+    if (default_rule_path) {
+        defaultpath = default_rule_path->val;
     }
 
     /* Path not specified */