Make find_path() a little more generic by not checking def_foo

variables inside it.  Instead, pass in ignore_dot as a function
argument.
This commit is contained in:
Todd C. Miller
2010-05-13 10:27:03 -04:00
parent 832ce341e4
commit d5bfd148d6
4 changed files with 13 additions and 10 deletions

View File

@@ -738,6 +738,7 @@ static int
set_cmnd(int sudo_mode)
{
int rval;
char *path = user_path;
/* Set project if applicable. */
set_project(runas_pw);
@@ -752,13 +753,17 @@ set_cmnd(int sudo_mode)
if (sudo_mode & (MODE_RUN | MODE_EDIT | MODE_CHECK)) {
if (ISSET(sudo_mode, MODE_RUN | MODE_CHECK)) {
if (def_secure_path && !user_is_exempt())
path = def_secure_path;
set_perms(PERM_RUNAS);
rval = find_path(NewArgv[0], &user_cmnd, user_stat, user_path);
rval = find_path(NewArgv[0], &user_cmnd, user_stat, path,
def_ignore_dot);
restore_perms();
if (rval != FOUND) {
/* Failed as root, try as invoking user. */
set_perms(PERM_USER);
rval = find_path(NewArgv[0], &user_cmnd, user_stat, user_path);
rval = find_path(NewArgv[0], &user_cmnd, user_stat, path,
def_ignore_dot);
restore_perms();
}
}