]> andersk Git - moira.git/blobdiff - update/exec_002.c
Switch from Imake-based build system to autoconf-based.
[moira.git] / update / exec_002.c
index aeec495c18d5634077fa16aadbbfa05b38c6fcce..77e1c23f827529902240823ee82a0650861dce03 100644 (file)
 #include <stdio.h>
 #include <unistd.h>
 
-#include <gdb.h>
-
 RCSID("$Header$");
 
-extern CONNECTION conn;
-extern int code, uid, log_priority, have_authorization;
-extern char *whoami;
-
-int exec_002(char *str)
+void exec_002(int conn, char *str)
 {
-  int waitb;
+  int waitb, n;
   sigset_t mask, oldmask;
-  int n, pid;
+  pid_t pid;
+  long code;
 
   if (!have_authorization)
     {
-      reject_call(MR_PERM);
-      return 0;
+      send_int(conn, MR_PERM);
+      return;
     }
   if (config_lookup("noexec"))
     {
-      code = EPERM;
-      send_object(conn, (char *)&code, INTEGER_T);
-      com_err(whoami, code, "Not allowed to execute");
-      return 0;
+      send_int(conn, EPERM);
+      com_err(whoami, EPERM, "Not allowed to execute");
+      return;
     }
+
   str += 8;
   while (*str == ' ')
     str++;
@@ -55,12 +50,12 @@ int exec_002(char *str)
     case -1:
       n = errno;
       sigprocmask(SIG_UNBLOCK, &oldmask, &mask);
-      log_priority = log_ERROR;
-      com_err(whoami, errno, ": can't fork to run install script");
-      code = send_object(conn, (char *)&n, INTEGER_T);
+      com_err(whoami, n, ": can't fork to run install script");
+      code = send_int(conn, n);
       if (code)
        exit(1);
-      return 0;
+      return;
+
     case 0:
       if (setuid(uid) < 0)
        {
@@ -71,19 +66,19 @@ int exec_002(char *str)
       execlp(str, str, NULL);
       n = errno;
       sigprocmask(SIG_UNBLOCK, &oldmask, &mask);
-      log_priority = log_ERROR;
       com_err(whoami, n, ": %s", str);
-      send_object(conn, (char *)&n, INTEGER_T);
+      send_int(conn, n);
       exit(1);
+
     default:
       do
        n = wait(&waitb);
       while (n != -1 && n != pid);
+
       sigprocmask(SIG_UNBLOCK, &oldmask, &mask);
       if ((WIFEXITED(waitb) && (WEXITSTATUS(waitb) != 0)) ||
          WIFSIGNALED(waitb))
        {
-         log_priority = log_ERROR;
          if (WIFSIGNALED(waitb))
            {
              n = MR_COREDUMP;
@@ -96,16 +91,16 @@ int exec_002(char *str)
              com_err(whoami, n, " child exited with status %d",
                      WEXITSTATUS(waitb));
            }
-         code = send_object(conn, (char *)&n, INTEGER_T);
+         code = send_int(conn, n);
          if (code)
            exit(1);
        }
       else
        {
-         code = send_ok();
+         code = send_ok(conn);
          if (code)
            exit(1);
        }
     }
-  return 0;
+  return;
 }
This page took 0.033574 seconds and 4 git commands to generate.