* but it is in '.' and IGNORE_DOT is set.
*/
int
-find_path(char *infile, char **outfile, struct stat *sbp, char *path)
+find_path(char *infile, char **outfile, struct stat *sbp, char *path,
+ int ignore_dot)
{
static char command[PATH_MAX]; /* qualified filename */
char *n; /* for traversing path */
return(NOT_FOUND);
}
- /* Use PATH passed in unless SECURE_PATH is in effect. */
- if (def_secure_path && !user_is_exempt())
- path = def_secure_path;
- else if (path == NULL)
+ if (path == NULL)
return(NOT_FOUND);
path = estrdup(path);
origpath = path;
if (len <= 0 || len >= sizeof(command))
errorx(1, "%s: File name too long", infile);
result = sudo_goodpath(command, sbp);
- if (result && def_ignore_dot)
+ if (result && ignore_dot)
return(NOT_FOUND_DOT);
}
set_cmnd(int sudo_mode)
{
int rval;
+ char *path = user_path;
/* Set project if applicable. */
set_project(runas_pw);
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();
}
}
char *sudo_goodpath(const char *, struct stat *);
/* findpath.c */
-int find_path(char *, char **, struct stat *, char *);
+int find_path(char *, char **, struct stat *, char *, int);
/* check.c */
int check_user(int, int);
UserEditor = NULL;
else if (UserEditor) {
UserEditorArgs = get_args(UserEditor);
- if (find_path(UserEditor, &Editor, NULL, getenv("PATH")) == FOUND) {
+ if (find_path(UserEditor, &Editor, NULL, getenv("PATH"), 0) == FOUND) {
UserEditor = Editor;
} else {
if (def_env_editor) {