diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-09-21 18:21:53 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-09-21 18:21:53 +0200 |
commit | f1f679c5b680be14c1c83bc34d00ecf276927ba0 (patch) | |
tree | 6d76fb54e5e74c958f81cb2a86528296ef08395d /src/core/execute.c | |
parent | 35bb18851a2b07d2b7ca65c6722012cdc3399a32 (diff) | |
parent | 5bc7452b3219456e07f931e40da30bb94a884293 (diff) |
Merge pull request #1320 from ronnychevalier/rc/core_fix_group_ownership
core: fix group ownership when Group is set
Diffstat (limited to 'src/core/execute.c')
-rw-r--r-- | src/core/execute.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/execute.c b/src/core/execute.c index 3c308e3e3e..6e14848cd4 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -629,15 +629,6 @@ static int enforce_groups(const ExecContext *context, const char *username, gid_ * we avoid NSS lookups for gid=0. */ if (context->group || username) { - - if (context->group) { - const char *g = context->group; - - r = get_group_creds(&g, &gid); - if (r < 0) - return r; - } - /* First step, initialize groups from /etc/groups */ if (username && gid != 0) { if (initgroups(username, gid) < 0) @@ -1414,6 +1405,17 @@ static int exec_child( } } + if (context->group) { + const char *g = context->group; + + r = get_group_creds(&g, &gid); + if (r < 0) { + *exit_status = EXIT_GROUP; + return r; + } + } + + /* If a socket is connected to STDIN/STDOUT/STDERR, we * must sure to drop O_NONBLOCK */ if (socket_fd >= 0) |