Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37902526
en ru br
ALT Linux repos
S:2.39.2-alt1
5.0: 2.14.1-alt1
4.1: 2.13-alt8
4.0: 2.12r-alt6
3.0: 2.12q-alt1

Group :: System/Base
RPM: util-linux

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: util-linux-2.13-rh-mount-drop-privileges.patch
Download


commit ebbeb2c7ac1b00b6083905957837a271e80b187e
Author: Ludwig Nussel <ludwig.nussel@suse.de>
Date:   Thu Sep 20 14:57:20 2007 +0200
    mount: doesn't drop privileges properly when calling helpers
    {,u}mount calls setuid() and setgid() in the wrong order and doesn't checking
    the return value of set{u,g}id(() when running helpers like mount.nfs.
    Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
    Signed-off-by: Karel Zak <kzak@redhat.com>
diff --git a/mount/mount.c b/mount/mount.c
index 40699f3..5bc2b30 100644
--- a/mount/mount.c
+++ b/mount/mount.c
@@ -634,8 +634,12 @@ check_special_mountprog(const char *spec, const char *node, const char *type, in
 		 char *oo, *mountargs[10];
 		 int i = 0;
 
-		 setuid(getuid());
-		 setgid(getgid());
+		 if(setgid(getgid()) < 0)
+			 die(EX_FAIL, _("mount: cannot set group id: %s"), strerror(errno));
+
+		 if(setuid(getuid()) < 0)
+			 die(EX_FAIL, _("mount: cannot set user id: %s"), strerror(errno));
+
 		 oo = fix_opts_string (flags, extra_opts, NULL);
 		 mountargs[i++] = mountprog;				/* 1 */
 		 mountargs[i++] = (char *) spec;			/* 2 */
diff --git a/mount/umount.c b/mount/umount.c
index b3100c9..3221619 100644
--- a/mount/umount.c
+++ b/mount/umount.c
@@ -102,8 +102,12 @@ check_special_umountprog(const char *spec, const char *node,
 				char *umountargs[8];
 				int i = 0;
 
-				setuid(getuid());
-				setgid(getgid());
+				if(setgid(getgid()) < 0)
+					die(EX_FAIL, _("umount: cannot set group id: %s"), strerror(errno));
+
+				if(setuid(getuid()) < 0)
+					die(EX_FAIL, _("umount: cannot set user id: %s"), strerror(errno));
+
 				umountargs[i++] = umountprog;
 				umountargs[i++] = xstrdup(node);
 				if (nomtab)
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin