Comment 42 for bug 32906

Revision history for this message
Paul Smith (psmith-gnu) wrote : Re: sudo shouldn’t ABSOLUTELY NEED to look up the host it’s running on

Let's please step back a bit. If we look at things from sudo's point of view, maybe this is just expected behavior and not a bug. But, if you look at it from the Ubuntu project's point of view, this is a major problem. There is simply no way on any kind of robust system _I_ want to be involved with, that messing up a simple configuration file like /etc/hosts can destroy my ability to log in with administration privileges, to _FIX_ the messed up file [*]. The idea that mistyping a host name or (as in my situation) having NetworkManager incorrectly modify /etc/hosts, should mean that I have to reboot with a rescue CD, mount the partition by hand, and edit this file.

I hope we can agree on this.

So the problem becomes how to resolve this. One simple idea is for sudo to defer the hostname lookup until it's absolutely required. On a standard Ubuntu /etc/sudoers file, it actually is NEVER required because there are no host-based restrictions in the file. So, we never need to know the hostname we're currently logged into. This may not be a solution that works for everyone but it will work for the vast majority of people, who do NOT share /etc/sudoers files and who do NOT have host-specific rules there.

[*] I realize that /etc/sudoers is another such file, but hopefully it's pretty obvious that if you mess up /etc/sudoers your ability to use sudo will be adversely affected... not so /etc/hosts and/or /etc/hostname. Also, there is a separate command to modify /etc/sudoers (visudo) which validates the /etc/sudoers file for basic correctness after you've finished editing it... again not so /etc/hosts and/or /etc/hostname.