]> granicus.if.org Git - sudo/commitdiff
now groks command arguments
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 14 Aug 1995 04:06:27 +0000 (04:06 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 14 Aug 1995 04:06:27 +0000 (04:06 +0000)
parse.c

diff --git a/parse.c b/parse.c
index 8110f1292497dc3272063a07a21cdbc25934cb15..65611e07c3f84a19801dd36b1eea5f32701f50e1 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -167,6 +167,7 @@ path_matches(cmnd, path)
     struct dirent *dent;
     char buf[MAXCOMMANDLENGTH+1];
     static char *c;
+    char *args;
 
     /* only need to stat cmnd once since it never changes */
     if (cmnd_st.st_dev == 0) {
@@ -178,6 +179,11 @@ path_matches(cmnd, path)
            c++;
     }
 
+    /* if the given path has command line args, split them out */
+    if ((args = strchr(path, ' '))) {
+       *args++ = '\0';
+    }
+
     plen = strlen(path);
     if (path[plen - 1] != '/') {
 #ifdef FAST_MATCH
@@ -194,6 +200,20 @@ path_matches(cmnd, path)
 
        if (stat(path, &pst) < 0)
            return(FALSE);
+
+       /* XXX - clean up this monstrosity! */
+       if (args)
+           *(args - 1) = ' ';
+
+       if (cmnd_st.st_dev == pst.st_dev && cmnd_st.st_ino == pst.st_ino) {
+           if (!cmnd_args && !args)
+               return(TRUE);
+           else if (cmnd_args && args)
+               return((strcmp(cmnd_args, args) == 0));
+           else
+               return(FALSE);
+       } else
+           return(FALSE);
        return(cmnd_st.st_dev == pst.st_dev && cmnd_st.st_ino == pst.st_ino);
     }