]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Add a --set command line option to set/override a configuration value.
authorJason Ish <jason.ish@emulex.com>
Wed, 4 Dec 2013 06:00:07 +0000 (00:00 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 4 Feb 2014 15:03:00 +0000 (16:03 +0100)
src/suricata.c

index 8df3bfb8ae3cba1d301906d986eea24f3b9057bd..64316c9abf65731def337fc484e74f7caae26b15 100644 (file)
@@ -565,6 +565,7 @@ void usage(const char *progname)
 #ifdef HAVE_MPIPE
     printf("\t--mpipe                              : run with tilegx mpipe interface(s)\n");
 #endif
+    printf("\t--set name=value                     : set a configuration value\n");
     printf("\n");
     printf("\nTo run the engine with default configuration on "
             "interface eth0 with signature file \"signatures.rules\", run the "
@@ -1054,6 +1055,7 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
 #ifdef HAVE_MPIPE
         {"mpipe", optional_argument, 0, 0},
 #endif
+        {"set", required_argument, 0, 0},
         {NULL, 0, NULL, 0}
     };
 
@@ -1338,6 +1340,20 @@ static TmEcode ParseCommandLine(int argc, char** argv, SCInstance *suri)
                 }
             }
 #endif
+            else if (strcmp((long_opts[option_index]).name, "set") == 0) {
+                char *val = strchr(optarg, '=');
+                if (val == NULL) {
+                    SCLogError(SC_ERR_CMD_LINE,
+                        "Invalid argument for --set, must be key=val.");
+                    exit(EXIT_FAILURE);
+                }
+                *val++ = '\0';
+                if (ConfSetFinal(optarg, val) != 1) {
+                    fprintf(stderr, "Failed to set configuration value %s.",
+                        optarg);
+                    exit(EXIT_FAILURE);
+                }
+            }
             break;
         case 'c':
             conf_filename = optarg;