summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-07-02 11:46:47 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2019-07-08 13:51:30 +0200
commitc7fd4aeecf899733d736c95bb6104401aecef5a0 (patch)
treef2fcea095e7028f612c618410791d0e277be590a
parent7d8f20b00e461a5a494c15d649068c66897cae58 (diff)
downloadNetworkManager-c7fd4aeecf899733d736c95bb6104401aecef5a0.tar.gz
device: properly honor flags when checking connection availability
The previous code returned that the device was available when it had only unmanaged-flags that can be overridden by user, without actually considering the @flags argument. Fixes: 920346a5b98c ('device: add and use overrule-unmanaged flag for nm_device_check_connection_available()')
-rw-r--r--src/devices/nm-device.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 569ff6289d..6a27469d41 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -13445,7 +13445,7 @@ _get_managed_by_flags(NMUnmanagedFlags flags, NMUnmanagedFlags mask, gboolean fo
return TRUE;
/* A for-user-request, is effectively the same as pretending
- * that user-dbus flag is cleared. */
+ * that user-explicit flag is cleared. */
mask |= NM_UNMANAGED_USER_EXPLICIT;
flags &= ~NM_UNMANAGED_USER_EXPLICIT;
}
@@ -13497,6 +13497,9 @@ _get_managed_by_flags(NMUnmanagedFlags flags, NMUnmanagedFlags mask, gboolean fo
* nm_device_get_managed:
* @self: the #NMDevice
* @for_user_request: whether to check the flags for an explicit user-request
+ * Setting this to %TRUE has the same effect as if %NM_UNMANAGED_USER_EXPLICIT
+ * unmanaged flag would be unset (meaning: explicitly not-unmanaged).
+ * If this parameter is %TRUE, the device can only appear more managed.
*
* Whether the device is unmanaged according to the unmanaged flags.
*
@@ -14066,13 +14069,17 @@ _nm_device_check_connection_available (NMDevice *self,
return FALSE;
}
if (state < NM_DEVICE_STATE_UNAVAILABLE) {
- if (!nm_device_get_managed (self, TRUE)) {
- if (!nm_device_get_managed (self, FALSE)) {
+ if (nm_device_get_managed (self, FALSE)) {
+ /* device is managed, both for user-requests and non-user-requests alike. */
+ } else {
+ if (!nm_device_get_managed (self, TRUE)) {
+ /* device is strictly unmanaged by authoritative unmanaged reasons. */
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_UNMANAGED_DEVICE,
"device is strictly unmanaged");
return FALSE;
}
if (!NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_OVERRULE_UNMANAGED)) {
+ /* device could be managed for an explict user-request, but this is not such a request. */
nm_utils_error_set_literal (error, NM_UTILS_ERROR_CONNECTION_AVAILABLE_UNMANAGED_DEVICE,
"device is currently unmanaged");
return FALSE;