ipaclient_test: Use validate_hostname with constants.MAXHOSTNAMELEN

Run validate_hostname to check for valid host name if constants.MAXHOSTNAMELEN
is defined. The call has not been used in older FreeIPA versions.
This commit is contained in:
Thomas Woerner
2019-06-07 17:25:12 +02:00
parent c82867585b
commit 9a53e71de8
2 changed files with 11 additions and 1 deletions

View File

@@ -529,6 +529,14 @@ def main():
"Invalid hostname, '{}' must not be used.".format(hostname),
rval=CLIENT_INSTALL_ERROR)
if hasattr(constants, "MAXHOSTNAMELEN"):
try:
validate_hostname(hostname, maxlen=constants.MAXHOSTNAMELEN)
except ValueError as e:
raise ScriptError(
'invalid hostname: {}'.format(e),
rval=CLIENT_INSTALL_ERROR)
if hasattr(tasks, "is_nosssd_supported"):
# --no-sssd is not supported any more for rhel-based distros
if not tasks.is_nosssd_supported() and not options.sssd: