]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: don't use setgroups at all()
authorKarel Zak <kzak@redhat.com>
Thu, 29 Jul 2021 18:37:32 +0000 (20:37 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 29 Jul 2021 18:37:32 +0000 (20:37 +0200)
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 <kzak@redhat.com>
include/c.h

index a4504e3ba5398691f9aa172336cbb6580ae46b28..354b59e299cddc120eff24e16bfce2f02e4e4b31 100644 (file)
@@ -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 */