summaryrefslogtreecommitdiff
blob: ff4c1f253677209bc8bb3cf8651dc586b1638b13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
From 776fafc133e18df48dc92a717c662e1b2858567e Mon Sep 17 00:00:00 2001
From: Mu Qiao <qiaomuf@gentoo.org>
Date: Fri, 25 Feb 2011 16:25:07 +0000
Subject: [PATCH 3/3] Won't write when nothing changed
 Signed-off-by: Mu Qiao <qiaomuf@gentoo.org>
 Make log less excessive, accept non-alnum ssid (bug #356337)

Signed-off-by: Mu Qiao <qiaomuf@gentoo.org>
---
 system-settings/plugins/ifnet/connection_parser.c |   33 +++++++++-----------
 system-settings/plugins/ifnet/net_parser.c        |    8 ++++-
 system-settings/plugins/ifnet/plugin.c            |    4 --
 system-settings/plugins/ifnet/wpa_parser.c        |    7 +++-
 4 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/system-settings/plugins/ifnet/connection_parser.c b/system-settings/plugins/ifnet/connection_parser.c
index 9b5ddc1..4ac2173 100644
--- a/system-settings/plugins/ifnet/connection_parser.c
+++ b/system-settings/plugins/ifnet/connection_parser.c
@@ -55,9 +55,16 @@ update_connection_id (NMConnection * connection, gchar * conn_name)
 	gchar *idstr = NULL;
 	gchar *uuid_base = NULL;
 	gchar *uuid = NULL;
+	int name_len;
 	NMSettingConnection *setting;
 
-	idstr = g_strdup_printf ("%s (%s)", get_prefix (), conn_name);
+	name_len = strlen (conn_name);
+	if ((name_len > 2) && (g_str_has_prefix (conn_name, "0x"))) {
+		gchar * conn_name_printable = utils_hexstr2bin (conn_name + 2, name_len - 2);
+		idstr = g_strdup_printf ("%s (%s)", get_prefix (), conn_name_printable);
+		g_free (conn_name_printable);
+	} else
+		idstr = g_strdup_printf ("%s (%s)", get_prefix (), conn_name);
 	uuid_base = idstr;
 	uuid = nm_utils_uuid_generate_from_string (uuid_base);
 	setting =
@@ -627,23 +634,13 @@ make_ip4_setting (NMConnection * connection, gchar * conn_name, GError ** error)
 				g_object_set (ip4_setting,
 					      NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES,
 					      TRUE, NULL);
-			if (nm_setting_ip4_config_add_address
-			    (ip4_setting, ip4_addr)) {
-				PLUGIN_PRINT (IFNET_PLUGIN_NAME,
-					      "new address: %d", iblock->ip);
-				PLUGIN_PRINT (IFNET_PLUGIN_NAME,
-					      "ipv4 addresses count: %d",
-					      nm_setting_ip4_config_get_num_addresses
-					      (ip4_setting));
-			} else {
-				PLUGIN_WARN (IFNET_PLUGIN_NAME,
-					     "ignoring duplicate IP4 address");
-			}
+			if (!nm_setting_ip4_config_add_address (ip4_setting, ip4_addr))
+				PLUGIN_WARN (IFNET_PLUGIN_NAME, 
+						"ignoring duplicate IP4 address");
 			nm_ip4_address_unref (ip4_addr);
 			current_iblock = iblock;
 			iblock = iblock->next;
 			destroy_ip_block (current_iblock);
-
 		}
 		g_object_set (ip4_setting,
 			      NM_SETTING_IP4_CONFIG_METHOD,
@@ -2276,11 +2273,12 @@ write_wireless_setting (NMConnection * connection,
 		return FALSE;
 	}
 
-	/* If the SSID contains any non-printable characters, we need to use the
-	 * hex notation of the SSID instead.
+	/* If the SSID contains any non-alnum characters, we need to use 
+	 * the hex notation of the SSID instead. (Because openrc doesn't 
+	 * support these characters, see bug #356337)
 	 */
 	for (i = 0; i < ssid->len; i++) {
-		if (!isprint (ssid->data[i])) {
+		if (!isalnum (ssid->data[i])) {
 			hex_ssid = TRUE;
 			break;
 		}
@@ -2487,7 +2485,6 @@ write_ip4_setting (NMConnection * connection, gchar * conn_name,
 		ifnet_set_data (conn_name, "config", "dhcp");
 
 	/* DNS Servers */
-	ifnet_set_data (conn_name, "dns_servers", NULL);
 	num = nm_setting_ip4_config_get_num_dns (s_ip4);
 	if (num > 0) {
 		dns = g_string_new (NULL);
diff --git a/system-settings/plugins/ifnet/net_parser.c b/system-settings/plugins/ifnet/net_parser.c
index de2db8a..57f3688 100644
--- a/system-settings/plugins/ifnet/net_parser.c
+++ b/system-settings/plugins/ifnet/net_parser.c
@@ -411,12 +411,16 @@ ifnet_set_data (gchar * conn_name, gchar * key, gchar * value)
 	}
 	/* Remove existing key value pair */
 	if (g_hash_table_lookup_extended (conn, key, &orin_key, &orin_value)) {
-		if (new_value && !strcmp (orin_value, new_value))
+		if (new_value && !strcmp (orin_value, new_value)){
+			g_free (new_value);
 			return;
+		}
 		g_hash_table_remove (conn, orin_key);
 		g_free (orin_key);
 		g_free (orin_value);
-	}
+	/* old key/value doesn't exist but new value is NULL  */
+	} else if (!value)
+		return;
 	if (new_value)
 		g_hash_table_insert (conn, g_strdup (key), new_value);
 	net_parser_data_changed = TRUE;
diff --git a/system-settings/plugins/ifnet/plugin.c b/system-settings/plugins/ifnet/plugin.c
index 94f9e79..3952e91 100644
--- a/system-settings/plugins/ifnet/plugin.c
+++ b/system-settings/plugins/ifnet/plugin.c
@@ -91,8 +91,6 @@ update_system_hostname (gpointer config)
 {
 	SCPluginIfnetPrivate *priv = SC_PLUGIN_IFNET_GET_PRIVATE (config);
 
-	PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Updating hostname");
-
 	if (priv->hostname)
 		g_free (priv->hostname);
 	priv->hostname = read_hostname (IFNET_SYSTEM_HOSTNAME_FILE);
@@ -184,8 +182,6 @@ monitor_file_changes (const char *filename,
 				   info);
 		g_signal_connect (monitor, "changed", G_CALLBACK (file_changed),
 				  info);
-		PLUGIN_PRINT (IFNET_PLUGIN_NAME, "Monitoring %s", filename);
-
 	} else
 		PLUGIN_WARN (IFNET_PLUGIN_NAME,
 			     "Monitoring %s failed, error: %s", filename,
diff --git a/system-settings/plugins/ifnet/wpa_parser.c b/system-settings/plugins/ifnet/wpa_parser.c
index 42c52c3..338c338 100644
--- a/system-settings/plugins/ifnet/wpa_parser.c
+++ b/system-settings/plugins/ifnet/wpa_parser.c
@@ -463,12 +463,15 @@ wpa_set_data (gchar * ssid, gchar * key, gchar * value)
 	/* Remove old key value pairs */
 	if (g_hash_table_lookup_extended
 	    (security, key, &orig_key, &orig_value)) {
-		if (new_value && !strcmp(orig_value, new_value))
+		if (new_value && !strcmp(orig_value, new_value)){
+			g_free (new_value);
 			return;
+		}
 		g_hash_table_remove (security, orig_key);
 		g_free (orig_key);
 		g_free (orig_value);
-	}
+	} else if (!value)
+		return;
 
 	/* Add new key value */
 	if (new_value)
-- 
1.7.3.4