Development

This commit is contained in:
Matthew Grotke 2026-06-05 02:00:01 -04:00
parent 58ab569e42
commit b307461d44

View file

@ -258,12 +258,16 @@ def set_freeradius_eap(data):
allow_weak_eap = eap_cfg.get('allow_weak_eap', False)
content = RADIUS_EAP_FILE.read_text()
tr_val = 'yes' if tunneled_reply else 'no'
eap_type = 'md5' if allow_weak_eap else 'peap'
content2 = re.sub(r'(?m)^(\s*use_tunneled_reply\s*=\s*)(yes|no)', rf'\g<1>{tr_val}', content)
content3 = toggle_freeradius_block(content2, 'md5', allow_weak_eap)
if content3 == content:
# Only replace the first occurrence -- that is the outer eap{} block's default.
# Inner blocks (e.g. peap's tunneled default) must not be touched.
content3 = re.sub(r'(?m)^(\s*default_eap_type\s*=\s*)\w+', rf'\g<1>{eap_type}', content2, count=1)
content4 = toggle_freeradius_block(content3, 'md5', allow_weak_eap)
if content4 == content:
return False
RADIUS_EAP_FILE.write_text(content3)
print(f"EAP: tunneled_reply={tr_val}, allow_weak_eap={allow_weak_eap}")
RADIUS_EAP_FILE.write_text(content4)
print(f"EAP: default_eap_type={eap_type}, tunneled_reply={tr_val}, allow_weak_eap={allow_weak_eap}")
return True