keyfile: convert relative cert/key paths to absolute ones when reading

Passing a relative path to wpa_supplicant does no good since the supplicant
may not have the same working directory as NetworkManager.  Relative paths
used in keyfiles are assumed to be relative to the keyfile itself anyway,
so actually use the absolute path we compute for the cert/key instead of
leaving it relative.
This commit is contained in:
Dan Williams 2011-06-01 16:10:58 -05:00
parent c1dd530798
commit 06ec2a5382
2 changed files with 10 additions and 4 deletions

View file

@ -865,7 +865,7 @@ cert_parser (NMSetting *setting, const char *key, GKeyFile *keyfile, const char
/* Construct the proper value as required for the PATH scheme */
val = g_byte_array_sized_new (strlen (SCHEME_PATH) + array->len + 1);
g_byte_array_append (val, (const guint8 *) SCHEME_PATH, strlen (SCHEME_PATH));
g_byte_array_append (val, array->data, array->len);
g_byte_array_append (val, (const guint8 *) path, strlen (path));
g_byte_array_append (val, (const guint8 *) "\0", 1);
g_object_set (setting, key, val, NULL);
g_byte_array_free (val, TRUE);

View file

@ -2019,6 +2019,7 @@ test_read_wired_8021x_tls_new_connection (void)
NMSetting8021x *s_8021x;
GError *error = NULL;
const char *tmp;
char *tmp2;
gboolean success;
connection = nm_keyfile_plugin_connection_from_file (TEST_WIRED_TLS_NEW_FILE, &error);
@ -2053,15 +2054,20 @@ test_read_wired_8021x_tls_new_connection (void)
tmp = nm_setting_802_1x_get_private_key_password (s_8021x);
g_assert (g_strcmp0 (tmp, "12345testing") == 0);
tmp2 = g_strdup_printf (TEST_KEYFILES_DIR "/test-ca-cert.pem");
tmp = nm_setting_802_1x_get_ca_cert_path (s_8021x);
g_assert (g_strcmp0 (tmp, "test-ca-cert.pem") == 0);
g_assert_cmpstr (tmp, ==, tmp2);
g_free (tmp2);
tmp2 = g_strdup_printf (TEST_KEYFILES_DIR "/test-key-and-cert.pem");
tmp = nm_setting_802_1x_get_client_cert_path (s_8021x);
g_assert (g_strcmp0 (tmp, "test-key-and-cert.pem") == 0);
g_assert_cmpstr (tmp, ==, tmp2);
tmp = nm_setting_802_1x_get_private_key_path (s_8021x);
g_assert (g_strcmp0 (tmp, "test-key-and-cert.pem") == 0);
g_assert_cmpstr (tmp, ==, tmp2);
g_free (tmp2);
g_object_unref (connection);
}