mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
firewall: Get service ports details
Add interface to get port types and numbers for a service. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
51fc87f1bc
commit
e5081018a3
@ -46,6 +46,12 @@ def parse_arguments():
|
|||||||
'--zone', help='Zone from which the list is to be retrieved',
|
'--zone', help='Zone from which the list is to be retrieved',
|
||||||
required=True)
|
required=True)
|
||||||
|
|
||||||
|
# Get service ports
|
||||||
|
get_service_ports = subparsers.add_parser(
|
||||||
|
'get-service-ports', help='Get list of ports for service')
|
||||||
|
get_service_ports.add_argument('--service', help='Name of service',
|
||||||
|
required=True)
|
||||||
|
|
||||||
# Get interface status
|
# Get interface status
|
||||||
get_interfaces = subparsers.add_parser(
|
get_interfaces = subparsers.add_parser(
|
||||||
'get-interfaces', help='Get list of interfaces in a zone')
|
'get-interfaces', help='Get list of interfaces in a zone')
|
||||||
@ -105,8 +111,8 @@ def _flush_iptables_rules():
|
|||||||
def set_firewall_backend(backend):
|
def set_firewall_backend(backend):
|
||||||
"""Set FirewallBackend attribute to the specified string."""
|
"""Set FirewallBackend attribute to the specified string."""
|
||||||
conf_file = '/etc/firewalld/firewalld.conf'
|
conf_file = '/etc/firewalld/firewalld.conf'
|
||||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
aug = augeas.Augeas(
|
||||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||||
|
|
||||||
# lens for shell-script config file
|
# lens for shell-script config file
|
||||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||||
@ -150,6 +156,14 @@ def subcommand_get_enabled_services(arguments):
|
|||||||
['firewall-cmd', '--zone', arguments.zone, '--list-services'])
|
['firewall-cmd', '--zone', arguments.zone, '--list-services'])
|
||||||
|
|
||||||
|
|
||||||
|
def subcommand_get_service_ports(arguments):
|
||||||
|
"""Print list of ports for service"""
|
||||||
|
subprocess.call([
|
||||||
|
'firewall-cmd', '--permanent', '--service', arguments.service,
|
||||||
|
'--get-ports'
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
def subcommand_get_interfaces(arguments):
|
def subcommand_get_interfaces(arguments):
|
||||||
"""Print the list of interfaces in a zone."""
|
"""Print the list of interfaces in a zone."""
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
|
|||||||
@ -95,6 +95,13 @@ def get_enabled_services(zone):
|
|||||||
return output.split()
|
return output.split()
|
||||||
|
|
||||||
|
|
||||||
|
def get_port_details(service_port):
|
||||||
|
"""Return the port types and numbers for a service port"""
|
||||||
|
output = _run(
|
||||||
|
['get-service-ports', '--service', service_port], superuser=True)
|
||||||
|
return output.split()
|
||||||
|
|
||||||
|
|
||||||
def get_interfaces(zone):
|
def get_interfaces(zone):
|
||||||
"""Return the list of interfaces in a zone."""
|
"""Return the list of interfaces in a zone."""
|
||||||
output = _run(['get-interfaces', '--zone', zone], superuser=True)
|
output = _run(['get-interfaces', '--zone', zone], superuser=True)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user