Commit 91ab673b authored by Dan Williams's avatar Dan Williams

ifcfg-rh: ensure SSIDs don't get double-quoted when written out (rh #606518)

parent 157959a1
......@@ -6329,6 +6329,8 @@ test_write_wifi_open (void)
guint32 channel = 9, mtu = 1345;
GByteArray *mac;
const unsigned char mac_data[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
shvarFile *ifcfg;
char *tmp;
connection = nm_connection_new ();
ASSERT (connection != NULL,
......@@ -6423,6 +6425,22 @@ test_write_wifi_open (void)
&route6file,
&error,
&ignore_error);
/* Now make sure that the ESSID item isn't double-quoted (rh #606518) */
ifcfg = svNewFile (testfile);
ASSERT (ifcfg != NULL,
"wifi-open-write-reread", "failed to load %s as shvarfile", testfile);
tmp = svGetValue (ifcfg, "ESSID", TRUE);
ASSERT (tmp != NULL,
"wifi-open-write-reread", "failed to read ESSID key from %s", testfile);
g_message (tmp);
ASSERT (strncmp (tmp, "\"\"", 2) != 0,
"wifi-open-write-reread", "unexpected ESSID double-quote in %s", testfile);
svCloseFile (ifcfg);
unlink (testfile);
ASSERT (reread != NULL,
......
......@@ -778,13 +778,20 @@ write_wireless_setting (NMConnection *connection,
svSetValue (ifcfg, "ESSID", str->str, TRUE);
g_string_free (str, TRUE);
} else {
/* Printable SSIDs get quoted */
/* Printable SSIDs always get quoted */
memset (buf, 0, sizeof (buf));
memcpy (buf, ssid->data, ssid->len);
tmp2 = svEscape (buf);
tmp = g_strdup_printf ("\"%s\"", tmp2);
svSetValue (ifcfg, "ESSID", tmp, TRUE);
g_free (tmp2);
tmp = svEscape (buf);
/* svEscape will usually quote the string, but just for consistency,
* if svEscape doesn't quote the ESSID, we quote it ourselves.
*/
if (tmp[0] != '"' && tmp[strlen (tmp) - 1] != '"') {
tmp2 = g_strdup_printf ("\"%s\"", tmp);
svSetValue (ifcfg, "ESSID", tmp2, TRUE);
g_free (tmp2);
} else
svSetValue (ifcfg, "ESSID", tmp, TRUE);
g_free (tmp);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment