mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 01:20:07 +01: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
This commit is contained in:
parent
81008c90ac
commit
348ffdec18
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);
|
||||
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue