Blame SOURCES/0005-clear-unsaved-flag-on-new-connections-rh1525078.patch

c48088
From dac6c0c2bf30af21d4876bcbd579f97cedf9f0a3 Mon Sep 17 00:00:00 2001
c48088
From: Beniamino Galvani <bgalvani@redhat.com>
c48088
Date: Wed, 20 Dec 2017 09:54:29 +0100
c48088
Subject: [PATCH] settings: clear unsaved flag on new settings-connection
c48088
c48088
When a new settings-connection is populated with the actual settings
c48088
read from disk by the plugin, calling nm_settings_connection_update()
c48088
with KEEP mode also marks it as unsaved, which should not happen on a
c48088
new connection just written to (or read from) disk.
c48088
c48088
Introduce a new KEEP_SAVED persist mode that is similar to KEEP but
c48088
clears the UNSAVED flag.
c48088
c48088
Fixes: 023ce50d2188af557b4f2af39ec5a3342612aa2f
c48088
c48088
https://bugzilla.redhat.com/show_bug.cgi?id=1525078
c48088
(cherry picked from commit 5fff928a6b746393e15487c348892b5ecaf8a416)
c48088
(cherry picked from commit b1b463d0dca46a25c5e46732949811c2c31fa4b2)
c48088
---
c48088
 src/settings/nm-settings-connection.c                   | 1 +
c48088
 src/settings/nm-settings-connection.h                   | 3 +++
c48088
 src/settings/plugins/ibft/nms-ibft-connection.c         | 2 +-
c48088
 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c | 2 +-
c48088
 src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c     | 2 +-
c48088
 src/settings/plugins/ifnet/nms-ifnet-connection.c       | 2 +-
c48088
 src/settings/plugins/ifnet/nms-ifnet-plugin.c           | 2 +-
c48088
 src/settings/plugins/keyfile/nms-keyfile-connection.c   | 2 +-
c48088
 src/settings/plugins/keyfile/nms-keyfile-plugin.c       | 2 +-
c48088
 9 files changed, 11 insertions(+), 7 deletions(-)
c48088
c48088
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
c48088
index b6e894049..62f2de399 100644
c48088
--- a/src/settings/nm-settings-connection.c
c48088
+++ b/src/settings/nm-settings-connection.c
c48088
@@ -517,6 +517,7 @@ set_persist_mode (NMSettingsConnection *self, NMSettingsConnectionPersistMode pe
c48088
 		                                  TRUE);
c48088
 		return;
c48088
 	case NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP:
c48088
+	case NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED:
c48088
 		/* Nothing to do */
c48088
 		return;
c48088
 	}
c48088
diff --git a/src/settings/nm-settings-connection.h b/src/settings/nm-settings-connection.h
c48088
index fc8ad1de1..d7a999697 100644
c48088
--- a/src/settings/nm-settings-connection.h
c48088
+++ b/src/settings/nm-settings-connection.h
c48088
@@ -137,6 +137,9 @@ gboolean nm_settings_connection_has_unmodified_applied_connection (NMSettingsCon
c48088
 
c48088
 typedef enum {
c48088
 	NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
c48088
+
c48088
+	/* like KEEP, but always clears the UNSAVED flag */
c48088
+	NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
c48088
 	NM_SETTINGS_CONNECTION_PERSIST_MODE_DISK,
c48088
 
c48088
 	/* unsaved, only sets the unsaved flag, but it doesn't touch
c48088
diff --git a/src/settings/plugins/ibft/nms-ibft-connection.c b/src/settings/plugins/ibft/nms-ibft-connection.c
c48088
index 2a7c5f4a0..fb7f18f8d 100644
c48088
--- a/src/settings/plugins/ibft/nms-ibft-connection.c
c48088
+++ b/src/settings/plugins/ibft/nms-ibft-connection.c
c48088
@@ -62,7 +62,7 @@ nms_ibft_connection_new (const GPtrArray *block, GError **error)
c48088
 	/* Update settings with what was read from iscsiadm */
c48088
 	if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
c48088
 	                                    source,
c48088
-	                                    NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
c48088
+	                                    NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
c48088
 	                                    NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
c48088
 	                                    NULL,
c48088
 	                                    error))
c48088
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c
c48088
index 3cf5c978c..6979fdaaa 100644
c48088
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c
c48088
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c
c48088
@@ -442,7 +442,7 @@ nm_ifcfg_connection_new (NMConnection *source,
c48088
 	if (nm_settings_connection_update (NM_SETTINGS_CONNECTION (object),
c48088
 	                                   tmp,
c48088
 	                                   full_path
c48088
-	                                     ? NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP /* connection is already on disk */
c48088
+	                                     ? NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED
c48088
 	                                     : NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED,
c48088
 	                                   NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
c48088
 	                                   NULL,
c48088
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c
c48088
index 04e74bbda..2b388d1d9 100644
c48088
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c
c48088
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c
c48088
@@ -315,7 +315,7 @@ update_connection (SettingsPluginIfcfg *self,
c48088
 
c48088
 			if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (connection_by_uuid),
c48088
 			                                    NM_CONNECTION (connection_new),
c48088
-			                                    NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
c48088
+			                                    NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
c48088
 			                                    NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
c48088
 			                                    "ifcfg-update",
c48088
 			                                    &local)) {
c48088
diff --git a/src/settings/plugins/ifnet/nms-ifnet-connection.c b/src/settings/plugins/ifnet/nms-ifnet-connection.c
c48088
index e7cd19cd2..ce0b3f2bf 100644
c48088
--- a/src/settings/plugins/ifnet/nms-ifnet-connection.c
c48088
+++ b/src/settings/plugins/ifnet/nms-ifnet-connection.c
c48088
@@ -190,7 +190,7 @@ nm_ifnet_connection_new (NMConnection *source, const char *conn_name)
c48088
 	                                    tmp,
c48088
 	                                    update_unsaved
c48088
 	                                      ? NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED
c48088
-	                                      : NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
c48088
+	                                      : NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
c48088
 	                                    NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
c48088
 	                                    NULL,
c48088
 	                                    NULL)) {
c48088
diff --git a/src/settings/plugins/ifnet/nms-ifnet-plugin.c b/src/settings/plugins/ifnet/nms-ifnet-plugin.c
c48088
index 38d23f306..d89e988ba 100644
c48088
--- a/src/settings/plugins/ifnet/nms-ifnet-plugin.c
c48088
+++ b/src/settings/plugins/ifnet/nms-ifnet-plugin.c
c48088
@@ -271,7 +271,7 @@ reload_connections (NMSettingsPlugin *config)
c48088
 				/* Update existing connection with new settings */
c48088
 				if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (old),
c48088
 				                                    NM_CONNECTION (new),
c48088
-				                                    NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
c48088
+				                                    NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
c48088
 				                                    NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
c48088
 				                                    "ifnet-update",
c48088
 				                                    &error)) {
c48088
diff --git a/src/settings/plugins/keyfile/nms-keyfile-connection.c b/src/settings/plugins/keyfile/nms-keyfile-connection.c
c48088
index 5a6d8a76e..5f72a9fab 100644
c48088
--- a/src/settings/plugins/keyfile/nms-keyfile-connection.c
c48088
+++ b/src/settings/plugins/keyfile/nms-keyfile-connection.c
c48088
@@ -163,7 +163,7 @@ nms_keyfile_connection_new (NMConnection *source,
c48088
 	                                    tmp,
c48088
 	                                    update_unsaved
c48088
 	                                      ? NM_SETTINGS_CONNECTION_PERSIST_MODE_UNSAVED
c48088
-	                                      : NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
c48088
+	                                      : NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
c48088
 	                                    NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
c48088
 	                                    NULL,
c48088
 	                                    error)) {
c48088
diff --git a/src/settings/plugins/keyfile/nms-keyfile-plugin.c b/src/settings/plugins/keyfile/nms-keyfile-plugin.c
c48088
index bc64b3ca4..222768db4 100644
c48088
--- a/src/settings/plugins/keyfile/nms-keyfile-plugin.c
c48088
+++ b/src/settings/plugins/keyfile/nms-keyfile-plugin.c
c48088
@@ -260,7 +260,7 @@ update_connection (NMSKeyfilePlugin *self,
c48088
 
c48088
 			if (!nm_settings_connection_update (NM_SETTINGS_CONNECTION (connection_by_uuid),
c48088
 			                                    NM_CONNECTION (connection_new),
c48088
-			                                    NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP,
c48088
+			                                    NM_SETTINGS_CONNECTION_PERSIST_MODE_KEEP_SAVED,
c48088
 			                                    NM_SETTINGS_CONNECTION_COMMIT_REASON_NONE,
c48088
 			                                    "keyfile-update",
c48088
 			                                    &local)) {
c48088
-- 
c48088
2.14.3
c48088