"visudo" is completely unusable (/etc/sudoers can only be editted with an external text editor)

Bug #207369 reported by Iain Buclaw
4
Affects Status Importance Assigned to Milestone
sudo (Ubuntu)
Fix Released
Low
Martin Pitt

Bug Description

Binary package hint: sudo

Hi, I can't use sudo visudo at all!

Known problems:
a) It can't close. not with Esc, not with Alt+x, not with Ctrl+Alt+C...
b) backspace isn't backspace
c) on starting a new line, the first character isn't printed.
d) navigation through the file is messed up.
e) delete is the equivalent of cutting the entire line.
f) it is completely unusable to the point where I was forced to edit it in nano.

Information you ask for below:
1)
Description: Ubuntu hardy (development branch)
Release: 8.04

2)
sudo:
  Installed: 1.6.9p10-1ubuntu3
  Candidate: 1.6.9p10-1ubuntu3
  Version table:
 *** 1.6.9p10-1ubuntu3 0
        500 http://gb.archive.ubuntu.com hardy/main Packages
        100 /var/lib/dpkg/status

3)
I expect the program visudo to act like nano (like what it did in Gutsy).

4)
A complete mess in the user input. Completely unusable. I can't type in a single line with it.
Let alone closing the app once I've given up trying to battle it.

ProblemType: Bug
Architecture: i386
Date: Wed Mar 26 21:08:27 2008
DistroRelease: Ubuntu 8.04
NonfreeKernelModules: nvidia ath_hal
Package: sudo 1.6.9p10-1ubuntu3
PackageArchitecture: i386
ProcEnviron:
 SHELL=/bin/bash
 PATH=/home/username/Public/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
 LANG=en_GB.UTF-8
SourcePackage: sudo
Uname: Linux 2.6.24-12-generic i686

Tags: apport-bug
Revision history for this message
Iain Buclaw (iainb) wrote :
Revision history for this message
Constantine Evans (cevans) wrote :

(I'm assuming this isn't a prank about vi)

I'm afraid this is the direct result of bug #388659, which means that visudo will now use vi by default. Vi is an editor with a rather different model of editing.

If you want to use nano, set your $EDITOR variable (eg, export EDITOR=nano), and then either use sudo -E to run visudo, or remove env_reset from sudoers.

I'm closing this as invalid, because it seems that it is actually the correct, documented behaviour of visudo (there is, after all, a reason for it to have that name). Discussions about changing this probably need to take place elsewhere.

Changed in sudo:
status: New → Invalid
Revision history for this message
Constantine Evans (cevans) wrote :

Sorry, that bug number appears to be a Debian bug. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=388659 .

Revision history for this message
Iain Buclaw (iainb) wrote :

Ok, that has solved it.
Sorry, but I've never used vi before.

But seriously, is it *that* unusable?
How do you write in it?
Space doesn't work, letters don't print, all what I managed to figure out was that "q" sets recording to on, whatever that is...

I'm not being funny, I was rather shocked how a five second job in nano
"Defaults:ALL timestamp_timeout=0"
Resulted in half an hour of getting absolutely nothing done but ruin the sudoers.tmp file and eventually lock myself out due to a forced close.

Sorry, as you may know all about how to use vi yourself, but it wasn't very pleasant to my first experience of it (and yes, I do use emacs on the odd occasion before you start thinking it)

Thank-you anyway.
Problem is solved now.

Regards
Iain

Revision history for this message
Martin Pitt (pitti) wrote :

Although I'm a die-hard vi user myself, I do appreciate that it is absolutely the wrong default if someone innocent accidentally runs into it. :-)

Therefore I am reopening this bug for usability reasons. I think the least that we can do is to add a comment to the top of the file to document how to use a different editor.

Changed in sudo:
assignee: nobody → pitti
importance: Undecided → Low
status: Invalid → Confirmed
Revision history for this message
Constantine Evans (cevans) wrote :

It's certainly an unfortunate default, and I had hoped it would be brought up elsewhere, as, at least at one time, I seem to recall that these sorts of issues weren't handled in bugs, especially for issues involving confusing behaviour and vi.

One option would be to undo the changes made for the Debian bug, making visudo use editor rather than vi once again, and then change the documentation, which seems mainly to consist of the man page. For consistency, however, it appears we would need to change vigr and vipw as well.

Another would be to create a command edit_sudoers (and presumably edit_passwd and edit_group as well), which would use editor/$EDITOR instead (the latter is made more difficult, of course, by the env_reset default of sudo); this would allow Ubuntu to have commands for editing these files that would be usable by most cli users, while at the same time not making the behaviour of the vi{sudo,pw,gr} commands unexpected for those experienced with other systems.

I don't quite understand why visudo is so restrictive about the editor anyway.

Revision history for this message
Iain Buclaw (iainb) wrote :

Okay, I agree with both you.

Martin, yes, a fix for this is something that should be discussed.

I totally agree with adding three new apps that have the ability to change the files in accordance.

In the one end you have "visudo, vigr & vipw" that use vi. and the other you can have "pisudo, pigr & pipw" that use pico/nano. (I checked the names for any clashes, and they seem to be original).

Also changing the /etc/sudoers file too would be another start too.

Currently it says:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Maybe having instructions on how to close vi. For when a future hardy user runs visudo without expecting it to open in vi (like what I did).
And including instructions on how to open and edit the file in another editor for users who either don't know how to work vi, or don't wish to work with vi.

And I agree with you too Constantine. I think that this bug should be closed and re-opened as a "wishlist" bug named "pico/nano editor for /etc/sudoers, passwd & group files". Also /etc/shadow & gshadow, respectively. (I have done some research since opening this bug and have learnt a bit about how things work)

Regards
Iain

Revision history for this message
apgomes (apgomes) wrote :

I am using the final version of Hardy and, like Iain, also have the habit to remove the password grace period. I also limit sudo password grace period to individual ttys, instead of global, by adding "Defaults:ALL tty_tickets".

I was driving nuts and almost ruined sudoers because I couldn't edit anything when "sudo visudo" (:i, Esc, :w, etc... nothing worked). Luckily I found this thread and the tip by Constantine Evans solved this issue.

Sorry to say, but this is totally crazy! I love Ubuntu (especially Hardy where everything works great) but this "bug" is a real pain in the neck.

Revision history for this message
Iain Buclaw (iainb) wrote :

You could add these lines:

CODE:
# Set Environment for sudo -E.
#export EDITOR=vim
#export EDITOR=nano

# Make sudo -E the default setting for sudo.
# alias sudo='sudo -E'
:CODE

to the "~/.bashrc" file, so that slightly advanced users can set this up right.
Or when given directions to this, all they have to do is uncomment the right lines.

At least, this is what I've ended up doing with my system

Regards
Iain

Revision history for this message
Martin Pitt (pitti) wrote :

In Ubuntu 8.10, sensible-editor defaults to nano now, and select-editor (which will run by default the first time) allows you to select another one.

Changed in sudo:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.