From 6a56aa6d4987bc4856997351a413c014e14abdd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Thu, 6 Dec 2018 17:29:26 +0100 Subject: [PATCH] ipa-client-automount: use nfs-utils unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - remove nfs-idmapd from units we enable & start as: - it is not used on NFS clients anymore - it is a static unit - remove rpc-gssd as well as it is a static unit - restart nfs-utils and rpc-gssd - manage systemctl-related exceptions during uninstall Fixes: https://pagure.io/freeipa/issue/7780 Fixes: https://pagure.io/freeipa/issue/7781 Signed-off-by: François Cami Reviewed-By: Alexander Bokovoy --- client/ipa-client-automount.in | 55 +++++++++++----------------------- ipaplatform/base/services.py | 3 +- 2 files changed, 20 insertions(+), 38 deletions(-) mode change 100644 => 100755 client/ipa-client-automount.in diff --git a/client/ipa-client-automount.in b/client/ipa-client-automount.in old mode 100644 new mode 100755 index 7348e2077..15926bd02 --- a/client/ipa-client-automount.in +++ b/client/ipa-client-automount.in @@ -314,23 +314,21 @@ def uninstall(fstore, statestore): print('Unable to restore SSSD configuration: %s' % str(e)) logger.debug('Unable to restore SSSD configuration: %s', str(e)) + + # rpcidmapd and rpcgssd are static units now if statestore.has_state('rpcidmapd'): - enabled = statestore.restore_state('rpcidmapd', 'enabled') - running = statestore.restore_state('rpcidmapd', 'running') - rpcidmapd = services.knownservices.rpcidmapd - if not enabled: - rpcidmapd.disable() - if not running: - rpcidmapd.stop() + statestore.delete_state('rpcidmapd','enabled') + statestore.delete_state('rpcidmapd','running') if statestore.has_state('rpcgssd'): - enabled = statestore.restore_state('rpcgssd', 'enabled') - running = statestore.restore_state('rpcgssd', 'running') - rpcgssd = services.knownservices.rpcgssd - if not enabled: - rpcgssd.disable() - if not running: - rpcgssd.stop() + statestore.delete_state('rpcgssd','enabled') + statestore.delete_state('rpcgssd','running') + nfsutils = services.knownservices['nfs-utils'] + try: + nfsutils.restart() + except Exception as e: + logger.error("Failed to restart nfs client services (%s)" % str(e)) + return 1 return 0 def configure_nfs(fstore, statestore): @@ -365,35 +363,18 @@ def configure_nfs(fstore, statestore): print("Configured %s" % paths.IDMAPD_CONF) - rpcidmapd = services.knownservices.rpcidmapd - statestore.backup_state('rpcidmapd', 'enabled', rpcidmapd.is_enabled()) - statestore.backup_state('rpcidmapd', 'running', rpcidmapd.is_running()) - try: - rpcidmapd.restart() - print("Started %s" % rpcidmapd.service_name) - except Exception as e: - logger.error("%s failed to restart: %s", rpcidmapd.service_name, e) - try: - rpcidmapd.enable() - except Exception as e: - print("Failed to configure automatic startup of the %s daemon" % (rpcidmapd.service_name)) - logger.error("Failed to enable automatic startup of the %s daemon: %s", - rpcidmapd.service_name, str(e)) - rpcgssd = services.knownservices.rpcgssd - statestore.backup_state('rpcgssd', 'enabled', rpcgssd.is_enabled()) - statestore.backup_state('rpcgssd', 'running', rpcgssd.is_running()) try: rpcgssd.restart() - print("Started %s" % rpcgssd.service_name) except Exception as e: - logger.error("%s failed to restart: %s", rpcgssd.service_name, e) + logger.error("Failed to restart rpc-gssd (%s)" % str(e)) + return 1 + nfsutils = services.knownservices['nfs-utils'] try: - rpcgssd.enable() + nfsutils.restart() except Exception as e: - print("Failed to configure automatic startup of the %s daemon" % (rpcgssd.service_name)) - logger.error("Failed to enable automatic startup of the %s daemon: %s", - rpcgssd.service_name, str(e)) + logger.error("Failed to restart nfs client services (%s)" % str(e)) + return 1 def main(): try: diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py index 20d6d5083..c2cfdbeb1 100644 --- a/ipaplatform/base/services.py +++ b/ipaplatform/base/services.py @@ -53,7 +53,8 @@ wellknownservices = ['certmonger', 'dirsrv', 'httpd', 'ipa', 'krb5kdc', 'dbus', 'nslcd', 'nscd', 'ntpd', 'portmap', 'rpcbind', 'kadmin', 'sshd', 'autofs', 'rpcgssd', 'rpcidmapd', 'pki_tomcatd', 'chronyd', 'domainname', - 'named', 'ods_enforcerd', 'ods_signerd', 'gssproxy'] + 'named', 'ods_enforcerd', 'ods_signerd', 'gssproxy', + 'nfs-utils'] # The common ports for these services. This is used to wait for the # service to become available.