/[gentoo-x86]/net-misc/networkmanager/files/networkmanager-0.8-read-hostname.patch
Gentoo

Contents of /net-misc/networkmanager/files/networkmanager-0.8-read-hostname.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Thu Sep 13 09:54:12 2012 UTC (21 months, 4 weeks ago) by tetromino
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Version bump with various fixes. No longer saves thousands of temporary ipv6 routes (bug #428274, thanks to Matthias Nagel). No longer installs dispatcher and init scripts when USE=systemd to avoid annoying systemd users (bug #434692, thanks to Arne St├Ącker). Drop old.

(Portage version: 2.2.0_alpha125/cvs/Linux x86_64)

1 When reading hostname from NM keyfile, if no hostname is set, read from the
2 system file at /etc/conf.d/hostname to set hostname. This patch is not meant to
3 be ever upstreamed. Proper fix is to write a gentoo-specific ifcfg plugin.
4
5 To change hostname, touch nm-system-settings.conf, which will reload the keyfile
6 and cause /etc/conf.d/hostname to be reloaded.
7
8 This horrible hack fixes http://bugs.gentoo.org/176873
9
10 Author: Nirbheek Chauhan <nirbheek@gentoo.org>
11 Reviewed-by: Arun Raghavan <ford_prefect@gentoo.org>
12
13 ---
14 --- system-settings/plugins/keyfile/plugin.c
15 +++ system-settings/plugins/keyfile/plugin.c
16 @@ -43,6 +43,9 @@
17 #define KEYFILE_PLUGIN_INFO "(c) 2007 - 2008 Red Hat, Inc. To report bugs please use the NetworkManager mailing list."
18
19 #define CONF_FILE SYSCONFDIR "/NetworkManager/nm-system-settings.conf"
20 +#ifdef TARGET_GENTOO
21 +#define HOSTNAME_FILE SYSCONFDIR "/conf.d/hostname"
22 +#endif
23
24 static char *plugin_get_hostname (SCPluginKeyfile *plugin);
25 static void system_config_interface_init (NMSystemConfigInterface *system_config_interface_class);
26 @@ -381,6 +384,12 @@
27 GKeyFile *key_file;
28 char *hostname = NULL;
29 GError *error = NULL;
30 +#ifdef TARGET_GENTOO
31 + char *contents = NULL;
32 + char **lines = NULL, **line;
33 + GError *contents_err = NULL;
34 + gsize contents_len = 0;
35 +#endif
36
37 key_file = g_key_file_new ();
38 if (g_key_file_load_from_file (key_file, CONF_FILE, G_KEY_FILE_NONE, &error))
39 @@ -392,7 +401,37 @@
40
41 g_key_file_free (key_file);
42
43 + if (hostname)
44 + goto out;
45 +#ifdef TARGET_GENTOO
46 + /* If hostname is unset in keyfile, read system file to get hostname */
47 + if (!g_file_get_contents (HOSTNAME_FILE, &contents,
48 + &contents_len, &contents_err))
49 + goto out;
50 +
51 + lines = g_strsplit_set (contents, "\n\r", 0);
52 + if (!lines)
53 + goto out;
54 +
55 + for (line = lines; *line; line++) {
56 + if (!g_str_has_prefix (*line, "hostname="))
57 + continue;
58 + hostname = g_strsplit_set (g_strsplit_set (*line, "=", 0)[1], "#", 0)[0];
59 + g_strstrip (hostname);
60 + if (!hostname)
61 + goto out;
62 + /* Remove quotes surrounding hostname */
63 + if (hostname[0] == '"' && hostname[strlen(hostname)-1] == '"')
64 + contents = g_strndup(&hostname[1], strlen(hostname)-2);
65 + /* Un-escape before using to imitate librc behaviour */
66 + hostname = g_strcompress (contents);
67 + }
68 +
69 +out:
70 + g_error_free(contents_err);
71 +
72 return hostname;
73 +#endif
74 }
75
76 static gboolean

  ViewVC Help
Powered by ViewVC 1.1.20