network: add check for autoconnect flag in settings

This commit is contained in:
Tim Kourt 2018-01-23 11:42:45 -08:00 committed by Denis Kenzior
parent 91b6efaf66
commit 3230cee2a1
1 changed files with 11 additions and 0 deletions

View File

@ -373,6 +373,7 @@ void network_sync_psk(struct network *network)
int network_autoconnect(struct network *network, struct scan_bss *bss)
{
struct wiphy *wiphy = device_get_wiphy(network->device);
bool is_autoconnectable;
switch (network_get_security(network)) {
case SECURITY_NONE:
@ -425,6 +426,16 @@ int network_autoconnect(struct network *network, struct scan_bss *bss)
return -ENOTSUP;
}
if (!l_settings_get_bool(network->settings, "Settings",
"Autoconnect", &is_autoconnectable))
goto connect;
if (!is_autoconnectable) {
network_settings_close(network);
return -EPERM;
}
connect:
device_connect_network(network->device, network, bss, NULL);
return 0;
}