iwd: don't set REQUEST_NEW secret request flag on first connection

Allow the IWD backend to use secrets provided in the connection settings
on initial connection attempt, only require new secrets on subsequent
connections when IWD asks for them -- it only asks if fresh secrets are
required.
This commit is contained in:
Andrew Zaborowski 2018-06-21 09:41:25 +02:00 committed by Thomas Haller
parent 74d9e04a66
commit 24f5cf23e5

View file

@ -1127,6 +1127,7 @@ wifi_secrets_cb (NMActRequest *req,
const gchar *setting_name;
const gchar *setting_key;
gboolean replied;
NMSecretAgentGetSecretsFlags get_secret_flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
nm_utils_user_data_unpack (user_data, &self, &invocation);
@ -1168,13 +1169,13 @@ wifi_secrets_cb (NMActRequest *req,
return;
}
if (nm_settings_connection_get_timestamp (nm_act_request_get_settings_connection (req),
NULL))
get_secret_flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
/* Request further secrets if we still need something */
wifi_secrets_get_one (self,
setting_name,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION
| NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW,
setting_key,
invocation);
wifi_secrets_get_one (self, setting_name, get_secret_flags,
setting_key, invocation);
return;
secrets_error:
@ -1854,6 +1855,7 @@ nm_device_iwd_agent_query (NMDeviceIwd *self,
const gchar *setting_name;
const gchar *setting_key;
gboolean replied;
NMSecretAgentGetSecretsFlags get_secret_flags = NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION;
req = nm_device_get_act_request (NM_DEVICE (self));
if (!req)
@ -1867,14 +1869,22 @@ nm_device_iwd_agent_query (NMDeviceIwd *self,
if (replied)
return TRUE;
/* Normally require new secrets every time IWD asks for them.
* IWD only queries us if it has not saved the secrets (e.g. by policy)
* or a previous attempt has failed with current secrets so it wants
* a fresh set. However if this is a new connection it may include
* all of the needed settings already so allow using these, too.
* Connection timestamp is set after activation or after first
* activation failure (to 0).
*/
if (nm_settings_connection_get_timestamp (nm_act_request_get_settings_connection (req),
NULL))
get_secret_flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW;
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_NEED_AUTH,
NM_DEVICE_STATE_REASON_NO_SECRETS);
wifi_secrets_get_one (self,
setting_name,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION
| NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW,
setting_key,
invocation);
wifi_secrets_get_one (self, setting_name, get_secret_flags,
setting_key, invocation);
return TRUE;
}