summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorChristian Heimes <cheimes@redhat.com>2017-11-17 11:42:33 +0100
committerChristian Heimes <cheimes@redhat.com>2017-11-21 16:13:28 +0100
commite1bd827bbf56970ddd02ec174bf2317b64e75514 (patch)
treef3fb9f250d862dd6cd5e11005a34dcb80c13cc81 /ipalib
parentba037a3551feb835b4e0880c4ba19d68214a1b96 (diff)
downloadfreeipa-e1bd827bbf56970ddd02ec174bf2317b64e75514.tar.gz
freeipa-e1bd827bbf56970ddd02ec174bf2317b64e75514.tar.xz
freeipa-e1bd827bbf56970ddd02ec174bf2317b64e75514.zip
Require UTF-8 fs encoding
http://blog.dscpl.com.au/2014/09/setting-lang-and-lcall-when-using.html https://pagure.io/freeipa/issue/5887 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/errors.py12
-rw-r--r--ipalib/plugable.py5
2 files changed, 17 insertions, 0 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index fb7fb4e2a..3a40fa28d 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -452,6 +452,18 @@ class EnvironmentError(PublicError):
errno = 912
+
+class SystemEncodingError(PublicError):
+ """
+ **913** Raised when system encoding is not UTF-8
+ """
+
+ errno = 913
+ format = _(
+ "System encoding must be UTF-8, '%(encoding)s' is not supported. "
+ "Set LC_ALL=\"C.UTF-8\", or LC_ALL=\"\" and LC_CTYPE=\"C.UTF-8\"."
+ )
+
##############################################################################
# 1000 - 1999: Authentication errors
class AuthenticationError(PublicError):
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 66a200ea3..b1fba368d 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -485,6 +485,11 @@ class API(ReadOnly):
handler.setFormatter(ipa_log_manager.Formatter(LOGGING_FORMAT_STDERR))
root_logger.addHandler(handler)
+ # check after logging is set up but before we create files.
+ fse = sys.getfilesystemencoding()
+ if fse.lower() not in {'utf-8', 'utf8'}:
+ raise errors.SystemEncodingError(encoding=fse)
+
# Add file handler:
if self.env.mode in ('dummy', 'unit_test'):
return # But not if in unit-test mode