]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
filestore: create file store directory if needed
authorEric Leblond <eric@regit.org>
Tue, 9 Oct 2012 10:56:17 +0000 (12:56 +0200)
committerEric Leblond <eric@regit.org>
Mon, 19 Nov 2012 22:52:19 +0000 (23:52 +0100)
This patch modifies the file store system to have it create the
file store directory if needed. It dos not create the full
directory tree as the parent directory must have already been
created.

src/log-filestore.c

index 645063a0bd38a4f7a985cc36147a902407f1a550..c6ea732008e1c40dce91e005e5b8aba0f0373a9f 100644 (file)
@@ -440,10 +440,21 @@ TmEcode LogFilestoreLogThreadInit(ThreadVars *t, void *initdata, void **data)
 
     struct stat stat_buf;
     if (stat(g_logfile_base_dir, &stat_buf) != 0) {
-        SCLogError(SC_ERR_LOGDIR_CONFIG, "The file drop directory \"%s\" "
-                "supplied doesn't exist. Shutting down the engine",
-                g_logfile_base_dir);
-        exit(EXIT_FAILURE);
+        int ret;
+        ret = mkdir(g_logfile_base_dir, S_IRWXU|S_IXGRP|S_IRGRP);
+        if (ret != 0) {
+            int err = errno;
+            if (err != EEXIST) {
+                SCLogError(SC_ERR_LOGDIR_CONFIG,
+                        "Cannot create file drop directory %s: %s",
+                        g_logfile_base_dir, strerror(err));
+                exit(EXIT_FAILURE);
+            }
+        } else {
+            SCLogInfo("Created file drop directory %s",
+                    g_logfile_base_dir);
+        }
+
     }
 
     *data = (void *)aft;