1 |
qiaomuf 10/11/30 09:35:18 |
2 |
|
3 |
Added: networkmanager-0.8.2-accept-gw.patch |
4 |
Log: |
5 |
Accept "gw" by the plugin. That should fix bug #339215 |
6 |
|
7 |
(Portage version: 2.1.9.25/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 net-misc/networkmanager/files/networkmanager-0.8.2-accept-gw.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.8.2-accept-gw.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.8.2-accept-gw.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: networkmanager-0.8.2-accept-gw.patch |
16 |
=================================================================== |
17 |
--- NetworkManager_Patched/system-settings/plugins/ifnet/net_utils.c 2010-11-04 04:10:52.000000000 +0800 |
18 |
+++ NetworkManager-0.8.2/system-settings/plugins/ifnet/net_utils.c 2010-11-23 15:11:08.024000011 +0800 |
19 |
@@ -19,7 +19,6 @@ |
20 |
* Copyright (C) 1999-2010 Gentoo Foundation, Inc. |
21 |
*/ |
22 |
|
23 |
-#include <config.h> |
24 |
#include <stdlib.h> |
25 |
#include <stdio.h> |
26 |
#include <string.h> |
27 |
@@ -194,6 +193,32 @@ |
28 |
return error_quark; |
29 |
} |
30 |
|
31 |
+static char * |
32 |
+find_default_gateway_str (char *str) |
33 |
+{ |
34 |
+ char *tmp; |
35 |
+ |
36 |
+ if ((tmp = strstr (str, "default via ")) != NULL) { |
37 |
+ return tmp + strlen ("default via "); |
38 |
+ } else if ((tmp = strstr (str, "default gw ")) != NULL) { |
39 |
+ return tmp + strlen ("default gw "); |
40 |
+ } |
41 |
+ return NULL; |
42 |
+} |
43 |
+ |
44 |
+static char * |
45 |
+find_gateway_str (char *str) |
46 |
+{ |
47 |
+ char *tmp; |
48 |
+ |
49 |
+ if ((tmp = strstr (str, "via ")) != NULL) { |
50 |
+ return tmp + strlen ("via "); |
51 |
+ } else if ((tmp = strstr (str, "gw ")) != NULL) { |
52 |
+ return tmp + strlen ("gw "); |
53 |
+ } |
54 |
+ return NULL; |
55 |
+} |
56 |
+ |
57 |
gboolean |
58 |
reload_parsers () |
59 |
{ |
60 |
@@ -362,11 +387,10 @@ |
61 |
if (!tmp) |
62 |
return FALSE; |
63 |
routes = g_strdup (tmp); |
64 |
- tmp = strstr (routes, "default via "); |
65 |
+ tmp = find_default_gateway_str (routes); |
66 |
if (!tmp) { |
67 |
goto error; |
68 |
} |
69 |
- tmp += strlen ("default via "); |
70 |
g_strstrip (tmp); |
71 |
if ((end = strstr (tmp, "\"")) != NULL) |
72 |
*end = '\0'; |
73 |
@@ -483,8 +507,13 @@ |
74 |
|
75 |
if (!gateway) |
76 |
return 0; |
77 |
- tmp = strstr (gateway, "via "); |
78 |
- tmp = g_strdup (tmp + strlen ("via ")); |
79 |
+ tmp = find_gateway_str(gateway); |
80 |
+ if (!tmp) { |
81 |
+ PLUGIN_WARN (IFNET_PLUGIN_NAME, |
82 |
+ "Couldn't obtain gateway in \"%s\"", gateway); |
83 |
+ return 0; |
84 |
+ } |
85 |
+ tmp = g_strdup (tmp); |
86 |
strip_string (tmp, ' '); |
87 |
strip_string (tmp, '"'); |
88 |
if ((split = strstr (tmp, "\"")) != NULL) |
89 |
@@ -509,8 +538,13 @@ |
90 |
|
91 |
if (!next_hop) |
92 |
return 0; |
93 |
- tmp = strstr (next_hop, "via "); |
94 |
- tmp = g_strdup (tmp + strlen ("via ")); |
95 |
+ tmp = find_gateway_str(next_hop); |
96 |
+ if (!tmp) { |
97 |
+ PLUGIN_WARN (IFNET_PLUGIN_NAME, |
98 |
+ "Couldn't obtain next_hop in \"%s\"", next_hop); |
99 |
+ return 0; |
100 |
+ } |
101 |
+ tmp = g_strdup (tmp); |
102 |
strip_string (tmp, ' '); |
103 |
strip_string (tmp, '"'); |
104 |
g_strstrip (tmp); |
105 |
@@ -671,8 +705,8 @@ |
106 |
length = g_strv_length (ipset); |
107 |
for (i = 0; i < length; i++) { |
108 |
ip = ipset[i]; |
109 |
- if (strstr (ip, "default via ") || strstr (ip, "::") |
110 |
- || !strstr (ip, "via")) |
111 |
+ if (find_default_gateway_str (ip) || strstr (ip, "::") |
112 |
+ || !find_gateway_str (ip)) |
113 |
continue; |
114 |
ip = strip_string (ip, '"'); |
115 |
iblock = create_ip4_block (ip); |
116 |
@@ -712,9 +746,7 @@ |
117 |
ip = strip_string (ip, '"'); |
118 |
if (ip[0] == '\0') |
119 |
continue; |
120 |
- printf ("ip:%s\n", ip); |
121 |
- if ((tmp_addr = strstr (ip, "default via ")) != NULL) { |
122 |
- tmp_addr += strlen ("default via "); |
123 |
+ if ((tmp_addr = find_default_gateway_str (ip)) != NULL) { |
124 |
if (!is_ip6_address (tmp_addr)) |
125 |
continue; |
126 |
else { |
127 |
@@ -855,7 +887,7 @@ |
128 |
void |
129 |
get_dhcp_hostname_and_client_id (char **hostname, char **client_id) |
130 |
{ |
131 |
- gchar *dhcp_client = ifnet_get_global_setting ("main", "dhcp"); |
132 |
+ gchar *dhcp_client = NULL; |
133 |
const gchar *dhcpcd_conf = "/etc/dhcpcd.conf"; |
134 |
const gchar *dhclient_conf = "/etc/dhcp/dhclient.conf"; |
135 |
gchar *line = NULL, *tmp = NULL, *contents = NULL; |
136 |
@@ -864,6 +896,7 @@ |
137 |
|
138 |
*hostname = NULL; |
139 |
*client_id = NULL; |
140 |
+ dhcp_client = ifnet_get_global_setting ("main", "dhcp"); |
141 |
if (dhcp_client) { |
142 |
if (!strcmp (dhcp_client, "dhclient")) |
143 |
g_file_get_contents (dhclient_conf, &contents, NULL, |
144 |
@@ -871,6 +904,7 @@ |
145 |
else if (!strcmp (dhcp_client, "dhcpcd")) |
146 |
g_file_get_contents (dhcpcd_conf, &contents, NULL, |
147 |
NULL); |
148 |
+ g_free (dhcp_client); |
149 |
} else { |
150 |
if (g_file_test (dhclient_conf, G_FILE_TEST_IS_REGULAR)) |
151 |
g_file_get_contents (dhclient_conf, &contents, NULL, |