summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2016-12-02 13:16:13 +0100
committerJan Cholasta <jcholast@redhat.com>2016-12-02 15:05:33 +0100
commitc2934aaa7eacb8390209a38029145b1c240d864c (patch)
tree299f4f0ba4f5f82c2b037681745db9908f793beb /ipalib
parentd4916254e995be1118ab8dbce5b60091305f97fe (diff)
downloadfreeipa-c2934aaa7eacb8390209a38029145b1c240d864c.tar.gz
freeipa-c2934aaa7eacb8390209a38029145b1c240d864c.tar.xz
freeipa-c2934aaa7eacb8390209a38029145b1c240d864c.zip
Raise errors.EnvironmentError if IPA_CONFDIR var is incorrectly used
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/config.py10
-rw-r--r--ipalib/errors.py7
-rw-r--r--ipalib/plugable.py4
3 files changed, 15 insertions, 6 deletions
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: