From 7b4951c58ffce7e182219d6d9613726f04859cc5 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 2 Jan 2015 08:18:44 +0000 Subject: [PATCH] =?UTF-8?q?apparently,=20we=E2=80=99re=20supposed=20to=20s?= =?UTF-8?q?etuid()=20before=20seteuid()=20cf.=20https://bugs.debian.org/cg?= =?UTF-8?q?i-bin/bugreport.cgi=3Fbug=3D772597=20also,=20groups=20before=20?= =?UTF-8?q?users,=20methinks=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- misc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/misc.c b/misc.c index c6456aa..21dd42a 100644 --- a/misc.c +++ b/misc.c @@ -30,7 +30,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.221 2014/11/25 21:13:29 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.222 2015/01/02 08:18:44 tg Exp $"); #define KSH_CHVT_FLAG #ifdef MKSH_SMALL @@ -281,15 +281,15 @@ change_flag(enum sh_flag f, int what, bool newset) #endif DO_SETUID(setresuid, (ksheuid, ksheuid, ksheuid)); #else /* !HAVE_SETRESUGID */ - /* seteuid, setegid, setgid don't EAGAIN on Linux */ -#ifndef MKSH__NO_SETEUGID - seteuid(ksheuid); -#endif - DO_SETUID(setuid, (ksheuid)); + /* setgid, setegid, seteuid don't EAGAIN on Linux */ + setgid(kshegid); #ifndef MKSH__NO_SETEUGID setegid(kshegid); #endif - setgid(kshegid); + DO_SETUID(setuid, (ksheuid)); +#ifndef MKSH__NO_SETEUGID + seteuid(ksheuid); +#endif #endif /* !HAVE_SETRESUGID */ } else if ((f == FPOSIX || f == FSH) && newval) { /* Turning on -o posix or -o sh? */