3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 21:22:37 +01:00

network: Start checking outcomes of setting loads

This commit is contained in:
Tim Kourt 2017-10-31 15:02:59 -07:00 committed by Denis Kenzior
parent e7d1b779e7
commit f4f1450880

View File

@ -153,12 +153,13 @@ bool network_connected(struct network *network)
break; break;
case -ENOENT: case -ENOENT:
/* /*
* This is an open network seen for the first time:
*
* Write an empty settings file to keep track of the * Write an empty settings file to keep track of the
* last connected time. This will also make iwd autoconnect * last connected time. This will also make iwd autoconnect
* to this network in the future. * to this network in the future.
*/ */
if (!network_settings_load(network)) network->settings = l_settings_new();
return false;
storage_network_sync(strtype, network->info->ssid, storage_network_sync(strtype, network->info->ssid,
network->settings); network->settings);
@ -394,7 +395,9 @@ int network_autoconnect(struct network *network, struct scan_bss *bss)
if (network->ask_psk) if (network->ask_psk)
return -ENOKEY; return -ENOKEY;
network_settings_load(network); if (!network_settings_load(network))
return -ENOKEY;
psk = l_settings_get_value(network->settings, "Security", psk = l_settings_get_value(network->settings, "Security",
"PreSharedKey"); "PreSharedKey");
@ -414,7 +417,9 @@ int network_autoconnect(struct network *network, struct scan_bss *bss)
break; break;
} }
case SECURITY_8021X: case SECURITY_8021X:
network_settings_load(network); if (!network_settings_load(network))
return -ENOKEY;
break; break;
default: default:
return -ENOTSUP; return -ENOTSUP;
@ -572,26 +577,28 @@ static struct l_dbus_message *network_connect_psk(struct network *network,
l_debug(""); l_debug("");
network_settings_load(network); if (network_settings_load(network)) {
psk = l_settings_get_value(network->settings, "Security",
"PreSharedKey");
psk = l_settings_get_value(network->settings, "Security", if (psk) {
"PreSharedKey"); size_t len;
if (psk) { l_debug("psk: %s", psk);
size_t len;
l_debug("psk: %s", psk);
l_free(network->psk);
network->psk = l_util_from_hexstring(psk, &len);
l_debug("len: %zd", len);
if (network->psk && len != 32) {
l_debug("Can't parse PSK");
l_free(network->psk); l_free(network->psk);
network->psk = NULL; network->psk = l_util_from_hexstring(psk, &len);
l_debug("len: %zd", len);
if (network->psk && len != 32) {
l_debug("Can't parse PSK");
l_free(network->psk);
network->psk = NULL;
}
} }
} else {
network->settings = l_settings_new();
} }
l_debug("ask_psk: %s", network->ask_psk ? "true" : "false"); l_debug("ask_psk: %s", network->ask_psk ? "true" : "false");
@ -643,7 +650,9 @@ static struct l_dbus_message *network_connect(struct l_dbus *dbus,
device_connect_network(device, network, bss, message); device_connect_network(device, network, bss, message);
return NULL; return NULL;
case SECURITY_8021X: case SECURITY_8021X:
network_settings_load(network); if (!network_settings_load(network))
return dbus_error_not_configured(message);
device_connect_network(device, network, bss, message); device_connect_network(device, network, bss, message);
return NULL; return NULL;
default: default: