mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
@@ -48,7 +48,8 @@ WSGISocketPrefix /run/httpd/wsgi
|
|||||||
|
|
||||||
# Configure mod_wsgi handler for /ipa
|
# Configure mod_wsgi handler for /ipa
|
||||||
WSGIDaemonProcess ipa processes=2 threads=1 maximum-requests=500 \
|
WSGIDaemonProcess ipa processes=2 threads=1 maximum-requests=500 \
|
||||||
user=ipaapi group=ipaapi display-name=%{GROUP} socket-timeout=2147483647
|
user=ipaapi group=ipaapi display-name=%{GROUP} socket-timeout=2147483647 \
|
||||||
|
lang=C.UTF-8 locale=C.UTF-8
|
||||||
WSGIImportScript /usr/share/ipa/wsgi.py process-group=ipa application-group=ipa
|
WSGIImportScript /usr/share/ipa/wsgi.py process-group=ipa application-group=ipa
|
||||||
WSGIScriptAlias /ipa /usr/share/ipa/wsgi.py
|
WSGIScriptAlias /ipa /usr/share/ipa/wsgi.py
|
||||||
WSGIScriptReloading Off
|
WSGIScriptReloading Off
|
||||||
|
|||||||
@@ -4,4 +4,5 @@
|
|||||||
Environment=KRB5CCNAME=$KRB5CC_HTTPD
|
Environment=KRB5CCNAME=$KRB5CC_HTTPD
|
||||||
Environment=GSS_USE_PROXY=yes
|
Environment=GSS_USE_PROXY=yes
|
||||||
Environment=KDCPROXY_CONFIG=$KDCPROXY_CONFIG
|
Environment=KDCPROXY_CONFIG=$KDCPROXY_CONFIG
|
||||||
|
Environment=LC_ALL=C.UTF-8
|
||||||
ExecStartPre=$IPA_HTTPD_KDCPROXY
|
ExecStartPre=$IPA_HTTPD_KDCPROXY
|
||||||
|
|||||||
@@ -452,6 +452,18 @@ class EnvironmentError(PublicError):
|
|||||||
|
|
||||||
errno = 912
|
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
|
# 1000 - 1999: Authentication errors
|
||||||
class AuthenticationError(PublicError):
|
class AuthenticationError(PublicError):
|
||||||
|
|||||||
@@ -485,6 +485,11 @@ class API(ReadOnly):
|
|||||||
handler.setFormatter(ipa_log_manager.Formatter(LOGGING_FORMAT_STDERR))
|
handler.setFormatter(ipa_log_manager.Formatter(LOGGING_FORMAT_STDERR))
|
||||||
root_logger.addHandler(handler)
|
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:
|
# Add file handler:
|
||||||
if self.env.mode in ('dummy', 'unit_test'):
|
if self.env.mode in ('dummy', 'unit_test'):
|
||||||
return # But not if in unit-test mode
|
return # But not if in unit-test mode
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import shlex
|
|
||||||
import sys
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import os
|
||||||
|
import shlex
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
import nose
|
import nose
|
||||||
import six
|
import six
|
||||||
@@ -15,6 +17,8 @@ if six.PY3:
|
|||||||
|
|
||||||
TEST_ZONE = u'zoneadd.%(domain)s' % api.env
|
TEST_ZONE = u'zoneadd.%(domain)s' % api.env
|
||||||
|
|
||||||
|
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
BASE_DIR = os.path.abspath(os.path.join(HERE, os.pardir, os.pardir))
|
||||||
|
|
||||||
@pytest.mark.tier0
|
@pytest.mark.tier0
|
||||||
class TestCLIParsing(object):
|
class TestCLIParsing(object):
|
||||||
@@ -305,3 +309,22 @@ class TestCLIParsing(object):
|
|||||||
|
|
||||||
if not adtrust_is_enabled:
|
if not adtrust_is_enabled:
|
||||||
mockldap.del_entry(adtrust_dn)
|
mockldap.del_entry(adtrust_dn)
|
||||||
|
|
||||||
|
|
||||||
|
def test_cli_fsencoding():
|
||||||
|
# https://pagure.io/freeipa/issue/5887
|
||||||
|
env = {
|
||||||
|
key: value for key, value in os.environ.items()
|
||||||
|
if not key.startswith(('LC_', 'LANG'))
|
||||||
|
}
|
||||||
|
env['LC_ALL'] = 'C'
|
||||||
|
env['PYTHONPATH'] = BASE_DIR
|
||||||
|
p = subprocess.Popen(
|
||||||
|
[sys.executable, '-m', 'ipaclient', 'help'],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
env=env,
|
||||||
|
)
|
||||||
|
out, err = p.communicate()
|
||||||
|
assert p.returncode > 0, (out, err)
|
||||||
|
assert b'System encoding must be UTF-8' in err, (out, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user