diff --git a/ipalib/constants.py b/ipalib/constants.py index 2aeafac7a..fb5fd95ff 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -23,6 +23,7 @@ All constants centralised in one file. """ import os +import string from ipaplatform.constants import constants as _constants from ipapython.dn import DN @@ -368,3 +369,5 @@ KRA_TRACKING_REQS = { 'transportCert cert-pki-kra': 'caTransportCert', 'storageCert cert-pki-kra': 'caStorageCert', } + +ALLOWED_NETBIOS_CHARS = string.ascii_uppercase + string.digits + '-' diff --git a/ipaserver/install/adtrustinstance.py b/ipaserver/install/adtrustinstance.py index b7cd8f7d8..96a47ec0b 100644 --- a/ipaserver/install/adtrustinstance.py +++ b/ipaserver/install/adtrustinstance.py @@ -25,7 +25,6 @@ import errno import ldap import tempfile import uuid -import string import struct import re import socket @@ -36,7 +35,8 @@ from ipaserver.install import service from ipaserver.install import installutils from ipaserver.install.replication import wait_for_task from ipalib import errors, api -from ipalib.constants import SUBID_RANGE_START +from ipalib.constants import SUBID_RANGE_START, ALLOWED_NETBIOS_CHARS + from ipalib.util import normalize_zone from ipapython.dn import DN from ipapython import ipachangeconf @@ -54,8 +54,6 @@ if six.PY3: logger = logging.getLogger(__name__) -ALLOWED_NETBIOS_CHARS = string.ascii_uppercase + string.digits + '-' - UPGRADE_ERROR = """ Entry %(dn)s does not exist. This means upgrade from IPA 2.x to 3.x did not went well and required S4U2Proxy diff --git a/ipatests/test_integration/test_caless.py b/ipatests/test_integration/test_caless.py index 16dfbb320..4481845da 100644 --- a/ipatests/test_integration/test_caless.py +++ b/ipatests/test_integration/test_caless.py @@ -60,6 +60,7 @@ def get_install_stdin(cert_passwords=()): '', # Server host name (has default) ] lines.extend(cert_passwords) # Enter foo.p12 unlock password + lines.extend('IPA') # NetBios name lines += [ 'no', # configure chrony with NTP server or pool address? 'yes', # Continue with these values? diff --git a/ipatests/test_integration/test_installation.py b/ipatests/test_integration/test_installation.py index e3c41eaa1..3a44f5ed8 100644 --- a/ipatests/test_integration/test_installation.py +++ b/ipatests/test_integration/test_installation.py @@ -22,6 +22,7 @@ from cryptography import x509 as crypto_x509 from ipalib import x509 from ipalib.constants import DOMAIN_LEVEL_0, KRA_TRACKING_REQS from ipalib.constants import IPA_CA_RECORD +from ipalib.constants import ALLOWED_NETBIOS_CHARS from ipalib.sysrestore import SYSRESTORE_STATEFILE, SYSRESTORE_INDEXFILE from ipapython.dn import DN from ipaplatform.constants import constants @@ -69,6 +70,17 @@ def server_cleanup(request): tasks.uninstall_master(host) +def create_netbios_name(host): + """ + Create a NetBIOS name based on the provided host + """ + netbios = ''.join( + c for c in host.domain.name.split('.')[0].upper() \ + if c in ALLOWED_NETBIOS_CHARS + )[:15] + return netbios + + class InstallTestBase1(IntegrationTest): num_replicas = 3 @@ -1171,6 +1183,8 @@ class TestInstallMaster(IntegrationTest): hosts = self.master.get_file_contents(paths.HOSTS, encoding='utf-8') new_hosts = hosts.replace(original_hostname, new_hostname) self.master.put_file_contents(paths.HOSTS, new_hosts) + netbios = create_netbios_name(self.master) + try: cmd = ['ipa-server-install', '--hostname', new_hostname] with self.master.spawn_expect(cmd) as e: @@ -1193,6 +1207,8 @@ class TestInstallMaster(IntegrationTest): e.sendline(self.master.config.admin_password) e.expect_exact('Password (confirm): ') e.sendline(self.master.config.admin_password) + e.expect_exact('NetBIOS domain name [{}]: '.format(netbios)) + e.sendline(netbios) e.expect_exact('Do you want to configure chrony with ' 'NTP server or pool address? [no]: ') e.sendline('no') @@ -1367,6 +1383,7 @@ class TestInstallMasterDNS(IntegrationTest): https://pagure.io/freeipa/issue/2575 """ cmd = ['ipa-server-install'] + netbios = create_netbios_name(self.master) with self.master.spawn_expect(cmd) as e: e.expect_exact('Do you want to configure integrated ' 'DNS (BIND)? [no]: ') @@ -1398,6 +1415,8 @@ class TestInstallMasterDNS(IntegrationTest): e.expect_exact('Do you want to search for missing reverse ' 'zones? [yes]: ') e.sendline('no') # irrelevant for this test + e.expect_exact('NetBIOS domain name [{}]: '.format(netbios)) + e.sendline(netbios) e.expect_exact('Do you want to configure chrony with NTP ' 'server or pool address? [no]: ') e.sendline('no') # irrelevant for this test diff --git a/ipatests/test_integration/test_ntp_options.py b/ipatests/test_integration/test_ntp_options.py index 27d35043e..efd950991 100644 --- a/ipatests/test_integration/test_ntp_options.py +++ b/ipatests/test_integration/test_ntp_options.py @@ -260,6 +260,8 @@ class TestNTPoptions(IntegrationTest): "No\n" # Server host name [hostname]: "\n" + # Enter the NetBIOS name for the IPA domain + "IPA\n" # Do you want to configure chrony with NTP server # or pool address? [no]: "Yes\n" @@ -372,6 +374,7 @@ class TestNTPoptions(IntegrationTest): server_input = ( "\n" + "\n" + "IPA\n" "No\n" "Yes" )