fix: handle open wifi in setKnownStationsWPA correctly

use `... key_mgmt NONE` instead of `... psk XXX`
This commit is contained in:
Daniel Rose 2024-07-24 10:04:19 +02:00
parent a0d8f22742
commit 534b4df01a

View file

@ -269,6 +269,7 @@ function setKnownStationsWPA($networks)
if (!networkExists($ssid, $wpaCliNetworks)) { if (!networkExists($ssid, $wpaCliNetworks)) {
$ssid = escapeshellarg('"'.$network['ssid'].'"'); $ssid = escapeshellarg('"'.$network['ssid'].'"');
$psk = escapeshellarg('"'.$network['passphrase'].'"'); $psk = escapeshellarg('"'.$network['passphrase'].'"');
$protocol = $network['protocol'];
$netid = trim(shell_exec("sudo wpa_cli -i $iface add_network")); $netid = trim(shell_exec("sudo wpa_cli -i $iface add_network"));
if (isset($netid) && !isset($known[$netid])) { if (isset($netid) && !isset($known[$netid])) {
$commands = [ $commands = [
@ -276,6 +277,9 @@ function setKnownStationsWPA($networks)
"sudo wpa_cli -i $iface set_network $netid psk $psk", "sudo wpa_cli -i $iface set_network $netid psk $psk",
"sudo wpa_cli -i $iface enable_network $netid" "sudo wpa_cli -i $iface enable_network $netid"
]; ];
if ($protocol === 'Open') {
$commands[1] = "sudo wpa_cli -i $iface set_network $netid key_mgmt NONE";
}
foreach ($commands as $cmd) { foreach ($commands as $cmd) {
exec($cmd); exec($cmd);
usleep(1000); usleep(1000);