privs: refactor SCGetUser/GroupID to void functions

SCGetUserID/SCGetGroupID either FatalErrored out or
returned zero. As a result, the functions got refactored
into non-returning void functions.
pull/9736/head
Lukas Sismis 3 years ago committed by Victor Julien
parent 5b4ba0fe46
commit 5300cb625e

@ -2155,20 +2155,11 @@ static int InitRunAs(SCInstance *suri)
}
/* Get the suricata user ID to given user ID */
if (suri->do_setuid == TRUE) {
if (SCGetUserID(suri->user_name, suri->group_name,
&suri->userid, &suri->groupid) != 0) {
SCLogError("failed in getting user ID");
return TM_ECODE_FAILED;
}
SCGetUserID(suri->user_name, suri->group_name, &suri->userid, &suri->groupid);
sc_set_caps = TRUE;
/* Get the suricata group ID to given group ID */
} else if (suri->do_setgid == TRUE) {
if (SCGetGroupID(suri->group_name, &suri->groupid) != 0) {
SCLogError("failed in getting group ID");
return TM_ECODE_FAILED;
}
SCGetGroupID(suri->group_name, &suri->groupid);
sc_set_caps = TRUE;
}
#endif

@ -145,9 +145,9 @@ void SCDropCaps(ThreadVars *tv)
* \param uid pointer to the user id in which result will be stored
* \param gid pointer to the group id in which result will be stored
*
* \retval upon success it return 0
* \retval FatalError on a failure
*/
int SCGetUserID(const char *user_name, const char *group_name, uint32_t *uid, uint32_t *gid)
void SCGetUserID(const char *user_name, const char *group_name, uint32_t *uid, uint32_t *gid)
{
uint32_t userid = 0;
uint32_t groupid = 0;
@ -204,8 +204,6 @@ int SCGetUserID(const char *user_name, const char *group_name, uint32_t *uid, ui
*uid = userid;
*gid = groupid;
return 0;
}
/**
@ -214,9 +212,9 @@ int SCGetUserID(const char *user_name, const char *group_name, uint32_t *uid, ui
* \param group_name pointer to the given group name
* \param gid pointer to the group id in which result will be stored
*
* \retval upon success it return 0
* \retval FatalError on a failure
*/
int SCGetGroupID(const char *group_name, uint32_t *gid)
void SCGetGroupID(const char *group_name, uint32_t *gid)
{
uint32_t grpid = 0;
struct group *gp;
@ -244,8 +242,6 @@ int SCGetGroupID(const char *group_name, uint32_t *gid)
endgrent();
*gid = grpid;
return 0;
}
#ifdef __OpenBSD__

@ -90,8 +90,8 @@ void SCDropMainThreadCaps(uint32_t , uint32_t );
#define SCDropMainThreadCaps(...)
#endif /* HAVE_LIBCAP_NG */
int SCGetUserID(const char *, const char *, uint32_t *, uint32_t *);
int SCGetGroupID(const char *, uint32_t *);
void SCGetUserID(const char *, const char *, uint32_t *, uint32_t *);
void SCGetGroupID(const char *, uint32_t *);
#ifdef __OpenBSD__
int SCPledge(void);

Loading…
Cancel
Save