From: Todd C. Miller Date: Fri, 16 Jan 2004 23:10:13 +0000 (+0000) Subject: If we can't stat the command as root, try as the runas user instead. X-Git-Tag: SUDO_1_6_8~234 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=69d47fe756b2d2ca6b34dc9ae241816c3eba200a;p=sudo If we can't stat the command as root, try as the runas user instead. --- diff --git a/parse.c b/parse.c index 8c2703b8a..bcfdc668a 100644 --- a/parse.c +++ b/parse.c @@ -252,7 +252,7 @@ command_matches(cmnd, cmnd_args, path, sudoers_args) char *path; char *sudoers_args; { - int plen; + int plen, error; static struct stat cst; struct stat pst; DIR *dirp; @@ -268,8 +268,15 @@ command_matches(cmnd, cmnd_args, path, sudoers_args) /* Only need to stat cmnd once since it never changes */ if (cst.st_dev == 0) { - if (stat(cmnd, &cst) == -1) - return(FALSE); + if ((error = stat(cmnd, &cst))) { + if (runas_pw->pw_uid != 0) { + set_perms(PERM_RUNAS); + error = stat(cmnd, &cst); + set_perms(PERM_ROOT); + } + if (error) + return(FALSE); + } if ((cmnd_base = strrchr(cmnd, '/')) == NULL) cmnd_base = cmnd; else