mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
client: Making the configure functions more readable
https://fedorahosted.org/freeipa/ticket/6392 Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
parent
2dedfe5d33
commit
cf1c4e84e7
@ -299,12 +299,7 @@ def configure_nsswitch_database(fstore, database, services, preserve=True,
|
|||||||
|
|
||||||
# Set new services as sources for database
|
# Set new services as sources for database
|
||||||
opts = [
|
opts = [
|
||||||
{
|
conf.setOption(database, new_value),
|
||||||
'name': database,
|
|
||||||
'type': 'option',
|
|
||||||
'action': 'set',
|
|
||||||
'value': new_value
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -329,50 +324,19 @@ def configure_ipa_conf(
|
|||||||
|
|
||||||
# [global]
|
# [global]
|
||||||
defopts = [
|
defopts = [
|
||||||
{
|
ipaconf.setOption('basedn', cli_basedn),
|
||||||
'name': 'basedn',
|
ipaconf.setOption('realm', cli_realm),
|
||||||
'type': 'option',
|
ipaconf.setOption('domain', cli_domain),
|
||||||
'value': cli_basedn
|
ipaconf.setOption('server', cli_server[0]),
|
||||||
},
|
ipaconf.setOption('host', hostname),
|
||||||
{
|
ipaconf.setOption('xmlrpc_uri',
|
||||||
'name': 'realm',
|
'https://{}/ipa/xml'.format(
|
||||||
'type': 'option',
|
ipautil.format_netloc(cli_server[0]))),
|
||||||
'value': cli_realm
|
ipaconf.setOption('enable_ra', 'True')
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'domain',
|
|
||||||
'type': 'option',
|
|
||||||
'value': cli_domain
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'server',
|
|
||||||
'type': 'option',
|
|
||||||
'value': cli_server[0]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'host',
|
|
||||||
'type': 'option',
|
|
||||||
'value': hostname
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'xmlrpc_uri',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'https://%s/ipa/xml' % ipautil.format_netloc(
|
|
||||||
cli_server[0])
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'enable_ra',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'True'
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
opts.extend([
|
opts.extend([
|
||||||
{
|
ipaconf.setSection('global', defopts),
|
||||||
'name': 'global',
|
|
||||||
'type': 'section',
|
|
||||||
'value': defopts
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -408,89 +372,38 @@ def configure_ldap_conf(
|
|||||||
'value': 'File modified by ipa-client-install'
|
'value': 'File modified by ipa-client-install'
|
||||||
},
|
},
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
{
|
|
||||||
'name': 'ldap_version',
|
ldapconf.setOption('ldap_version', '3'),
|
||||||
'type': 'option',
|
ldapconf.setOption('base', cli_basedn),
|
||||||
'value': '3'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'base',
|
|
||||||
'type': 'option',
|
|
||||||
'value': cli_basedn
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
{
|
|
||||||
'name': 'nss_base_passwd',
|
ldapconf.setOption(
|
||||||
'type': 'option',
|
'nss_base_passwd', '{dn}{suffix}'
|
||||||
'value': str(
|
.format(dn=DN(('cn', 'users'), ('cn', 'accounts'), cli_basedn),
|
||||||
DN(('cn', 'users'), ('cn', 'accounts'), cli_basedn)
|
suffix='?sub')),
|
||||||
) + '?sub'
|
ldapconf.setOption(
|
||||||
},
|
'nss_base_group', '{dn}{suffix}'
|
||||||
{
|
.format(dn=DN(('cn', 'groups'), ('cn', 'accounts'), cli_basedn),
|
||||||
'name': 'nss_base_group',
|
suffix='?sub')),
|
||||||
'type': 'option',
|
ldapconf.setOption('nss_schema', 'rfc2307bis'),
|
||||||
'value': str(
|
ldapconf.setOption('nss_map_attribute', 'uniqueMember member'),
|
||||||
DN(('cn', 'groups'), ('cn', 'accounts'), cli_basedn)
|
ldapconf.setOption('nss_initgroups_ignoreusers', 'root,dirsrv'),
|
||||||
) + '?sub'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'nss_schema',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'rfc2307bis'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'nss_map_attribute',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'uniqueMember member'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'nss_initgroups_ignoreusers',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'root,dirsrv'
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
{
|
|
||||||
'name': 'nss_reconnect_maxsleeptime',
|
ldapconf.setOption('nss_reconnect_maxsleeptime', '8'),
|
||||||
'type': 'option',
|
ldapconf.setOption('nss_reconnect_sleeptime', '1'),
|
||||||
'value': '8'
|
ldapconf.setOption('bind_timelimit', '5'),
|
||||||
},
|
ldapconf.setOption('timelimit', '15'),
|
||||||
{
|
|
||||||
'name': 'nss_reconnect_sleeptime',
|
|
||||||
'type': 'option',
|
|
||||||
'value': '1'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'bind_timelimit',
|
|
||||||
'type': 'option',
|
|
||||||
'value': '5'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'timelimit',
|
|
||||||
'type': 'option',
|
|
||||||
'value': '15'
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
]
|
]
|
||||||
if not dnsok or options.force or options.on_master:
|
if not dnsok or options.force or options.on_master:
|
||||||
if options.on_master:
|
if options.on_master:
|
||||||
opts.append({
|
opts.append(ldapconf.setOption('uri', 'ldap://localhost'))
|
||||||
'name': 'uri',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'ldap://localhost'
|
|
||||||
})
|
|
||||||
else:
|
else:
|
||||||
opts.append({
|
opts.append(ldapconf.setOption('uri', 'ldap://{}'.format(
|
||||||
'name': 'uri',
|
ipautil.format_netloc(cli_server[0]))))
|
||||||
'type': 'option',
|
|
||||||
'value': 'ldap://{}'.format(
|
|
||||||
ipautil.format_netloc(cli_server[0]))
|
|
||||||
})
|
|
||||||
else:
|
else:
|
||||||
opts.append({
|
opts.append(ldapconf.setOption('nss_srv_domain', cli_domain))
|
||||||
'name': 'nss_srv_domain',
|
|
||||||
'type': 'option',
|
|
||||||
'value': cli_domain
|
|
||||||
})
|
|
||||||
|
|
||||||
opts.append(IPAChangeConf.EMPTY_LINE)
|
opts.append(IPAChangeConf.EMPTY_LINE)
|
||||||
|
|
||||||
@ -523,57 +436,27 @@ def configure_nslcd_conf(
|
|||||||
'value': 'File modified by ipa-client-install'
|
'value': 'File modified by ipa-client-install'
|
||||||
},
|
},
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
{
|
|
||||||
'name': 'ldap_version',
|
nslcdconf.setOption('ldap_version', '3'),
|
||||||
'type': 'option',
|
nslcdconf.setOption('base', cli_basedn),
|
||||||
'value': '3'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'base',
|
|
||||||
'type': 'option',
|
|
||||||
'value': cli_basedn
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
{
|
|
||||||
'name': 'base passwd',
|
nslcdconf.setOption('base passwd', str(
|
||||||
'type': 'option',
|
DN(('cn', 'users'), ('cn', 'accounts'), cli_basedn))),
|
||||||
'value': str(
|
nslcdconf.setOption('base group', str(
|
||||||
DN(('cn', 'users'), ('cn', 'accounts'), cli_basedn))
|
DN(('cn', 'groups'), ('cn', 'accounts'), cli_basedn))),
|
||||||
},
|
nslcdconf.setOption('timelimit', '15'),
|
||||||
{
|
|
||||||
'name': 'base group',
|
|
||||||
'type': 'option',
|
|
||||||
'value': str(
|
|
||||||
DN(('cn', 'groups'), ('cn', 'accounts'), cli_basedn))
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'timelimit',
|
|
||||||
'type': 'option',
|
|
||||||
'value': '15'
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
]
|
]
|
||||||
|
|
||||||
if not dnsok or options.force or options.on_master:
|
if not dnsok or options.force or options.on_master:
|
||||||
if options.on_master:
|
if options.on_master:
|
||||||
opts.append({
|
opts.append(nslcdconf.setOption('uri', 'ldap://localhost'))
|
||||||
'name': 'uri',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'ldap://localhost'
|
|
||||||
})
|
|
||||||
else:
|
else:
|
||||||
opts.append({
|
opts.append(nslcdconf.setOption('uri', 'ldap://{}'.format(
|
||||||
'name': 'uri',
|
ipautil.format_netloc(cli_server[0]))))
|
||||||
'type': 'option',
|
|
||||||
'value': 'ldap://{}'.format(
|
|
||||||
ipautil.format_netloc(cli_server[0]))
|
|
||||||
})
|
|
||||||
else:
|
else:
|
||||||
opts.append({
|
opts.append(nslcdconf.setOption('uri', 'DNS'))
|
||||||
'name': 'uri',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'DNS'
|
|
||||||
})
|
|
||||||
|
|
||||||
opts.append(IPAChangeConf.EMPTY_LINE)
|
opts.append(IPAChangeConf.EMPTY_LINE)
|
||||||
|
|
||||||
@ -716,12 +599,8 @@ def hardcode_ldap_server(cli_server):
|
|||||||
ldapconf.setOptionAssignment(" ")
|
ldapconf.setOptionAssignment(" ")
|
||||||
|
|
||||||
opts = [
|
opts = [
|
||||||
{
|
ldapconf.setOption('uri', 'ldap://{}'.format(
|
||||||
'name': 'uri',
|
ipautil.format_netloc(cli_server[0]))),
|
||||||
'type': 'option',
|
|
||||||
'action': 'set',
|
|
||||||
'value': 'ldap://{}'.format(ipautil.format_netloc(cli_server[0]))
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE,
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -766,82 +645,39 @@ def configure_krb5_conf(
|
|||||||
'value': paths.SSSD_PUBCONF_KRB5_INCLUDE_D_DIR,
|
'value': paths.SSSD_PUBCONF_KRB5_INCLUDE_D_DIR,
|
||||||
'delim': ' '
|
'delim': ' '
|
||||||
},
|
},
|
||||||
IPAChangeConf.EMPTY_LINE,
|
IPAChangeConf.EMPTY_LINE
|
||||||
])
|
])
|
||||||
|
|
||||||
# [libdefaults]
|
# [libdefaults]
|
||||||
libopts = [{
|
libopts = [
|
||||||
'name': 'default_realm',
|
krbconf.setOption('default_realm', cli_realm)
|
||||||
'type': 'option',
|
]
|
||||||
'value': cli_realm
|
|
||||||
}]
|
|
||||||
|
|
||||||
if not dnsok or not cli_kdc or options.force:
|
if not dnsok or not cli_kdc or options.force:
|
||||||
libopts.extend([
|
libopts.extend([
|
||||||
{
|
krbconf.setOption('dns_lookup_realm', 'false'),
|
||||||
'name': 'dns_lookup_realm',
|
krbconf.setOption('dns_lookup_kdc', 'false')
|
||||||
'type': 'option',
|
|
||||||
'value': 'false'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'dns_lookup_kdc',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'false'
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
else:
|
else:
|
||||||
libopts.extend([
|
libopts.extend([
|
||||||
{
|
krbconf.setOption('dns_lookup_realm', 'true'),
|
||||||
'name': 'dns_lookup_realm',
|
krbconf.setOption('dns_lookup_kdc', 'true')
|
||||||
'type': 'option',
|
|
||||||
'value': 'true'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'dns_lookup_kdc',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'true'
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
|
|
||||||
libopts.extend([
|
libopts.extend([
|
||||||
{
|
krbconf.setOption('rdns', 'false'),
|
||||||
'name': 'rdns',
|
krbconf.setOption('ticket_lifetime', '24h'),
|
||||||
'type': 'option',
|
krbconf.setOption('forwardable', 'true'),
|
||||||
'value': 'false'
|
krbconf.setOption('udp_preference_limit', '0')
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'ticket_lifetime',
|
|
||||||
'type': 'option',
|
|
||||||
'value': '24h'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'forwardable',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'true'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'udp_preference_limit',
|
|
||||||
'type': 'option',
|
|
||||||
'value': '0'
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
|
|
||||||
# Configure KEYRING CCACHE if supported
|
# Configure KEYRING CCACHE if supported
|
||||||
if kernel_keyring.is_persistent_keyring_supported():
|
if kernel_keyring.is_persistent_keyring_supported():
|
||||||
root_logger.debug("Enabling persistent keyring CCACHE")
|
root_logger.debug("Enabling persistent keyring CCACHE")
|
||||||
libopts.append({
|
libopts.append(krbconf.setOption('default_ccache_name',
|
||||||
'name': 'default_ccache_name',
|
'KEYRING:persistent:%{uid}'))
|
||||||
'type': 'option',
|
|
||||||
'value': 'KEYRING:persistent:%{uid}'
|
|
||||||
})
|
|
||||||
|
|
||||||
opts.extend([
|
opts.extend([
|
||||||
{
|
krbconf.setSection('libdefaults', libopts),
|
||||||
'name': 'libdefaults',
|
IPAChangeConf.EMPTY_LINE
|
||||||
'type': 'section',
|
|
||||||
'value': libopts
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
|
||||||
])
|
])
|
||||||
|
|
||||||
# the following are necessary only if DNS discovery does not work
|
# the following are necessary only if DNS discovery does not work
|
||||||
@ -850,96 +686,43 @@ def configure_krb5_conf(
|
|||||||
# [realms]
|
# [realms]
|
||||||
for server in cli_server:
|
for server in cli_server:
|
||||||
kropts.extend([
|
kropts.extend([
|
||||||
{
|
krbconf.setOption('kdc', ipautil.format_netloc(server, 88)),
|
||||||
'name': 'kdc',
|
krbconf.setOption('master_kdc',
|
||||||
'type': 'option',
|
ipautil.format_netloc(server, 88)),
|
||||||
'value': ipautil.format_netloc(server, 88)
|
krbconf.setOption('admin_server',
|
||||||
},
|
ipautil.format_netloc(server, 749)),
|
||||||
{
|
krbconf.setOption('kpasswd_server',
|
||||||
'name': 'master_kdc',
|
ipautil.format_netloc(server, 464))
|
||||||
'type': 'option',
|
|
||||||
'value': ipautil.format_netloc(server, 88)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'admin_server',
|
|
||||||
'type': 'option',
|
|
||||||
'value': ipautil.format_netloc(server, 749)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': 'kpasswd_server',
|
|
||||||
'type': 'option',
|
|
||||||
'value': ipautil.format_netloc(server, 464)
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
|
kropts.append(krbconf.setOption('default_domain', cli_domain))
|
||||||
|
|
||||||
kropts.append({
|
kropts.append(krbconf.setOption('pkinit_anchors', 'FILE: %s' % CACERT))
|
||||||
'name': 'default_domain',
|
|
||||||
'type': 'option',
|
|
||||||
'value': cli_domain
|
|
||||||
})
|
|
||||||
|
|
||||||
kropts.append({
|
|
||||||
'name': 'pkinit_anchors',
|
|
||||||
'type': 'option',
|
|
||||||
'value': 'FILE:{}'.format(CACERT)
|
|
||||||
})
|
|
||||||
|
|
||||||
ropts = [{
|
ropts = [{
|
||||||
'name': cli_realm,
|
'name': cli_realm,
|
||||||
'type': 'subsection',
|
'type': 'subsection',
|
||||||
'value': kropts
|
'value': kropts
|
||||||
}]
|
}]
|
||||||
|
|
||||||
opts.extend([
|
opts.append(krbconf.setSection('realms', ropts))
|
||||||
{
|
opts.append(IPAChangeConf.EMPTY_LINE)
|
||||||
'name': 'realms',
|
|
||||||
'type': 'section',
|
|
||||||
'value': ropts
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
|
||||||
])
|
|
||||||
|
|
||||||
# [domain_realm]
|
# [domain_realm]
|
||||||
dropts = [
|
dropts = [
|
||||||
{
|
krbconf.setOption('.{}'.format(cli_domain), cli_realm),
|
||||||
'name': '.{}'.format(cli_domain),
|
krbconf.setOption(cli_domain, cli_realm),
|
||||||
'type': 'option',
|
krbconf.setOption(client_hostname, cli_realm)
|
||||||
'value': cli_realm
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': cli_domain,
|
|
||||||
'type': 'option',
|
|
||||||
'value': cli_realm
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': client_hostname,
|
|
||||||
'type': 'option',
|
|
||||||
'value': cli_realm
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# add client domain mapping if different from server domain
|
# add client domain mapping if different from server domain
|
||||||
if cli_domain != client_domain:
|
if cli_domain != client_domain:
|
||||||
dropts.extend([
|
dropts.extend([
|
||||||
{
|
krbconf.setOption('.{}'.format(client_domain), cli_realm),
|
||||||
'name': '.{}'.format(client_domain),
|
krbconf.setOption(client_domain, cli_realm)
|
||||||
'type': 'option',
|
|
||||||
'value': cli_realm
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'name': client_domain,
|
|
||||||
'type': 'option',
|
|
||||||
'value': cli_realm
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
|
|
||||||
opts.extend([
|
opts.extend([
|
||||||
{
|
krbconf.setSection('domain_realm', dropts),
|
||||||
'name': 'domain_realm',
|
IPAChangeConf.EMPTY_LINE
|
||||||
'type': 'section',
|
|
||||||
'value': dropts
|
|
||||||
},
|
|
||||||
IPAChangeConf.EMPTY_LINE,
|
|
||||||
])
|
])
|
||||||
|
|
||||||
root_logger.debug("Writing Kerberos configuration to %s:", filename)
|
root_logger.debug("Writing Kerberos configuration to %s:", filename)
|
||||||
|
Loading…
Reference in New Issue
Block a user