Re: Replacing nano-default-editor doesn't affect visudo

Jonathan Wakely via devel <[email protected]>
Newsgroups gmane.linux.redhat.fedora.devel
Message-ID <CACb0b4n7jiLW-nAht3ff4-kUvZg6cLFnv5mY9ZTfDiZPmrAW8g@mail.gmail.com>
On Fri, 28 Aug 2026 at 18:51, Chris Adams <[email protected]> wrote:
>
> Once upon a time, Neal Gompa <[email protected]> said:
> > That said, visudo probably needs a patch to respect the EDITOR variable.
>
> visudo DOES respect the EDITOR variable.  However, running a command
> directly with "sudo <command>" does not SET the EDITOR variable.  It's
> not safe to pass through the user's EDITOR setting (as that can open up
> a whole set of security issues), and when sudo runs a command without a
> shell, most environment is not set (you can see this with "sudo env").

Right, so you need to use 'sudo --login visudo' or 'sudo
EDITOR=/usr/bin/vim visudo' and of course I don't remember to do that
first time, and find myself in nano and kick myself.
(I've removed nano now, so visudo uses the second option in it's
default config, which is vim, but out-of-the-box the experience still
seems suboptimal to me.)

I think it would make sense for vim-default-editor to install a
/etc/sudoers.d/editor file that contains:
  Defaults editor /usr/bin/vim:/usr/bin/vi:/usr/bin/nano

This just reorders the three options in the hardcoded default, which
means that it's still possible to select nano explicitly via EDITOR.
See the visudo(1) man page which expains that nano needs to still be
in the list for it to be selectable via $EDITOR.

-- 
_______________________________________________
devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/[email protected]
Do not reply to spam, report it: https://forge.fedoraproject.org/infra/tickets/issues/new
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.