diff options
author | bfox <bfox> | 2001-01-24 01:34:33 +0000 |
---|---|---|
committer | bfox <bfox> | 2001-01-24 01:34:33 +0000 |
commit | 41a603ad1682ac504c19d6a3b203ac54d586e5ad (patch) | |
tree | c5e19934cdc86cfe6c5a16b12cb2dcf90e2e63a5 /textw | |
parent | a00b6bd4c4800817722496e0f4cc8475b90d9dc0 (diff) | |
download | anaconda-41a603ad1682ac504c19d6a3b203ac54d586e5ad.tar.gz anaconda-41a603ad1682ac504c19d6a3b203ac54d586e5ad.tar.xz anaconda-41a603ad1682ac504c19d6a3b203ac54d586e5ad.zip |
Added sanity checking code for firewall ports.
Diffstat (limited to 'textw')
-rw-r--r-- | textw/firewall_text.py | 101 |
1 files changed, 62 insertions, 39 deletions
diff --git a/textw/firewall_text.py b/textw/firewall_text.py index 943b8c68d..bf731e002 100644 --- a/textw/firewall_text.py +++ b/textw/firewall_text.py @@ -137,11 +137,70 @@ class FirewallWindow: poplevel.add (popbb, 0, 4, (0, 0, 0, 0), growx = 1) poplevel.add (bigGrid, 0, 1, (0, 0, 0, 0), anchorLeft = 1) + result2 = poplevel.run() - screen.popWindow() +# screen.popWindow() + rc2 = popbb.buttonPressed(result2) + + +# rc2 = "" + if rc2 == "ok": + + #- Do some sanity checking on port list + portstring = string.strip(self.other.value()) + portlist = "" + bad_token_found = 0 + bad_token = "" + if portstring != "": + tokens = string.split(portstring, ',') + for token in tokens: + try: + if string.index(token,':'): #- if there's a colon in the token, it's valid + parts = string.split(token, ':') + if len(parts) > 2: #- We've found more than one colon. Break loop and raise an error. + bad_token_found = 1 + bad_token = token + else: + if parts[1] == 'tcp' or parts[1] == 'udp': #-upd and tcp are the only valid protocols + if portlist == "": + portlist = token + else: + portlist = portlist + ',' + token + else: #- Found a protocol other than tcp or udp. Break loop + bad_token_found = 1 + bad_token = token + pass + except: + if token != "": + if portlist == "": + portlist = token + ":tcp" + else: + portlist = portlist + ',' + token + ':tcp' + else: + pass + + done = 0 + if bad_token_found == 1: + pass + ButtonChoiceWindow(screen, _("Invalid Choice"), + _("Warning: %s is not a valid port." %token), + buttons = [ _("OK") ], width = 40) + screen.popWindow() + else: + todo.firewall.portlist = portlist + screen.popWindow() + + + +# print todo.firewall.portlist +# import time +# time.sleep(3) + +# break if rc == "ok" or result == "F12": - break + + break screen.popWindow() @@ -164,43 +223,7 @@ class FirewallWindow: else: todo.firewall.policy = 1 - #- Do some sanity checking on port list - portstring = string.strip(self.other.value()) - portlist = "" - bad_token_found = 0 - bad_token = "" - if portstring != "": - tokens = string.split(portstring, ',') - for token in tokens: - try: - if string.index(token,':'): #- if there's a colon in the token, it's valid - parts = string.split(token, ':') - if len(parts) > 2: #- We've found more than one colon. Break loop and raise an error. - bad_token_found = 1 - bad_token = token - else: - if parts[1] == 'tcp' or parts[1] == 'udp': #-upd and tcp are the only valid protocols - if portlist == "": - portlist = token - else: - portlist = portlist + ',' + token - else: #- Found a protocol other than tcp or udp. Break loop - bad_token_found = 1 - bad_token = token - pass - except: - if token != "": - if portlist == "": - portlist = token + ":tcp" - else: - portlist = portlist + ',' + token + ':tcp' - else: - pass - todo.firewall.portlist = portlist - -# print todo.firewall.portlist -# import time -# time.sleep(3) + return INSTALL_OK |