scan for setresuid/setresgid and setgroups
no alternative implementation yet
This commit is contained in:
parent
5b525d79fb
commit
a799f50fea
14
Build.sh
14
Build.sh
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# $MirOS: src/bin/mksh/Build.sh,v 1.75 2006/11/10 07:18:56 tg Exp $
|
# $MirOS: src/bin/mksh/Build.sh,v 1.76 2006/11/12 12:56:09 tg Exp $
|
||||||
#-
|
#-
|
||||||
# Environment: CC, CFLAGS, CPPFLAGS, LDFLAGS, LIBS, NROFF
|
# Environment: CC, CFLAGS, CPPFLAGS, LDFLAGS, LIBS, NROFF
|
||||||
|
|
||||||
|
@ -236,6 +236,18 @@ ac_test setmode mksh_full 1 <<-'EOF'
|
||||||
int main(int ac, char *av[]) { setmode(av[0]); return (ac); }
|
int main(int ac, char *av[]) { setmode(av[0]); return (ac); }
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
ac_test setresugid <<-'EOF'
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
int main(void) { setresuid(0,0,0); return (setresgid(0,0,0)); }
|
||||||
|
EOF
|
||||||
|
|
||||||
|
ac_test setgroups setresugid 0 <<-'EOF'
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
int main(void) { gid_t gid = 0; return (setgroups(0, &gid)); }
|
||||||
|
EOF
|
||||||
|
|
||||||
ac_test strlcpy <<-'EOF'
|
ac_test strlcpy <<-'EOF'
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
int main(int ac, char *av[]) { strlcpy(av[0], av[1], 1); return (ac); }
|
int main(int ac, char *av[]) { strlcpy(av[0], av[1], 1); return (ac); }
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -1,11 +1,12 @@
|
||||||
# $MirOS: src/bin/mksh/Makefile,v 1.17 2006/11/09 15:03:56 tg Exp $
|
# $MirOS: src/bin/mksh/Makefile,v 1.18 2006/11/12 12:56:09 tg Exp $
|
||||||
|
|
||||||
PROG= mksh
|
PROG= mksh
|
||||||
SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \
|
SRCS= alloc.c edit.c eval.c exec.c expr.c funcs.c histrap.c \
|
||||||
jobs.c lex.c main.c misc.c shf.c syn.c tree.c var.c
|
jobs.c lex.c main.c misc.c shf.c syn.c tree.c var.c
|
||||||
CPPFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_ARC4RANDOM_PUSH -DHAVE_SYS_PARAM_H
|
CPPFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_ARC4RANDOM_PUSH -DHAVE_SYS_PARAM_H
|
||||||
CPPFLAGS+= -DHAVE_LANGINFO_CODESET -DHAVE_SETLOCALE_CTYPE
|
CPPFLAGS+= -DHAVE_LANGINFO_CODESET -DHAVE_SETLOCALE_CTYPE
|
||||||
CPPFLAGS+= -DHAVE_SETMODE -DHAVE_STRLCPY
|
CPPFLAGS+= -DHAVE_SETMODE -DHAVE_SETRESUGID -DHAVE_SETGROUPS
|
||||||
|
CPPFLAGS+= -DHAVE_STRLCPY
|
||||||
CDIAGFLAGS+= -Wno-cast-qual
|
CDIAGFLAGS+= -Wno-cast-qual
|
||||||
|
|
||||||
LINKS+= ${BINDIR}/${PROG} ${BINDIR}/sh
|
LINKS+= ${BINDIR}/${PROG} ${BINDIR}/sh
|
||||||
|
|
8
misc.c
8
misc.c
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.39 2006/11/10 19:11:57 tg Exp $\t"
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.40 2006/11/12 12:56:10 tg Exp $\t"
|
||||||
MKSH_SH_H_ID);
|
MKSH_SH_H_ID);
|
||||||
|
|
||||||
#undef USE_CHVT
|
#undef USE_CHVT
|
||||||
|
@ -239,11 +239,17 @@ change_flag(enum sh_flag f,
|
||||||
Flag(f) = newval;
|
Flag(f) = newval;
|
||||||
} else if (f == FPRIVILEGED && oldval && !newval) {
|
} else if (f == FPRIVILEGED && oldval && !newval) {
|
||||||
/* Turning off -p? */
|
/* Turning off -p? */
|
||||||
|
#if HAVE_SETRESUGID
|
||||||
gid_t kshegid = getgid();
|
gid_t kshegid = getgid();
|
||||||
|
|
||||||
setresgid(kshegid, kshegid, kshegid);
|
setresgid(kshegid, kshegid, kshegid);
|
||||||
|
#if HAVE_SETGROUPS
|
||||||
setgroups(1, &kshegid);
|
setgroups(1, &kshegid);
|
||||||
|
#endif
|
||||||
setresuid(ksheuid, ksheuid, ksheuid);
|
setresuid(ksheuid, ksheuid, ksheuid);
|
||||||
|
#else
|
||||||
|
#error setresid/setresgid required at the moment
|
||||||
|
#endif
|
||||||
} else if (f == FPOSIX && newval) {
|
} else if (f == FPOSIX && newval) {
|
||||||
Flag(FBRACEEXPAND) = 0;
|
Flag(FBRACEEXPAND) = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue