Commit 7044febf authored by Thomas Haller's avatar Thomas Haller

settings: fix clearing nm-generated/volatile flags of connection

There are a few cases where we don't want to clear a potential
nm-generated/volatile flag, but only mark the connection as
unsaved.

Otherwise, we wrongly end up clearing these flags and the connection
is wrongly not NM_DEVICE_SYS_IFACE_STATE_EXTERNAL.

Fixes: 35dc6421
parent e75fc827
......@@ -495,9 +495,6 @@ set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode pe
| NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED
| NM_SETTINGS_CONNECTION_FLAGS_VOLATILE;
if (persist_mode == NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP)
return;
switch (persist_mode) {
case NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK:
flags = NM_SETTINGS_CONNECTION_FLAGS_NONE;
......@@ -512,8 +509,16 @@ set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode pe
flags = NM_SETTINGS_CONNECTION_FLAGS_UNSAVED |
NM_SETTINGS_CONNECTION_FLAGS_VOLATILE;
break;
case NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED:
/* only set the connection as unsaved, but preserve the nm-generated
* and volatile flag. */
nm_settings_connection_set_flags (self,
NM_SETTINGS_CONNECTION_FLAGS_UNSAVED,
TRUE);
return;
case NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP:
g_return_if_reached ();
/* Nothing to do */
return;
}
nm_settings_connection_set_flags_full (self, ALL, flags);
......@@ -522,7 +527,7 @@ set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode pe
static void
connection_changed_cb (NMSettingsConnection *self, gpointer unused)
{
set_persist_mode (self, NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY);
set_persist_mode (self, NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED);
_emit_updated (self, FALSE);
}
......
......@@ -138,6 +138,11 @@ gboolean nm_settings_connection_has_unmodified_applied_connection (NMSettingsCon
typedef enum {
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
/* unsaved, only sets the unsaved flag, but it doesn't touch
* the NM_GENERATED nor VOLATILE flag. */
NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED,
NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY,
NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY_DETACHED,
NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY_ONLY,
......
......@@ -443,7 +443,7 @@ nm_ifcfg_connection_new (NMConnection *source,
tmp,
full_path
? NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP /* connection is already on disk */
: NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY,
: NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
NULL,
error))
......
......@@ -189,7 +189,7 @@ nm_ifnet_connection_new (NMConnection *source, const char *conn_name)
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
tmp,
update_unsaved
? NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY
? NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
NULL,
......
......@@ -162,7 +162,7 @@ nms_keyfile_connection_new (NMConnection *source,
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
tmp,
update_unsaved
? NM_SETTINGS_CONNECTION_PERSIST_MODE_IN_MEMORY
? NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
NULL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment