ipa-client: Set NIS domain name in the installer

Provides two new options for the ipa-client-install:
    --nisdomain: specifies the NIS domain name
    --no_nisdomain: flag to aviod setting the NIS domain name

In case no --nisdomain is specified and --no_nisdomain flag was
not set, the IPA domain is used.

Manual pages updated.

http://fedorahosted.org/freeipa/ticket/3202

Reviewed-By: Jakub Hrozek <jhrozek@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Tomas Babej
2014-05-09 13:57:04 +03:00
committed by Alexander Bokovoy
parent 23302645aa
commit d90eb46cce
4 changed files with 75 additions and 1 deletions
+65
View File
@@ -126,6 +126,11 @@ def parse_options():
basic_group.add_option("", "--force-ntpd", dest="force_ntpd",
action="store_true", default=False,
help="Stop and disable any time&date synchronization services besides ntpd")
basic_group.add_option("--nisdomain", dest="nisdomain",
help="NIS domain name")
basic_group.add_option("--no-nisdomain", action="store_true", default=False,
help="do not configure NIS domain name",
dest="no_nisdomain")
basic_group.add_option("--ssh-trust-dns", dest="trust_sshfp", default=False, action="store_true",
help="configure OpenSSH client to trust DNS SSHFP records")
basic_group.add_option("--no-ssh", dest="conf_ssh", default=True, action="store_false",
@@ -195,6 +200,9 @@ def parse_options():
if options.firefox_dir and not options.configure_firefox:
parser.error("--firefox-dir cannot be used without --configure-firefox option")
if options.no_nisdomain and options.nisdomain:
parser.error("--no-nisdomain cannot be used together with --nisdomain")
return safe_opts, options
def logging_setup(options):
@@ -595,6 +603,7 @@ def uninstall(options, env):
fstore.restore_all_files()
ipautil.restore_hostname(statestore)
unconfigure_nisdomain()
nscd = ipaservices.knownservices.nscd
nslcd = ipaservices.knownservices.nslcd
@@ -1351,6 +1360,59 @@ def configure_automount(options):
root_logger.info(stdout)
def configure_nisdomain(options, domain):
domain = options.nisdomain or domain
root_logger.info('Configuring %s as NIS domain.' % domain)
nis_domain_name = ''
# First backup the old NIS domain name
if os.path.exists('/usr/bin/nisdomainname'):
try:
nis_domain_name, _, _ = ipautil.run(['/usr/bin/nisdomainname'])
except CalledProcessError, e:
pass
statestore.backup_state('network', 'nisdomain', nis_domain_name)
# Backup the state of the domainname service
statestore.backup_state("domainname", "enabled",
ipaservices.knownservices.domainname.is_enabled())
# Set the new NIS domain name
set_nisdomain(domain)
# Enable and start the domainname service
ipaservices.knownservices.domainname.enable()
ipaservices.knownservices.domainname.start()
def unconfigure_nisdomain():
# Set the nisdomain permanent and current nisdomain configuration as it was
if statestore.has_state('network'):
old_nisdomain = statestore.restore_state('network','nisdomain') or ''
if old_nisdomain:
root_logger.info('Restoring %s as NIS domain.' % old_nisdomain)
else:
root_logger.info('Unconfiguring the NIS domain.')
set_nisdomain(old_nisdomain)
# Restore the configuration of the domainname service
enabled = statestore.restore_state('domainname', 'enabled')
if not enabled:
ipaservices.knownservices.domainname.disable()
def set_nisdomain(nisdomain):
# Let authconfig setup the permanent configuration
auth_config = ipaservices.authconfig()
auth_config.add_parameter("nisdomain", nisdomain)
auth_config.add_option("update")
auth_config.execute()
def resolve_ipaddress(server):
""" Connect to the server's LDAP port in order to determine what ip
address this machine uses as "public" ip (relative to the server).
@@ -2695,6 +2757,9 @@ def install(options, env, fstore, statestore):
if options.configure_firefox:
configure_firefox(options, statestore, cli_domain)
if not options.no_nisdomain:
configure_nisdomain(options=options, domain=cli_domain)
root_logger.info('Client configuration complete.')
return 0
+6
View File
@@ -125,6 +125,12 @@ Do not configure or enable NTP.
\fB\-\-force\-ntpd\fR
Stop and disable any time&date synchronization services besides ntpd.
.TP
\fB\-\-nisdomain\fR=\fINIS_DOMAIN\fR
Set the NIS domain name as specified. By default, this is set to the IPA domain name.
.TP
\fB\-\-no\-nisdomain\fR
Do not configure NIS domain name.
.TP
\fB\-\-ssh\-trust\-dns\fR
Configure OpenSSH client to trust DNS SSHFP records.
.TP
+2 -1
View File
@@ -27,7 +27,8 @@ import os
wellknownservices = ['certmonger', 'dirsrv', 'httpd', 'ipa', 'krb5kdc',
'messagebus', 'nslcd', 'nscd', 'ntpd', 'portmap',
'rpcbind', 'kadmin', 'sshd', 'autofs', 'rpcgssd',
'rpcidmapd', 'pki_tomcatd', 'pki_cad', 'chronyd']
'rpcidmapd', 'pki_tomcatd', 'pki_cad', 'chronyd',
'domainname']
# System may support more time&date services. FreeIPA supports ntpd only, other
# services will be disabled during IPA installation
+2
View File
@@ -54,6 +54,8 @@ system_units['pki_cad'] = system_units['pki-cad']
system_units['pki-tomcatd'] = 'pki-tomcatd@pki-tomcat.service'
system_units['pki_tomcatd'] = system_units['pki-tomcatd']
system_units['ipa-otpd'] = 'ipa-otpd.socket'
# Service that sets domainname on Fedora is called fedora-domainname.service
system_units['domainname'] = 'fedora-domainname.service'
class Fedora16Service(systemd.SystemdService):
def __init__(self, service_name):