Date: Monday, August 2, 2021 @ 12:35:27 Author: eworm Revision: 421038
upgpkg: util-linux 2.37.1-3: libmount: fix setgroups() use Added: util-linux/trunk/0002-libmount-fix-setgroups-use.patch Modified: util-linux/trunk/PKGBUILD ---------------------------------------+ 0002-libmount-fix-setgroups-use.patch | 38 ++++++++++++++++++++++++++++++++ PKGBUILD | 5 +++- 2 files changed, 42 insertions(+), 1 deletion(-) Added: 0002-libmount-fix-setgroups-use.patch =================================================================== --- 0002-libmount-fix-setgroups-use.patch (rev 0) +++ 0002-libmount-fix-setgroups-use.patch 2021-08-02 12:35:27 UTC (rev 421038) @@ -0,0 +1,38 @@ +From 420e914c4cc4c2ba34fd75790ea194d7f4a47d2c Mon Sep 17 00:00:00 2001 +From: Karel Zak <[email protected]> +Date: Thu, 29 Jul 2021 11:50:48 +0200 +Subject: [PATCH] libmount: fix setgroups() use + +* keep process in single supplementary group, which is the real group ID for the process + +* make sure we have rights to call setgroups(), requires group permissions + +Fixes: https://github.com/karelzak/util-linux/issues/1398 +Signed-off-by: Karel Zak <[email protected]> +--- + include/c.h | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/include/c.h b/include/c.h +index c1e4c5ffc..a4504e3ba 100644 +--- a/include/c.h ++++ b/include/c.h +@@ -340,14 +340,16 @@ static inline size_t get_hostname_max(void) + + static inline int drop_permissions(void) + { ++ gid_t newgid = getgid(); ++ + errno = 0; + + /* drop supplementary groups */ +- if (setgroups(0, NULL) != 0) ++ if (geteuid() == 0 && setgroups(1, &newgid) != 0) + goto fail; + + /* drop GID */ +- if (setgid(getgid()) < 0) ++ if (setgid(newgid) < 0) + goto fail; + + /* drop UID */ Modified: PKGBUILD =================================================================== --- PKGBUILD 2021-08-02 12:31:20 UTC (rev 421037) +++ PKGBUILD 2021-08-02 12:35:27 UTC (rev 421038) @@ -7,7 +7,7 @@ _pkgmajor=2.37 _realver=${_pkgmajor}.1 pkgver=${_realver/-/} -pkgrel=2 +pkgrel=3 pkgdesc='Miscellaneous system utilities for Linux' url='https://github.com/karelzak/util-linux' arch=('x86_64') @@ -17,6 +17,7 @@ validpgpkeys=('B0C64D14301CC6EFAEDF60E4E4B71D5EEC39C284') # Karel Zak source=("https://www.kernel.org/pub/linux/utils/util-linux/v${_pkgmajor}/${pkgbase}-${_realver}.tar."{xz,sign} '0001-sulogin-fix-getpasswd.patch' + '0002-libmount-fix-setgroups-use.patch' pam-{login,common,runuser,su} 'util-linux.sysusers' '60-rfkill.rules' @@ -25,6 +26,7 @@ sha256sums=('8e4bd42053b726cf86eb4d13a73bc1d9225a2c2e1a2e0d2a891f1020f83e6b76' 'SKIP' '00d526cfaca8979e433c7379c634cf14e700322f0ed0c5a7996af1c900147268' + '56fbc491b999aa18113237f28d399045a6d66678353b3619ab8da2f8518d2a4d' '99cd77f21ee44a0c5e57b0f3670f711a00496f198fc5704d7e44f5d817c81a0f' '57e057758944f4557762c6def939410c04ca5803cbdd2bfa2153ce47ffe7a4af' '48d6fba767631e3dd3620cf02a71a74c5d65a525d4c4ce4b5a0b7d9f41ebfea1' @@ -38,6 +40,7 @@ cd "${pkgbase}-${_realver}" patch -Np1 < ../0001-sulogin-fix-getpasswd.patch + patch -Np1 < ../0002-libmount-fix-setgroups-use.patch } build() {
