]> granicus.if.org Git - sudo/commitdiff
added support for command line args in /etc/sudoers
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 1 Sep 1995 02:44:18 +0000 (02:44 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 1 Sep 1995 02:44:18 +0000 (02:44 +0000)
testsudoers.c

index 682b1bd60714fa11fcc704550f19d1d0a6c99191..460940c358fadf1acb922e19510d9d5a988bf88d 100644 (file)
@@ -61,8 +61,9 @@ extern int clearaliases;
 extern struct interface *interfaces;
 extern int num_interfaces;
 
-char *cmnd;
-char *user;
+char *cmnd = NULL;
+char *cmnd_args = NULL;
+char *user = NULL;
 char host[MAXHOSTNAMELEN+1];
 char cwd[MAXPATHLEN+1];
 char *epasswd = NULL;
@@ -79,26 +80,39 @@ int path_matches(cmnd, path)
     char *cmnd, *path;
 {
     int clen, plen;
+    char *args;
 
     if (cmnd == NULL)
-       return FALSE;
+       return(FALSE);
+
+    if ((args = strchr(path, ' ')))  
+       *args++ = '\0';
 
     plen = strlen(path);
-    if (path[plen] != '/')
-       return strcmp(cmnd, path) == 0;
+    if (path[plen - 1] != '/') {
+       if (strcmp(cmnd, path) == 0) {
+           if (!cmnd_args && !args)
+               return(TRUE);
+           else if (cmnd_args && args)
+               return((strcmp(cmnd_args, args) == 0));
+           else
+               return(FALSE);
+       } else
+           return(FALSE);
+    }
 
     clen = strlen(cmnd);
     if (clen < plen + 1)
        /* path cannot be the parent dir of cmnd */
-       return FALSE;
+       return(FALSE);
 
     if (strchr(cmnd + plen + 1, '/') != NULL)
        /* path could only be an anscestor of cmnd -- */
        /* ignoring, of course, things like // & /./  */
-       return FALSE;
+       return(FALSE);
 
     /* see whether path is the prefix of cmnd */
-    return strncmp(cmnd, path, plen) == 0;
+    return((strncmp(cmnd, path, plen) == 0));
 }