summaryrefslogtreecommitdiffstats
path: root/src/core/dynamic-user.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-07-26 04:42:54 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-07-26 08:38:18 +0200
commit25a1df7c652d180eb716412885c3ce3fcc1bbded (patch)
tree7f85b0e9a2d521bdd9433d851bcf52f47cc9b567 /src/core/dynamic-user.c
parentMerge pull request #9667 from poettering/pam_systemd-fixes (diff)
downloadsystemd-25a1df7c652d180eb716412885c3ce3fcc1bbded.tar.xz
systemd-25a1df7c652d180eb716412885c3ce3fcc1bbded.zip
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 9ec655cbbd7505ef465e0444da0622e46099ce42. Fixes #9702.
Diffstat (limited to '')
-rw-r--r--src/core/dynamic-user.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/core/dynamic-user.c b/src/core/dynamic-user.c
index 7c5111ddf6..f380db553e 100644
--- a/src/core/dynamic-user.c
+++ b/src/core/dynamic-user.c
@@ -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