From 117cbd18949a197f663ef51e95535e76e99e387f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 26 Mar 2020 12:41:13 +0100 Subject: libnm: allow setting empty vpn.secrets item Like for data, now also allow empty secrets to be added to the VPN setting. For one, this avoids an assertion failure, where keyfile reader wouldn't check whether a secret key is set to the empty word. For data, it's more clear that we want to allow setting empty data values. VPN settings are only interpreted by the VPN plugin, so libnm and the daemon shouldn't prevent empty settings. It can be useful to distinguish between unset (NULL) and empty values. For secrets, it's less clear that empty secrets shall be allowed. I think it should. Of course, the empty secret likely isn't a correct nor valid secret. But libnm cannot validate the secrets anyway. It's up to the VPN plugin to handle this in any way they see fit. Also, already before, the user could set NM_SETTING_VPN_SECRETS to a string dictionary with empty passwords. So, the API didn't fully prevent that. Only certain API wouldn't play along. --- libnm-core/tests/test-general.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'libnm-core/tests') diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c index 5d3494d869..0301473bc9 100644 --- a/libnm-core/tests/test-general.c +++ b/libnm-core/tests/test-general.c @@ -1197,13 +1197,9 @@ test_setting_vpn_items (void) nm_setting_vpn_add_secret (s_vpn, "", ""); g_test_assert_expected_messages (); - NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (secret && secret[0])); - nm_setting_vpn_add_secret (s_vpn, "foobar1", NULL); - g_test_assert_expected_messages (); - - NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (secret && secret[0])); nm_setting_vpn_add_secret (s_vpn, "foobar1", ""); - g_test_assert_expected_messages (); + + nm_setting_vpn_add_secret (s_vpn, "foobar1", NULL); NMTST_EXPECT_LIBNM_CRITICAL (NMTST_G_RETURN_MSG (key && key[0])); nm_setting_vpn_add_secret (s_vpn, NULL, "blahblah1"); -- cgit v1.2.1