diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/execute.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/core/execute.c b/src/core/execute.c index a9b2b8f299..53356c3c06 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -789,6 +789,19 @@ static int get_fixed_supplementary_groups(const ExecContext *c, return 0; /* + * If SupplementaryGroups= was passed then NGROUPS_MAX has to + * be positive, otherwise fail. + */ + errno = 0; + ngroups_max = (int) sysconf(_SC_NGROUPS_MAX); + if (ngroups_max <= 0) { + if (errno > 0) + return -errno; + else + return -EOPNOTSUPP; /* For all other values */ + } + + /* * If user is given, then lookup GID and supplementary group list. * We avoid NSS lookups for gid=0. */ @@ -800,8 +813,6 @@ static int get_fixed_supplementary_groups(const ExecContext *c, keep_groups = true; } - assert_se((ngroups_max = (int) sysconf(_SC_NGROUPS_MAX)) > 0); - l_gids = new(gid_t, ngroups_max); if (!l_gids) return -ENOMEM; |