From 54cb0dd60ca3768fffe70d62400936bf387389bc Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 29 Jul 2021 20:37:32 +0200 Subject: [PATCH] libmount: don't use setgroups at all() It's probably good idea to call setgroups() to cleanup groups, but it introduces a regression as some mount helpers depend on supplementary groups like "network" etc. Fixes: https://github.com/karelzak/util-linux/issues/1398 Signed-off-by: Karel Zak --- include/c.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/include/c.h b/include/c.h index a4504e3ba..354b59e29 100644 --- a/include/c.h +++ b/include/c.h @@ -340,16 +340,10 @@ static inline size_t get_hostname_max(void) static inline int drop_permissions(void) { - gid_t newgid = getgid(); - errno = 0; - /* drop supplementary groups */ - if (geteuid() == 0 && setgroups(1, &newgid) != 0) - goto fail; - /* drop GID */ - if (setgid(newgid) < 0) + if (setgid(getgid()) < 0) goto fail; /* drop UID */