From 5b4ba0fe46f5e4ec79f9d6388e0458b25c31f8c4 Mon Sep 17 00:00:00 2001 From: Lukas Sismis Date: Fri, 8 Sep 2023 11:13:01 +0200 Subject: [PATCH] privs: hint the user of unset user/group name Ticket: #6278 --- src/util-privs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) { -- 2.47.2