Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 260873 Details for
Bug 176873
net-misc/networkmanager changes hostname when connecting to wireless networks
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
fixed read-hostname-patch for net-misc/networkmanager-0.8-r1
networkmanager-0.8-read-hostname.patch (text/plain), 4.02 KB, created by
Tanyel A. Nimeu
on 2011-01-27 15:00:13 UTC
(
hide
)
Description:
fixed read-hostname-patch for net-misc/networkmanager-0.8-r1
Filename:
MIME Type:
Creator:
Tanyel A. Nimeu
Created:
2011-01-27 15:00:13 UTC
Size:
4.02 KB
patch
obsolete
>When reading hostname from NM keyfile, if no hostname is set, read from the >system file at /etc/conf.d/hostname to set hostname. This patch is not meant to >be ever upstreamed. Proper fix is to write a gentoo-specific ifcfg plugin. > >To change hostname, touch nm-system-settings.conf, which will reload the keyfile >and cause /etc/conf.d/hostname to be reloaded. > >This horrible hack fixes http://bugs.gentoo.org/176873 > >Author: Nirbheek Chauhan <nirbheek@gentoo.org> >Reviewed-by: Arun Raghavan <ford_prefect@gentoo.org> > >--- >--- system-settings/plugins/keyfile/plugin.c >+++ system-settings/plugins/keyfile/plugin.c >@@ -43,6 +43,9 @@ > #define KEYFILE_PLUGIN_INFO "(c) 2007 - 2008 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." > > #define CONF_FILE SYSCONFDIR "/NetworkManager/nm-system-settings.conf" >+#ifdef TARGET_GENTOO >+#define HOSTNAME_FILE SYSCONFDIR "/conf.d/hostname" >+#endif > > static char *plugin_get_hostname (SCPluginKeyfile *plugin); > static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class); >@@ -65,6 +65,11 @@ typedef struct { > GFileMonitor *conf_file_monitor; > guint conf_file_monitor_id; > >+#ifdef TARGET_GENTOO >+ GFileMonitor *gentoo_conf_file_monitor; >+ guint gentoo_conf_file_monitor_id; >+#endif >+ > char *hostname; > > gboolean disposed; >@@ -288,6 +293,10 @@ setup_monitoring (NMSystemConfigInterface *config) > SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (config); > GFile *file; > GFileMonitor *monitor; >+#ifdef TARGET_GENTOO >+ GFile *gentoo_file; >+ GFileMonitor *gentoo_monitor; >+#endif > > priv->hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); > >@@ -308,6 +317,17 @@ setup_monitoring (NMSystemConfigInterface *config) > priv->conf_file_monitor_id = g_signal_connect (monitor, "changed", G_CALLBACK (conf_file_changed), config); > priv->conf_file_monitor = monitor; > } >+ >+#ifdef TARGET_GENTOO >+ gentoo_file = g_file_new_for_path (HOSTNAME_FILE); >+ gentoo_monitor = g_file_monitor_file (gentoo_file, G_FILE_MONITOR_NONE, NULL, NULL); >+ g_object_unref (gentoo_file); >+ >+ if (gentoo_monitor) { >+ priv->gentoo_conf_file_monitor_id = g_signal_connect (gentoo_monitor, "changed", G_CALLBACK (conf_file_changed), config); >+ priv->gentoo_conf_file_monitor = monitor; >+ } >+#endif > } > > static void >@@ -381,6 +384,12 @@ > GKeyFile *key_file; > char *hostname = NULL; > GError *error = NULL; >+#ifdef TARGET_GENTOO >+ char *contents = NULL; >+ char **lines = NULL, **line; >+ GError *contents_err = NULL; >+ gsize contents_len = 0; >+#endif > > key_file = g_key_file_new (); > if (g_key_file_load_from_file (key_file, CONF_FILE, G_KEY_FILE_NONE, &error)) >@@ -392,7 +401,37 @@ > > g_key_file_free (key_file); > >+#ifdef TARGET_GENTOO >+ if (hostname) >+ goto out; >+ /* If hostname is unset in keyfile, read system file to get hostname */ >+ if (!g_file_get_contents (HOSTNAME_FILE, &contents, >+ &contents_len, &contents_err)) >+ goto out; >+ >+ lines = g_strsplit_set (contents, "\n\r", 0); >+ if (!lines) >+ goto out; >+ >+ for (line = lines; *line; line++) { >+ if (!g_str_has_prefix (*line, "HOSTNAME=")) >+ continue; >+ hostname = g_strsplit_set (g_strsplit_set (*line, "=", 0)[1], "#", 0)[0]; >+ g_strstrip (hostname); >+ if (!hostname) >+ goto out; >+ /* Remove quotes surrounding hostname */ >+ if (hostname[0] == '"' && hostname[strlen(hostname)-1] == '"') >+ contents = g_strndup(&hostname[1], strlen(hostname)-2); >+ /* Un-escape before using to imitate librc behaviour */ >+ hostname = g_strcompress (contents); >+ } >+ >+out: >+ g_error_free(contents_err); >+ >+#endif > return hostname; > } > > static gboolean >@@ -552,6 +572,16 @@ dispose (GObject *object) > g_object_unref (priv->conf_file_monitor); > } > >+#ifdef TARGET_GENTOO >+ if (priv->gentoo_conf_file_monitor) { >+ if (priv->gentoo_conf_file_monitor_id) >+ g_signal_handler_disconnect (priv->gentoo_conf_file_monitor, priv->gentoo_conf_file_monitor_id); >+ >+ g_file_monitor_cancel (priv->gentoo_conf_file_monitor); >+ g_object_unref (priv->gentoo_conf_file_monitor); >+ } >+#endif >+ > g_free (priv->hostname); > > if (priv->hash)
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 176873
:
118007
|
118008
|
118009
|
118011
|
124584
| 260873