summaryrefslogtreecommitdiffstats
path: root/sys-apps/util-linux/files/util-linux-2.13-setuid-checks.patch
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-09-01 00:00:32 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-09-01 00:00:32 +0200
commitca9627e70852f6b2e835660df870fe3ab405882d (patch)
tree0a008b1d5b16fa0679a195ed7b5662c7891f591c /sys-apps/util-linux/files/util-linux-2.13-setuid-checks.patch
downloaddarklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.gz
darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.bz2
darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.tar.xz
darklin4-ca9627e70852f6b2e835660df870fe3ab405882d.zip
Initial import
Diffstat (limited to 'sys-apps/util-linux/files/util-linux-2.13-setuid-checks.patch')
-rw-r--r--sys-apps/util-linux/files/util-linux-2.13-setuid-checks.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/sys-apps/util-linux/files/util-linux-2.13-setuid-checks.patch b/sys-apps/util-linux/files/util-linux-2.13-setuid-checks.patch
new file mode 100644
index 0000000..a3758dd
--- /dev/null
+++ b/sys-apps/util-linux/files/util-linux-2.13-setuid-checks.patch
@@ -0,0 +1,52 @@
+From: Ludwig Nussel <ludwig.nussel@suse.de>
+Date: Thu, 20 Sep 2007 12:57:20 +0000 (+0200)
+Subject: mount: doesn't drop privileges properly when calling helpers
+X-Git-Url: http://git.kernel.org/?p=utils%2Futil-linux-ng%2Futil-linux-ng.git;a=commitdiff_plain;h=ebbeb2c7ac1b00b6083905957837a271e80b187e
+
+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)