dist-upgrade changes hostname in /etc/hosts breaking sudo

Bug #178831 reported by Christian Csar on 2007-12-27
8
Affects Status Importance Assigned to Milestone
sudo (Ubuntu)
Undecided
Unassigned

Bug Description

I did a dist-upgrade to hardy and part way through sudo would give me a message along the lines of "sudo: unable to resolve host NULL", 'NULL' happens to be my hostname. Following the information here, http://ubuntuforums.org/archive/index.php/t-613521.html I opened up my /etc/hosts and saw that I had the host name I had originally entered when I installed Gutsy, and then changed a few weeks later, instead of NULL,
So instead of "127.0.1.1 NULL" there was "127.0.1.1 <oldhostname>" where <oldhostname> was the name I had set originally.

I was able to go into recovery mode and change this as root, but it was very problematic to say the least since I could not use sudo.

B. Clausius (barcc) wrote :

I had the same problem with some odd effects.

barcc:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 bluebox.IWNETZ
...

1) After installing sudo 1.6.9p9-1ubuntu1:
  barcc:~$ sudo ls
  sudo: unable to resolve host System5

  barcc:~$ gksudo gedit test&
(nothing happens, i have to do: killall gksudo)

2) With sudo 1.6.8p12-5ubuntu2 there is no problem. Seems to me that the old version ignores /etc/hosts, so the file should be checked when upgrading.
3) With version 1.6.9p9-1ubuntu1 there is no way to become root with one exception:
I started aptitude and selected actions->become root. Then i get the same message, but i can enter my password and then i am root.

  barcc:~$ aptitude
  sudo: unable to resolve host System5
  [sudo] password for barcc:

After leaving aptitude type in the same terminal:
  barcc:~$ gksudo gedit test&
The same message occurs, but gedit opens as root

  barcc:~$ sudo gedit test
  sudo: unable to resolve host System5
(gedit is not opened)

4) After changing /etc/hosts sudo works.
barcc:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 System5
...

I think sudo does not handle the problematic file conformal.

B. Clausius (barcc) wrote :

Related bug: sudo shouldn’t ABSOLUTELY NEED to look up the host it’s running on https://launchpad.net/bugs/32906

Kyubutsu (jf) wrote :

i had the same issue/bug. trying your approach resolved the problem; or should i say the "host" .
good one, kudos to you. hopefully someone is paying attention since this single bug renders the system unable to complete the upgrade process just to say the least.

Martin Pitt (pitti) wrote :

Do you know where "System5' comes from? Is that your actual hostname which is set in /etc/hostname? Where and how did you set it?

Changed in sudo:
status: New → Incomplete
B. Clausius (barcc) wrote :

bluebox was the hostname when i installed feisty.
IWNETZ was the Workgroup when i used samba to connect with vmware.
System5 is the hostname now (/etc/hostname), but i don't remember when and how i changed it.
To reproduce it i startet gutsy and done this:

login
-----------------
  engl@SystemA:~$ cat /etc/hostname
  SystemA
  engl@SystemA:~$ cat /etc/hosts
  127.0.0.1 localhost
  127.0.1.1 SystemA

  # The following lines are desirable for IPv6 capable hosts
  ::1 ip6-localhost ip6-loopback
  fe00::0 ip6-localnet
  ff00::0 ip6-mcastprefix
  ff02::1 ip6-allnodes
  ff02::2 ip6-allrouters
  ff02::3 ip6-allhosts
---------------------------
System->Administration->Network->General->Hostname: SystemA=>SystemB
---------------------------
logout/login
---------------------------
  engl@SystemB:~$ cat /etc/hostname
  SystemB
  engl@SystemB:~$ cat /etc/hosts
  127.0.0.1 localhost
  127.0.1.1 SystemB
...
---------------------------------
I can't reproduce the change from SystemB to SystemB.IWNETZ, so edit the file /etc/hosts.
---------------------------------
  engl@SystemB:~$ cat /etc/hosts
  127.0.0.1 localhost
  127.0.1.1 SystemB.IWNETZ
...
---------------------------------
restart
----------------------
System->Administration->Network->General->Hostname: SystemB=>SystemC
-----------------------
log out/log in
-----------------------
  engl@SystemC:~$ cat /etc/hostname
  SystemC
  engl@SystemC:~$ cat /etc/hosts
  127.0.0.1 localhost
  127.0.1.1 SystemB.IWNETZ
...
-----------------------

I don't know, whether it was a bug under gutsy (or feisty?) that added .IWNETZ to the line in /etc/hosts, but there may be some computers having such a (defective?) /etc/hosts and these computers may have a problem when upgrading to hardy.
The situation
  $ cat /etc/hostname
  MyHostname
  $ cat /etc/hosts
  127.0.0.1 localhost
  127.0.1.1 MyHostname.MyWorkgroup
  ...
works under Gutsy, but not under Hardy.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers