]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/exec-invoke: rename parameters of get_fixed_{user,group}
authorMike Yuan <me@yhndnzj.com>
Fri, 13 Oct 2023 21:14:40 +0000 (05:14 +0800)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 14 Oct 2023 08:09:32 +0000 (09:09 +0100)
Follow-up for 1c9433559a40982785011aa187e2b34420a67e7e

The user/group passed in could be either the name or the uid/gid.

src/core/exec-invoke.c

index ea39e0aff12c4ce631c2c490b8b508279966faee..72aa05780e596c13d7435bb3f072ffbe338e4c46 100644 (file)
@@ -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;
 }