Comment 27 for bug 32906

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

@Dorin
> Perhaps sudo should try to use the name from /etc/hostname when gethostbyname fails?
> It looks quite simple to do that, and assume that you'll have there 127:0.0.1 (in both IPv4 and v6)?!?!?!

You seem to be confused.

That's _exactly_ what `sudo` is doing: it's using the known _local_ hostname which would've been set in "/etc/hostname."
It has to resolve this _local_ hostname and does so with the _local_ "/etc/hosts" file.

> gnome-terminal is simply broken if it needs to resolve any kind of hostname during startup.

you are aware that the X Window System is a client-server setup over the loopback interface aren't you?!?
Apps should _always_ be able to resolve the _local_ hostname and some have come to rely on this fact.

@everyone
*_There is no bug here_*
The original "bug reporter" in the _blog_ overwrote his "/etc/hosts" file and in doing so broke his _local_ host configuration.
`sudo` errors were merely the first symptom he noticed of his newly broken system.

*_To prove that something is wrong with sudo_*
you would need to show a situation where `sudo` does _not_ work but the following does:

~$ grep `hostname` /etc/hosts

***Revised Proof: Same machine, 2 terminals; root breaks and fixes the system; asmoore tests sudo:

-----
asmoore@pickles:~$ grep `hostname` /etc/hosts
127.0.1.1 pickles
asmoore@pickles:~$ sudo id
[sudo] password for asmoore:
uid=0(root) gid=0(root) groups=0(root)
asmoore@pickles:~$ sudo -k

root@pickles:~# sed -i "s/pickles/foobar/g" /etc/hosts

asmoore@pickles:~$ grep `hostname` /etc/hosts
asmoore@pickles:~$ sudo id
sudo: unable to resolve host pickles
asmoore@pickles:~$ sudo -k
sudo: unable to resolve host pickles

root@pickles:~# hostname foobar

asmoore@pickles:~$ grep `hostname` /etc/hosts
127.0.1.1 foobar
asmoore@pickles:~$ sudo id
[sudo] password for asmoore:
uid=0(root) gid=0(root) groups=0(root)
asmoore@pickles:~$ sudo -k

root@pickles:~# hostname `cat /etc/hostname`
root@pickles:~# sed -i "s/foobar/pickles/g" /etc/hosts

asmoore@pickles:~$ grep `hostname` /etc/hosts
127.0.1.1 pickles
asmoore@pickles:~$ sudo id
[sudo] password for asmoore:
uid=0(root) gid=0(root) groups=0(root)
asmoore@pickles:~$ sudo -k
-----

Adam sM