settings-connection: all method to internally supply new secrets

It's sort of a very very lightweight version of get_secrets_done_cb()
that allows as to add secrets to the connection that didn't come from
the agent manager.
This commit is contained in:
Lubomir Rintel 2017-04-28 18:52:39 +02:00
parent 5c80571006
commit f87912326c
2 changed files with 31 additions and 0 deletions

View file

@ -974,6 +974,31 @@ get_cmp_flags (NMSettingsConnection *self, /* only needed for logging */
}
}
gboolean
nm_settings_connection_new_secrets (NMSettingsConnection *self,
NMConnection *applied_connection,
const char *setting_name,
GVariant *secrets,
GError **error)
{
if (!nm_settings_connection_has_unmodified_applied_connection (self, applied_connection,
NM_SETTING_COMPARE_FLAG_NONE)) {
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"The connection was modified since activation");
return FALSE;
}
if (!nm_connection_update_secrets (NM_CONNECTION (self), setting_name, secrets, error))
return FALSE;
update_system_secrets_cache (self);
update_agent_secrets_cache (self, NULL);
nm_settings_connection_commit_changes (self, NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
new_secrets_commit_cb, NULL);
return TRUE;
}
static void
get_secrets_done_cb (NMAgentManager *manager,
NMAgentManagerCallId call_id_a,

View file

@ -163,6 +163,12 @@ typedef void (*NMSettingsConnectionSecretsFunc) (NMSettingsConnection *self,
GError *error,
gpointer user_data);
gboolean nm_settings_connection_new_secrets (NMSettingsConnection *self,
NMConnection *applied_connection,
const char *setting_name,
GVariant *secrets,
GError **error);
NMSettingsConnectionCallId nm_settings_connection_get_secrets (NMSettingsConnection *self,
NMConnection *applied_connection,
NMAuthSubject *subject,