]> andersk Git - moira.git/blobdiff - update/exec_002.c
handle "noexec" and "user" config options
[moira.git] / update / exec_002.c
index ee2e32fe6d537b59b2479e19d3d0196bb6b092c6..887c4b1316a3d7014069ca0f271435c9a65ebd92 100644 (file)
@@ -12,14 +12,18 @@ static char *rcsid_exec_002_c = "$Header$";
 
 #include <mit-copyright.h>
 #include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
 #include <sys/wait.h>
 #include <signal.h>
 #include <gdb.h>
-#include <sms.h>
+#include <moira.h>
 #include "update.h"
 
 extern CONNECTION conn;
-extern int code, errno;
+extern int code, errno, uid;
+extern char *whoami;
+
 
 int
 exec_002(str)
@@ -28,6 +32,12 @@ exec_002(str)
     union wait waitb;
     int n, pid, mask;
 
+    if (config_lookup("noexec")) {
+       code = EPERM;
+       code = send_object(conn, (char *)&code, INTEGER_T);
+       com_err(whoami, code, "Not allowed to execute");
+       return;
+    }
     str += 8;
     while (*str == ' ')
        str++;
@@ -44,6 +54,11 @@ exec_002(str)
            exit(1);
        return;
     case 0:
+       if (setuid(uid) < 0) {
+           com_err(whoami, errno, "Unable to setuid to %d\n", uid);
+           exit(1);
+       }
+       sigsetmask(mask);
        execlp(str, str, (char *)NULL);
        n = errno;
        sigsetmask(mask);
This page took 0.044284 seconds and 4 git commands to generate.