summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorDjalal Harouni <tixxdz@opendz.org>2016-11-03 11:48:28 +0100
committerGitHub <noreply@github.com>2016-11-03 11:48:28 +0100
commit34f139c52640f4791249e965a1d3d12be35077c1 (patch)
tree06c31a1f0806304cf51f67c65745fdb6958563c8 /src/core
parentb2c82a7f2f7c8ae426a9208fb79c5abbd5e3181c (diff)
parent5c67067f0e521aba061904c7bb3aa092281ef9c4 (diff)
Merge pull request #4543 from endocode/djalal/fix-dynamicuser-supplementary-groups
core: intialize user aux groups and SupplementaryGroups= when DynamicUser= is set
Diffstat (limited to 'src/core')
-rw-r--r--src/core/execute.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 3f053602b5..f13ca30395 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -773,11 +773,9 @@ static int get_fixed_group(const ExecContext *c, const char **group, gid_t *gid)
return 0;
}
-static int get_fixed_supplementary_groups(const ExecContext *c,
- const char *user,
- const char *group,
- gid_t gid,
- gid_t **supplementary_gids, int *ngids) {
+static int get_supplementary_groups(const ExecContext *c, const char *user,
+ const char *group, gid_t gid,
+ gid_t **supplementary_gids, int *ngids) {
char **i;
int r, k = 0;
int ngroups_max;
@@ -790,8 +788,8 @@ static int get_fixed_supplementary_groups(const ExecContext *c,
/*
* If user is given, then lookup GID and supplementary groups list.
* We avoid NSS lookups for gid=0. Also we have to initialize groups
- * as early as possible so we keep the list of supplementary groups
- * of the caller.
+ * here and as early as possible so we keep the list of supplementary
+ * groups of the caller.
*/
if (user && gid_is_valid(gid) && gid != 0) {
/* First step, initialize groups from /etc/groups */
@@ -2347,13 +2345,14 @@ static int exec_child(
*exit_status = EXIT_GROUP;
return r;
}
+ }
- r = get_fixed_supplementary_groups(context, username, groupname,
- gid, &supplementary_gids, &ngids);
- if (r < 0) {
- *exit_status = EXIT_GROUP;
- return r;
- }
+ /* Initialize user supplementary groups and get SupplementaryGroups= ones */
+ r = get_supplementary_groups(context, username, groupname, gid,
+ &supplementary_gids, &ngids);
+ if (r < 0) {
+ *exit_status = EXIT_GROUP;
+ return r;
}
r = send_user_lookup(unit, user_lookup_fd, uid, gid);