501
503
new_format = FALSE;
506
510
if (new_format) {
507
ssid = g_malloc0 (array->len + 1);
508
memcpy (ssid, array->data, array->len);
511
ssid = g_malloc0 (array->len + semicolons + 1);
513
memcpy (ssid, array->data, array->len);
515
/* Escape semicolons with backslashes to make strings
516
* containing ';', such as '16;17;' unambiguous */
518
for (i = 0; i < array->len; i++) {
519
if (array->data[i] == ';')
521
ssid[j++] = array->data[i];
509
524
g_key_file_set_string (file, setting_name, key, ssid);
876
891
} else if (type == G_TYPE_BOOLEAN) {
877
892
g_key_file_set_boolean (info->keyfile, setting_name, key, g_value_get_boolean (value));
878
893
} else if (type == G_TYPE_CHAR) {
879
g_key_file_set_integer (info->keyfile, setting_name, key, (int) g_value_get_char (value));
894
g_key_file_set_integer (info->keyfile, setting_name, key, (int) g_value_get_schar (value));
880
895
} else if (type == DBUS_TYPE_G_UCHAR_ARRAY) {
881
896
GByteArray *array;
994
1009
path = g_strdup_printf ("%s/%s-%s", keyfile_dir, filename, nm_connection_get_uuid (connection));
995
1010
if (g_file_test (path, G_FILE_TEST_EXISTS)) {
996
/* Hmm, this is odd. Give up. */
997
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
998
"%s.%d: could not find suitable keyfile file name (%s already used)",
999
__FILE__, __LINE__, path);
1011
if (existing_path == NULL || g_strcmp0 (path, existing_path) != 0) {
1012
/* This should not happen. But, it actually occurs when
1013
* two connections have the same UUID, and one of the connections
1014
* is edited to contain the same ID as the other one.
1017
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,
1018
"%s.%d: could not find suitable keyfile file name (%s already used)",
1019
__FILE__, __LINE__, path);
1026
/* In case of updating the connection and changing the file path,
1027
* we need to remove the old one, not to end up with two connections.
1029
if (existing_path != NULL && strcmp (path, existing_path) != 0)
1030
unlink (existing_path);
1005
1032
g_file_set_contents (path, data, len, error);
1006
1033
if (chown (path, owner_uid, owner_grp) < 0) {
1007
1034
g_set_error (error, KEYFILE_PLUGIN_ERROR, 0,