fix: reject mixed 2.4GHz and radio1 AP requests with clear error

This commit is contained in:
2026-08-18 07:23:25 -05:00
parent cd39833f4b
commit 4fa7f8f855
2 changed files with 17 additions and 2 deletions
@@ -1817,8 +1817,14 @@ def h_pineap_wifi_set_ap(ctx):
open_band = channel_band(openap.get('channel')) if openap.get('channel') is not None else None
use_radio1 = wpa_band in (BAND_5G, BAND_6G) or open_band in (BAND_5G, BAND_6G)
if use_radio1:
wpa_active = bool(wpa.get('enabled', True)) and wpa.get('channel') is not None
open_active = bool(openap.get('enabled', True)) and openap.get('channel') is not None
wpa_active = (wpa_band in (BAND_5G, BAND_6G) and bool(wpa.get('enabled', True))
and wpa.get('channel') is not None)
open_active = (open_band in (BAND_5G, BAND_6G) and bool(openap.get('enabled', True))
and openap.get('channel') is not None)
wpa_present = bool(wpa.get('ssid') or wpa.get('enabled') is not None)
open_present = bool(openap.get('ssid') or openap.get('enabled') is not None)
if (wpa_present and wpa_band == BAND_2G) or (open_present and open_band == BAND_2G):
return 400, {'error': 'cannot configure 2.4GHz and radio1 APs in one request'}
if not (wpa_active or open_active):
_remove_radio1_ap()
device_run(['wifi', 'reload'])
+9
View File
@@ -249,6 +249,15 @@ class SetApRadio1Test(unittest.TestCase):
self.assertEqual(self.uci['pineapd.wlan1mon.hop'], '1')
self.assertEqual(self.uci.get('wireless.radio1.channel'), 'auto')
def test_mixed_24g_and_radio1_rejected(self):
status, payload = server.h_pineap_wifi_set_ap(ctx({
'open': {'ssid': 'CorpGuest', 'hidden': False, 'enabled': True,
'channel': 36, 'country': 'US'},
'wpa': {'ssid': 'Office', 'passphrase': 'secret123', 'enctype': 'psk2',
'hidden': False, 'enabled': True, 'channel': 6}}))
self.assertEqual(status, 400)
self.assertIn('2.4GHz', payload['error'])
class GetApRadioChannelFallbackTest(unittest.TestCase):
"""Regression: iface without a channel option inherits the radio channel."""