From 5d8b71b76857d36706cc608ff76ad69b6bda1142 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 28 Apr 2025 00:14:04 -0700 Subject: [PATCH] Delegate raspap-network-activity@*.service control to raspapd.service --- includes/hostapd.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/includes/hostapd.php b/includes/hostapd.php index 1c10084f..f9bd53bc 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -57,19 +57,16 @@ function DisplayHostAPDConfig() if (isset($_POST['StartHotspot']) || isset($_POST['RestartHotspot'])) { $status->addMessage('Attempting to start hotspot', 'info'); if ($arrHostapdConf['BridgedEnable'] == 1) { - exec('sudo '.RASPI_CONFIG.'/hostapd/servicestart.sh --interface br0 --seconds 2', $return); - exec('sudo systemctl stop "raspap-network-activity@*.service"'); - exec("sudo systemctl start raspap-network-activity@br0.service"); + exec('sudo '.RASPI_CONFIG.'/hostapd/servicestart.sh --interface br0 --seconds 1', $return); } elseif ($arrHostapdConf['WifiAPEnable'] == 1) { - exec('sudo '.RASPI_CONFIG.'/hostapd/servicestart.sh --interface uap0 --seconds 2', $return); - exec('sudo systemctl stop "raspap-network-activity@*.service"'); - exec("sudo systemctl start raspap-network-activity@uap0.service"); + exec('sudo '.RASPI_CONFIG.'/hostapd/servicestart.sh --interface uap0 --seconds 1', $return); } else { - exec('sudo '.RASPI_CONFIG.'/hostapd/servicestart.sh --seconds 2', $return); - exec('sudo systemctl stop "raspap-network-activity@*.service"'); - if (!empty($_SESSION['ap_interface'])) { - $iface = escapeshellarg($_SESSION['ap_interface']); - exec("sudo systemctl start raspap-network-activity@{$iface}.service"); + // systemctl expects a unit name like raspap-network-activity@wlan0.service, no extra quotes + $iface_nonescaped = $_POST['interface']; + if (preg_match('/^[a-zA-Z0-9_-]+$/', $iface_nonescaped)) { // validate interface name + exec('sudo '.RASPI_CONFIG.'/hostapd/servicestart.sh --interface ' .$iface_nonescaped. ' --seconds 1', $return); + } else { + throw new \Exception('Invalid network interface'); } } foreach ($return as $line) {