libnm-util: fix updating secrets

Broken by 5dd4f1ea01
This commit is contained in:
Dan Williams 2011-02-02 17:18:50 -06:00
parent da47a2add4
commit c36c81e2b9
2 changed files with 23 additions and 9 deletions

View file

@ -664,28 +664,39 @@ nm_connection_verify (NMConnection *connection, GError **error)
gboolean
nm_connection_update_secrets (NMConnection *connection,
const char *setting_name,
GHashTable *secrets,
GHashTable *all_secrets,
GError **error)
{
NMSetting *setting;
gboolean success;
GHashTable *setting_secrets;
g_return_val_if_fail (connection != NULL, FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
g_return_val_if_fail (setting_name != NULL, FALSE);
g_return_val_if_fail (secrets != NULL, FALSE);
g_return_val_if_fail (all_secrets != NULL, FALSE);
if (error)
g_return_val_if_fail (*error == NULL, FALSE);
setting = nm_connection_get_setting (connection, nm_connection_lookup_setting_type (setting_name));
if (!setting) {
g_set_error (error, NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND,
"%s", setting_name);
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND,
setting_name);
return FALSE;
}
success = nm_setting_update_secrets (setting, secrets, error);
setting_secrets = g_hash_table_lookup (all_secrets, setting_name);
if (!setting_secrets) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND,
setting_name);
return FALSE;
}
success = nm_setting_update_secrets (setting, setting_secrets, error);
if (success)
g_signal_emit (connection, signals[SECRETS_UPDATED], 0, setting_name);
return success;

View file

@ -559,15 +559,18 @@ nm_setting_update_secrets (NMSetting *setting, GHashTable *secrets, GError **err
g_return_val_if_fail (*error == NULL, FALSE);
g_hash_table_iter_init (&iter, secrets);
while (g_hash_table_iter_next (&iter, &key, &data) && !tmp_error) {
while (g_hash_table_iter_next (&iter, &key, &data)) {
const char *secret_key = (const char *) key;
GValue *secret_value = (GValue *) data;
NM_SETTING_GET_CLASS (setting)->update_one_secret (setting, secret_key, secret_value, &tmp_error);
if (tmp_error) {
g_propagate_error (error, tmp_error);
break;
}
}
g_propagate_error (error, tmp_error);
return !!tmp_error;
return tmp_error ? FALSE : TRUE;
}
static gboolean