mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-07-29 15:55:47 -05:00
Prevent installation with single label domains
Adds validation to prevent user to install ipa with single label domain. https://pagure.io/freeipa/issue/7207 Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
committed by
Michal Reznik
parent
f4a208311a
commit
905ab93c95
@@ -129,6 +129,10 @@ class ServiceInstallInterface(common.Installable,
|
||||
cli_names='--realm',
|
||||
)
|
||||
|
||||
@realm_name.validator
|
||||
def realm_name(self, value):
|
||||
validate_domain_name(value, entity="realm")
|
||||
|
||||
host_name = knob(
|
||||
str, None,
|
||||
description="The hostname of this machine (FQDN). If specified, the "
|
||||
|
||||
+8
-1
@@ -388,12 +388,19 @@ def validate_dns_label(dns_label, allow_underscore=False, allow_slash=False):
|
||||
% dict(chars=chars, chars2=chars2))
|
||||
|
||||
|
||||
def validate_domain_name(domain_name, allow_underscore=False, allow_slash=False):
|
||||
def validate_domain_name(
|
||||
domain_name, allow_underscore=False,
|
||||
allow_slash=False, entity='domain'
|
||||
):
|
||||
if domain_name.endswith('.'):
|
||||
domain_name = domain_name[:-1]
|
||||
|
||||
domain_name = domain_name.split(".")
|
||||
|
||||
if len(domain_name) < 2:
|
||||
raise ValueError(_(
|
||||
'single label {}s are not supported'.format(entity)))
|
||||
|
||||
# apply DNS name validator to every name part
|
||||
for label in domain_name:
|
||||
validate_dns_label(label, allow_underscore, allow_slash)
|
||||
|
||||
Reference in New Issue
Block a user