mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 11:58:12 +02:00
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 commit142ebb1"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:142ebb1037(cherry picked from commit348ffdec18)
This commit is contained in:
parent
8da225283b
commit
33d3ec3b3e
1 changed files with 13 additions and 11 deletions
|
|
@ -1894,21 +1894,23 @@ _config_device_state_data_new (int ifindex, GKeyFile *kf)
|
||||||
nm_assert (ifindex > 0);
|
nm_assert (ifindex > 0);
|
||||||
|
|
||||||
if (kf) {
|
if (kf) {
|
||||||
gboolean managed;
|
switch (nm_config_keyfile_get_boolean (kf,
|
||||||
|
DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
||||||
managed = nm_config_keyfile_get_boolean (kf,
|
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_MANAGED,
|
||||||
DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
-1)) {
|
||||||
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_MANAGED,
|
case TRUE:
|
||||||
FALSE);
|
managed_type = NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED;
|
||||||
managed_type = managed
|
|
||||||
? NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED
|
|
||||||
: NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNMANAGED;
|
|
||||||
|
|
||||||
if (managed) {
|
|
||||||
connection_uuid = nm_config_keyfile_get_value (kf,
|
connection_uuid = nm_config_keyfile_get_value (kf,
|
||||||
DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
||||||
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_CONNECTION_UUID,
|
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_CONNECTION_UUID,
|
||||||
NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
|
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,
|
perm_hw_addr_fake = nm_config_keyfile_get_value (kf,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue