Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As far as I know, the major difference is that visudo has a simple parser for seeing if /etc/sudoers (and other sudoers files) is goodly; however, I also noticed that, when I set EDITOR=emacs, sudoedit honours the change, however, visudo does not. From what I can tell, this is because visudo does not honour $EDITOR values unless they are listed in sudoers. What I want to know is if I can make sudoedit do the same thing, so as to not allow things like EDITOR=deleverything.sh.

Another thing I noticed, which seems related, is that as root (after su-ing as user jef), (with the line export EDITOR=emacs in /home/anachrome/.bashrc), both visudo and sudoedit use emacs as the editor, but when not su'd into root, only sudoedit uses it. I'm curious as to why this is (I presume it has something to do with sudo not actually resetting the evironment variables when sudoing as yourself (e.g. root $ sudo -u root), but this is just me assuming).

EDIT: The second question is apparently just because $EDITOR wasn't one of the variables kept by sudo.

And incidentally, I'm using Arch Linux, in case that's relevant.

share|improve this question
    
Wouldn't sudo env answer the second part of your question? –  Daniel Beck Nov 19 '11 at 6:19
    
Ah. A quick check confirms that if I run something with 'sudo' EDITOR isn't used, while if I run something without, (i.e., I'm root and don't need sudo), EDITOR is preserved. Thanks for that. –  Anachrome Nov 19 '11 at 23:05
    
You can configure which environment variables are considered safe in /etc/sudoers. All others are usually unset by sudo. –  Daniel Beck Nov 20 '11 at 7:57
    
Yea, I figured that out now, my real question is: visudo, when determining which editor to use, only considers $EDITOR if it is in the list defined by Defaults editor=[...]. How can I make sudoedit mirror this behavior? –  Anachrome Nov 20 '11 at 15:53

2 Answers 2

For me on Arch, neither visudo nor sudoedit honor $EDITOR but they do both honor $VISUAL, so maybe that's worth a try.

share|improve this answer

Also check that the desired editor is actually installed. Specifying EDITOR=vim when all you've got is vi.tiny won't give much joy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.