Defaults editor= with last entry not existing in the OS get sudoedit fail with error

Daniele Palumbo <[email protected]> Tue, 17 Apr 2018 17:38:02 +0200
Newsgroups gmane.comp.tools.sudo.devel
Message-ID <[email protected]>
Hi,

Sorry for the long subject :)

I have spotted the following, valid (seems to me) into all version up to 1.8.21 of sudo.
I’m on Debian but i have seen it also in RHEL.

If i am not wrong, sudoedit will look into the editor Default.
As by
https://www.sudo.ws/man/1.8.22/sudoers.man.html
“”"
editor
A colon (‘:’) separated list of editors allowed to be used with visudo. visudo will choose the editor that matches the user's SUDO_EDITOR,VISUAL or EDITOR environment variable if possible, or the first editor in the list that exists and is executable. Note that the SUDO_EDITOR, VISUALand EDITOR environment variables are not preserved by default when the env_reset option is enabled. The default is vi.
“””

Given therefore the following definition:
Defaults editor=/usr/bin/vim:/bin/vim:/usr/bin/vi:/bin/vi:/usr/bin/vi
Note the double "/usr/bin/vi”, this is by purpose.

# sudoedit -n /etc/fstab (can be any user running it)
This do work. Content is not meaningful, may be any file.

If instead the last entry in the Defaults is not existing, an error will be thrown.
Tested by removing the last part.
Defaults editor=/usr/bin/vim:/bin/vim:/usr/bin/vi:/bin/vi
“”"
# sudoedit -n /etc/fstab
sudoedit: /usr/bin/vim:/bin/vim:/usr/bin/vi:/bin/vi: command not found
“””

The command listed on the Defaults:
# ls -la /usr/bin/vim /usr/bin/vi /bin/vim /bin/vi
ls: cannot access /bin/vim: No such file or directory
ls: cannot access /bin/vi: No such file or directory
lrwxrwxrwx 1 root root 20 May 27  2015 /usr/bin/vi -> /etc/alternatives/vi
lrwxrwxrwx 1 root root 21 May 16  2016 /usr/bin/vim -> /etc/alternatives/vim

Please note that this is happening only in case of the _last entry_ not existing.
also /bin/vim is not existing, and the in the first example this is by purpose not the last.

Version of sudo running
# sudo -V|head
Sudo version 1.8.21p2

Do you confirm this one as a bug?

Of course i can fill a bug on this.

Thank you very much,
Daniele

____________________________________________________________
sudo-workers mailing list <[email protected]>
For list information, options, or to unsubscribe, visit:
https://www.sudo.ws/mailman/listinfo/sudo-workers
signature.asc (application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE-----

iFwEARECAB0WIQQ2i6u6VhCxV1aSkPHxOPmZ9ILUVAUCWtYU2gAKCRDxOPmZ9ILU
VIWHAJj8WpIxuG1V+KOsI1dIJFvNyQH4AJsEmUP0NEPkp+dXIYj2Bn+vP9tntg==
=areE
-----END PGP SIGNATURE-----