wifi: merge branch 'balrog-kun:iwd-agent'

https://github.com/NetworkManager/NetworkManager/pull/139
This commit is contained in:
Thomas Haller 2018-06-22 16:39:26 +02:00
commit 5e8773ee63
6 changed files with 296 additions and 161 deletions

View file

@ -217,6 +217,21 @@ add_8021x_secrets (NMSecretAgentSimpleRequest *request,
const char *eap_method;
NMSecretAgentSimpleSecret *secret;
/* If hints are given, then always ask for what the hints require */
if (request->hints) {
char **iter;
for (iter = request->hints; *iter; iter++) {
secret = nm_secret_agent_simple_secret_new (NM_SECRET_AGENT_SECRET_TYPE_SECRET,
_(*iter),
NM_SETTING (s_8021x),
*iter,
NULL);
g_ptr_array_add (secrets, secret);
}
return TRUE;
}
eap_method = nm_setting_802_1x_get_eap_method (s_8021x, 0);
if (!eap_method)
return FALSE;

View file

@ -73,7 +73,6 @@ typedef struct {
GCancellable * cancellable;
NMDeviceWifiCapabilities capabilities;
NMActRequestGetSecretsCallId *wifi_secrets_id;
GDBusMethodInvocation *secrets_request;
guint periodic_scan_id;
bool enabled:1;
bool can_scan:1;
@ -379,14 +378,6 @@ wifi_secrets_cancel (NMDeviceIwd *self)
if (priv->wifi_secrets_id)
nm_act_request_cancel_secrets (NULL, priv->wifi_secrets_id);
nm_assert (!priv->wifi_secrets_id);
if (priv->secrets_request) {
g_dbus_method_invocation_return_error_literal (priv->secrets_request, NM_DEVICE_ERROR,
NM_DEVICE_ERROR_INVALID_CONNECTION,
"NM secrets request cancelled");
priv->secrets_request = NULL;
}
}
static void
@ -545,7 +536,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
return FALSE;
mode = nm_setting_wireless_get_mode (s_wireless);
if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_INFRA) != 0)
if (mode && g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_INFRA) != 0)
return FALSE;
/* 8021x networks can only be used if they've been provisioned on the IWD side and
@ -575,7 +566,7 @@ check_connection_available (NMDevice *device,
/* Only Infrastrusture mode at this time */
mode = nm_setting_wireless_get_mode (s_wifi);
if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_INFRA) != 0)
if (mode && g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_INFRA) != 0)
return FALSE;
/* Hidden SSIDs not supported yet */
@ -630,7 +621,7 @@ complete_connection (NMDevice *device,
mode = s_wifi ? nm_setting_wireless_get_mode (s_wifi) : NULL;
if (s_wifi && !nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_INFRA)) {
if (mode && !nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_INFRA)) {
g_set_error_literal (error,
NM_DEVICE_ERROR,
NM_DEVICE_ERROR_INVALID_CONNECTION,
@ -806,7 +797,7 @@ can_auto_connect (NMDevice *device,
/* Only Infrastrusture mode */
mode = nm_setting_wireless_get_mode (s_wifi);
if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_INFRA) != 0)
if (mode && g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_INFRA) != 0)
return FALSE;
/* Don't autoconnect to networks that have been tried at least once
@ -1001,6 +992,127 @@ scanning_prohibited (NMDeviceIwd *self, gboolean periodic)
return !priv->can_scan;
}
/*
* try_reply_agent_request
*
* Check if the connection settings already have the secrets corresponding
* to the IWD agent method that was invoked. If they do, send the method reply
* with the appropriate secrets. Otherwise return the missing secret's setting
* name and key so the caller can send a NM secrets request with this data.
* Return TRUE in either case, return FALSE if an error is detected.
*/
static gboolean
try_reply_agent_request (NMDeviceIwd *self,
NMConnection *connection,
GDBusMethodInvocation *invocation,
const gchar **setting_name,
const gchar **setting_key,
gboolean *replied)
{
const gchar *method_name = g_dbus_method_invocation_get_method_name (invocation);
NMSettingWirelessSecurity *s_wireless_sec;
NMSetting8021x *s_8021x;
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
s_8021x = nm_connection_get_setting_802_1x (connection);
*replied = FALSE;
if (!strcmp (method_name, "RequestPassphrase")) {
const gchar *psk;
if (!s_wireless_sec)
return FALSE;
psk = nm_setting_wireless_security_get_psk (s_wireless_sec);
if (psk) {
_LOGD (LOGD_DEVICE | LOGD_WIFI,
"Returning the PSK to the IWD Agent");
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(s)", psk));
*replied = TRUE;
return TRUE;
}
*setting_name = NM_SETTING_WIRELESS_SECURITY_SETTING_NAME;
*setting_key = NM_SETTING_WIRELESS_SECURITY_PSK;
return TRUE;
} else if (!strcmp (method_name, "RequestPrivateKeyPassphrase")) {
const gchar *password;
if (!s_8021x)
return FALSE;
password = nm_setting_802_1x_get_private_key_password (s_8021x);
if (password) {
_LOGD (LOGD_DEVICE | LOGD_WIFI,
"Returning the private key password to the IWD Agent");
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(s)", password));
*replied = TRUE;
return TRUE;
}
*setting_name = NM_SETTING_802_1X_SETTING_NAME;
*setting_key = NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD;
return TRUE;
} else if (!strcmp (method_name, "RequestUserNameAndPassword")) {
const gchar *identity, *password;
if (!s_8021x)
return FALSE;
identity = nm_setting_802_1x_get_identity (s_8021x);
password = nm_setting_802_1x_get_password (s_8021x);
if (identity && password) {
_LOGD (LOGD_DEVICE | LOGD_WIFI,
"Returning the username and password to the IWD Agent");
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(ss)", identity, password));
*replied = TRUE;
return TRUE;
}
*setting_name = NM_SETTING_802_1X_SETTING_NAME;
if (!identity)
*setting_key = NM_SETTING_802_1X_IDENTITY;
else
*setting_key = NM_SETTING_802_1X_PASSWORD;
return TRUE;
} else if (!strcmp (method_name, "RequestUserPassword")) {
const gchar *password;
if (!s_8021x)
return FALSE;
password = nm_setting_802_1x_get_password (s_8021x);
if (password) {
_LOGD (LOGD_DEVICE | LOGD_WIFI,
"Returning the user password to the IWD Agent");
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(s)", password));
*replied = TRUE;
return TRUE;
}
*setting_name = NM_SETTING_802_1X_SETTING_NAME;
*setting_key = NM_SETTING_802_1X_PASSWORD;
return TRUE;
} else
return FALSE;
}
static void
wifi_secrets_get_one (NMDeviceIwd *self,
const char *setting_name,
NMSecretAgentGetSecretsFlags flags,
const char *setting_key,
GDBusMethodInvocation *invocation);
static void
wifi_secrets_cb (NMActRequest *req,
NMActRequestGetSecretsCallId *call_id,
@ -1008,25 +1120,33 @@ wifi_secrets_cb (NMActRequest *req,
GError *error,
gpointer user_data)
{
NMDevice *device = user_data;
NMDeviceIwd *self = user_data;
NMDeviceIwd *self;
NMDeviceIwdPrivate *priv;
NMSettingWirelessSecurity *s_wireless_sec;
const gchar *psk;
NMDevice *device;
GDBusMethodInvocation *invocation;
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);
g_return_if_fail (NM_IS_DEVICE_IWD (self));
g_return_if_fail (NM_IS_ACT_REQUEST (req));
priv = NM_DEVICE_IWD_GET_PRIVATE (self);
device = NM_DEVICE (self);
g_return_if_fail (priv->wifi_secrets_id == call_id);
priv->wifi_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_dbus_method_invocation_return_error_literal (invocation, NM_DEVICE_ERROR,
NM_DEVICE_ERROR_INVALID_CONNECTION,
"NM secrets request cancelled");
return;
}
g_return_if_fail (priv->secrets_request);
g_return_if_fail (req == nm_device_get_act_request (device));
g_return_if_fail (nm_act_request_get_settings_connection (req) == s_connection);
@ -1038,32 +1158,30 @@ wifi_secrets_cb (NMActRequest *req,
goto secrets_error;
}
s_wireless_sec = nm_connection_get_setting_wireless_security (nm_act_request_get_applied_connection (req));
if (!s_wireless_sec)
if (!try_reply_agent_request (self, nm_act_request_get_applied_connection (req),
invocation, &setting_name, &setting_key,
&replied))
goto secrets_error;
psk = nm_setting_wireless_security_get_psk (s_wireless_sec);
if (!psk)
goto secrets_error;
if (replied) {
/* Change state back to what it was before NEED_AUTH */
nm_device_state_changed (device, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE);
return;
}
_LOGD (LOGD_DEVICE | LOGD_WIFI,
"Returning a new PSK to the IWD Agent");
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;
g_dbus_method_invocation_return_value (priv->secrets_request,
g_variant_new ("(s)", psk));
priv->secrets_request = NULL;
/* Change state back to what it was before NEED_AUTH */
nm_device_state_changed (device, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE);
/* Request further secrets if we still need something */
wifi_secrets_get_one (self, setting_name, get_secret_flags,
setting_key, invocation);
return;
secrets_error:
if (priv->secrets_request) {
g_dbus_method_invocation_return_error_literal (priv->secrets_request, NM_DEVICE_ERROR,
NM_DEVICE_ERROR_INVALID_CONNECTION,
"NM secrets request failed");
priv->secrets_request = NULL;
}
g_dbus_method_invocation_return_error_literal (invocation, NM_DEVICE_ERROR,
NM_DEVICE_ERROR_INVALID_CONNECTION,
"NM secrets request failed");
nm_device_state_changed (device,
NM_DEVICE_STATE_FAILED,
@ -1073,9 +1191,11 @@ secrets_error:
}
static void
wifi_secrets_get_secrets (NMDeviceIwd *self,
const char *setting_name,
NMSecretAgentGetSecretsFlags flags)
wifi_secrets_get_one (NMDeviceIwd *self,
const char *setting_name,
NMSecretAgentGetSecretsFlags flags,
const char *setting_key,
GDBusMethodInvocation *invocation)
{
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
NMActRequest *req;
@ -1089,9 +1209,9 @@ wifi_secrets_get_secrets (NMDeviceIwd *self,
TRUE,
setting_name,
flags,
NULL,
setting_key,
wifi_secrets_cb,
self);
nm_utils_user_data_pack (self, invocation));
}
static void
@ -1219,15 +1339,13 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
ap = ap_path ? nm_wifi_ap_lookup_for_device (NM_DEVICE (self), ap_path) : NULL;
if (!ap) {
ap = nm_wifi_aps_find_first_compatible (&priv->aps_lst_head, connection);
/* TODO: assuming hidden networks aren't supported do we need
* to consider the case of APs that are not in the scan list
* yet, for which nm-device-wifi.c creates the temporary fake
* AP object?
*/
if (!ap) {
NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
return NM_ACT_STAGE_RETURN_FAILURE;
}
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
nm_dbus_object_get_path (NM_DBUS_OBJECT (ap)));
}
set_current_ap (self, ap, FALSE);
@ -1730,40 +1848,44 @@ nm_device_iwd_set_dbus_object (NMDeviceIwd *self, GDBusObject *object)
}
gboolean
nm_device_iwd_agent_psk_query (NMDeviceIwd *self,
GDBusMethodInvocation *invocation)
nm_device_iwd_agent_query (NMDeviceIwd *self,
GDBusMethodInvocation *invocation)
{
NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self);
NMActRequest *req;
NMSettingWirelessSecurity *s_wireless_sec;
const gchar *psk;
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)
return FALSE;
s_wireless_sec = nm_connection_get_setting_wireless_security (nm_act_request_get_applied_connection (req));
if (!s_wireless_sec)
if (!try_reply_agent_request (self, nm_act_request_get_applied_connection (req),
invocation, &setting_name, &setting_key,
&replied))
return FALSE;
psk = nm_setting_wireless_security_get_psk (s_wireless_sec);
if (psk) {
_LOGD (LOGD_DEVICE | LOGD_WIFI,
"Returning the PSK to the IWD Agent");
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(s)", psk));
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_secrets (self,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION
| NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW);
wifi_secrets_get_one (self, setting_name, get_secret_flags,
setting_key, invocation);
priv->secrets_request = invocation;
return TRUE;
}

View file

@ -51,8 +51,8 @@ NMDevice *nm_device_iwd_new (const char *iface, NMDeviceWifiCapabilities capabil
void nm_device_iwd_set_dbus_object (NMDeviceIwd *device, GDBusObject *object);
gboolean nm_device_iwd_agent_psk_query (NMDeviceIwd *device,
GDBusMethodInvocation *invocation);
gboolean nm_device_iwd_agent_query (NMDeviceIwd *device,
GDBusMethodInvocation *invocation);
const CList *_nm_device_iwd_get_aps (NMDeviceIwd *self);

View file

@ -84,27 +84,31 @@ G_DEFINE_TYPE (NMIwdManager, nm_iwd_manager, G_TYPE_OBJECT)
/*****************************************************************************/
static void
psk_agent_dbus_method_cb (GDBusConnection *connection,
const gchar *sender, const gchar *object_path,
const gchar *interface_name, const gchar *method_name,
GVariant *parameters,
GDBusMethodInvocation *invocation,
gpointer user_data)
agent_dbus_method_cb (GDBusConnection *connection,
const gchar *sender, const gchar *object_path,
const gchar *interface_name, const gchar *method_name,
GVariant *parameters,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
NMIwdManager *self = user_data;
NMIwdManagerPrivate *priv = NM_IWD_MANAGER_GET_PRIVATE (self);
GDBusObjectManagerClient *omc = G_DBUS_OBJECT_MANAGER_CLIENT (priv->object_manager);
const gchar *network_path, *device_path, *ifname;
gs_unref_object GDBusInterface *network = NULL, *device_obj = NULL;
gs_unref_variant GVariant *value = NULL;
gint ifindex;
NMDevice *device;
gs_free char *name_owner = NULL;
/* Be paranoid and check the sender address */
if (!nm_streq0 (g_dbus_object_manager_client_get_name_owner (omc), sender))
name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (priv->object_manager));
if (!nm_streq0 (name_owner, sender))
goto return_error;
g_variant_get (parameters, "(&o)", &network_path);
if (!strcmp (method_name, "RequestUserPassword"))
g_variant_get (parameters, "(&os)", &network_path, NULL);
else
g_variant_get (parameters, "(&o)", &network_path);
network = g_dbus_object_manager_get_interface (priv->object_manager,
network_path,
@ -113,7 +117,7 @@ psk_agent_dbus_method_cb (GDBusConnection *connection,
device_path = g_variant_get_string (value, NULL);
if (!device_path) {
_LOGE ("Device not cached for network %s in IWD Agent request",
_LOGD ("agent-request: device not cached for network %s in IWD Agent request",
network_path);
goto return_error;
}
@ -126,103 +130,99 @@ psk_agent_dbus_method_cb (GDBusConnection *connection,
ifname = g_variant_get_string (value, NULL);
if (!ifname) {
_LOGE ("Name not cached for device %s in IWD Agent request",
_LOGD ("agent-request: name not cached for device %s in IWD Agent request",
device_path);
goto return_error;
}
ifindex = if_nametoindex (ifname);
if (!ifindex) {
_LOGE ("if_nametoindex failed for Name %s for Device at %s: %i",
_LOGD ("agent-request: if_nametoindex failed for Name %s for Device at %s: %i",
ifname, device_path, errno);
goto return_error;
}
device = nm_manager_get_device_by_ifindex (priv->manager, ifindex);
if (!NM_IS_DEVICE_IWD (device)) {
_LOGE ("IWD device named %s is not a Wifi device in IWD Agent request",
ifname);
_LOGD ("agent-request: IWD device named %s is not a Wifi device in IWD Agent request",
ifname);
goto return_error;
}
if (nm_device_iwd_agent_psk_query (NM_DEVICE_IWD (device), invocation))
if (nm_device_iwd_agent_query (NM_DEVICE_IWD (device), invocation))
return;
_LOGE ("Device %s did not handle the IWD Agent request", ifname);
_LOGD ("agent-request: device %s did not handle the IWD Agent request", ifname);
return_error:
/* IWD doesn't look at the specific error */
g_dbus_method_invocation_return_error_literal (invocation, NM_DEVICE_ERROR,
NM_DEVICE_ERROR_INVALID_CONNECTION,
"No PSK available for this connection");
"Secrets not available for this connection");
}
static const GDBusInterfaceInfo iwd_agent_iface_info = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT (
"net.connman.iwd.Agent",
.methods = NM_DEFINE_GDBUS_METHOD_INFOS (
NM_DEFINE_GDBUS_METHOD_INFO (
"RequestPassphrase",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("network", "o"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("passphrase", "s"),
),
),
NM_DEFINE_GDBUS_METHOD_INFO (
"RequestPrivateKeyPassphrase",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("network", "o"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("passphrase", "s"),
),
),
NM_DEFINE_GDBUS_METHOD_INFO (
"RequestUserNameAndPassword",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("network", "o"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("user", "s"),
NM_DEFINE_GDBUS_ARG_INFO ("password", "s"),
),
),
NM_DEFINE_GDBUS_METHOD_INFO (
"RequestUserPassword",
.in_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("network", "o"),
NM_DEFINE_GDBUS_ARG_INFO ("user", "s"),
),
.out_args = NM_DEFINE_GDBUS_ARG_INFOS (
NM_DEFINE_GDBUS_ARG_INFO ("password", "s"),
),
),
),
);
static guint
psk_agent_export (GDBusConnection *connection, gpointer user_data,
iwd_agent_export (GDBusConnection *connection, gpointer user_data,
gchar **agent_path, GError **error)
{
static const GDBusArgInfo request_passphrase_arg_network = {
-1,
(gchar *) "network",
(gchar *) "o",
NULL,
static const GDBusInterfaceVTable vtable = {
.method_call = agent_dbus_method_cb,
};
static const GDBusArgInfo *const request_passphrase_in_args[] = {
&request_passphrase_arg_network,
NULL,
};
static const GDBusArgInfo request_passphrase_arg_passphrase = {
-1,
(gchar *) "passphrase",
(gchar *) "s",
NULL,
};
static const GDBusArgInfo *const request_passphrase_out_args[] = {
&request_passphrase_arg_passphrase,
NULL,
};
static const GDBusMethodInfo request_passphrase_info = {
-1,
(gchar *) "RequestPassphrase",
(GDBusArgInfo **) &request_passphrase_in_args,
(GDBusArgInfo **) &request_passphrase_out_args,
NULL,
};
static const GDBusMethodInfo *const method_info[] = {
&request_passphrase_info,
NULL,
};
static GDBusInterfaceInfo interface_info = {
-1,
(gchar *) "net.connman.iwd.Agent",
(GDBusMethodInfo **) &method_info,
NULL,
NULL,
NULL,
};
static GDBusInterfaceVTable vtable = {
psk_agent_dbus_method_cb,
NULL,
NULL,
};
gchar path[50];
unsigned int rnd;
guint id;
if (!nm_utils_random_bytes (&rnd, sizeof (rnd))) {
g_set_error_literal (error,
NM_DEVICE_ERROR,
NM_DEVICE_ERROR_FAILED,
"Can't read urandom.");
return 0;
}
nm_utils_random_bytes (&rnd, sizeof (rnd));
nm_sprintf_buf (path, "/agent/%u", rnd);
id = g_dbus_connection_register_object (connection, path,
&interface_info, &vtable,
user_data, NULL, error);
NM_UNCONST_PTR (GDBusInterfaceInfo, &iwd_agent_iface_info),
&vtable, user_data, NULL, error);
if (id)
*agent_path = g_strdup (path);
@ -549,7 +549,7 @@ got_object_manager (GObject *object, GAsyncResult *result, gpointer user_data)
connection = g_dbus_object_manager_client_get_connection (G_DBUS_OBJECT_MANAGER_CLIENT (object_manager));
priv->agent_id = psk_agent_export (connection, self,
priv->agent_id = iwd_agent_export (connection, self,
&priv->agent_path, &error);
if (!priv->agent_id) {
_LOGE ("failed to export the IWD Agent: PSK/8021x WiFi networks will not work: %s",

View file

@ -1210,9 +1210,11 @@ nm_manager_get_device_by_ifindex (NMManager *self, int ifindex)
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
NMDevice *device;
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
if (nm_device_get_ifindex (device) == ifindex)
return device;
if (ifindex > 0) {
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
if (nm_device_get_ifindex (device) == ifindex)
return device;
}
}
return NULL;

View file

@ -1033,7 +1033,7 @@ get_secrets_done_cb (NMAgentManager *manager,
NMSettingsConnectionPrivate *priv;
NMConnection *applied_connection;
gs_free_error GError *local = NULL;
GVariant *dict;
GVariant *dict = NULL;
gboolean agent_had_system = FALSE;
ForEachSecretFlags cmp_flags = { NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_SECRET_FLAG_NONE };
@ -1096,7 +1096,8 @@ get_secrets_done_cb (NMAgentManager *manager,
setting_name,
call_id);
dict = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
if (priv->system_secrets)
dict = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
/* Update the connection with our existing secrets from backing storage */
nm_connection_clear_secrets (NM_CONNECTION (self));
@ -1240,7 +1241,7 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
gpointer callback_data)
{
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
GVariant *existing_secrets;
GVariant *existing_secrets = NULL;
NMAgentManagerCallId call_id_a;
gs_free char *joined_hints = NULL;
NMSettingsConnectionCallId *call_id;
@ -1262,15 +1263,6 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
call_id->callback_data = callback_data;
c_list_link_tail (&priv->call_ids_lst_head, &call_id->call_ids_lst);
/* Use priv->secrets to work around the fact that nm_connection_clear_secrets()
* will clear secrets on this object's settings.
*/
if (!priv->system_secrets) {
g_set_error_literal (&local, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED,
"secrets cache invalid");
goto schedule_dummy;
}
/* Make sure the request actually requests something we can return */
if (!nm_connection_get_setting_by_name (NM_CONNECTION (self), setting_name)) {
g_set_error (&local, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
@ -1286,7 +1278,11 @@ nm_settings_connection_get_secrets (NMSettingsConnection *self,
goto schedule_dummy;
}
existing_secrets = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
/* Use priv->system_secrets to work around the fact that nm_connection_clear_secrets()
* will clear secrets on this object's settings.
*/
if (priv->system_secrets)
existing_secrets = nm_connection_to_dbus (priv->system_secrets, NM_CONNECTION_SERIALIZE_ONLY_SECRETS);
if (existing_secrets)
g_variant_ref_sink (existing_secrets);