From e22ba3c8267252fe1680b339785e571416f22e6d Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Mon, 4 Jan 2010 11:33:44 +0530 Subject: [PATCH] check for the existance of default logging directory --- src/suricata-common.h | 1 + src/suricata.c | 14 ++++++++++++++ src/util-error.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-) diff --git a/src/suricata-common.h b/src/suricata-common.h index f19dd7c..0a996e9 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/src/suricata.c b/src/suricata.c index 1e16787..2736348 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -300,6 +300,9 @@ int main(int argc, char **argv) int list_unittests = 0; int daemon = 0; + char *log_dir; + struct stat buf; + /* initialize the logging subsys */ SCLogInitLogModule(NULL); @@ -445,6 +448,17 @@ int main(int argc, char **argv) exit(EXIT_SUCCESS); } + /* Check for the existance of the default logging directory which we pick + * from suricata.yaml. If not found, shut the engine down */ + if (ConfGet("default-log-dir", &log_dir) != 1) + log_dir = DEFAULT_LOG_DIR; + if (stat(log_dir, &buf) != 0) { + SCLogError(SC_ERR_STAT_ERROR, "The logging directory \"%s\" picked from " + "suricata.yaml(default-log-dir), doesn't exist. Shutting " + "down the engine", log_dir); + exit(EXIT_FAILURE); + } + /* Since our config is now loaded we can finish configurating the * logging module. */ SCLogLoadConfig(); diff --git a/src/util-error.h b/src/util-error.h index 950d7ef..e845874 100644 --- a/src/util-error.h +++ b/src/util-error.h @@ -84,6 +84,7 @@ typedef enum { SC_ERR_NO_URICONTENT_NEGATION, SC_ERR_FOPEN_ERROR, SC_ERR_HASH_TABLE_INIT_FAILED, + SC_ERR_STAT_ERROR, } SCError; const char *SCErrorToString(SCError); -- 1.5.5