about summary refs log tree commit diff
path: root/debian
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2017-05-11 23:28:39 +0200
committerMichael Biebl <biebl@debian.org>2017-05-12 01:25:54 +0200
commit15cc7d3d3d80780ec9fa3287ed6db65188dd3f96 (patch)
treede12c654f672533d6ee01f7af8f35280412cb8f9 /debian
parent34bc0c7d337d0d3bf9aee372fe0d6e784e4503d3 (diff)
core: fix reading device state file
Properly setup devices which were marked as managed=unknown when
restoring from state file.
Diffstat (limited to 'debian')
-rw-r--r--debian/patches/core-fix-reading-device-state-file.patch64
-rw-r--r--debian/patches/series1
2 files changed, 65 insertions, 0 deletions
diff --git a/debian/patches/core-fix-reading-device-state-file.patch b/debian/patches/core-fix-reading-device-state-file.patch
new file mode 100644
index 00000000..b124884a
--- /dev/null
+++ b/debian/patches/core-fix-reading-device-state-file.patch
@@ -0,0 +1,64 @@
+From: Thomas Haller <thaller@redhat.com>
+Date: Thu, 11 May 2017 19:40:55 +0200
+Subject: core: fix reading device state file
+
+For manged=unknown, we don't write the value to the
+device state keyfile. The results in an empty file,
+or at least, a keyfile that doesn't have device.managed
+set.
+
+On read, we must treat a missing device.managed flag as
+unknown, and not as unmanaged. Otherwise, on restart
+a device becomes marked as explicitly unmanaged.
+
+This was broken by commit 142ebb1 "core: only persist explicit managed
+state in device's state file", where we started conditionally
+to no longer write the managed state.
+
+Reported-by: Michael Biebl <mbiebl@debian.org>
+Fixes: 142ebb10376ec592593f15b0359f38be89c97620
+(cherry picked from commit 348ffdec183ee198499dad1365906e8d16ff4122)
+(cherry picked from commit 33d3ec3b3e5d2e737afc8db6c64850e67db5c12d)
+---
+ src/nm-config.c | 24 +++++++++++++-----------
+ 1 file changed, 13 insertions(+), 11 deletions(-)
+
+diff --git a/src/nm-config.c b/src/nm-config.c
+index 2cdf855..5033d5c 100644
+--- a/src/nm-config.c
++++ b/src/nm-config.c
+@@ -1887,21 +1887,23 @@ _config_device_state_data_new (int ifindex, GKeyFile *kf)
+ 	nm_assert (ifindex > 0);
+ 
+ 	if (kf) {
+-		gboolean managed;
+-
+-		managed = nm_config_keyfile_get_boolean (kf,
+-		                                         DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
+-		                                         DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_MANAGED,
+-		                                         FALSE);
+-		managed_type = managed
+-		               ? NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED
+-		               : NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNMANAGED;
+-
+-		if (managed) {
++		switch (nm_config_keyfile_get_boolean (kf,
++		                                       DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
++		                                       DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_MANAGED,
++		                                       -1)) {
++		case TRUE:
++			managed_type = NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED;
+ 			connection_uuid = nm_config_keyfile_get_value (kf,
+ 			                                               DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
+ 			                                               DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_CONNECTION_UUID,
+ 			                                               NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
++			break;
++		case FALSE:
++			managed_type = NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNMANAGED;
++			break;
++		case -1:
++			/* missing property in keyfile. */
++			break;
+ 		}
+ 
+ 		perm_hw_addr_fake = nm_config_keyfile_get_value (kf,
diff --git a/debian/patches/series b/debian/patches/series
index 01c14f38..a9be5fd7 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@ Fix-arping-path.patch
 Don-t-make-NetworkManager-D-Bus-activatable.patch
 systemd-Don-t-enable-NetworkManager-wait-online.serv.patch
 Fix-iscsiadm-path.patch
+core-fix-reading-device-state-file.patch