From: mar Date: Tue, 25 Aug 1992 14:43:12 +0000 (+0000) Subject: handle "noexec" and "user" config options X-Git-Tag: release77~425 X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/8b3ba58ebf0a18a240e178ea05986f646e4cbe8d handle "noexec" and "user" config options --- diff --git a/update/exec_002.c b/update/exec_002.c index f02f2081..887c4b13 100644 --- a/update/exec_002.c +++ b/update/exec_002.c @@ -12,6 +12,7 @@ static char *rcsid_exec_002_c = "$Header$"; #include #include +#include #include #include #include @@ -20,7 +21,9 @@ static char *rcsid_exec_002_c = "$Header$"; #include "update.h" extern CONNECTION conn; -extern int code, errno; +extern int code, errno, uid; +extern char *whoami; + int exec_002(str) @@ -29,6 +32,12 @@ exec_002(str) union wait waitb; int n, pid, mask; + if (config_lookup("noexec")) { + code = EPERM; + code = send_object(conn, (char *)&code, INTEGER_T); + com_err(whoami, code, "Not allowed to execute"); + return; + } str += 8; while (*str == ' ') str++; @@ -45,6 +54,10 @@ exec_002(str) exit(1); return; case 0: + if (setuid(uid) < 0) { + com_err(whoami, errno, "Unable to setuid to %d\n", uid); + exit(1); + } sigsetmask(mask); execlp(str, str, (char *)NULL); n = errno;