]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
conf: user-configurable umask setting
authorMats Klepsland <mats.klepsland@gmail.com>
Tue, 21 Feb 2017 11:06:17 +0000 (12:06 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 20 Mar 2018 15:27:22 +0000 (16:27 +0100)
Make umask user-configurable by setting 'umask' in suricata.yaml.

src/suricata.c
src/util-daemon.c
suricata.yaml.in

index 10d5fcd823aa6508b5c7aabc8c8c67e5fba96265..0258e2c7cfb35144ef57da6f69ddcc458131f95b 100644 (file)
 #include "util-debug.h"
 #include "util-error.h"
 #include "util-daemon.h"
+#include "util-byte.h"
 #include "reputation.h"
 
 #include "output.h"
@@ -2577,6 +2578,17 @@ static int PostConfLoadedSetup(SCInstance *suri)
 #endif
     AppLayerSetup();
 
+    /* Suricata will use this umask if provided. By default it will use the
+       umask passed on from the shell. */
+    const char *custom_umask;
+    if (ConfGet("umask", &custom_umask) == 1) {
+        uint16_t mask;
+        if (ByteExtractStringUint16(&mask, 8, strlen(custom_umask),
+                                    custom_umask) > 0) {
+            umask((mode_t)mask);
+        }
+    }
+
     /* Check for the existance of the default logging directory which we pick
      * from suricata.yaml.  If not found, shut the engine down */
     suri->log_dir = ConfigGetLogDirectory();
index 5eba5a6cdf39296b318745061b8364f22292a9b0..ee2d625a00e996ea21d4f9e252d439a0d9d8abee 100644 (file)
@@ -121,8 +121,6 @@ void Daemonize (void)
         /* Child continues here */
         const char *daemondir;
 
-        umask(027);
-
         sid = setsid();
         if (sid < 0) {
             SCLogError(SC_ERR_DAEMON, "Error creating new session");
index 02333e98299b73a2cbc569293bff839484af4430..662f1a610371f4fce76efa6ffc1cd8f1c1ab63e9 100644 (file)
@@ -1046,6 +1046,11 @@ asn1-max-frames: 256
 # Default: "/"
 #daemon-directory: "/"
 
+# Umask.
+# Suricata will use this umask if it is provided. By default it will use the
+# umask passed on by the shell.
+#umask: 022
+
 # Suricata core dump configuration. Limits the size of the core dump file to
 # approximately max-dump. The actual core dump size will be a multiple of the
 # page size. Core dumps that would be larger than max-dump are truncated. On