From 8d85efae91ad430c8f7e80b23ef3c509ade879fd Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Sat, 14 Oct 2023 05:14:40 +0800 Subject: [PATCH] core/exec-invoke: rename parameters of get_fixed_{user,group} Follow-up for 1c9433559a40982785011aa187e2b34420a67e7e The user/group passed in could be either the name or the uid/gid. --- src/core/exec-invoke.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index ea39e0aff12c4..72aa05780e596 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -888,8 +888,8 @@ static int ask_for_confirmation(const ExecContext *context, const ExecParameters } static int get_fixed_user( - const char *username, - const char **ret_user, + const char *user_or_uid, + const char **ret_username, uid_t *ret_uid, gid_t *ret_gid, const char **ret_home, @@ -897,35 +897,39 @@ static int get_fixed_user( int r; - assert(username); - assert(ret_user); + assert(user_or_uid); + assert(ret_username); /* Note that we don't set $HOME or $SHELL if they are not particularly enlightening anyway * (i.e. are "/" or "/bin/nologin"). */ - r = get_user_creds(&username, ret_uid, ret_gid, ret_home, ret_shell, USER_CREDS_CLEAN); + r = get_user_creds(&user_or_uid, ret_uid, ret_gid, ret_home, ret_shell, USER_CREDS_CLEAN); if (r < 0) return r; - *ret_user = username; + /* user_or_uid is normalized by get_user_creds to username */ + *ret_username = user_or_uid; + return 0; } static int get_fixed_group( - const char *groupname, - const char **ret_group, + const char *group_or_gid, + const char **ret_groupname, gid_t *ret_gid) { int r; - assert(groupname); - assert(ret_group); + assert(group_or_gid); + assert(ret_groupname); - r = get_group_creds(&groupname, ret_gid, /* flags = */ 0); + r = get_group_creds(&group_or_gid, ret_gid, /* flags = */ 0); if (r < 0) return r; - *ret_group = groupname; + /* group_or_gid is normalized by get_group_creds to groupname */ + *ret_groupname = group_or_gid; + return 0; }