device: add and use overrule-unmanaged flag for nm_device_check_connection_available()
This flag is more granular in whether to consider the connection available or not. We probably should never check for the combined flag NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST directly, but always explicitly for the relevant parts. Also, improve the error message, to indicate whether the device is strictly unmanaged or whether it could be overruled.
This commit is contained in:
@@ -13669,16 +13669,15 @@ _nm_device_check_connection_available (NMDevice *self,
|
||||
return FALSE;
|
||||
}
|
||||
if (state < NM_DEVICE_STATE_UNAVAILABLE) {
|
||||
if (NM_FLAGS_ANY (flags, NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST)) {
|
||||
if (!nm_device_get_managed (self, TRUE)) {
|
||||
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_UNMANAGED_DEVICE,
|
||||
"device is unmanaged");
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
if (!nm_device_get_managed (self, TRUE)) {
|
||||
if (!nm_device_get_managed (self, FALSE)) {
|
||||
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_UNMANAGED_DEVICE,
|
||||
"device is unmanaged for internal request");
|
||||
"device is strictly unmanaged");
|
||||
return FALSE;
|
||||
}
|
||||
if (!NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED)) {
|
||||
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_UNMANAGED_DEVICE,
|
||||
"device is currently unmanaged");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@@ -182,12 +182,20 @@ typedef enum { /*< skip >*/
|
||||
* visible. */
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP = (1L << 2),
|
||||
|
||||
/* a device can be marked as unmanaged for various reasons. Some of these reasons
|
||||
* are authorative, others not. Non-authoritative reasons can be overruled by
|
||||
* `nmcli device set $DEVICE managed yes`. Also, for an explicit user activation
|
||||
* request we may want to consider the device as managed. This flag makes devices
|
||||
* that are unmanaged appear available. */
|
||||
_NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED = (1L << 3),
|
||||
|
||||
/* a collection of flags, that are commonly set for an explict user-request. */
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST = _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP,
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_IGNORE_AP
|
||||
| _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED,
|
||||
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_ALL = (1L << 3) - 1,
|
||||
NM_DEVICE_CHECK_CON_AVAILABLE_ALL = (1L << 4) - 1,
|
||||
} NMDeviceCheckConAvailableFlags;
|
||||
|
||||
struct _NMDevicePrivate;
|
||||
|
Reference in New Issue
Block a user