feat: enterprise deploy retry loop + karma filters (deny=allow-all)

This commit is contained in:
2026-08-18 19:58:01 -05:00
parent c33d5d01f3
commit f31b38d1fa
@@ -3009,23 +3009,40 @@ def _deploy_enterprise(fields):
'ctrl_interface=%s\n' % (ENT_IFACE, ssid, int(ch), ENT_EAP_USERS, ENT_CTRL_DIR)) 'ctrl_interface=%s\n' % (ENT_IFACE, ssid, int(ch), ENT_EAP_USERS, ENT_CTRL_DIR))
except OSError as exc: except OSError as exc:
raise RuntimeError('could not write enterprise config: %s' % exc) raise RuntimeError('could not write enterprise config: %s' % exc)
# Tell the karma build which iface is the management (enterprise) AP. # Tell the karma build which iface is the management (enterprise) AP and
# make karma respond to any SSID (deny mode = allow by default).
device_run(['uci', 'set', 'pineapd.@hostapd[0].mgmtiface=%s' % ENT_IFACE]) device_run(['uci', 'set', 'pineapd.@hostapd[0].mgmtiface=%s' % ENT_IFACE])
device_run(['uci', 'set', 'pineapd.@ssid_filter[0].mode=deny'])
device_run(['uci', 'set', 'pineapd.@mac_filter[0].mode=deny'])
device_run(['uci', 'commit', 'pineapd']) device_run(['uci', 'commit', 'pineapd'])
_pause_hop() _pause_hop()
rc, out, err = device_run(['/usr/sbin/hostapd', '-B', '-P', ENT_PIDFILE, ENT_CONF], # The daemon's wireless reconciliation races standalone iface creation;
timeout=20) # retry through a few quiet windows before giving up.
verified = _ent_running() verified = False
if not verified: last_err = ''
_disable_enterprise_ap() for attempt in range(3):
raise RuntimeError('hostapd failed to start for enterprise AP: %s' % (err or out)[-300:]) rc, out, err = device_run(['/usr/sbin/hostapd', '-B', '-P', ENT_PIDFILE, ENT_CONF],
deadline = time.time() + 20 timeout=25)
while time.time() < deadline: deadline = time.time() + 12
rc, out = _ent_ctrl('status') while time.time() < deadline:
if 'state=ENABLED' in out: rc2, out2 = _ent_ctrl('status')
if 'state=ENABLED' in (out2 or ''):
verified = True
break
time.sleep(2)
if verified:
break break
time.sleep(2) last_err = (err or out or '')[-500:]
verified = 'state=ENABLED' in (_ent_ctrl('status')[1] or '') _disable_enterprise_ap()
if attempt < 2:
time.sleep(5)
rc, out, err = device_run(['iw', 'phy', 'phy1', 'interface', 'add',
ENT_IFACE, 'type', 'managed'], timeout=15)
if rc == 0:
device_run(['iw', 'dev', ENT_IFACE, 'set', 'type', 'ap'])
device_run(['ip', 'link', 'set', ENT_IFACE, 'up'])
if not verified:
raise RuntimeError('hostapd failed to start for enterprise AP: %s' % last_err)
_ent_ctrl('pineap_enable') _ent_ctrl('pineap_enable')
_ent_ctrl('pineape_enable') _ent_ctrl('pineape_enable')
_ent_ctrl('pineape_auth_enable') _ent_ctrl('pineape_auth_enable')