From deac75af89784888edc5fd24c9993a6f29d6f686 Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 8 Oct 2023 11:46:12 +0200 Subject: [PATCH 1/2] Fix: handle 64 char passkey in absence of 8-63 char passhprase --- includes/configure_client.php | 6 ++++++ includes/wifi_functions.php | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/configure_client.php b/includes/configure_client.php index 64164f947..9abb61910 100755 --- a/includes/configure_client.php +++ b/includes/configure_client.php @@ -77,6 +77,12 @@ function DisplayWPAConfig() } } } + } elseif (strlen($network['passphrase']) == 0 && strlen($network['passkey']) == 64) { + $line = "\tpsk=" . $network['passkey']; + fwrite($wpa_file, "network={".PHP_EOL); + fwrite($wpa_file, "\tssid=\"".$ssid."\"".PHP_EOL); + fwrite($wpa_file, $line.PHP_EOL); + fwrite($wpa_file, "}".PHP_EOL); } else { $status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger'); $ok = false; diff --git a/includes/wifi_functions.php b/includes/wifi_functions.php index 34f8bc580..1ef0e2253 100755 --- a/includes/wifi_functions.php +++ b/includes/wifi_functions.php @@ -27,9 +27,9 @@ function knownWifiStations(&$networks) $network['ssid'] = $ssid; break; case 'psk': - if (array_key_exists('passphrase', $network)) { - break; - } + $network['passkey'] = trim($lineArr[1]); + $network['protocol'] = 'WPA'; + break; case '#psk': $network['protocol'] = 'WPA'; case 'wep_key0': // Untested From ff3f6ddb907b81841b22afc7e02874d399cf73c8 Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 8 Oct 2023 11:49:56 +0200 Subject: [PATCH 2/2] fwrite priority to wpa network if defined --- includes/configure_client.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/configure_client.php b/includes/configure_client.php index 9abb61910..41da0716f 100755 --- a/includes/configure_client.php +++ b/includes/configure_client.php @@ -82,6 +82,9 @@ function DisplayWPAConfig() fwrite($wpa_file, "network={".PHP_EOL); fwrite($wpa_file, "\tssid=\"".$ssid."\"".PHP_EOL); fwrite($wpa_file, $line.PHP_EOL); + if (array_key_exists('priority', $network)) { + fwrite($wpa_file, "\tpriority=".$network['priority'].PHP_EOL); + } fwrite($wpa_file, "}".PHP_EOL); } else { $status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');