diff --git a/src/Makefile.am b/src/Makefile.am index 23f6dbe41e..363f0b9539 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/suricata.c b/src/suricata.c index cc6d4e6ce8..1d71725ac0 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -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(); diff --git a/src/suricata.h b/src/suricata.h index abbd79ec4a..673e863732 100644 --- a/src/suricata.h +++ b/src/suricata.h @@ -73,6 +73,15 @@ #define PROG_NAME "Suricata" #define PROG_VER "1.3dev" +/* workaround SPlint error (don't know __gnuc_va_list) */ +#ifdef S_SPLINT_S +# include +# 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 */ diff --git a/src/util-classification-config.c b/src/util-classification-config.c index 069db20510..ce3da6ec0e 100644 --- a/src/util-classification-config.c +++ b/src/util-classification-config.c @@ -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; diff --git a/src/util-reference-config.c b/src/util-reference-config.c index d136735165..86a17baaab 100644 --- a/src/util-reference-config.c +++ b/src/util-reference-config.c @@ -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; diff --git a/src/util-threshold-config.c b/src/util-threshold-config.c index a250561e70..6eb4c0501c 100644 --- a/src/util-threshold-config.c +++ b/src/util-threshold-config.c @@ -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;