From e239a8358a1a6901ed14c060636ea81b6f4ae375 Mon Sep 17 00:00:00 2001 From: tg Date: Fri, 3 Oct 2014 17:19:27 +0000 Subject: [PATCH] use issetugid(2) as additional aid in determining if we are FPRIVILEGED --- Build.sh | 9 +++++++-- main.c | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Build.sh b/Build.sh index a90ac6d..5381c9d 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.666 2014/09/29 18:57:00 tg Exp $' +srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.667 2014/10/03 17:19:26 tg Exp $' #- # Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011, 2012, 2013, 2014 @@ -1784,7 +1784,7 @@ else #define EXTERN #define MKSH_INCLUDES_ONLY #include "sh.h" - __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.666 2014/09/29 18:57:00 tg Exp $"); + __RCSID("$MirOS: src/bin/mksh/Build.sh,v 1.667 2014/10/03 17:19:26 tg Exp $"); int main(void) { printf("Hello, World!\n"); return (isatty(0)); } EOF case $cm in @@ -1904,6 +1904,11 @@ ac_test gettimeofday <<-'EOF' int main(void) { struct timeval tv; return (gettimeofday(&tv, NULL)); } EOF +ac_test issetugid <<-'EOF' + #include + int main(void) { return (issetugid()); } +EOF + ac_test killpg <<-'EOF' #include int main(int ac, char *av[]) { return (av[0][killpg(123, ac)]); } diff --git a/main.c b/main.c index a288ed5..f12d9b9 100644 --- a/main.c +++ b/main.c @@ -34,7 +34,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.283 2014/10/02 13:55:16 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.284 2014/10/03 17:19:27 tg Exp $"); extern char **environ; @@ -407,7 +407,11 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp) setint_n((vp_pipest = global("PIPESTATUS")), 0, 10); /* Set this before parsing arguments */ - Flag(FPRIVILEGED) = (kshuid != ksheuid || kshgid != kshegid) ? 2 : 0; + Flag(FPRIVILEGED) = ( +#if HAVE_ISSETUGID + issetugid() || +#endif + kshuid != ksheuid || kshgid != kshegid) ? 2 : 0; /* this to note if monitor is set on command line (see below) */ #ifndef MKSH_UNEMPLOYED