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) && (WEXITSTATUS(waitb)!=0)) || WIFSIGNALED(waitb) ) {
114 /* This is not really correct. It will cause teh moira server to
115 report a bogus error message if the script died on a signal.
116 However this is the same thing that occurs in the non-POSIX
117 case, and I don't know how to come up with a useful error based
118 on the signal recieved.
120 n = WEXITSTATUS(waitb) + ERROR_TABLE_BASE_sms;
121 log_priority = log_ERROR;
122 com_err(whoami, n, " child exited with status %d",
125 if (waitb.w_status) {
126 n = waitb.w_retcode + ERROR_TABLE_BASE_sms;
127 log_priority = log_ERROR;
128 com_err(whoami, n, " child exited with status %d",
131 code = send_object(conn, (char *)&n, INTEGER_T);