mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Raise errors.EnvironmentError if IPA_CONFDIR var is incorrectly used
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
parent
d4916254e9
commit
c2934aaa7e
@ -43,7 +43,7 @@ from ipapython.dn import DN
|
|||||||
from ipalib.base import check_name
|
from ipalib.base import check_name
|
||||||
from ipalib.constants import CONFIG_SECTION
|
from ipalib.constants import CONFIG_SECTION
|
||||||
from ipalib.constants import OVERRIDE_ERROR, SET_ERROR, DEL_ERROR
|
from ipalib.constants import OVERRIDE_ERROR, SET_ERROR, DEL_ERROR
|
||||||
from ipapython.admintool import ScriptError
|
from ipalib import errors
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
unicode = str
|
unicode = str
|
||||||
@ -462,11 +462,17 @@ class Env(object):
|
|||||||
|
|
||||||
# Set confdir:
|
# Set confdir:
|
||||||
self.env_confdir = os.environ.get('IPA_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 'confdir' not in self:
|
||||||
if self.env_confdir is not None:
|
if self.env_confdir is not None:
|
||||||
if (not path.isabs(self.env_confdir)
|
if (not path.isabs(self.env_confdir)
|
||||||
or not path.isdir(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 "
|
"IPA_CONFDIR env var must be an absolute path to an "
|
||||||
"existing directory, got '{}'.".format(
|
"existing directory, got '{}'.".format(
|
||||||
self.env_confdir))
|
self.env_confdir))
|
||||||
|
@ -445,6 +445,13 @@ class RefererError(PublicError):
|
|||||||
format = _('Missing or invalid HTTP Referer, %(referer)s')
|
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
|
# 1000 - 1999: Authentication errors
|
||||||
class AuthenticationError(PublicError):
|
class AuthenticationError(PublicError):
|
||||||
|
@ -717,10 +717,6 @@ class API(ReadOnly):
|
|||||||
if self.env.env_confdir == self.env.confdir:
|
if self.env.env_confdir == self.env.confdir:
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"IPA_CONFDIR env sets confdir to '%s'.", self.env.confdir)
|
"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:
|
for plugin in self.__plugins:
|
||||||
if not self.env.validate_api:
|
if not self.env.validate_api:
|
||||||
|
Loading…
Reference in New Issue
Block a user