diff --git a/pykolab/setup/__init__.py b/pykolab/setup/__init__.py --- a/pykolab/setup/__init__.py +++ b/pykolab/setup/__init__.py @@ -21,6 +21,7 @@ import sys import pykolab +from pykolab.translate import _ log = pykolab.getLogger('pykolab.setup') conf = pykolab.getConf() @@ -40,6 +41,36 @@ to_execute.append(sys.argv[arg_num].replace('-','_')) def run(self): + if os.path.isfile('/sys/fs/selinux/enforce'): + if os.access('/sys/fs/selinux/enforce', os.R_OK): + # Set a gentle default because strictly speaking, + # setup won't fail (run-time does) + enforce = "0" + + with open('/sys/fs/selinux/enforce', 'r') as f: + enforce = f.read() + + if enforce.strip() == "1": + log.fatal( + _("SELinux currently enforcing. Read " + \ + "https://git.kolab.org/u/1") + ) + + sys.exit(1) + + if os.path.isfile('/etc/selinux/config'): + if os.access('/etc/selinux/config', os.R_OK): + with open('/etc/selinux/config', 'r') as f: + for line in f: + if line.strip() == "SELINUX=enforcing": + log.fatal( + _("SELinux configured to enforce a " + \ + "policy on startup. Read " + \ + "https://git.kolab.org/u/1") + ) + + sys.exit(1) + components.execute('_'.join(to_execute)) if os.path.exists('/tmp/kolab-setup-my.cnf'): diff --git a/setup-kolab.py b/setup-kolab.py --- a/setup-kolab.py +++ b/setup-kolab.py @@ -29,6 +29,7 @@ import pykolab from pykolab.setup import Setup +from pykolab.translate import _ try: from pykolab.constants import *