diff options
author | Chris Lumens <clumens@redhat.com> | 2006-06-08 14:33:38 +0000 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2006-06-08 14:33:38 +0000 |
commit | 44ac0b508e092e35e047d734eb9dff485d791fda (patch) | |
tree | 11c38e9626ed3b30e8fc9f7016f070c1137db196 /network.py | |
parent | 6549f4a4c12cc27e30927bb52b0ab50c39d9f365 (diff) | |
download | anaconda-44ac0b508e092e35e047d734eb9dff485d791fda.tar.gz anaconda-44ac0b508e092e35e047d734eb9dff485d791fda.tar.xz anaconda-44ac0b508e092e35e047d734eb9dff485d791fda.zip |
A better validation check that takes IPv6 into account.
Diffstat (limited to 'network.py')
-rw-r--r-- | network.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/network.py b/network.py index c386e6b9a..a2f48f76c 100644 --- a/network.py +++ b/network.py @@ -21,7 +21,6 @@ import isys import iutil import socket import os -import re import kudzu import rhpl from flags import flags @@ -86,13 +85,20 @@ def anyUsingDHCP(devices): # sanity check an IP string. def sanityCheckIPString(ip_string): - ip_re = re.compile('^([0-2]?[0-9]?[0-9])\\.([0-2]?[0-9]?[0-9])\\.([0-2]?[0-9]?[0-9])\\.([0-2]?[0-9]?[0-9])$') - if ip_string.strip() == "": - raise IPMissing, _("IP Address is missing.") + raise IPMissing, _("IP Address is missing.") + + if ip_string.find(':') == -1: + family = socket.AF_INET + errstr = _("IP Addresses must contain four numbers between 0 and 255, separated by periods.") + else: + family = socket.AF_INET6 + errstr = _("'%s' is not a valid IPv6 address.") % ip_string - if not ip_re.match(ip_string): - raise IPError, _("IP Addresses must contain four numbers between 0 and 255, separated by periods.") + try: + socket.inet_pton(family, ip_string) + except socket.error: + raise IPError, errstr def hasActiveNetDev(): # try to load /tmp/netinfo and see if we can sniff out network info |