]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
config: use config file in sysconfdir by default.
authorEric Leblond <eric@regit.org>
Sun, 10 Jun 2012 18:23:55 +0000 (20:23 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 11 Jun 2012 14:05:49 +0000 (16:05 +0200)
src/Makefile.am
src/suricata.c
src/suricata.h
src/util-classification-config.c
src/util-reference-config.c
src/util-threshold-config.c

index 23f6dbe41eeb061f1d293ae4ac64249920426768..363f0b95396974e9ecb3210e36dc9b6c179a4a5e 100644 (file)
@@ -5,6 +5,9 @@ noinst_HEADERS = action-globals.h \
        suricata-common.h threadvars.h util-binsearch.h \
     util-atomic.h util-validate.h
 bin_PROGRAMS = suricata
+
+AM_CPPFLAGS = -DCONFIG_DIR=\"$(sysconfdir)\"
+
 suricata_SOURCES = suricata.c suricata.h \
 runmodes.c runmodes.h \
 runmode-pcap.c runmode-pcap.h \
index cc6d4e6ce8702dc07a2dfd16a4b257d97922bdb4..1d71725ac07cc5567cfe46f6f671322fdd057385 100644 (file)
@@ -1202,6 +1202,12 @@ int main(int argc, char **argv)
     /* load the pattern matchers */
     MpmTableSetup();
 
+    if (run_mode != RUNMODE_UNITTEST &&
+            !list_keywords &&
+            !list_app_layer_protocols) {
+        conf_filename = DEFAULT_CONF_FILE;
+    }
+
     /** \todo we need an api for these */
     /* Load yaml configuration file if provided. */
     if (conf_filename != NULL) {
@@ -1229,13 +1235,6 @@ int main(int argc, char **argv)
                 }
             }
         }
-
-    } else if (run_mode != RUNMODE_UNITTEST &&
-                !list_keywords &&
-                !list_app_layer_protocols) {
-        SCLogError(SC_ERR_OPENING_FILE, "Configuration file has not been provided");
-        usage(argv[0]);
-        exit(EXIT_FAILURE);
     }
 
     AppLayerDetectProtoThreadInit();
index abbd79ec4a1c47d9e6da790f6f50c0412be37ca8..673e863732b3eeef0365960c8ab39605023e463a 100644 (file)
 #define PROG_NAME "Suricata"
 #define PROG_VER "1.3dev"
 
+/* workaround SPlint error (don't know __gnuc_va_list) */
+#ifdef S_SPLINT_S
+#  include <err.h>
+#  define CONFIG_DIR "/etc/suricata"
+#endif
+
+#define DEFAULT_CONF_FILE CONFIG_DIR "/suricata.yaml"
+
+
 /* runtime engine control flags */
 #define SURICATA_STOP    0x01   /**< gracefully stop the engine: process all
                                      outstanding packets first */
index 069db2051047943d31cd3769c05851e1025ac9d5..ce3da6ec0ecafb0b75df3f7c84c9424b2b4054f7 100644 (file)
@@ -41,7 +41,7 @@
 #define DETECT_CLASSCONFIG_REGEX "^\\s*config\\s*classification\\s*:\\s*([a-zA-Z][a-zA-Z0-9-_]*)\\s*,\\s*(.+)\\s*,\\s*(\\d+)\\s*$"
 
 /* Default path for the classification.config file */
-#define SC_CLASS_CONF_DEF_CONF_FILEPATH "classification.config"
+#define SC_CLASS_CONF_DEF_CONF_FILEPATH CONFIG_DIR "/classification.config"
 
 /* Holds a pointer to the default path for the classification.config file */
 static const char *default_file_path = SC_CLASS_CONF_DEF_CONF_FILEPATH;
index d1367351655c0d47f0c8a51b4ea7f7bea0c1fafc..86a17baaab905a412893ab9ef5e84e3e5814da10 100644 (file)
@@ -39,7 +39,7 @@
 #define SC_RCONF_REGEX "^\\s*config\\s+reference\\s*:\\s*([a-zA-Z][a-zA-Z0-9-_]*)\\s+(.+)\\s*$"
 
 /* Default path for the reference.conf file */
-#define SC_RCONF_DEFAULT_FILE_PATH "reference.config"
+#define SC_RCONF_DEFAULT_FILE_PATH CONFIG_DIR "/reference.config"
 
 /* Holds a pointer to the default path for the reference.config file */
 static const char *file_path = SC_RCONF_DEFAULT_FILE_PATH;
index a250561e7044b6411ccb2a32f0b19ede8d25f067..6eb4c0501c98664c85c396a88d64ca1f27d67243 100644 (file)
@@ -75,7 +75,7 @@ typedef enum ThresholdRuleType {
 #define DETECT_SUPPRESS_REGEX "^,\\s*track\\s*(by_dst|by_src)\\s*,\\s*ip\\s*([\\d.:/]+)*\\s*$"
 
 /* Default path for the threshold.config file */
-#define THRESHOLD_CONF_DEF_CONF_FILEPATH "threshold.config"
+#define THRESHOLD_CONF_DEF_CONF_FILEPATH CONFIG_DIR "/threshold.config"
 
 static pcre *regex_base = NULL;
 static pcre_extra *regex_base_study = NULL;