diff options
author | Thomas Haller <thaller@redhat.com> | 2019-01-31 10:04:43 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-02-04 11:00:17 +0100 |
commit | 92ccb9de50a7f114403f1af867a9ca741a0562e0 (patch) | |
tree | de804e040de1f9e808b0b64b1596bd0cf1a3baf2 | |
parent | d3144b99a94f9c0aae8fea872925155c0feb2165 (diff) | |
download | NetworkManager-92ccb9de50a7f114403f1af867a9ca741a0562e0.tar.gz |
settings: fix handling of VPN secrets in for_each_secret()
nm_setting_get_secret_flags() looks whether we have a suitable "-flags"
data value, or whether we have a secret with that name.
In fact, we know this is a valid secret-name. Even if there are no secret-flags
and the secret (currently) does not exists. We shall not care about the
return value.
Note that nm_setting_get_secret_flags() also for non-secrets will set
the flags to "NONE", which is just what we need.
-rw-r--r-- | src/settings/nm-settings-connection.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c index 68efe8d31c..9ea3253733 100644 --- a/src/settings/nm-settings-connection.c +++ b/src/settings/nm-settings-connection.c @@ -279,11 +279,12 @@ for_each_secret (NMConnection *self, g_variant_builder_init (&vpn_secrets_builder, G_VARIANT_TYPE ("a{ss}")); g_variant_iter_init (&vpn_secrets_iter, val); while (g_variant_iter_next (&vpn_secrets_iter, "{&s&s}", &vpn_secret_name, &secret)) { - if (!nm_setting_get_secret_flags (setting, vpn_secret_name, &secret_flags, NULL)) { - if (!remove_non_secrets) - g_variant_builder_add (&vpn_secrets_builder, "{ss}", vpn_secret_name, secret); - continue; - } + + /* we ignore the return value of get_secret_flags. The function may determine + * that this is not a secret, based on having not secret-flags and no secrets. + * But we have the secret at hand. We know it would be a valid secret, if we + * only would add it to the VPN settings. */ + nm_setting_get_secret_flags (setting, vpn_secret_name, &secret_flags, NULL); if (callback (secret_flags, callback_data)) g_variant_builder_add (&vpn_secrets_builder, "{ss}", vpn_secret_name, secret); |