Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 592972 Details for
Bug 831735
NetworkManager should not touch the hostname
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
patch
0001-ifcfg-rh-etc-hostname-should-override-etc-sysconfig-.patch (text/plain), 7.68 KB, created by
Dan Winship
on 2012-06-19 14:11:40 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Dan Winship
Created:
2012-06-19 14:11:40 UTC
Size:
7.68 KB
patch
obsolete
>From 34c0e3955111e87331e33b408c923420eee271a2 Mon Sep 17 00:00:00 2001 >From: Dan Winship <danw@gnome.org> >Date: Tue, 19 Jun 2012 10:07:17 -0400 >Subject: [PATCH] ifcfg-rh: /etc/hostname should override > /etc/sysconfig/network > >When determining the system hostname, /etc/hostname should override >/etc/sysconfig/network, so monitor both files. Switch to use >GFileMonitor rather than using inotify directly, because GFileMonitor >also deals with watching for file creation if the file doesn't exist >yet when you start monitoring it. > >When setting the hostname, set it in /etc/hostname, and delete the >/etc/sysconfig/network HOSTNAME entry if present. > >https://bugzilla.redhat.com/show_bug.cgi?id=831735 >--- > src/settings/plugins/ifcfg-rh/plugin.c | 120 ++++++++++++++++++++------------ > 1 file changed, 76 insertions(+), 44 deletions(-) > >diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c >index 04d5463..a9bed47 100644 >--- a/src/settings/plugins/ifcfg-rh/plugin.c >+++ b/src/settings/plugins/ifcfg-rh/plugin.c >@@ -46,7 +46,6 @@ > #include "nm-settings-error.h" > > #include "nm-ifcfg-connection.h" >-#include "nm-inotify-helper.h" > #include "shvar.h" > #include "writer.h" > #include "utils.h" >@@ -78,12 +77,14 @@ G_DEFINE_TYPE_EXTENDED (SCPluginIfcfg, sc_plugin_ifcfg, G_TYPE_OBJECT, 0, > typedef struct { > GHashTable *connections; > >- gulong ih_event_id; >- int sc_network_wd; > char *hostname; > >- GFileMonitor *monitor; >- guint monitor_id; >+ GFileMonitor *ifcfg_monitor; >+ guint ifcfg_monitor_id; >+ GFileMonitor *sc_network_monitor; >+ guint sc_network_monitor_id; >+ GFileMonitor *hostname_monitor; >+ guint hostname_monitor_id; > > DBusGConnection *bus; > } SCPluginIfcfgPrivate; >@@ -325,11 +326,11 @@ connection_new_or_changed (SCPluginIfcfg *self, > } > > static void >-dir_changed (GFileMonitor *monitor, >- GFile *file, >- GFile *other_file, >- GFileMonitorEvent event_type, >- gpointer user_data) >+ifcfg_dir_changed (GFileMonitor *monitor, >+ GFile *file, >+ GFile *other_file, >+ GFileMonitorEvent event_type, >+ gpointer user_data) > { > SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data); > SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); >@@ -379,8 +380,9 @@ setup_ifcfg_monitoring (SCPluginIfcfg *plugin) > g_object_unref (file); > > if (monitor) { >- priv->monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (dir_changed), plugin); >- priv->monitor = monitor; >+ priv->ifcfg_monitor_id = g_signal_connect (monitor, "changed", >+ G_CALLBACK (ifcfg_dir_changed), plugin); >+ priv->ifcfg_monitor = monitor; > } > } > >@@ -463,7 +465,8 @@ add_connection (NMSystemConfigInterface *config, > return (NMSettingsConnection *) added; > } > >-#define SC_NETWORK_FILE SYSCONFDIR"/sysconfig/network" >+#define SC_NETWORK_FILE "/etc/sysconfig/network" >+#define HOSTNAME_FILE "/etc/hostname" > > static char * > plugin_get_hostname (SCPluginIfcfg *plugin) >@@ -472,6 +475,11 @@ plugin_get_hostname (SCPluginIfcfg *plugin) > char *hostname; > gboolean ignore_localhost; > >+ if (g_file_get_contents (HOSTNAME_FILE, &hostname, NULL, NULL)) { >+ g_strchomp (hostname); >+ return hostname; >+ } >+ > network = svNewFile (SC_NETWORK_FILE); > if (!network) { > PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not get hostname: failed to read " SC_NETWORK_FILE); >@@ -500,34 +508,35 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) > SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); > shvarFile *network; > >- network = svCreateFile (SC_NETWORK_FILE); >- if (!network) { >- PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not save hostname: failed to create/open " SC_NETWORK_FILE); >+ if (!g_file_set_contents (HOSTNAME_FILE, hostname, -1, NULL)) { >+ PLUGIN_WARN (IFCFG_PLUGIN_NAME, "Could not save hostname: failed to create/open " HOSTNAME_FILE); > return FALSE; > } > >- svSetValue (network, "HOSTNAME", hostname, FALSE); >- svWriteFile (network, 0644); >- svCloseFile (network); >- > g_free (priv->hostname); > priv->hostname = g_strdup (hostname); >+ >+ network = svNewFile (SC_NETWORK_FILE); >+ if (network) { >+ svSetValue (network, "HOSTNAME", NULL, FALSE); >+ svWriteFile (network, 0644); >+ svCloseFile (network); >+ } >+ > return TRUE; > } > > static void >-sc_network_changed_cb (NMInotifyHelper *ih, >- struct inotify_event *evt, >- const char *path, >- gpointer user_data) >+hostname_maybe_changed (GFileMonitor *monitor, >+ GFile *file, >+ GFile *other_file, >+ GFileMonitorEvent event_type, >+ gpointer user_data) > { > SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data); > SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); > char *new_hostname; > >- if (evt->wd != priv->sc_network_wd) >- return; >- > new_hostname = plugin_get_hostname (plugin); > if ( (new_hostname && !priv->hostname) > || (!new_hostname && priv->hostname) >@@ -611,13 +620,28 @@ static void > sc_plugin_ifcfg_init (SCPluginIfcfg *plugin) > { > SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); >- NMInotifyHelper *ih; > GError *error = NULL; > gboolean success = FALSE; >+ GFile *file; >+ GFileMonitor *monitor; >+ >+ file = g_file_new_for_path (SC_NETWORK_FILE); >+ monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); >+ g_object_unref (file); >+ if (monitor) { >+ priv->sc_network_monitor_id = >+ g_signal_connect (monitor, "changed", G_CALLBACK (hostname_maybe_changed), plugin); >+ priv->sc_network_monitor = monitor; >+ } > >- ih = nm_inotify_helper_get (); >- priv->ih_event_id = g_signal_connect (ih, "event", G_CALLBACK (sc_network_changed_cb), plugin); >- priv->sc_network_wd = nm_inotify_helper_add_watch (ih, SC_NETWORK_FILE); >+ file = g_file_new_for_path (HOSTNAME_FILE); >+ monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); >+ g_object_unref (file); >+ if (monitor) { >+ priv->sc_network_monitor_id = >+ g_signal_connect (monitor, "changed", G_CALLBACK (hostname_maybe_changed), plugin); >+ priv->sc_network_monitor = monitor; >+ } > > priv->hostname = plugin_get_hostname (plugin); > >@@ -667,31 +691,39 @@ dispose (GObject *object) > { > SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (object); > SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin); >- NMInotifyHelper *ih; > > if (priv->bus) { > dbus_g_connection_unref (priv->bus); > priv->bus = NULL; > } > >- ih = nm_inotify_helper_get (); >- >- g_signal_handler_disconnect (ih, priv->ih_event_id); >- >- if (priv->sc_network_wd >= 0) >- nm_inotify_helper_remove_watch (ih, priv->sc_network_wd); >- > g_free (priv->hostname); > > if (priv->connections) > g_hash_table_destroy (priv->connections); > >- if (priv->monitor) { >- if (priv->monitor_id) >- g_signal_handler_disconnect (priv->monitor, priv->monitor_id); >+ if (priv->ifcfg_monitor) { >+ if (priv->ifcfg_monitor_id) >+ g_signal_handler_disconnect (priv->ifcfg_monitor, priv->ifcfg_monitor_id); >+ >+ g_file_monitor_cancel (priv->ifcfg_monitor); >+ g_object_unref (priv->ifcfg_monitor); >+ } >+ >+ if (priv->sc_network_monitor) { >+ if (priv->sc_network_monitor_id) >+ g_signal_handler_disconnect (priv->sc_network_monitor, priv->sc_network_monitor_id); >+ >+ g_file_monitor_cancel (priv->sc_network_monitor); >+ g_object_unref (priv->sc_network_monitor); >+ } >+ >+ if (priv->hostname_monitor) { >+ if (priv->hostname_monitor_id) >+ g_signal_handler_disconnect (priv->hostname_monitor, priv->hostname_monitor_id); > >- g_file_monitor_cancel (priv->monitor); >- g_object_unref (priv->monitor); >+ g_file_monitor_cancel (priv->hostname_monitor); >+ g_object_unref (priv->hostname_monitor); > } > > G_OBJECT_CLASS (sc_plugin_ifcfg_parent_class)->dispose (object); >-- >1.7.10.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 831735
:
592972
|
594242