From 52e9600f039da05a5e0cf6d19552cee9fb034bb6 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Mon, 21 Aug 2023 14:11:28 -0400 Subject: [PATCH 1/2] Revert "nm-policy: stop rechecking autoactivation if device is unregistered" When we register the auto-activate, the device has to be registered in NMPolicy, the assertion is correct and ensure that. This reverts commit 712729f6523f2e41a6c78e9a4f4d36a17d9464bd. --- src/core/nm-policy.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index 024f76546..efdb06360 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -1662,15 +1662,14 @@ nm_policy_device_recheck_auto_activate_schedule(NMPolicy *self, NMDevice *device g_return_if_fail(NM_IS_POLICY(self)); g_return_if_fail(NM_IS_DEVICE(device)); - if (g_signal_handler_find(device, - G_SIGNAL_MATCH_DATA, - 0, - 0, - NULL, - NULL, - NM_POLICY_GET_PRIVATE(self)) - == 0) - return; + nm_assert(g_signal_handler_find(device, + G_SIGNAL_MATCH_DATA, + 0, + 0, + NULL, + NULL, + NM_POLICY_GET_PRIVATE(self)) + != 0); if (!c_list_is_empty(&device->policy_auto_activate_lst)) { /* already queued. Return. */ From b341161e2a4988403ae4a6ef7653e01567da36a0 Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Thu, 3 Aug 2023 10:16:42 -0400 Subject: [PATCH 2/2] nm-manager: ensure device is exported on D-Bus in authentication request The device authentication request is an async process, it can not know the answer right away, it is not guarantee that device is still exported on D-Bus when authentication finishes. Thus, do not return SUCCESS and abort the authentication request when device is not alive. https://bugzilla.redhat.com/show_bug.cgi?id=2210271 --- src/core/nm-manager.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 2175a9c48..4fb9194a2 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -3222,6 +3222,13 @@ device_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer nm_assert(error || (result == NM_AUTH_CALL_RESULT_YES)); } + if (!error && !nm_dbus_object_is_exported(NM_DBUS_OBJECT(device))) { + g_set_error(&error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_UNKNOWN_DEVICE, + "device no longer exists"); + } + callback(device, context, subject, error, nm_auth_chain_get_data(chain, "user-data")); } @@ -3287,6 +3294,14 @@ nm_manager_device_auth_request(NMManager *self, &error)) goto fail_on_idle; + if (!nm_dbus_object_is_exported(NM_DBUS_OBJECT(device))) { + g_set_error(&error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_UNKNOWN_DEVICE, + "device no longer exists"); + goto fail_on_idle; + } + chain = nm_auth_chain_new_subject(subject, context, device_auth_done_cb, self); if (cancellable) nm_auth_chain_set_cancellable(chain, cancellable);