device: fix reapplying changes to connection ID and UUID

4 properties are not really relevant for an already activated connection
or it makes not sense to change them. These are connection.id, connection.uuid,
connection.autoconnect and connection.stable-id.

For convenience, we allow to reapply these. This way, one can take
a different setting (e.g. with a different connection.id or
connection.uuid) and reapply them, but such changes are silently
ignored.

However this was done wrongly. Instead of reverting the change to the new
applied connection, we would change the input connection.

This is bad, for example with

  nmcli connection up uuid cb922f18-e99a-49c6-b200-1678b5070a82
  nmcli connection modify cb922f18-e99a-49c6-b200-1678b5070a82 con-name "bogus"
  nmcli device reapply eth0

the last re-apply would reset the settings-connection's connection ID to
what was before, while accepting the new name on the applied-connection
(while it should have been rejected).

Fixes: bf3b3d444c ('device: avoid changing immutable properties during reapply')
This commit is contained in:
Thomas Haller
2019-07-16 09:24:25 +02:00
parent 1bee1f5530
commit adb51c2a7f

View File

@@ -11507,7 +11507,7 @@ check_and_reapply_connection (NMDevice *self,
|| !nm_streq0 (nm_setting_connection_get_stable_id (s_con_a), nm_setting_connection_get_stable_id (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_free = nm_simple_connection_new_clone (connection);
connection_clean = connection_clean_free; connection_clean = connection_clean_free;
s_con_n = nm_connection_get_setting_connection (connection); s_con_n = nm_connection_get_setting_connection (connection_clean);
g_object_set (s_con_n, g_object_set (s_con_n,
NM_SETTING_CONNECTION_ID, nm_setting_connection_get_id (s_con_a), 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_UUID, nm_setting_connection_get_uuid (s_con_a),