From f2d3f916808fbfcf2ea35c6aa7a9eeca1ed5f492 Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Mon, 23 Jan 2012 10:01:41 -0500 Subject: Add SSH service to platform-specific services. Add method for getting configuration directory path of a service, so that a different SSH configuration directory can be specified on different platforms. https://fedorahosted.org/freeipa/ticket/754 --- ipapython/platform/base.py | 8 ++++++-- ipapython/platform/fedora16.py | 6 ++++++ ipapython/platform/redhat.py | 13 +++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'ipapython') diff --git a/ipapython/platform/base.py b/ipapython/platform/base.py index 99189a10..d177cc82 100644 --- a/ipapython/platform/base.py +++ b/ipapython/platform/base.py @@ -21,8 +21,9 @@ from ipalib.plugable import MagicDict # Canonical names of services as IPA wants to see them. As we need to have *some* naming, # set them as in Red Hat distributions. Actual implementation should make them available # through knownservices. and take care of remapping internally, if needed -wellknownservices = ['certmonger', 'dirsrv', 'httpd', 'ipa', 'krb5kdc', 'messagebus', - 'nslcd', 'nscd', 'ntpd', 'portmap', 'rpcbind', 'kadmin'] +wellknownservices = ['certmonger', 'dirsrv', 'httpd', 'ipa', 'krb5kdc', + 'messagebus', 'nslcd', 'nscd', 'ntpd', 'portmap', + 'rpcbind', 'kadmin', 'sshd'] class AuthConfig(object): """ @@ -141,6 +142,9 @@ class PlatformService(object): def remove(self, instance_name=""): return + def get_config_dir(self, instance_name=""): + return + class KnownServices(MagicDict): """ KnownServices is an abstract class factory that should give out instances of well-known diff --git a/ipapython/platform/fedora16.py b/ipapython/platform/fedora16.py index 369a1778..2d0ede99 100644 --- a/ipapython/platform/fedora16.py +++ b/ipapython/platform/fedora16.py @@ -100,12 +100,18 @@ class Fedora16IPAService(Fedora16Service): super(Fedora16IPAService, self).enable(instance_name) self.restart(instance_name) +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 def f16_service(name): if name == 'dirsrv': return Fedora16DirectoryService(name) if name == 'ipa': return Fedora16IPAService(name) + if name == 'sshd': + return Fedora16SSHService(name) return Fedora16Service(name) class Fedora16Services(base.KnownServices): diff --git a/ipapython/platform/redhat.py b/ipapython/platform/redhat.py index d99a9174..aee8bcc3 100644 --- a/ipapython/platform/redhat.py +++ b/ipapython/platform/redhat.py @@ -82,6 +82,10 @@ class RedHatService(base.PlatformService): def remove(self, instance_name=""): ipautil.run(["/sbin/chkconfig", "--del", self.service_name]) +class RedHatSSHService(RedHatService): + def get_config_dir(self, instance_name=""): + return '/etc/ssh' + class RedHatAuthConfig(base.AuthConfig): """ AuthConfig class implements system-independent interface to configure @@ -109,16 +113,21 @@ class RedHatAuthConfig(base.AuthConfig): args = self.__build_args() ipautil.run(["/usr/sbin/authconfig"]+args) +def redhat_service(name): + if name == 'sshd': + return RedHatSSHService(name) + return RedHatService(name) + class RedHatServices(base.KnownServices): def __init__(self): services = dict() for s in base.wellknownservices: - services[s] = RedHatService(s) + services[s] = redhat_service(s) # Call base class constructor. This will lock services to read-only super(RedHatServices, self).__init__(services) authconfig = RedHatAuthConfig -service = RedHatService +service = redhat_service knownservices = RedHatServices() def restore_context(filepath): -- cgit