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>
29 extern CONNECTION conn;
30 extern int code, errno, uid;
33 #if defined(vax) || defined(ibm032)
34 #define WEXITSTATUS(waitb) ((waitb).w_retcode)
44 sigset_t mask,oldmask;
51 if (config_lookup("noexec")) {
53 code = send_object(conn, (char *)&code, INTEGER_T);
54 com_err(whoami, code, "Not allowed to execute");
62 sigaddset(&mask,SIGCHLD);
63 sigprocmask(SIG_BLOCK,&mask,&oldmask);
65 mask = sigblock(sigmask(SIGCHLD));
72 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
76 log_priority = log_ERROR;
77 com_err(whoami, errno, ": can't fork to run install script");
78 code = send_object(conn, (char *)&n, INTEGER_T);
83 if (setuid(uid) < 0) {
84 com_err(whoami, errno, "Unable to setuid to %d\n", uid);
88 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
92 execlp(str, str, (char *)NULL);
95 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
99 log_priority = log_ERROR;
100 com_err(whoami, n, ": %s", str);
101 (void) send_object(conn, (char *)&n, INTEGER_T);
106 } while (n != -1 && n != pid);
108 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
113 if (WIFEXITED(waitb)) {
114 n = WEXITSTATUS(waitb) + ERROR_TABLE_BASE_sms;
115 log_priority = log_ERROR;
116 com_err(whoami, n, " child exited with status %d",
119 if (waitb.w_status) {
120 n = waitb.w_retcode + ERROR_TABLE_BASE_sms;
121 log_priority = log_ERROR;
122 com_err(whoami, n, " child exited with status %d",
125 code = send_object(conn, (char *)&n, INTEGER_T);