From c6d0fbe7b0bb4def9003b31de70a172da3e6bcdb Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 5 Feb 2018 15:06:24 +0100 Subject: [PATCH] manager: abort activation if the device is still unmanaged unmanaged_to_disconnected() is supposed to mark the device as managed. However, it may easily be unable to do so, for example if the device is unmanaged by NM_UNMANAGED_USER_SETTINGS. Shortly before actually enqueuing the activation request, check and error out. Otherwise, we might hit an assertion later in _device_activate(). --- src/nm-manager.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/nm-manager.c b/src/nm-manager.c index cf4f9c834..a498758d4 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -3786,9 +3786,20 @@ _internal_activate_device (NMManager *self, NMActiveConnection *active, GError * } /* If the device is there, we can ready it for the activation. */ - if (nm_device_is_real (device)) + if (nm_device_is_real (device)) { unmanaged_to_disconnected (device); + if (!nm_device_get_managed (device, FALSE)) { + /* Unexpectedly, the device is still unmanaged. That can happen for example, + * if the device is forcibly unmanaged due to NM_UNMANAGED_USER_SETTINGS. */ + g_set_error_literal (error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_DEPENDENCY_FAILED, + "Activation failed because the device is unmanaged"); + return FALSE; + } + } + /* Export the new ActiveConnection to clients and start it on the device */ active_connection_add (self, active); nm_device_queue_activation (device, NM_ACT_REQUEST (active));