summaryrefslogtreecommitdiffstats
path: root/ipapython/platform/fedora16.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipapython/platform/fedora16.py')
-rw-r--r--ipapython/platform/fedora16.py77
1 files changed, 50 insertions, 27 deletions
diff --git a/ipapython/platform/fedora16.py b/ipapython/platform/fedora16.py
index 2d0ede99a..830771d83 100644
--- a/ipapython/platform/fedora16.py
+++ b/ipapython/platform/fedora16.py
@@ -22,25 +22,36 @@ from ipapython.platform import base, redhat, systemd
import os
# All what we allow exporting directly from this module
-# Everything else is made available through these symbols when they directly imported into ipapython.services:
-# authconfig -- class reference for platform-specific implementation of authconfig(8)
-# service -- class reference for platform-specific implementation of a PlatformService class
-# knownservices -- factory instance to access named services IPA cares about, names are ipapython.services.wellknownservices
-# backup_and_replace_hostname -- platform-specific way to set hostname and make it persistent over reboots
-# restore_context -- platform-sepcific way to restore security context, if applicable
-__all__ = ['authconfig', 'service', 'knownservices', 'backup_and_replace_hostname', 'restore_context']
+# Everything else is made available through these symbols when they are
+# directly imported into ipapython.services:
+# authconfig -- class reference for platform-specific implementation of
+# authconfig(8)
+# service -- class reference for platform-specific implementation of a
+# PlatformService class
+# knownservices -- factory instance to access named services IPA cares about,
+# names are ipapython.services.wellknownservices
+# backup_and_replace_hostname -- platform-specific way to set hostname and
+# make it persistent over reboots
+# restore_context -- platform-sepcific way to restore security context, if
+# applicable
+# check_selinux_status -- platform-specific way to see if SELinux is enabled
+# and restorecon is installed.
+__all__ = ['authconfig', 'service', 'knownservices', 'backup_and_replace_hostname', 'restore_context', 'check_selinux_status']
# For beginning just remap names to add .service
# As more services will migrate to systemd, unit names will deviate and
# mapping will be kept in this dictionary
system_units = dict(map(lambda x: (x, "%s.service" % (x)), base.wellknownservices))
-# Rewrite dirsrv and pki-cad services as they support instances via separate service generator
-# To make this working, one needs to have both foo@.service and foo.target -- the latter is used
-# when request should be coming for all instances (like stop). systemd, unfortunately, does not allow
-# to request action for all service instances at once if only foo@.service unit is available.
-# To add more, if any of those services need to be started/stopped automagically, one needs to manually
-# create symlinks in /etc/systemd/system/foo.target.wants/ (look into systemd.py's enable() code).
+# Rewrite dirsrv and pki-cad services as they support instances via separate
+# service generator. To make this working, one needs to have both foo@.servic
+# and foo.target -- the latter is used when request should be coming for
+# all instances (like stop). systemd, unfortunately, does not allow one
+# to request action for all service instances at once if only foo@.service
+# unit is available. To add more, if any of those services need to be
+# started/stopped automagically, one needs to manually create symlinks in
+# /etc/systemd/system/foo.target.wants/ (look into systemd.py's enable()
+# code).
system_units['dirsrv'] = 'dirsrv@.service'
# Our directory server instance for PKI is dirsrv@PKI-IPA.service
system_units['pkids'] = 'dirsrv@PKI-IPA.service'
@@ -53,30 +64,35 @@ class Fedora16Service(systemd.SystemdService):
service_name = system_units[service_name]
else:
if len(service_name.split('.')) == 1:
- # if service_name does not have a dot, it is not foo.service and not a foo.target
- # Thus, not correct service name for systemd, default to foo.service style then
+ # if service_name does not have a dot, it is not foo.service
+ # and not a foo.target. Thus, not correct service name for
+ # systemd, default to foo.service style then
service_name = "%s.service" % (service_name)
super(Fedora16Service, self).__init__(service_name)
# Special handling of directory server service
#
-# We need to explicitly enable instances to install proper symlinks as dirsrv.target.wants/
-# dependencies. Standard systemd service class does it on #enable() method call. Unfortunately,
-# ipa-server-install does not do explicit dirsrv.enable() because the service startup is handled by ipactl.
+# We need to explicitly enable instances to install proper symlinks as
+# dirsrv.target.wants/ dependencies. Standard systemd service class does it
+# on enable() method call. Unfortunately, ipa-server-install does not do
+# explicit dirsrv.enable() because the service startup is handled by ipactl.
#
-# If we wouldn't do this, our instances will not be started as systemd would not have any clue
-# about instances (PKI-IPA and the domain we serve) at all. Thus, hook into dirsrv.restart().
+# If we wouldn't do this, our instances will not be started as systemd would
+# not have any clue about instances (PKI-IPA and the domain we serve) at all.
+# Thus, hook into dirsrv.restart().
class Fedora16DirectoryService(Fedora16Service):
def enable(self, instance_name=""):
super(Fedora16DirectoryService, self).enable(instance_name)
dirsrv_systemd = "/etc/sysconfig/dirsrv.systemd"
if os.path.exists(dirsrv_systemd):
# We need to enable LimitNOFILE=8192 in the dirsrv@.service
- # Since 389-ds-base-1.2.10-0.8.a7 the configuration of the service parameters is performed
- # via /etc/sysconfig/dirsrv.systemd file which is imported by systemd into dirsrv@.service unit
+ # Since 389-ds-base-1.2.10-0.8.a7 the configuration of the
+ # service parameters is performed via
+ # /etc/sysconfig/dirsrv.systemd file which is imported by systemd
+ # into dirsrv@.service unit
replacevars = {'LimitNOFILE':'8192'}
ipautil.inifile_replace_variables(dirsrv_systemd, 'service', replacevars=replacevars)
- redhat.restore_context(dirsrv_systemd)
+ restore_context(dirsrv_systemd)
ipautil.run(["/bin/systemctl", "--system", "daemon-reload"],raiseonerr=False)
def restart(self, instance_name="", capture_output=True):
@@ -93,8 +109,9 @@ class Fedora16DirectoryService(Fedora16Service):
super(Fedora16DirectoryService, self).restart(instance_name, capture_output=capture_output)
# Enforce restart of IPA services when we do enable it
-# This gets around the fact that after ipa-server-install systemd thinks ipa.service is not yet started
-# but all services were actually started already.
+# This gets around the fact that after ipa-server-install systemd thinks
+# ipa.service is not yet started but all services were actually started
+# already.
class Fedora16IPAService(Fedora16Service):
def enable(self, instance_name=""):
super(Fedora16IPAService, self).enable(instance_name)
@@ -104,7 +121,8 @@ class Fedora16SSHService(Fedora16Service):
def get_config_dir(self, instance_name=""):
return '/etc/ssh'
-# Redirect directory server service through special sub-class due to its special handling of instances
+# Redirect directory server service through special sub-class due to its
+# special handling of instances
def f16_service(name):
if name == 'dirsrv':
return Fedora16DirectoryService(name)
@@ -122,8 +140,13 @@ class Fedora16Services(base.KnownServices):
# Call base class constructor. This will lock services to read-only
super(Fedora16Services, self).__init__(services)
+def restore_context(filepath, restorecon='/usr/sbin/restorecon'):
+ return redhat.restore_context(filepath, restorecon)
+
+def check_selinux_status(restorecon='/usr/sbin/restorecon'):
+ return redhat.check_selinux_status(restorecon)
+
authconfig = redhat.authconfig
service = f16_service
knownservices = Fedora16Services()
-restore_context = redhat.restore_context
backup_and_replace_hostname = redhat.backup_and_replace_hostname