Clean up sanityCheckHostname() in network.py (#559626)
Hostnames can start with digits. Removed inStrRange() since
it seemed a little redundant. Left hostname length check at
64 characters, but put a comment reminding me that POSIX
sets this limit to 255, so we should examine this in the
future again.
---
network.py | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/network.py b/network.py
index 0327ef9..0feb8fd 100644
--- a/network.py
+++ b/network.py
@@ -37,26 +37,25 @@ class IPError(Exception):
class IPMissing(Exception):
pass
+ # XXX: POSIX says this limit is 255, but Linux also defines HOST_NAME_MAX
+ # as 64, so I don't know which we should believe. --dcantrell
if len(hostname) > 64:
- return _("Hostname must be 64 or less characters in length.")
-
- if not inStrRange(hostname[0], string.ascii_letters):
- return _("Hostname must start with a valid character in the range "
- "'a-z' or 'A-Z'")
+ return _("Hostname must be 64 or fewer characters in length.")
+
+ validStart = string.ascii_letters + string.digits
+ validAll = validStart + ".-"
+
+ if string.find(validStart, hostname[0]) == -1:
+ return _("Hostname must start with a valid character in the ranges "
+ "'a-z', 'A-Z', or '0-9'")
for i in range(1, len(hostname)):
- if not inStrRange(hostname[i], string.ascii_letters+string.digits+".-"):
- return _("Hostnames can only contain the characters 'a-z', 'A-Z', '-', or '.'")
+ if string.find(validAll, hostname[i]) == -1:
+ return _("Hostnames can only contain the characters 'a-z', 'A-Z', '0-9', '-', or '.'")
return None
--
1.7.1.1
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
08-07-2010, 05:42 AM
Clean up sanityCheckHostname() in network.py (#559626)
From: David Cantrell <dcantrell@redhat.com>
Hostnames can start with digits. Removed inStrRange() since
it seemed a little redundant. Left hostname length check at
64 characters, but put a comment reminding me that POSIX
sets this limit to 255, so we should examine this in the
future again.
---
network.py | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/network.py b/network.py
index 0327ef9..0feb8fd 100644
--- a/network.py
+++ b/network.py
@@ -37,26 +37,25 @@ class IPError(Exception):
class IPMissing(Exception):
pass
+ # XXX: POSIX says this limit is 255, but Linux also defines HOST_NAME_MAX
+ # as 64, so I don't know which we should believe. --dcantrell
if len(hostname) > 64:
- return _("Hostname must be 64 or less characters in length.")
-
- if not inStrRange(hostname[0], string.ascii_letters):
- return _("Hostname must start with a valid character in the range "
- "'a-z' or 'A-Z'")
+ return _("Hostname must be 64 or fewer characters in length.")
+
+ validStart = string.ascii_letters + string.digits
+ validAll = validStart + ".-"
+
+ if string.find(validStart, hostname[0]) == -1:
+ return _("Hostname must start with a valid character in the ranges "
+ "'a-z', 'A-Z', or '0-9'")
for i in range(1, len(hostname)):
- if not inStrRange(hostname[i], string.ascii_letters+string.digits+".-"):
- return _("Hostnames can only contain the characters 'a-z', 'A-Z', '-', or '.'")
+ if string.find(validAll, hostname[i]) == -1:
+ return _("Hostnames can only contain the characters 'a-z', 'A-Z', '0-9', '-', or '.'")
return None
--
1.7.2.1
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
08-07-2010, 05:45 AM
Clean up sanityCheckHostname() in network.py (#559626)
From: David Cantrell <dcantrell@redhat.com>
Hostnames can start with digits. Removed inStrRange() since
it seemed a little redundant. Left hostname length check at
64 characters, but put a comment reminding me that POSIX
sets this limit to 255, so we should examine this in the
future again.
---
network.py | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/network.py b/network.py
index 0327ef9..0feb8fd 100644
--- a/network.py
+++ b/network.py
@@ -37,26 +37,25 @@ class IPError(Exception):
class IPMissing(Exception):
pass
+ # XXX: POSIX says this limit is 255, but Linux also defines HOST_NAME_MAX
+ # as 64, so I don't know which we should believe. --dcantrell
if len(hostname) > 64:
- return _("Hostname must be 64 or less characters in length.")
-
- if not inStrRange(hostname[0], string.ascii_letters):
- return _("Hostname must start with a valid character in the range "
- "'a-z' or 'A-Z'")
+ return _("Hostname must be 64 or fewer characters in length.")
+
+ validStart = string.ascii_letters + string.digits
+ validAll = validStart + ".-"
+
+ if string.find(validStart, hostname[0]) == -1:
+ return _("Hostname must start with a valid character in the ranges "
+ "'a-z', 'A-Z', or '0-9'")
for i in range(1, len(hostname)):
- if not inStrRange(hostname[i], string.ascii_letters+string.digits+".-"):
- return _("Hostnames can only contain the characters 'a-z', 'A-Z', '-', or '.'")
+ if string.find(validAll, hostname[i]) == -1:
+ return _("Hostnames can only contain the characters 'a-z', 'A-Z', '0-9', '-', or '.'")
return None
--
1.7.2.1
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
08-07-2010, 05:45 AM
Clean up sanityCheckHostname() in network.py (#559626)
From: David Cantrell <dcantrell@redhat.com>
Hostnames can start with digits. Removed inStrRange() since
it seemed a little redundant. Left hostname length check at
64 characters, but put a comment reminding me that POSIX
sets this limit to 255, so we should examine this in the
future again.
---
network.py | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/network.py b/network.py
index 0327ef9..0feb8fd 100644
--- a/network.py
+++ b/network.py
@@ -37,26 +37,25 @@ class IPError(Exception):
class IPMissing(Exception):
pass
+ # XXX: POSIX says this limit is 255, but Linux also defines HOST_NAME_MAX
+ # as 64, so I don't know which we should believe. --dcantrell
if len(hostname) > 64:
- return _("Hostname must be 64 or less characters in length.")
-
- if not inStrRange(hostname[0], string.ascii_letters):
- return _("Hostname must start with a valid character in the range "
- "'a-z' or 'A-Z'")
+ return _("Hostname must be 64 or fewer characters in length.")
+
+ validStart = string.ascii_letters + string.digits
+ validAll = validStart + ".-"
+
+ if string.find(validStart, hostname[0]) == -1:
+ return _("Hostname must start with a valid character in the ranges "
+ "'a-z', 'A-Z', or '0-9'")
for i in range(1, len(hostname)):
- if not inStrRange(hostname[i], string.ascii_letters+string.digits+".-"):
- return _("Hostnames can only contain the characters 'a-z', 'A-Z', '-', or '.'")
+ if string.find(validAll, hostname[i]) == -1:
+ return _("Hostnames can only contain the characters 'a-z', 'A-Z', '0-9', '-', or '.'")
return None
--
1.7.2.1
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
08-09-2010, 05:31 PM
"Brian C. Lane"
Clean up sanityCheckHostname() in network.py (#559626)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/06/2010 10:45 PM, dcantrell@redhat.com wrote:
> From: David Cantrell <dcantrell@redhat.com>
>
> Hostnames can start with digits. Removed inStrRange() since
> it seemed a little redundant. Left hostname length check at
> 64 characters, but put a comment reminding me that POSIX
> sets this limit to 255, so we should examine this in the
> future again.
> ---
> network.py | 25 ++++++++++++-------------
> 1 files changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/network.py b/network.py
> index 0327ef9..0feb8fd 100644
> --- a/network.py
> +++ b/network.py
> @@ -37,26 +37,25 @@ class IPError(Exception):
> class IPMissing(Exception):
> pass
>
> -def inStrRange(v, s):
> - if string.find(s, v) == -1:
> - return 0
> - else:
> - return 1
> -
> def sanityCheckHostname(hostname):
> if len(hostname) < 1:
> return None
>
> + # XXX: POSIX says this limit is 255, but Linux also defines HOST_NAME_MAX
> + # as 64, so I don't know which we should believe. --dcantrell
> if len(hostname) > 64:
> - return _("Hostname must be 64 or less characters in length.")
In RHEL6 this has been changed to 255
- --
Brian C. Lane <bcl@redhat.com>
Red Hat / Port Orchard, WA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Remember Lexington Green!
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
08-09-2010, 08:36 PM
David Cantrell
Clean up sanityCheckHostname() in network.py (#559626)
On Mon, 9 Aug 2010, Brian C. Lane wrote:
On 08/06/2010 10:45 PM, dcantrell@redhat.com wrote:
From: David Cantrell <dcantrell@redhat.com>
Hostnames can start with digits. Removed inStrRange() since
it seemed a little redundant. Left hostname length check at
64 characters, but put a comment reminding me that POSIX
sets this limit to 255, so we should examine this in the
future again.
---
network.py | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/network.py b/network.py
index 0327ef9..0feb8fd 100644
--- a/network.py
+++ b/network.py
@@ -37,26 +37,25 @@ class IPError(Exception):
class IPMissing(Exception):
pass
+ # XXX: POSIX says this limit is 255, but Linux also defines HOST_NAME_MAX
+ # as 64, so I don't know which we should believe. --dcantrell
if len(hostname) > 64:
- return _("Hostname must be 64 or less characters in length.")
In RHEL6 this has been changed to 255
New patch:
Clean up sanityCheckHostname() in network.py (#559626)
Hostnames can start with digits and be up to 255 characters in length.
Removed inStrRange() since it seemed a little redundant.
---
network.py | 25 +++++++++++--------------
1 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/network.py b/network.py
index 0327ef9..6036b59 100644
--- a/network.py
+++ b/network.py
@@ -37,26 +37,23 @@ class IPError(Exception):
class IPMissing(Exception):
pass
- if len(hostname) > 64:
- return _("Hostname must be 64 or less characters in length.")
-
- if not inStrRange(hostname[0], string.ascii_letters):
- return _("Hostname must start with a valid character in the range "
- "'a-z' or 'A-Z'")
+ if len(hostname) > 255:
+ return _("Hostname must be 255 or fewer characters in length.")
+
+ validStart = string.ascii_letters + string.digits
+ validAll = validStart + ".-"
+
+ if string.find(validStart, hostname[0]) == -1:
+ return _("Hostname must start with a valid character in the ranges "
+ "'a-z', 'A-Z', or '0-9'")
for i in range(1, len(hostname)):
- if not inStrRange(hostname[i], string.ascii_letters+string.digits+".-"):
- return _("Hostnames can only contain the characters 'a-z', 'A-Z', '-', or '.'")
+ if string.find(validAll, hostname[i]) == -1:
+ return _("Hostnames can only contain the characters 'a-z', 'A-Z', '0-9', '-', or '.'")
return None
--
David Cantrell <dcantrell@redhat.com>
Red Hat / Honolulu, HI
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list