]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysusers: properly process user entries with an explicit GID
authorLuca BRUNO <luca.bruno@coreos.com>
Mon, 8 Aug 2022 15:56:06 +0000 (15:56 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 8 Aug 2022 19:58:32 +0000 (04:58 +0900)
This tweaks user creation logic to properly take into consideration
an explicitly requested GID.
It fixes a bug where the creation flow would mistakenly fall back
to use the username instead, resulting in wrong lookups in case of
users and groups using the same name.

src/sysusers/sysusers.c

index 9444244d29c4dae127e536b005c7f066f67bfa64..901e8aaf02e001dba6c816eed73a961e72cfcd41 100644 (file)
@@ -1348,9 +1348,11 @@ static int process_item(Item *i) {
         switch (i->type) {
 
         case ADD_USER: {
-                Item *j;
+                Item *j = NULL;
+
+                if (!i->gid_set)
+                        j = ordered_hashmap_get(groups, i->group_name ?: i->name);
 
-                j = ordered_hashmap_get(groups, i->group_name ?: i->name);
                 if (j && j->todo_group) {
                         /* When a group with the target name is already in queue,
                          * use the information about the group and do not create