From b57d861cbe12aee734ba444068907f0fba4f5f3f Mon Sep 17 00:00:00 2001 From: Alexis Gavoty Date: Fri, 6 Jun 2014 11:48:58 +0200 Subject: [PATCH] [fix] Properly handle protocols --- firewall.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/firewall.py b/firewall.py index f877272ba..cf2f3cca7 100644 --- a/firewall.py +++ b/firewall.py @@ -39,10 +39,8 @@ from moulinette.core import MoulinetteError If we don't find the ssh port we define 22""" try: - with open('/etc/ssh/sshd_config') as ssh_config_file: for line in ssh_config_file: - line0 = line.split(" ")[0] if line0 == 'Port': @@ -51,17 +49,15 @@ try: ssh_config_file.close() - if ssh_port == '' : - + if ssh_port == '': ssh_port = '22' except: - ssh_port = '22' ssh_port = int(ssh_port) -def firewall_allow(port=None, protocol='TCP', ipv6=False, no_upnp=False): +def firewall_allow(port=None, protocol=['TCP'], ipv6=False, no_upnp=False): """ Allow connection port/protocol @@ -74,7 +70,8 @@ def firewall_allow(port=None, protocol='TCP', ipv6=False, no_upnp=False): """ port = int(port) ipv = "ipv4" - protocols = [protocol] + protocols = protocol + protocol = protocol[0] firewall = firewall_list(raw=True) @@ -100,7 +97,7 @@ def firewall_allow(port=None, protocol='TCP', ipv6=False, no_upnp=False): return firewall_reload() -def firewall_disallow(port=None, protocol='TCP', ipv6=False): +def firewall_disallow(port=None, protocol=['TCP'], ipv6=False): """ Allow connection port/protocol @@ -112,7 +109,8 @@ def firewall_disallow(port=None, protocol='TCP', ipv6=False): """ port = int(port) ipv = "ipv4" - protocols = [protocol] + protocols = protocol + protocol = protocol[0] firewall = firewall_list(raw=True)