--- src/NetworkManagerPolicy.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) Index: network-manager.ubuntu.07/src/NetworkManagerPolicy.c =================================================================== --- network-manager.ubuntu.07.orig/src/NetworkManagerPolicy.c +++ network-manager.ubuntu.07/src/NetworkManagerPolicy.c @@ -334,16 +334,34 @@ } static void set_system_hostname (const char *new_hostname, const char *msg) { char old_hostname[HOST_NAME_MAX + 1]; int ret = 0; const char *name = new_hostname ? new_hostname : FALLBACK_HOSTNAME; +#ifdef TARGET_DEBIAN + if (!new_hostname) { + static char* sysconf_hostname = NULL; + char *contents = NULL; + gsize contents_len; + GError *error = NULL; + if (!sysconf_hostname && !g_file_get_contents (SYSCONFDIR "/hostname", &contents, &contents_len, &error)) { + nm_warning ("%s: couldn't read " SYSCONFDIR "/hostname: (%d) %s", + __func__, error ? error->code : 0, + (error && error->message) ? error->message : "(unknown)"); + } else if (!sysconf_hostname) { + sysconf_hostname = g_strstrip(contents); + } + if(sysconf_hostname) + name = sysconf_hostname; + } +#endif + old_hostname[HOST_NAME_MAX] = '\0'; errno = 0; ret = gethostname (old_hostname, HOST_NAME_MAX); if (ret != 0) { nm_warning ("%s: couldn't get the system hostname: (%d) %s", __func__, errno, strerror (errno)); } else {