mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 02:50:10 +01:00
ifcfg-rh: ensure SSIDs don't get double-quoted when written out (rh #606518)
This commit is contained in:
parent
73e7528350
commit
d874beaa7d
2 changed files with 30 additions and 5 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue