updating the hostname via snappy config does not update /etc/hosts

Bug #1495058 reported by Oliver Grawert on 2015-09-12
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snappy
Medium
Oliver Grawert

Bug Description

when using snappy config to set a hostname only /etc/hostname is updated, but there is no:

127.0.1.1 <newhostname>

added to /etc/hosts which results in:

sudo: unable to resolve host <newhostname>

when using sudo after the name change.

/etc/hosts should be made writable and whatever is used as backend to snappy config here should set a proper "127.0.1.1" entry in that file.

On Sat, Sep 12, 2015 at 11:26:11AM -0000, Oliver Grawert wrote:
> Public bug reported:

> when using snappy config to set a hostname only /etc/hostname is
> updated, but there is no:

> 127.0.1.1 <newhostname>

> added to /etc/hosts which results in:

> sudo: unable to resolve host <newhostname>

> when using sudo after the name change.

> /etc/hosts should be made writable and whatever is used as backend to
> snappy config here should set a proper "127.0.1.1" entry in that file.

You might want to look into whether using libnss-myhostname is a better
choice for snappy, to avoid /etc/hosts having to be added to the list of
bind-mounted files.

Oliver Grawert (ogra) wrote :

i guess that would require using systemd-hostnamed, which we do not do yet apparently:
...
// getHostname returns the hostname for the host
var getHostname = os.Hostname

var hostnamePath = "/etc/writable/hostname"
var syscallSethostname = syscall.Sethostname

// setHostname sets the hostname for the host
var setHostname = func(hostname string) error {
    hostnameB := []byte(hostname)

    if err := syscallSethostname(hostnameB); err != nil {
        return err
    }

    return ioutil.WriteFile(hostnamePath, hostnameB, 0644)
}
...
(from lp:snappy/coreconfig/config.go)

Oliver Grawert (ogra) wrote :

hmm, i just notice that for plain name resolution it shouldnt matter, i'll seed libnss-myhostname for a test to see if it gets along with the symlinked /etc/hosts

Oliver Grawert (ogra) wrote :

tested and verified that libnss-myhostname works fine in our setup

Oliver Grawert (ogra) wrote :

libnss-myhostname is seeded in both, stable and rolling now

Changed in snappy:
status: New → Fix Released
importance: Undecided → Medium
assignee: nobody → Oliver Grawert (ogra)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers