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().
This commit is contained in:
Thomas Haller
2018-02-05 15:06:24 +01:00
parent 6b08d2dda2
commit c6d0fbe7b0

View File

@@ -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 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); 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 */ /* Export the new ActiveConnection to clients and start it on the device */
active_connection_add (self, active); active_connection_add (self, active);
nm_device_queue_activation (device, NM_ACT_REQUEST (active)); nm_device_queue_activation (device, NM_ACT_REQUEST (active));