mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
core: fix gid when DynamicUser=yes with static User=
When DynamicUser=yes and static User= are set, and the user has
different uid and gid, then as the storage socket for the dynamic
user does not contains gid, we need to obtain gid.
Follow-up for 9ec655cbbd.
Fixes #9702.
This commit is contained in:
@@ -525,6 +525,16 @@ static int dynamic_user_realize(
|
||||
num = new_uid;
|
||||
uid_lock_fd = new_uid_lock_fd;
|
||||
}
|
||||
} else if (is_user && !uid_is_dynamic(num)) {
|
||||
struct passwd *p;
|
||||
|
||||
/* Statically allocated user may have different uid and gid. So, let's obtain the gid. */
|
||||
errno = 0;
|
||||
p = getpwuid(num);
|
||||
if (!p)
|
||||
return errno > 0 ? -errno : -ESRCH;
|
||||
|
||||
gid = p->pw_gid;
|
||||
}
|
||||
|
||||
/* If the UID/GID was already allocated dynamically, push the data we popped out back in. If it was already
|
||||
|
||||
Reference in New Issue
Block a user