Development
This commit is contained in:
parent
58ab569e42
commit
b307461d44
1 changed files with 8 additions and 4 deletions
|
|
@ -258,12 +258,16 @@ def set_freeradius_eap(data):
|
||||||
allow_weak_eap = eap_cfg.get('allow_weak_eap', False)
|
allow_weak_eap = eap_cfg.get('allow_weak_eap', False)
|
||||||
content = RADIUS_EAP_FILE.read_text()
|
content = RADIUS_EAP_FILE.read_text()
|
||||||
tr_val = 'yes' if tunneled_reply else 'no'
|
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)
|
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)
|
# Only replace the first occurrence -- that is the outer eap{} block's default.
|
||||||
if content3 == content:
|
# 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
|
return False
|
||||||
RADIUS_EAP_FILE.write_text(content3)
|
RADIUS_EAP_FILE.write_text(content4)
|
||||||
print(f"EAP: tunneled_reply={tr_val}, allow_weak_eap={allow_weak_eap}")
|
print(f"EAP: default_eap_type={eap_type}, tunneled_reply={tr_val}, allow_weak_eap={allow_weak_eap}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue