cli: copy remote connection to local one on 'save' (rh #997958)

Plugins may have problems with preserving some properties on write/read cycle,
may add ipv{4,6} settings when they are not present in the connection, etc.
That makes local and remote connection differ.
So we copy remote connection into the local to get rid of such problems.

Note:
68f12b4e9c and
f03635e5ac
commits ensure that all connection (except slaves) have IPv{4,6} settings.

https://bugzilla.redhat.com/show_bug.cgi?id=997958
This commit is contained in:
Jiří Klimeš
2013-10-08 12:24:05 +02:00
parent 3eb1d5e902
commit 3d14d52325

View File

@@ -6288,11 +6288,25 @@ editor_menu_main (NmCli *nmc, NMConnection *connection, const char *connection_t
nmc_editor_error->code, nmc_editor_error->message);
g_error_free (nmc_editor_error);
} else
} else {
NMRemoteConnection *con_tmp;
printf (_("Connection '%s' (%s) successfully saved.\n"),
nm_connection_get_id (connection),
nm_connection_get_uuid (connection));
/* Replace local connection with the remote one to be sure they are equal.
* This mitigates problems with plugins not preserving some properties or
* adding ipv{4,6} settings when not present.
*/
con_tmp = nm_remote_settings_get_connection_by_uuid (nmc->system_settings,
nm_connection_get_uuid (connection));
if (con_tmp)
nm_connection_replace_settings_from_connection (connection,
NM_CONNECTION (con_tmp),
NULL);
}
nmc_editor_cb_called = FALSE;
nmc_editor_error = NULL;
g_mutex_unlock (&nmc_editor_mutex);