Hi Thomas,

Thomas Danckaert <thomas.dancka...@aeronomie.be> skribis:

> AFAIU, the cause is that networkmanager changes my hostname

I’ve never experienced this (even though I don’t have /etc/hostname),
but that looks like a serious bug we should fix.  Why would NM fiddle
with the host name?

I see that NM implements a “SetHostname” D-Bus RPC, and ‘nmtui’ has a
menu item to change the host name.

In NM, the ‘update_system_hostname’ function has this comment:

        /* Hostname precedence order:
         *
         * 1) a configured hostname (from settings)
         * 2) automatic hostname from the default device's config (DHCP, VPN, 
etc)
         * 3) the last hostname set outside NM
         * 4) reverse-DNS of the best device's IPv4 address
         *
         */

Then nm-settings.c has code to deal with host names in all sort of
unpredictable ways.  To give you an idea:

--8<---------------cut here---------------start------------->8---
#define HOSTNAME_FILE_DEFAULT        "/etc/hostname"
#define HOSTNAME_FILE_UCASE_HOSTNAME "/etc/HOSTNAME"
#define HOSTNAME_FILE_GENTOO         "/etc/conf.d/hostname"

[...]

#if defined(HOSTNAME_PERSIST_SUSE)
#define HOSTNAME_FILE           HOSTNAME_FILE_UCASE_HOSTNAME
#elif defined(HOSTNAME_PERSIST_SLACKWARE)
#define HOSTNAME_FILE           HOSTNAME_FILE_UCASE_HOSTNAME
#elif defined(HOSTNAME_PERSIST_GENTOO)
#define HOSTNAME_FILE           HOSTNAME_FILE_GENTOO
#else
#define HOSTNAME_FILE           HOSTNAME_FILE_DEFAULT
#endif

[...]

static gchar *
read_hostname_gentoo (const char *path)
--8<---------------cut here---------------end--------------->8---

So, like Chris wrote, it honors /etc/hostname or /etc/HoSTNaM3 depending
on the phase of the moon.

I don’t understand the logic in there, but a quick fix would be to have
‘network-manager-service-type’ create /etc/hostname.

What do people think?

Ludo’.

Reply via email to