fix: enable_shell_access.py: experimental support for firmware V3.3.8
This commit is contained in:
@@ -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',
|
def is_shell_access_enabled(config: ET.Element, interface: Literal['LAN', 'WAN'] = 'LAN',
|
||||||
protocol: Literal['SSH', 'Telnet'] = 'SSH') -> bool:
|
protocol: Literal['SSH', 'Telnet'] = 'SSH') -> bool:
|
||||||
ssh_policy = config.find(f".//ServiceControl/*[ServiceList='{protocol.upper()}'][Interface='{interface}']/Policy")
|
service_policy = config.find(f".//ServiceControl/*[ServiceList='{protocol.upper()}'][Interface='{interface}']/Policy")
|
||||||
return ssh_policy.text == "Permit"
|
return (service_policy is not None) and (service_policy.text == "Permit")
|
||||||
|
|
||||||
|
|
||||||
def enable_shell_access(config: ET.Element, interface: Literal['LAN', 'WAN'] = 'LAN',
|
def enable_shell_access(config: ET.Element, interface: Literal['LAN', 'WAN'] = 'LAN',
|
||||||
protocol: Literal['SSH', 'Telnet'] = 'SSH', disable: bool = False) -> bool:
|
protocol: Literal['SSH', 'Telnet'] = 'SSH', disable: bool = False) -> bool:
|
||||||
service_policy = config.find(
|
service = config.find(f".//ServiceControl/*[ServiceList='{protocol.upper()}'][Interface='{interface}']")
|
||||||
f".//ServiceControl/*[ServiceList='{protocol.upper()}'][Interface='{interface}']/Policy")
|
if service is None:
|
||||||
remote_management = config.find(f'.//RemoteManagement/{protocol.upper()}/{protocol}Enable')
|
return False
|
||||||
if (service_policy is not None) and (remote_management is not None):
|
service_policy = service.find(".Policy")
|
||||||
service_policy.text = "Discard" if disable else "Permit"
|
if service_policy is None:
|
||||||
if not disable:
|
service_policy = ET.SubElement(service, 'Policy', attrib={'PARAMETER': 'configured'})
|
||||||
remote_management.text = '1'
|
service_policy.text = "Discard" if disable else "Permit"
|
||||||
return True
|
return True
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def create_arg_parser():
|
def create_arg_parser():
|
||||||
|
Reference in New Issue
Block a user