]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
privs: hint the user of unset user/group name
authorLukas Sismis <lsismis@oisf.net>
Fri, 8 Sep 2023 09:13:01 +0000 (11:13 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 2 Nov 2023 19:49:27 +0000 (20:49 +0100)
Ticket: #6278

src/util-privs.c

index 7e6f20bb1a7ac6c50c0736450b2bbe45d3ff43f1..b08516b650e06dfe480fffd9dac999bc388d334c 100644 (file)
@@ -153,6 +153,11 @@ int SCGetUserID(const char *user_name, const char *group_name, uint32_t *uid, ui
     uint32_t groupid = 0;
     struct passwd *pw;
 
+    if (user_name == NULL || strlen(user_name) == 0) {
+        FatalError("no user name was provided - ensure it is specified either in the configuration "
+                   "file (run-as.user) or in command-line arguments (--user)");
+    }
+
     /* Get the user ID */
     if (isdigit((unsigned char)user_name[0]) != 0) {
         if (ByteExtractStringUint32(&userid, 10, 0, (const char *)user_name) < 0) {
@@ -216,6 +221,11 @@ int SCGetGroupID(const char *group_name, uint32_t *gid)
     uint32_t grpid = 0;
     struct group *gp;
 
+    if (group_name == NULL || strlen(group_name) == 0) {
+        FatalError("no group name was provided - ensure it is specified either in the "
+                   "configuration file (run-as.group) or in command-line arguments (--group)");
+    }
+
     /* Get the group ID */
     if (isdigit((unsigned char)group_name[0]) != 0) {
         if (ByteExtractStringUint32(&grpid, 10, 0, (const char *)group_name) < 0) {