diff --git a/ipaclient/install/client.py b/ipaclient/install/client.py index 36280df8c..793bf6ec7 100644 --- a/ipaclient/install/client.py +++ b/ipaclient/install/client.py @@ -305,10 +305,7 @@ def configure_nsswitch_database(fstore, database, services, preserve=True, 'action': 'set', 'value': new_value }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ] conf.changeConf(paths.NSSWITCH_CONF, opts) @@ -327,10 +324,7 @@ def configure_ipa_conf( 'type': 'comment', 'value': 'File modified by ipa-client-install' }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ] # [global] @@ -379,10 +373,7 @@ def configure_ipa_conf( 'type': 'section', 'value': defopts }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ]) target_fname = paths.IPA_DEFAULT_CONF @@ -416,10 +407,7 @@ def configure_ldap_conf( 'type': 'comment', 'value': 'File modified by ipa-client-install' }, - { - 'name': 'empty', - 'type': 'empty' - }, + IPAChangeConf.EMPTY_LINE, { 'name': 'ldap_version', 'type': 'option', @@ -430,10 +418,7 @@ def configure_ldap_conf( 'type': 'option', 'value': cli_basedn }, - { - 'name': 'empty', - 'type': 'empty' - }, + IPAChangeConf.EMPTY_LINE, { 'name': 'nss_base_passwd', 'type': 'option', @@ -463,10 +448,7 @@ def configure_ldap_conf( 'type': 'option', 'value': 'root,dirsrv' }, - { - 'name': 'empty', - 'type': 'empty' - }, + IPAChangeConf.EMPTY_LINE, { 'name': 'nss_reconnect_maxsleeptime', 'type': 'option', @@ -487,10 +469,7 @@ def configure_ldap_conf( 'type': 'option', 'value': '15' }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ] if not dnsok or options.force or options.on_master: if options.on_master: @@ -513,10 +492,7 @@ def configure_ldap_conf( 'value': cli_domain }) - opts.append({ - 'name': 'empty', - 'type': 'empty' - }) + opts.append(IPAChangeConf.EMPTY_LINE) # Depending on the release and distribution this may exist in any # number of different file names, update what we find @@ -546,10 +522,7 @@ def configure_nslcd_conf( 'type': 'comment', 'value': 'File modified by ipa-client-install' }, - { - 'name': 'empty', - 'type': 'empty' - }, + IPAChangeConf.EMPTY_LINE, { 'name': 'ldap_version', 'type': 'option', @@ -560,10 +533,7 @@ def configure_nslcd_conf( 'type': 'option', 'value': cli_basedn }, - { - 'name': 'empty', - 'type': 'empty' - }, + IPAChangeConf.EMPTY_LINE, { 'name': 'base passwd', 'type': 'option', @@ -581,10 +551,7 @@ def configure_nslcd_conf( 'type': 'option', 'value': '15' }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ] if not dnsok or options.force or options.on_master: @@ -608,10 +575,7 @@ def configure_nslcd_conf( 'value': 'DNS' }) - opts.append({ - 'name': 'empty', - 'type': 'empty' - }) + opts.append(IPAChangeConf.EMPTY_LINE) for filename in files: try: @@ -653,10 +617,7 @@ def configure_openldap_conf(fstore, cli_basedn, cli_server): 'type': 'comment', 'value': ' File modified by ipa-client-install' }, - { - 'name': 'empty', - 'type': 'empty' - }, + IPAChangeConf.EMPTY_LINE, { 'name': 'comment', 'type': 'comment', @@ -698,14 +659,8 @@ def configure_openldap_conf(fstore, cli_basedn, cli_server): 'type': 'comment', 'value': ' corresponding lines generated by IPA.' }, - { - 'name': 'empty', - 'type': 'empty' - }, - { - 'name': 'empty', - 'type': 'empty' - }, + IPAChangeConf.EMPTY_LINE, + IPAChangeConf.EMPTY_LINE, { 'action': 'addifnotset', 'name': 'URI', @@ -767,10 +722,7 @@ def hardcode_ldap_server(cli_server): 'action': 'set', 'value': 'ldap://{}'.format(ipautil.format_netloc(cli_server[0])) }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ] # Errors raised by this should be caught by the caller @@ -796,10 +748,7 @@ def configure_krb5_conf( 'type': 'comment', 'value': 'File modified by ipa-client-install' }, - { - 'name': 'empty', - 'type': 'empty' - }, + IPAChangeConf.EMPTY_LINE, { 'name': 'includedir', 'type': 'option', @@ -817,10 +766,7 @@ def configure_krb5_conf( 'value': paths.SSSD_PUBCONF_KRB5_INCLUDE_D_DIR, 'delim': ' ' }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ]) # [libdefaults] @@ -895,10 +841,7 @@ def configure_krb5_conf( 'type': 'section', 'value': libopts }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ]) # the following are necessary only if DNS discovery does not work @@ -953,10 +896,7 @@ def configure_krb5_conf( 'type': 'section', 'value': ropts }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ]) # [domain_realm] @@ -999,10 +939,7 @@ def configure_krb5_conf( 'type': 'section', 'value': dropts }, - { - 'name': 'empty', - 'type': 'empty' - } + IPAChangeConf.EMPTY_LINE, ]) root_logger.debug("Writing Kerberos configuration to %s:", filename) diff --git a/ipaclient/ipachangeconf.py b/ipaclient/ipachangeconf.py index b7d8ffc33..1bcfe37b7 100644 --- a/ipaclient/ipachangeconf.py +++ b/ipaclient/ipachangeconf.py @@ -50,6 +50,11 @@ def openLocked(filename, perms): #TODO: add a comment all but provided options as a section option class IPAChangeConf(object): + EMPTY_LINE = { + 'name': 'empty', + 'type': 'empty' + } + def __init__(self, name): self.progname = name self.indent = ("", "", "")