fix: enable_shell_access.py: experimental support for firmware V3.3.8

This commit is contained in:
Victor Golovanenko
2025-08-06 08:29:27 +03:00
parent 77ff60920a
commit 540e712452

View File

@@ -40,21 +40,20 @@ def set_shell_access_creds(config: ET.Element, protocol: Literal['SSH', 'Telnet'
def is_shell_access_enabled(config: ET.Element, interface: Literal['LAN', 'WAN'] = 'LAN',
protocol: Literal['SSH', 'Telnet'] = 'SSH') -> bool:
ssh_policy = config.find(f".//ServiceControl/*[ServiceList='{protocol.upper()}'][Interface='{interface}']/Policy")
return ssh_policy.text == "Permit"
service_policy = config.find(f".//ServiceControl/*[ServiceList='{protocol.upper()}'][Interface='{interface}']/Policy")
return (service_policy is not None) and (service_policy.text == "Permit")
def enable_shell_access(config: ET.Element, interface: Literal['LAN', 'WAN'] = 'LAN',
protocol: Literal['SSH', 'Telnet'] = 'SSH', disable: bool = False) -> bool:
service_policy = config.find(
f".//ServiceControl/*[ServiceList='{protocol.upper()}'][Interface='{interface}']/Policy")
remote_management = config.find(f'.//RemoteManagement/{protocol.upper()}/{protocol}Enable')
if (service_policy is not None) and (remote_management is not None):
service_policy.text = "Discard" if disable else "Permit"
if not disable:
remote_management.text = '1'
return True
return False
service = config.find(f".//ServiceControl/*[ServiceList='{protocol.upper()}'][Interface='{interface}']")
if service is None:
return False
service_policy = service.find(".Policy")
if service_policy is None:
service_policy = ET.SubElement(service, 'Policy', attrib={'PARAMETER': 'configured'})
service_policy.text = "Discard" if disable else "Permit"
return True
def create_arg_parser():