diff options
author | Thomas Haller <thaller@redhat.com> | 2020-11-23 16:04:35 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-11-24 08:49:21 +0100 |
commit | eed23269bdf2294a3c419bded6dc5475de19fce9 (patch) | |
tree | 8c0011f49f4c16e4a7b49008f9b2fc21075baf09 /src/nm-manager.c | |
parent | c0c6470e4d21cc7dfa6db27bb78b316304ff0756 (diff) | |
download | NetworkManager-eed23269bdf2294a3c419bded6dc5475de19fce9.tar.gz |
core: fix modifying connection during recheck_assume_connection()
Since commit d35d3c468a30 ('settings: rework tracking settings
connections and settings plugins') must settings connections not
be modified. They must be treated immutable and only updated by
replacing them with a new variant. There is even an assertion
for that.
Fix the code that attempts to modify an existing NMConnection.
https://bugzilla.redhat.com/show_bug.cgi?id=1900536
Fixes: f2fe6c03ee3f ('manager: don't treat the initramfs-configured DHCP connections as generated')
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/690
Diffstat (limited to 'src/nm-manager.c')
-rw-r--r-- | src/nm-manager.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c index c17c881b68..75117bbc63 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2879,15 +2879,20 @@ recheck_assume_connection(NMManager *self, NMDevice *device) activation_type_assume = TRUE; if (generated) { + gs_unref_object NMConnection *con2 = NULL; + + con2 = nm_simple_connection_new_clone( + nm_settings_connection_get_connection(sett_conn)); + /* Reset the IPv4 setting to empty method=auto, regardless of what assumption guessed. */ - nm_connection_add_setting(nm_settings_connection_get_connection(sett_conn), + nm_connection_add_setting(con2, g_object_new(NM_TYPE_SETTING_IP4_CONFIG, NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL)); nm_settings_connection_update(sett_conn, - NULL, + con2, NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP, NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, NM_SETTINGS_CONNECTION_INT_FLAGS_VOLATILE |