From: Lukas Sismis Date: Fri, 8 Sep 2023 09:13:01 +0000 (+0200) Subject: privs: hint the user of unset user/group name X-Git-Tag: suricata-7.0.3~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b4ba0fe46f5e4ec79f9d6388e0458b25c31f8c4;p=thirdparty%2Fsuricata.git privs: hint the user of unset user/group name Ticket: #6278 --- diff --git a/src/util-privs.c b/src/util-privs.c index 7e6f20bb1a..b08516b650 100644 --- a/src/util-privs.c +++ b/src/util-privs.c @@ -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) {