From: Todd C. Miller Date: Fri, 21 Aug 2015 17:25:02 +0000 (-0600) Subject: When parsing def_editor, break out of the loop when we find the X-Git-Tag: SUDO_1_8_15^2~79 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=333faa20e21bf66a7b7a28a450a73f0eca3cf4ee;p=sudo When parsing def_editor, break out of the loop when we find the first valid editor. Bug #714 --- diff --git a/NEWS b/NEWS index cbe2d8b82..f4cc18a6b 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,10 @@ What's new in Sudo 1.8.15 enabling the sudoedit_follow option in sudoers or on a per-command basis with the FOLLOW and NOFOLLOW tags. Bug #707. + * Fixed a bug introduced in versino 1.8.14 that caused the last + valid editor in the sudoers "editor" list to be used by visudo + and sudoedit instead of the first. Bug #714. + What's new in Sudo 1.8.14p3 * Fixed a bug introduced in sudo 1.8.14p2 that prevented sudo diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index fd5c58f2d..effd22b63 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -1201,7 +1201,9 @@ find_editor(int nfiles, char **files, int *argc_out, char ***argv_out) if ((editor = getenv(*ev)) != NULL && *editor != '\0') { editor_path = resolve_editor(editor, strlen(editor), nfiles, files, argc_out, argv_out, NULL); - if (editor_path == NULL && errno != ENOENT) + if (editor_path != NULL) + break; + if (errno != ENOENT) debug_return_str(NULL); } } diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index af0f46779..b209fe00e 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -330,7 +330,9 @@ get_editor(int *editor_argc, char ***editor_argv) cp != NULL; cp = sudo_strsplit(NULL, def_editor_end, ":", &ep)) { editor_path = resolve_editor(cp, (size_t)(ep - cp), 2, files, editor_argc, editor_argv, whitelist); - if (editor_path == NULL && errno != ENOENT) + if (editor_path != NULL) + break; + if (errno != ENOENT) debug_return_str(NULL); } }