Merge pull request #1627 from daniel-rose/bugfix/handle-open-wifi-correctly

fix: handle open wifi in `setKnownStationsWPA` correctly
This commit is contained in:
Bill Zimmerman 2024-08-02 19:05:06 +02:00 committed by GitHub
commit 98c2a7cb34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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);