[sudo-users] per-user editor for visudo

balducci at units.it balducci at units.it
Sun Jul 31 00:54:19 MDT 2016

> The reason this doesn't work is that visudo is being run as root
> and so the editor Defaults setting will match on root, not the user
> running "sudo visudo".

I did consider that and, actually, with the following:

  Defaults:root   editor=/usr/bin/nano

visudo uses nano, overriding the --with-editor=/usr/bin/emacs option at
build time (however, aside, I have also noticed that with both the
Defaults:root entry above and a global:

  Defaults editor=/usr/bin/emacs:/usr/bin/nano

emacs is used; ie apparently the global Defaults wins)

However, and here I'm probably misunderstanding something, if I have:

  Defaults:balducci  editor=/usr/bin/nano, \
                     timestamp_timeout=-1,        \
                     !env_reset, \

then running "sudo visudo" picks all options (but for the editor) for
balducci; which makes sense to me: I run visudo as root, but sudo knows
who I actually am and loads my default options.

So: why is "sudo visudo" honoring all options for balducci, but for the
editor? what am I missing?

> It would be possible for visudo to look at the SUDO_USER environment
> variable but it does not currently do that.

many thanks to all for the quick reply


More information about the sudo-users mailing list