diff --git a/ipalib/cli.py b/ipalib/cli.py index 40dbc6316fe..7b2af485d94 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -1454,7 +1454,7 @@ def run(api): (_options, argv) = api.bootstrap_with_global_options(context='cli') try: - check_client_configuration() + check_client_configuration(env=api.env) except ScriptError as e: sys.exit(e) diff --git a/ipalib/util.py b/ipalib/util.py index 68857baec78..8551bd0e82a 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -1122,15 +1122,16 @@ def ensure_krbcanonicalname_set(ldap, entry_attrs): entry_attrs.update(old_entry) -def check_client_configuration(): +def check_client_configuration(env=None): """ Check if IPA client is configured on the system. Hardcode return code to avoid recursive imports """ - if (not os.path.isfile(paths.IPA_DEFAULT_CONF) or + if ((env is not None and not os.path.isfile(env.conf_default)) or + (not os.path.isfile(paths.IPA_DEFAULT_CONF) or not os.path.isdir(paths.IPA_CLIENT_SYSRESTORE) or - not os.listdir(paths.IPA_CLIENT_SYSRESTORE)): + not os.listdir(paths.IPA_CLIENT_SYSRESTORE))): raise ScriptError('IPA client is not configured on this system', 2) # CLIENT_NOT_CONFIGURED