diff --git a/src/RaspAP/Networking/Hotspot/WiFiManager.php b/src/RaspAP/Networking/Hotspot/WiFiManager.php index 316ba074..e61044a8 100644 --- a/src/RaspAP/Networking/Hotspot/WiFiManager.php +++ b/src/RaspAP/Networking/Hotspot/WiFiManager.php @@ -313,6 +313,8 @@ class WiFiManager */ public function setKnownStationsWPA($networks) { + $this->ensureWpaSupplicantConf(); + $iface = escapeshellarg($_SESSION['wifi_client_interface']); $output = shell_exec("sudo wpa_cli -i $iface list_networks 2>&1"); @@ -475,5 +477,42 @@ class WiFiManager return false; } + /** + * Ensures /etc/wpa_supplicant/wpa_supplicant.conf exists with minimal safe contents + * Does not overwrite an existing file + * + * @throws \RuntimeException on permission or write failure + */ + public function ensureWpaSupplicantConf(): void + { + $confPath = '/etc/wpa_supplicant/wpa_supplicant.conf'; + + if (file_exists($confPath)) { + // Already exists, do nothing + return; + } + + $contents = <<