summaryrefslogtreecommitdiffstats
path: root/src/core/exec-invoke.c
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2023-10-13 23:14:40 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-10-14 10:09:32 +0200
commit8d85efae91ad430c8f7e80b23ef3c509ade879fd (patch)
tree19d2d71fc9c4922732ddff92fcc5125ba0499888 /src/core/exec-invoke.c
parentMerge pull request #29569 from YHNdnzj/foreach-array (diff)
downloadsystemd-8d85efae91ad430c8f7e80b23ef3c509ade879fd.tar.xz
systemd-8d85efae91ad430c8f7e80b23ef3c509ade879fd.zip
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.
Diffstat (limited to 'src/core/exec-invoke.c')
-rw-r--r--src/core/exec-invoke.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c
index ea39e0aff1..72aa05780e 100644
--- a/src/core/exec-invoke.c
+++ b/src/core/exec-invoke.c
@@ -888,8 +888,8 @@ restore_stdio:
}
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;
}