diff --git a/system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c index 2e61e4b2c4..6e873fe82b 100644 --- a/system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c +++ b/system-settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c @@ -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, diff --git a/system-settings/plugins/ifcfg-rh/writer.c b/system-settings/plugins/ifcfg-rh/writer.c index 2d206c7354..90a7549c15 100644 --- a/system-settings/plugins/ifcfg-rh/writer.c +++ b/system-settings/plugins/ifcfg-rh/writer.c @@ -768,13 +768,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); }