summaryrefslogtreecommitdiff
path: root/src/settings
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2011-06-01 16:10:58 -0500
committerDan Williams <dcbw@redhat.com>2011-06-01 16:10:58 -0500
commit06ec2a5382d61e26cd228ea5c65b476294afc322 (patch)
treeab4ccbd144b282f74728951dc2955ff6b772b9a6 /src/settings
parentc1dd530798301be08197a390516a44c423bfc029 (diff)
downloadNetworkManager-06ec2a5382d61e26cd228ea5c65b476294afc322.tar.gz
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.
Diffstat (limited to 'src/settings')
-rw-r--r--src/settings/plugins/keyfile/reader.c2
-rw-r--r--src/settings/plugins/keyfile/tests/test-keyfile.c12
2 files changed, 10 insertions, 4 deletions
diff --git a/src/settings/plugins/keyfile/reader.c b/src/settings/plugins/keyfile/reader.c
index a8eaaa8e21..7ef429e3c5 100644
--- a/src/settings/plugins/keyfile/reader.c
+++ b/src/settings/plugins/keyfile/reader.c
@@ -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);
diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c
index bfe5aa43d2..80a7f7ff6b 100644
--- a/src/settings/plugins/keyfile/tests/test-keyfile.c
+++ b/src/settings/plugins/keyfile/tests/test-keyfile.c
@@ -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);
}