From a7b14880ab393651a13431c0abe5cb35d9d7d336 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 1 Sep 1995 04:04:43 +0000 Subject: [PATCH] if given a fully-qualified or relative path we now check it with sudo_goodpath() and error out with the appropriate error message if the file does not exist or is not executable --- find_path.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/find_path.c b/find_path.c index 6df3f30d9..19b9fc04e 100644 --- a/find_path.c +++ b/find_path.c @@ -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; -- 2.49.0