File nm-fix-hostname-from-dhcp.patch of Package NetworkManager
Index: NetworkManager-0.7.0/system-settings/plugins/ifcfg-suse/plugin.c
===================================================================
--- NetworkManager-0.7.0.orig/system-settings/plugins/ifcfg-suse/plugin.c
+++ NetworkManager-0.7.0/system-settings/plugins/ifcfg-suse/plugin.c
@@ -57,6 +57,7 @@ G_DEFINE_TYPE_EXTENDED (SCPluginIfcfg, s
typedef struct {
GFileMonitor *hostname_monitor;
+ GFileMonitor *dhcp_monitor;
char *hostname;
} SCPluginIfcfgPrivate;
@@ -180,6 +181,7 @@ init (NMSystemConfigInterface *config, N
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (config);
priv->hostname_monitor = monitor_file_changes (HOSTNAME_FILE, hostname_changed, config);
+ priv->dhcp_monitor = monitor_file_changes (CONF_DHCP, hostname_changed, config);
if (!hostname_is_dynamic ())
priv->hostname = hostname_read ();
@@ -195,6 +197,9 @@ finalize (GObject *object)
{
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (object);
+ if (priv->dhcp_monitor)
+ g_object_unref (priv->dhcp_monitor);
+
if (priv->hostname_monitor)
g_object_unref (priv->hostname_monitor);
Index: NetworkManager-0.7.0/system-settings/src/dbus-settings.c
===================================================================
--- NetworkManager-0.7.0.orig/system-settings/src/dbus-settings.c
+++ NetworkManager-0.7.0/system-settings/src/dbus-settings.c
@@ -251,6 +251,7 @@ get_property (GObject *object, guint pro
NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (object);
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GSList *iter;
+ gboolean cap_hostname;
switch (prop_id) {
@@ -261,6 +262,8 @@ get_property (GObject *object, guint pro
/* Hostname returned is the hostname returned from the first plugin
* that provides one.
*/
+
+ cap_hostname = FALSE;
for (iter = priv->plugins; iter; iter = iter->next) {
NMSystemConfigInterfaceCapabilities caps = NM_SYSTEM_CONFIG_INTERFACE_CAP_NONE;
@@ -268,6 +271,7 @@ get_property (GObject *object, guint pro
if (caps & NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_HOSTNAME) {
char *hostname = NULL;
+ cap_hostname = TRUE;
g_object_get (G_OBJECT (iter->data), NM_SYSTEM_CONFIG_INTERFACE_HOSTNAME, &hostname, NULL);
if (hostname && strlen (hostname)) {
g_value_take_string (value, hostname);
@@ -277,7 +281,7 @@ get_property (GObject *object, guint pro
}
/* If no plugin provided a hostname, try the original hostname of the machine */
- if (!g_value_get_string (value) && priv->orig_hostname)
+ if (!g_value_get_string (value) && !cap_hostname && priv->orig_hostname)
g_value_set_string (value, priv->orig_hostname);
/* Don't ever pass NULL through D-Bus */