core: do not fail in a container if we can't use setgroups

It might be blocked through /proc/PID/setgroups
This commit is contained in:
Giuseppe Scrivano
2016-10-06 11:49:00 +02:00
parent f006b30bd5
commit 36d854780c
4 changed files with 31 additions and 3 deletions
+2 -1
View File
@@ -31,6 +31,7 @@
#include "log.h"
#include "macro.h"
#include "parse-util.h"
#include "user-util.h"
#include "util.h"
int have_effective_cap(int value) {
@@ -295,7 +296,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
if (setresgid(gid, gid, gid) < 0)
return log_error_errno(errno, "Failed to change group ID: %m");
if (setgroups(0, NULL) < 0)
if (maybe_setgroups(0, NULL) < 0)
return log_error_errno(errno, "Failed to drop auxiliary groups list: %m");
/* Ensure we keep the permitted caps across the setresuid() */