From df20a98aa4fb374c6debe23a6fc8c3badffa523f Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Thu, 26 Mar 2020 10:06:14 +0100 Subject: [PATCH 1/2] nm-device-modem: deactivate device when modem unlocked When the modem is unlocked externally to NetworkManager, it is kept in the 'need-auth' state. The current connection activation continues as if nothing had changed, and the secrets request for the PIN code (which is no longer necessary) eventually times out. The device state is then changed to 'failed', meaning there won't be a new try at activating the default connection automatically. In order to prevent this, and retry activating the default connection when the modem gets unlocked, we change the device state to 'deactivating' when we identify the modem has been unlocked externally. Signed-off-by: Arnaud Ferraris --- src/devices/wwan/nm-device-modem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index 8e5b70bded..a2f2e7a6f8 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -384,6 +384,15 @@ modem_state_cb (NMModem *modem, */ nm_modem_set_mm_enabled (priv->modem, priv->rf_enabled); + if (dev_state == NM_DEVICE_STATE_NEED_AUTH) { + /* The modem was unlocked externally to NetworkManager, + deactivate so the default connection can be + automatically activated again */ + nm_device_state_changed (device, + NM_DEVICE_STATE_DEACTIVATING, + NM_DEVICE_STATE_REASON_MODEM_AVAILABLE); + } + /* Now allow connections without a PIN to be available */ nm_device_recheck_available_connections (device); } From 0cf7f1d2f580d761ebf3915a04056d150621d067 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Thu, 26 Mar 2020 10:06:45 +0100 Subject: [PATCH 2/2] nm-modem: don't fail if secrets request times out When starting with a locked modem, it may take some time for the user to enter the PIN code, leading to the secrets request timing out. In that case, we want the connection activation to be retried automatically once the modem is unlocked, which can't be achieved if we propagate the error, as the device will change state to 'failed'. This patch ignores the 'no-secrets' error, as it means either the request has timed out, or the user cancelled the request without notifying NetworkManager. By doing this, we allow the connection to be re-activated once the modem is unlocked. Signed-off-by: Arnaud Ferraris --- src/devices/wwan/nm-modem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 88239b63de..bedc38448a 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -975,7 +975,8 @@ modem_secrets_cb (NMActRequest *req, priv->secrets_id = NULL; - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || + g_error_matches (error, NM_AGENT_MANAGER_ERROR, NM_AGENT_MANAGER_ERROR_NO_SECRETS)) return; if (error)