Skip to content

Commit

Permalink
Merge pull request #3049 from xqrustc2020/master
Browse files Browse the repository at this point in the history
Use Linux HOST_NAME_MAX hostname length limit
  • Loading branch information
rvykydal committed Feb 15, 2021
2 parents 8aa3962 + 078ef68 commit b29d9a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pyanaconda/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def is_valid_hostname(hostname, local=False):
if not hostname:
return (False, _("Host name cannot be None or an empty string."))

if len(hostname) > 255:
return (False, _("Host name must be 255 or fewer characters in length."))
if len(hostname) > 64:
return (False, _("Host name must be 64 or fewer characters in length."))

if local and hostname[-1] == ".":
return (False, _("Local host name must not end with period '.'."))
Expand Down
6 changes: 3 additions & 3 deletions tests/nosetests/pyanaconda_tests/network_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def is_valid_hostname_test(self):
self.assertTrue(network.is_valid_hostname("h"*63)[0])
self.assertFalse(network.is_valid_hostname("h"*64)[0])

# length < 256
self.assertTrue(network.is_valid_hostname("section." * 31+"section")[0])
self.assertFalse(network.is_valid_hostname("section." * 31+"sectionx")[0])
# length < 65
self.assertTrue(network.is_valid_hostname("section." * 7+"sectionx")[0])
self.assertFalse(network.is_valid_hostname("section." * 7+"sectionxx")[0])

self.assertFalse(network.is_valid_hostname(
"section.must.be..nonempty.")[0])
Expand Down

0 comments on commit b29d9a6

Please sign in to comment.