use issetugid(2) as additional aid in determining if we are FPRIVILEGED

This commit is contained in:
tg 2014-10-03 17:19:27 +00:00
parent 478a2af837
commit e239a8358a
2 changed files with 13 additions and 4 deletions

View File

@ -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 <unistd.h>
int main(void) { return (issetugid()); }
EOF
ac_test killpg <<-'EOF'
#include <signal.h>
int main(int ac, char *av[]) { return (av[0][killpg(123, ac)]); }

8
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#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