]> granicus.if.org Git - sudo/commitdiff
if given a fully-qualified or relative path we now check it
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 1 Sep 1995 04:04:43 +0000 (04:04 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 1 Sep 1995 04:04:43 +0000 (04:04 +0000)
with sudo_goodpath() and error out with the appropriate error
message if the file does not exist or is not executable

find_path.c

index 6df3f30d9f6b571ff43cfaebfabec09816a940a6..19b9fc04e5603b18fe8b3df19787e0bf2ea7c4f1 100644 (file)
@@ -110,11 +110,20 @@ char * find_path(file)
     }
 
     /*
-     * If we were given a fully qualified or relative path just accept for now
+     * If we were given a fully qualified or relative path
+     * there is no need to look at PATH.
+     * We really want to fall back if !sudo_goodpath() but then
+     * the error is "not found" -- this way we get the correct error.
      */
     if (strchr(file, '/')) {
        (void) strcpy(command, file);
-       return(command);
+       if (sudo_goodpath(command)) {
+           return(command);
+       } else {
+           (void) fprintf(stderr, "%s: %s: ", Argv[0], command);
+           perror("");
+           exit(1);
+       }
     }
 
     /*
@@ -124,7 +133,7 @@ char * find_path(file)
        return(NULL);
 
     if ((path = strdup(path)) == NULL) {
-       (void) fprintf(stderr, "sudo: out of memory!\n");
+       (void) fprintf(stderr, "%s: out of memory!\n", Argv[0]);
        exit(1);
     }
     origpath=path;