5 /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */
6 /* For copying and distribution information, please see the file */
7 /* <mit-copyright.h>. */
10 static char *rcsid_exec_002_c = "$Header$";
13 #include <mit-copyright.h>
16 #include <sys/types.h>
23 extern CONNECTION conn;
24 extern int code, errno, uid;
27 #if defined(vax) || defined(ibm032)
28 #define WEXITSTATUS(waitb) ((waitb).w_retcode)
38 sigset_t mask,oldmask;
45 if (config_lookup("noexec")) {
47 code = send_object(conn, (char *)&code, INTEGER_T);
48 com_err(whoami, code, "Not allowed to execute");
56 sigaddset(&mask,SIGCHLD);
57 sigprocmask(SIG_BLOCK,&mask,&oldmask);
59 mask = sigblock(sigmask(SIGCHLD));
66 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
70 log_priority = log_ERROR;
71 com_err(whoami, errno, ": can't fork to run install script");
72 code = send_object(conn, (char *)&n, INTEGER_T);
77 if (setuid(uid) < 0) {
78 com_err(whoami, errno, "Unable to setuid to %d\n", uid);
82 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
86 execlp(str, str, (char *)NULL);
89 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
93 log_priority = log_ERROR;
94 com_err(whoami, n, ": %s", str);
95 (void) send_object(conn, (char *)&n, INTEGER_T);
100 } while (n != -1 && n != pid);
102 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
107 if (WIFEXITED(waitb)) {
108 n = WEXITSTATUS(waitb) + ERROR_TABLE_BASE_sms;
109 log_priority = log_ERROR;
110 com_err(whoami, n, " child exited with status %d",
113 if (waitb.w_status) {
114 n = waitb.w_retcode + ERROR_TABLE_BASE_sms;
115 log_priority = log_ERROR;
116 com_err(whoami, n, " child exited with status %d",
119 code = send_object(conn, (char *)&n, INTEGER_T);