summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-01-10 20:07:23 +0100
committerThomas Haller <thaller@redhat.com>2017-01-12 13:02:25 +0100
commitbf3b3d444c7750a68a0771d99f48e663815e258e (patch)
treec413143ba34742a99b40016b202cf40dd37a9dbb
parent304e2f56af90123af99343a5c9671699a75dca94 (diff)
downloadNetworkManager-bf3b3d444c7750a68a0771d99f48e663815e258e.tar.gz
device: avoid changing immutable properties during reapply
We allow to reapply a connection with different id, uuid, stable-id, autoconnect value. This is allowed for convenience, so that a user can reapply a connection that differs in these fields. But actually, these fields cannot be reapplied. That is, their new values are not considered and the old values are continued to be used. Thus, mangle the reapplied connection to use the original, actually used values.
-rw-r--r--src/devices/nm-device.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 75fbcb2bc9..64bb62c893 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -8423,9 +8423,37 @@ reapply_connection (NMDevice *self,
diffs ? "" : " (unmodified)");
if (diffs) {
+ NMConnection *connection_clean = connection;
+ gs_free NMConnection *connection_clean_free = NULL;
+
+ {
+ NMSettingConnection *s_con_a, *s_con_n;
+
+ /* we allow re-applying a connection with differing ID, UUID, STABLE_ID and AUTOCONNECT.
+ * This is for convenience but these values are not actually changable. So, check
+ * if they changed, and if the did revert to the original values. */
+ s_con_a = nm_connection_get_setting_connection (applied);
+ s_con_n = nm_connection_get_setting_connection (connection);
+
+ if ( !nm_streq (nm_setting_connection_get_id (s_con_a), nm_setting_connection_get_id (s_con_n))
+ || !nm_streq (nm_setting_connection_get_uuid (s_con_a), nm_setting_connection_get_uuid (s_con_n))
+ || nm_setting_connection_get_autoconnect (s_con_a) != nm_setting_connection_get_autoconnect (s_con_n)
+ || !nm_streq0 (nm_setting_connection_get_stable_id (s_con_a), nm_setting_connection_get_stable_id (s_con_n))) {
+ connection_clean_free = nm_simple_connection_new_clone (connection);
+ connection_clean = connection_clean_free;
+ s_con_n = nm_connection_get_setting_connection (connection);
+ g_object_set (s_con_n,
+ NM_SETTING_CONNECTION_ID, nm_setting_connection_get_id (s_con_a),
+ NM_SETTING_CONNECTION_UUID, nm_setting_connection_get_uuid (s_con_a),
+ NM_SETTING_CONNECTION_AUTOCONNECT, nm_setting_connection_get_autoconnect (s_con_a),
+ NM_SETTING_CONNECTION_STABLE_ID, nm_setting_connection_get_stable_id (s_con_a),
+ NULL);
+ }
+ }
+
con_old = applied_clone = nm_simple_connection_new_clone (applied);
con_new = applied;
- nm_connection_replace_settings_from_connection (applied, connection);
+ nm_connection_replace_settings_from_connection (applied, connection_clean);
nm_connection_clear_secrets (applied);
} else
con_old = con_new = applied;