]> granicus.if.org Git - sudo/commitdiff
Fix some XXX
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 1 Oct 2004 19:06:44 +0000 (19:06 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 1 Oct 2004 19:06:44 +0000 (19:06 +0000)
mon_systrace.c
mon_systrace.h

index fd1ee143c4eefd67f407a4b3912f83c214977ea1..28a8b62c29fba772b2137f22418523a6a209dfd3 100644 (file)
@@ -55,7 +55,6 @@ static const char rcsid[] = "$Sudo$";
 
 /*
  * Open the systrace device and return the fd or -1 on failure.
- * XXX - warn here on error or in caller?
  */
 static int
 systrace_open()
@@ -192,7 +191,7 @@ systrace_attach(pid)
        if (nread != sizeof(msg)) {
            if (nread == -1 && (errno == EINTR || errno == EAGAIN))
                continue;
-           kill(pid, SIGKILL); /* XXX - kill all pids in list */
+           killall(&children, SIGKILL);
            _exit(nread != 0);  /* shouldn't happen */
        }
 
@@ -226,9 +225,9 @@ systrace_attach(pid)
                handler = find_handler(msg.msg_pid, msg.msg_data.msg_ask.code);
                if (handler != NULL) {
                    /*
-                    * handler is run twice, once before we answer and once
-                    * after.  We only want to log attempts when our answer
-                    * is accepted; otherwise we can get dupes.
+                    * The handler is run twice, once before we answer and
+                    * once after.  We only want to log attempts when our
+                    * answer is accepted; otherwise we can get dupes.
                     */
                    cookie = handler(fd, msg.msg_pid, &msg.msg_data.msg_ask, -1,
                        &ans.stra_policy, &ans.stra_error);
@@ -273,7 +272,7 @@ systrace_attach(pid)
     }
 
 fail:
-    kill(pid, SIGKILL);        /* XXX - kill all pids in list */
+    killall(&children, SIGKILL);
     _exit(1);
 }
 
@@ -461,9 +460,8 @@ systrace_read(fd, pid, addr, buf, bufsiz)
 /*
  * Read up to bufsiz bytes from addr into buf, stopping when we hit
  * a NUL byte.  Reads are done in chunks since STRIOCIO cannot
- * handle a strio_len > the actual kernel buffer.
- * XXX - could pass a hint for chunksiz
- * XXX - need to indicate oflow
+ * handle a strio_len > the actual kernel buffer.  It might be nice
+ * to pass a starting chunksize though.
  */
 static ssize_t
 read_string(fd, pid, addr, buf, bufsiz)
@@ -492,7 +490,7 @@ read_string(fd, pid, addr, buf, bufsiz)
        }
     }
     *cp = '\0';
-    return(cp - buf);
+    return(bufsiz >= chunksiz ? cp - buf : -1);
 }
 
 static schandler_t
@@ -556,10 +554,8 @@ decode_args(fd, pid, askp)
        }
        if (off == (char *)askp->args[1])
            continue;                   /* skip argv[0] */
-       if ((len = read_string(fd, pid, ap, cp, ep - cp)) == -1) {
-           warn("STRIOCIO");
+       if ((len = read_string(fd, pid, ap, cp, ep - cp)) == -1)
            return(-1);
-       }
        cp += len;
        *cp++ = ' ';            /* replace NUL with a space */
     }
@@ -634,3 +630,17 @@ check_exec(fd, pid, askp, cookie, policyp, errorp)
     }
     return(validated);
 }
+
+/*
+ * Kill all pids in the list
+ */
+static void
+killall(head, sig)
+    struct listhead *head;
+    int sig;
+{
+    struct childinfo *child;
+
+    for (child = head->first; child != NULL; child = child->next)
+       (void) kill(child->pid, sig);
+}
index aa7f4fdaaa178c448151ada886bed20d4d037e9c..7bd5fda8d71547d543f560df338731b71e8c8510 100644 (file)
@@ -20,6 +20,7 @@ typedef int (*schandler_t)
     __P((int, pid_t, struct str_msg_ask *, int, int *, int *));
 
 struct childinfo;
+struct listhead;
 
 extern struct passwd *sudo_pwdup __P((const struct passwd *, int));
 extern struct passwd *sudo_getpwuid __P((uid_t));
@@ -37,6 +38,7 @@ static void new_child         __P((pid_t, pid_t));
 static void rm_child           __P((pid_t));
 static void update_child       __P((pid_t, uid_t));
 static struct childinfo *find_child __P((pid_t));
+static void killall            __P((struct listhead *, int));
 
 static struct listhead children;       /* list of children being traced */
 static int initialized;                        /* set to true when we are inited */