summaryrefslogtreecommitdiff
path: root/src/settings/nm-settings-connection.c
diff options
context:
space:
mode:
authorAndrew Zaborowski <andrew.zaborowski@intel.com>2018-06-15 04:46:36 +0200
committerThomas Haller <thaller@redhat.com>2018-06-22 16:46:05 +0200
commitbf7705a4b8140ea421b28aefd6057ac454458681 (patch)
treee661d47a92f6e9ab86e3158dff721b8233971a12 /src/settings/nm-settings-connection.c
parentd1163e9499825991aa4a28962bf5b642549a3753 (diff)
downloadNetworkManager-bf7705a4b8140ea421b28aefd6057ac454458681.tar.gz
settings-connection: don't expect system_secrets always present
priv->system_secrets may be updated by e.g. nm_settings_connection_new_secrets and nm_settings_connection_update, but if the plugin creates the object with g_object_new, then adds some settings but never adds any secrets there's no reason to call either of those two methods. A call to nm_settings_connection_get_secrets should still be able to request new secrets (and may then update priv->system_secrets as a result). (cherry picked from commit f11246154eafe82b4e8acd52aa1c8ce21f0f5500)
Diffstat (limited to 'src/settings/nm-settings-connection.c')
-rw-r--r--src/settings/nm-settings-connection.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index 50cc14274d..c09f680400 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -1033,7 +1033,7 @@ get_secrets_done_cb (NMAgentManager *manager,
NMSettingsConnectionPrivate *priv;
NMConnection *applied_connection;
gs_free_error GError *local = NULL;
- GVariant *dict;
+ GVariant *dict = NULL;
gboolean agent_had_system = FALSE;
ForEachSecretFlags cmp_flags = { NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_SECRET_FLAG_NONE };
@@ -1096,7 +1096,8 @@ get_secrets_done_cb (NMAgentManager *manager,
setting_name,
call_id);
- dict = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
+ if (priv->system_secrets)
+ dict = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
/* Update the connection with our existing secrets from backing storage */
nm_connection_clear_secrets (NM_CONNECTION (self));
@@ -1240,7 +1241,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
gpointer callback_data)
{
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
- GVariant *existing_secrets;
+ GVariant *existing_secrets = NULL;
NMAgentManagerCallId call_id_a;
gs_free char *joined_hints = NULL;
NMSettingsConnectionCallId *call_id;
@@ -1262,15 +1263,6 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
call_id->callback_data = callback_data;
c_list_link_tail (&priv->call_ids_lst_head, &call_id->call_ids_lst);
- /* Use priv->secrets to work around the fact that nm_connection_clear_secrets()
- * will clear secrets on this object's settings.
- */
- if (!priv->system_secrets) {
- g_set_error_literal (&local, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
- "secrets cache invalid");
- goto schedule_dummy;
- }
-
/* Make sure the request actually requests something we can return */
if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) {
g_set_error (&local, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
@@ -1286,7 +1278,11 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
goto schedule_dummy;
}
- existing_secrets = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
+ /* Use priv->system_secrets to work around the fact that nm_connection_clear_secrets()
+ * will clear secrets on this object's settings.
+ */
+ if (priv->system_secrets)
+ existing_secrets = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
if (existing_secrets)
g_variant_ref_sink (existing_secrets);