Strip off trailing period of a user-provided FQDN in installer

The example text included a trailing dot which isn't actually
allowed in a system hostname (just DNS). Remove the suggestion
to include it and strip off any trailing dot so that the install
can proceed.

Related: https://pagure.io/freeipa/issue/9111

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Rob Crittenden 2022-02-11 13:07:41 -05:00 committed by Florence Blanc-Renaud
parent 8b517e6825
commit b445cff453
8 changed files with 120 additions and 7 deletions

View File

@ -186,7 +186,7 @@ def read_host_name(host_default):
print("Enter the fully qualified domain name of the computer")
print("on which you're setting up server software. Using the form")
print("<hostname>.<domainname>")
print("Example: master.example.com.")
print("Example: master.example.com")
print("")
print("")
if host_default == "":
@ -194,6 +194,9 @@ def read_host_name(host_default):
host_name = user_input("Server host name", host_default, allow_empty=False)
print("")
if host_name.endswith('.'):
host_name = host_name[:-1]
return host_name

View File

@ -1522,6 +1522,18 @@ jobs:
timeout: 3600
topology: *master_1repl
fedora-latest/hostname_validator:
requires: [fedora-latest/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{fedora-latest/build_url}'
test_suite: test_integration/test_installation.py::TestHostnameValidator
template: *ci-master-latest
timeout: 3600
topology: *master_1repl
fedora-latest/automember:
requires: [fedora-latest/build]
priority: 50

View File

@ -1629,6 +1629,19 @@ jobs:
timeout: 3600
topology: *master_1repl
fedora-latest/hostname_validator:
requires: [fedora-latest/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{fedora-latest/build_url}'
selinux_enforcing: True
test_suite: test_integration/test_installation.py::TestHostnameValidator
template: *ci-master-latest
timeout: 3600
topology: *master_1repl
fedora-latest/automember:
requires: [fedora-latest/build]
priority: 50

View File

@ -1629,6 +1629,19 @@ jobs:
timeout: 3600
topology: *master_1repl
testing-fedora/hostname_validator:
requires: [testing-fedora/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{testing-fedora/build_url}'
update_packages: True
test_suite: test_integration/test_installation.py::TestHostnameValidator
template: *testing-master-latest
timeout: 3600
topology: *master_1repl
testing-fedora/automember:
requires: [testing-fedora/build]
priority: 50

View File

@ -1748,6 +1748,20 @@ jobs:
timeout: 3600
topology: *master_1repl
testing-fedora/hostname_validator:
requires: [testing-fedora/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{testing-fedora/build_url}'
update_packages: True
selinux_enforcing: True
test_suite: test_integration/test_installation.py::TestHostnameValidator
template: *testing-master-latest
timeout: 3600
topology: *master_1repl
testing-fedora/automember:
requires: [testing-fedora/build]
priority: 50

View File

@ -1522,6 +1522,18 @@ jobs:
timeout: 3600
topology: *master_1repl
fedora-previous/hostname_validator:
requires: [fedora-previous/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{fedora-previous/build_url}'
test_suite: test_integration/test_installation.py::TestHostnameValidator
template: *ci-master-previous
timeout: 3600
topology: *master_1repl
fedora-previous/automember:
requires: [fedora-previous/build]
priority: 50

View File

@ -1616,6 +1616,19 @@ jobs:
timeout: 3600
topology: *master_1repl
fedora-rawhide/hostname_validator:
requires: [fedora-rawhide/build]
priority: 50
job:
class: RunPytest
args:
build_url: '{fedora-rawhide/build_url}'
update_packages: True
test_suite: test_integration/test_installation.py::TestHostnameValidator
template: *ci-master-frawhide
timeout: 3600
topology: *master_1repl
# fedora-rawhide/nfs:
# requires: [fedora-rawhide/build]
# priority: 50

View File

@ -1997,19 +1997,52 @@ class TestInstallwithSHA384withRSA(IntegrationTest):
class TestHostnameValidator(IntegrationTest):
"""Test installer options/validation"""
"""Test installer hostname validator."""
num_replicas = 0
def test_validate_hostname(self):
def get_args(self, host):
return [
'ipa-server-install',
'-n', host.domain.name,
'-r', host.domain.realm,
'-p', host.config.dirman_password,
'-a', host.config.admin_password,
'--setup-dns',
'--forwarder', host.config.dns_forwarder,
'--auto-reverse',
'--netbios-name', 'EXAMPLE',
]
def test_user_input_hostname(self):
# https://pagure.io/freeipa/issue/9111
# Validate the user-provided hostname
self.master.run_command(['hostname', 'fedora'])
result = tasks.install_master(
self.master, unattended=False,
result = self.master.run_command(
self.get_args(self.master), raiseonerr=False,
stdin_text=self.master.hostname + '\nn\nn\nn\n',
extra_args=('--netbios-name', 'EXAMPLE',),
raiseonerr=False
)
# Scrape the output for the summary which is only displayed
# if the hostname is validated.
hostname = None
for line in result.stdout_text.split('\n'):
print(line)
m = re.match(
r"Hostname:\s+({})".format(self.master.hostname), line
)
if m:
hostname = m.group(1)
break
assert hostname == self.master.hostname
def test_hostname_with_dot(self):
# https://pagure.io/freeipa/issue/9111
# Validate the user-provided hostname
self.master.run_command(['hostname', 'fedora'])
result = self.master.run_command(
self.get_args(self.master), raiseonerr=False,
stdin_text=self.master.hostname + '.\nn\nn\nn\n',
)
# Scrape the output for the summary which is only displayed