[hostnamed] Changing hostname doesn't update /etc/hosts

Bug #1162475 reported by Jeremy Bícha
240
This bug affects 72 people
Affects Status Importance Assigned to Milestone
gnome-control-center (Debian)
Fix Released
Unknown
gnome-control-center (Ubuntu)
Invalid
Undecided
Unassigned
Xenial
Confirmed
Undecided
Unassigned
systemd (Ubuntu)
Won't Fix
Low
Unassigned
Xenial
Triaged
Low
Unassigned
unity-control-center (Ubuntu)
Won't Fix
Low
Unassigned
Xenial
Confirmed
Undecided
Unassigned

Bug Description

GUI
---
1a. Run sudo gnome-control-center, or...
1b. Save the gnome-control-center.pkla from https://bazaar.launchpad.net/~ubuntu-desktop/gnome-control-center/ubuntu/revision/556 to /var/lib/polkit-1/localauthority/10-vendor.d/ and then run gnome-control-center as an admin user

2. Enter the Details panel
3. The "Device name" (hostname) text field should be editable; change the text to something else.
4. The hostname is updated instantly which can be verified by looking in /etc/hostname. However /etc/hosts/ is not updated.

Command line
------------
hostnamectl set-hostname

The hostnamed documentation at http://www.freedesktop.org/wiki/Software/systemd/hostnamed says
"To properly handle name lookups with changing local hostnames without having to edit /etc/hosts for them we recommend using hostnamed in combination with nss-myhostname: http://0pointer.de/lennart/projects/nss-myhostname/ "

Without /etc/hosts being handled correctly, the hostnamed integration is only half-working.

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: gnome-control-center 1:3.6.3-0ubuntu18
ProcVersionSignature: Ubuntu 3.8.0-15.25-generic 3.8.4
Uname: Linux 3.8.0-15-generic x86_64
ApportVersion: 2.9.2-0ubuntu5
Architecture: amd64
Date: Sun Mar 31 08:52:57 2013
MarkForUpload: True
SourcePackage: gnome-control-center
UpgradeStatus: No upgrade log present (probably fresh install)
usr_lib_gnome-control-center:
 activity-log-manager-control-center 0.9.4-0ubuntu6.1
 deja-dup 26.0-0ubuntu1
 gnome-control-center-signon 0.1.5-0ubuntu1
 gnome-control-center-unity 1.2daily13.02.15-0ubuntu1
 indicator-datetime 12.10.3daily13.03.26-0ubuntu1

Revision history for this message
Jeremy Bícha (jbicha) wrote :
description: updated
Revision history for this message
Jeremy Bícha (jbicha) wrote :

Ah, nss-myhostname is already in Debian and Ubuntu. I filed bug 1162478 to get it in main.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gnome-control-center - 1:3.6.3-0ubuntu20

---------------
gnome-control-center (1:3.6.3-0ubuntu20) raring; urgency=low

  * debian/gnome-control-center.pkla, gnome-control-center-data.install:
    - Install a .pkla to allow admins to set the hostname. This can be dropped
      when Ubuntu includes policykit >=0.106 since gnome-control-center
      ships the updated rules already (LP: #962369)
  * debian/control.in:
    - Recommend libnss-myhostname (LP: #1162475, #1162478)
  * debian/patches/62_update_translations_template.patch: Refreshed
 -- Jeremy Bicha <email address hidden> Wed, 10 Apr 2013 16:15:36 -0400

Changed in gnome-control-center (Ubuntu):
status: New → Fix Released
Jeremy Bícha (jbicha)
Changed in gnome-control-center (Ubuntu):
status: Fix Released → Triaged
description: updated
description: updated
Revision history for this message
Martin Pitt (pitti) wrote :

I believe Ryan was looking into this.

summary: - Changing hostname doesn't update /etc/hosts
+ [hostnamed] Changing hostname doesn't update /etc/hosts
Changed in systemd (Ubuntu):
assignee: nobody → Ryan Lortie (desrt)
status: New → Triaged
Changed in systemd (Debian):
status: Unknown → New
Revision history for this message
Ubuntu QA Website (ubuntuqa) wrote :

This bug has been reported on the Ubuntu ISO testing tracker.

A list of all reports related to this bug can be found here:
http://iso.qa.ubuntu.com/qatracker/reports/bugs/1162475

tags: added: iso-testing
Revision history for this message
hackel (hackel) wrote :

This problem still exists in Ubuntu 14.04. My dmesg contains a bunch of these errors:

systemd-hostnamed[1487]: Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!

Running systemd-services 204-5ubuntu13
Also, gnome-control-center (1:3.6.3-0ubuntu54) no longer recommends libnss-myhostname as indicated in #3 above.

Changed in systemd (Ubuntu):
importance: Undecided → Low
assignee: Ryan Lortie (desrt) → nobody
Changed in systemd (Debian):
status: New → Fix Released
Revision history for this message
philinux (philcb) wrote :

Just noticed this in 64 bit 14.04 which is fully up to date.

systemd-hostnamed[8656]: Warning: nss-myhostname is not installed. Changing the local hostname might make it unresolveable. Please install nss-myhostname!

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

Not a bug in systemd itself; (unity|gnome)-control-center need to start depending on libnss-myhostname, like in Debian.

affects: systemd (Debian) → gnome-control-center (Debian)
affects: systemd (Ubuntu) → unity-control-center (Ubuntu)
Revision history for this message
Martin Pitt (pitti) wrote :

Actually, in the MIR bug there is still some dispute, so reassigning back to systemd for now.

affects: unity-control-center (Ubuntu) → systemd (Ubuntu)
Revision history for this message
Vincent Jaubert (0-contact-7) wrote :

Still present on 14.10

Revision history for this message
Sebastien Bacher (seb128) wrote :

That's still an issue, /etc/hosts doesn't seem to update even after installing nss-myhostname

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

> /etc/hosts doesn't seem to update even after installing nss-myhostname

FTR, the purpose of nss-myhostname is *not* to update /etc/hosts, but to add itself to /etc/nsswitch.conf and dynamically resolve its own hostname (from /etc/hostname).

tags: added: rls-w-incoming
tags: added: rls-x-incoming
removed: rls-w-incoming
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in unity-control-center (Ubuntu):
status: New → Confirmed
Revision history for this message
dbstephenson (sxndave) wrote :

issue still remains in ubuntu-control-center 15.04.0+16.04.20160413-0ubuntu1

Revision history for this message
dbstephenson (sxndave) wrote :

typo above, unity-control-center

Changed in unity-control-center (Ubuntu):
importance: Undecided → Low
tags: added: zesty
Revision history for this message
Dan Cotruta (dcotruta) wrote :

I just want to add, this is not minor. If you don't update /etc/hosts then sudo hangs, which in our case breaks automation.

tags: added: rls-ee-incoming
removed: rls-x-incoming
Changed in systemd (Ubuntu Xenial):
status: New → Triaged
importance: Undecided → Low
Changed in unity-control-center (Ubuntu):
status: Confirmed → Won't Fix
Revision history for this message
Sebastien Bacher (seb128) wrote :

@Mathieu, why do you think it's a gnome-control-center issue? It just calls to hostnamed no?

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

I don't think it's *-control-center.

At the time, that was filed there by pitti, who correctly pointed out that something might need to depend on libnss-myhostname (from systemd) for a fallback to resolving hostname via just /etc/hostname (since /etc/hosts isn't changed). At this point though, it looks like this is no longer required.

Now, AFAICT the desktop correctly calls to systemd via dbus to ask for the change. I'll leave to you to make sure this is indeed the case (since you had commented on the bug previously, and I can't see any issues changing hostname as it is now, but maybe I'm not quite doing the same tests you were).

unity-control-center is an obvious Won't Fix for Eoan or Disco, but I'll let the Desktop Team decide whether this needs to be fixed in other releases.

Finally, this is still assigned to systemd, low priority, because hostnamed *doesn't* change /etc/hosts, and probably should (at the very least for consistency, to avoid keeping a reference to an old name for the system); but I didn't notice ill effects from not changing that file. sudo certainly doesn't hang here trying to resolve the new or old hostname.

Changed in gnome-control-center (Ubuntu):
status: Triaged → Invalid
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gnome-control-center (Ubuntu Xenial):
status: New → Confirmed
Changed in unity-control-center (Ubuntu Xenial):
status: New → Confirmed
Revision history for this message
Patrick O'Keeffe (patricktokeeffe) wrote :

Hi apologies if this is the wrong thread. Just wanted to report I see this issue on the Raspberry Pi build of Ubuntu MATE 16.04 running `mate-control-center` 1.16.1-1~xenial4.0 and `systemd` 229-4ubuntu21.22.

I see resolution failures using `sudo` afterwards so even though it still works, stdout gets polluted with error messages. I would call that an ill effect.

Nick Rosbrook (enr0n)
Changed in systemd (Ubuntu):
status: Triaged → Won't Fix
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.