diff --git a/ipalib/config.py b/ipalib/config.py index 9d877828f..20591dbf0 100644 --- a/ipalib/config.py +++ b/ipalib/config.py @@ -43,7 +43,7 @@ from ipapython.dn import DN from ipalib.base import check_name from ipalib.constants import CONFIG_SECTION from ipalib.constants import OVERRIDE_ERROR, SET_ERROR, DEL_ERROR -from ipapython.admintool import ScriptError +from ipalib import errors if six.PY3: unicode = str @@ -462,11 +462,17 @@ class Env(object): # Set confdir: self.env_confdir = os.environ.get('IPA_CONFDIR') + + if 'confdir' in self and self.env_confdir is not None: + raise errors.EnvironmentError( + "IPA_CONFDIR env cannot be set because explicit confdir " + "is used") + if 'confdir' not in self: if self.env_confdir is not None: if (not path.isabs(self.env_confdir) or not path.isdir(self.env_confdir)): - raise ScriptError( + raise errors.EnvironmentError( "IPA_CONFDIR env var must be an absolute path to an " "existing directory, got '{}'.".format( self.env_confdir)) diff --git a/ipalib/errors.py b/ipalib/errors.py index d1fe5f0ac..88707ac31 100644 --- a/ipalib/errors.py +++ b/ipalib/errors.py @@ -445,6 +445,13 @@ class RefererError(PublicError): format = _('Missing or invalid HTTP Referer, %(referer)s') +class EnvironmentError(PublicError): + """ + **912** Raised when a command is called with invalid environment settings + """ + + errno = 912 + ############################################################################## # 1000 - 1999: Authentication errors class AuthenticationError(PublicError): diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 142b3e60d..1a9164fc6 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -717,10 +717,6 @@ class API(ReadOnly): if self.env.env_confdir == self.env.confdir: self.log.info( "IPA_CONFDIR env sets confdir to '%s'.", self.env.confdir) - else: - self.log.warn( - "IPA_CONFDIR env is overridden by an explicit confdir " - "argument.") for plugin in self.__plugins: if not self.env.validate_api: