diff options
author | Luca BRUNO <luca.bruno@coreos.com> | 2022-08-08 15:56:06 +0000 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-08-09 04:58:32 +0900 |
commit | 5ed47c4d230b9491339c16c6ea4181dfd293bc98 (patch) | |
tree | 76ce3b388e6b037f4b42f6e825014231e4601d46 /src/sysusers | |
parent | 6b6e45eb7386bb4399746b70f6f606caea450fed (diff) | |
download | systemd-5ed47c4d230b9491339c16c6ea4181dfd293bc98.tar.gz |
sysusers: properly process user entries with an explicit GID
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.
Diffstat (limited to 'src/sysusers')
-rw-r--r-- | src/sysusers/sysusers.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 9444244d29..901e8aaf02 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -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 |