summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2014-11-06 17:16:01 +0100
committerJiří Klimeš <jklimes@redhat.com>2014-11-19 11:47:58 +0100
commit6fd8afd39fde640d202209d9a7e2b549ab388e19 (patch)
tree68d56fc6ef8e5eb7074d5c757a08b881f0226b28
parent86fd678e4e2af94d7fb395b2c284c56913479e2f (diff)
downloadNetworkManager-6fd8afd39fde640d202209d9a7e2b549ab388e19.tar.gz
cli: fix showing secrets in nmcli editor (bgo #737415)
Put secrets into the local connection. https://bugzilla.gnome.org/show_bug.cgi?id=737415
-rw-r--r--clients/cli/connections.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 3456b92e20..5102148313 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -633,16 +633,23 @@ get_ac_for_connection (const GPtrArray *active_cons, NMConnection *connection)
return ac;
}
+/* Put secrets into local connection. */
static void
-update_secrets_in_connection (NMRemoteConnection *con)
+update_secrets_in_connection (NMRemoteConnection *remote, NMConnection *local)
{
GVariant *secrets;
int i;
+ GError *error = NULL;
for (i = 0; nmc_fields_settings_names[i].name; i++) {
- secrets = nm_remote_connection_get_secrets (con, nmc_fields_settings_names[i].name, NULL, NULL);
+ secrets = nm_remote_connection_get_secrets (remote, nmc_fields_settings_names[i].name, NULL, NULL);
if (secrets) {
- (void) nm_connection_update_secrets (NM_CONNECTION (con), NULL, secrets, NULL);
+ if (!nm_connection_update_secrets (local, NULL, secrets, &error) && error) {
+ g_printerr (_("Error updating secrets for %s: %s\n"),
+ nmc_fields_settings_names[i].name,
+ error->message);
+ g_clear_error (&error);
+ }
g_variant_unref (secrets);
}
}
@@ -1462,7 +1469,7 @@ do_connections_show (NmCli *nmc, gboolean active_only, gboolean show_secrets,
if (con) {
nmc->required_fields = profile_flds;
if (show_secrets)
- update_secrets_in_connection (NM_REMOTE_CONNECTION (con));
+ update_secrets_in_connection (NM_REMOTE_CONNECTION (con), con);
res = nmc_connection_profile_details (con, nmc, show_secrets);
nmc->required_fields = NULL;
if (!res)
@@ -6925,6 +6932,7 @@ is_connection_dirty (NMConnection *connection, NMRemoteConnection *remote)
{
return !nm_connection_compare (connection,
remote ? NM_CONNECTION (remote) : NULL,
+ NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS |
NM_SETTING_COMPARE_FLAG_IGNORE_TIMESTAMP);
}
@@ -8283,14 +8291,14 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
goto error;
}
- /* Merge secrets into the connection */
- update_secrets_in_connection (NM_REMOTE_CONNECTION (found_con));
-
/* Duplicate the connection and use that so that we need not
* differentiate existing vs. new later
*/
connection = nm_simple_connection_new_clone (found_con);
+ /* Merge secrets into the connection */
+ update_secrets_in_connection (NM_REMOTE_CONNECTION (found_con), connection);
+
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
connection_type = nm_setting_connection_get_connection_type (s_con);