[sudo-workers] Defaults editor= with last entry not existing in the OS get sudoedit fail with error

Daniele Palumbo daniele at retaggio.net
Tue Apr 17 09:38:02 MDT 2018


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://www.sudo.ws/pipermail/sudo-workers/attachments/20180417/8e3db45b/attachment.bin>


More information about the sudo-workers mailing list