diff --git a/pykolab/setup/__init__.py b/pykolab/setup/__init__.py --- a/pykolab/setup/__init__.py +++ b/pykolab/setup/__init__.py @@ -40,6 +40,25 @@ 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.error(_("SELinux currently enforcing. Read https://docs.kolab.org/installation-guide/preparing-the-system.html#selinux")) + + 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.error(_("SELinux configured to enforce a policy on startup. Read https://docs.kolab.org/installation-guide/preparing-the-system.html#selinux")) + components.execute('_'.join(to_execute)) if os.path.exists('/tmp/kolab-setup-my.cnf'):