From: Karel Zak Date: Thu, 29 Jul 2021 18:37:32 +0000 (+0200) Subject: libmount: don't use setgroups at all() X-Git-Tag: v2.38-rc1~335 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c6d0ea9844fb502e79e558a4ef79ab4e4746afe6;p=thirdparty%2Futil-linux.git 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 --- diff --git a/include/c.h b/include/c.h index a4504e3ba5..354b59e299 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 */