Raise error when running ipa-adtrust-install with empty netbios--name

When running ipa-adtrust-install, a netbios-name option must be specified.
Currently if an invalid netbios name in form of empty string is specified, the
installation proceeds, but changes the invalid value to a netbios name
determined from domain name without any notification.

Fixing this so that any attempt to supply empty string as netbios name fails
with error in case of unattended installation, or to request input of valid
netbios name from command line during normal installation.

https://fedorahosted.org/freeipa/ticket/6120

Reviewed-By: Tomas Krizek <tkrizek@redhat.com>
This commit is contained in:
Lenka Doudova 2016-08-25 13:39:49 +02:00 committed by Martin Basti
parent 5812af84a4
commit 2c7b7b3acc
2 changed files with 6 additions and 6 deletions

View File

@ -93,7 +93,7 @@ def parse_options():
def netbios_name_error(name):
print("\nIllegal NetBIOS name [%s].\n" % name)
print("Up to 15 characters and only uppercase ASCII letters, digits "
"and dashes are allowed.")
"and dashes are allowed. Empty string is not allowed.")
def read_netbios_name(netbios_default):
netbios_name = ""
@ -193,8 +193,11 @@ def set_and_check_netbios_name(netbios_name, unattended):
# all possible cases should be covered above
raise Exception('Unexpected state while checking NetBIOS domain name')
if unattended and netbios_name is None and gen_netbios_name:
netbios_name = gen_netbios_name
if not adtrustinstance.check_netbios_name(netbios_name):
if unattended and not gen_netbios_name:
if unattended:
netbios_name_error(netbios_name)
sys.exit("Aborting installation.")
else:
@ -205,9 +208,6 @@ def set_and_check_netbios_name(netbios_name, unattended):
if not unattended and not netbios_name:
netbios_name = read_netbios_name(gen_netbios_name)
if unattended and not netbios_name and gen_netbios_name:
netbios_name = gen_netbios_name
return (netbios_name, reset_netbios_name)
def ensure_admin_kinit(admin_name, admin_password):

View File

@ -94,7 +94,7 @@ def ipa_smb_conf_exists():
def check_netbios_name(name):
# Empty NetBIOS name is not allowed
if name is None:
if not name:
return False
# NetBIOS names may not be longer than 15 allowed characters