settings: clear unsaved flag on new settings-connection

When a new settings-connection is populated with the actual settings
read from disk by the plugin, calling nm_settings_connection_update()
with KEEP mode also marks it as unsaved, which should not happen on a
new connection just written to (or read from) disk.

Introduce a new KEEP_SAVED persist mode that is similar to KEEP but
clears the UNSAVED flag.

Fixes: 023ce50d21

https://bugzilla.redhat.com/show_bug.cgi?id=1525078
(cherry picked from commit 5fff928a6b)
This commit is contained in:
Beniamino Galvani 2017-12-20 09:54:29 +01:00
parent fa53c715d1
commit b1b463d0dc
9 changed files with 11 additions and 7 deletions

View file

@ -517,6 +517,7 @@ set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode pe
TRUE);
return;
case NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP:
case NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED:
/* Nothing to do */
return;
}

View file

@ -137,6 +137,9 @@ gboolean nm_settings_connection_has_unmodified_applied_connection (NMSettingsCon
typedef enum {
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
/* like KEEP, but always clears the UNSAVED flag */
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
/* unsaved, only sets the unsaved flag, but it doesn't touch

View file

@ -62,7 +62,7 @@ nms_ibft_connection_new (const GPtrArray *block, GError **error)
/* Update settings with what was read from iscsiadm */
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
source,
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
NULL,
error))

View file

@ -442,7 +442,7 @@ nm_ifcfg_connection_new (NMConnection *source,
if (nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
tmp,
full_path
? NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP /* connection is already on disk */
? NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED
: NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
NULL,

View file

@ -315,7 +315,7 @@ update_connection (SettingsPluginIfcfg *self,
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (connection_by_uuid),
NM_CONNECTION (connection_new),
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
"ifcfg-update",
&local)) {

View file

@ -190,7 +190,7 @@ nm_ifnet_connection_new (NMConnection *source, const char *conn_name)
tmp,
update_unsaved
? NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
NULL,
NULL)) {

View file

@ -271,7 +271,7 @@ reload_connections (NMSettingsPlugin *config)
/* Update existing connection with new settings */
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (old),
NM_CONNECTION (new),
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
"ifnet-update",
&error)) {

View file

@ -163,7 +163,7 @@ nms_keyfile_connection_new (NMConnection *source,
tmp,
update_unsaved
? NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
: NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
NULL,
error)) {

View file

@ -260,7 +260,7 @@ update_connection (NMSKeyfilePlugin *self,
if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (connection_by_uuid),
NM_CONNECTION (connection_new),
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
"keyfile-update",
&local)) {