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, log_priority, have_authorization;
33 #if defined(vax) || defined(ibm032)
34 #define WEXITSTATUS(waitb) ((waitb).w_retcode)
44 sigset_t mask,oldmask;
51 if (!have_authorization) {
55 if (config_lookup("noexec")) {
57 code = send_object(conn, (char *)&code, INTEGER_T);
58 com_err(whoami, code, "Not allowed to execute");
66 sigaddset(&mask,SIGCHLD);
67 sigprocmask(SIG_BLOCK,&mask,&oldmask);
69 mask = sigblock(sigmask(SIGCHLD));
76 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
80 log_priority = log_ERROR;
81 com_err(whoami, errno, ": can't fork to run install script");
82 code = send_object(conn, (char *)&n, INTEGER_T);
87 if (setuid(uid) < 0) {
88 com_err(whoami, errno, "Unable to setuid to %d\n", uid);
92 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
96 execlp(str, str, (char *)NULL);
99 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
103 log_priority = log_ERROR;
104 com_err(whoami, n, ": %s", str);
105 (void) send_object(conn, (char *)&n, INTEGER_T);
110 } while (n != -1 && n != pid);
112 sigprocmask(SIG_UNBLOCK,&oldmask,&mask);
117 if ( (WIFEXITED(waitb) && (WEXITSTATUS(waitb)!=0)) || WIFSIGNALED(waitb) ) {
118 /* This is not really correct. It will cause teh moira server to
119 report a bogus error message if the script died on a signal.
120 However this is the same thing that occurs in the non-POSIX
121 case, and I don't know how to come up with a useful error based
122 on the signal recieved.
124 n = WEXITSTATUS(waitb) + ERROR_TABLE_BASE_sms;
125 log_priority = log_ERROR;
126 com_err(whoami, n, " child exited with status %d",
129 if (waitb.w_status) {
130 n = waitb.w_retcode + ERROR_TABLE_BASE_sms;
131 log_priority = log_ERROR;
132 com_err(whoami, n, " child exited with status %d",
135 code = send_object(conn, (char *)&n, INTEGER_T);