diff options
author | Ana Krivokapic <akrivoka@redhat.com> | 2013-11-07 17:18:32 +0100 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2014-01-14 09:28:39 +0100 |
commit | 367c1301857f475baa1ed58c06ca0379d42847d5 (patch) | |
tree | e29ea81f1f2400a59b921ba440447d30afa5246e /ipa-client | |
parent | f7128b9c03eadb9593be9b781cf5c9a34b9e10bc (diff) | |
download | freeipa-367c1301857f475baa1ed58c06ca0379d42847d5.tar.gz freeipa-367c1301857f475baa1ed58c06ca0379d42847d5.tar.xz freeipa-367c1301857f475baa1ed58c06ca0379d42847d5.zip |
Make sure state of services is preserved after client uninstall
IPA client installation did not preserve the status of nscd and nslcd services
correctly. E.g. nscd would be started after uninstallation, even though it
wasn't running before client installation. Make sure the state of services is
saved before installation and correctly restored after uninstallation.
https://fedorahosted.org/freeipa/ticket/3790
Diffstat (limited to 'ipa-client')
-rwxr-xr-x | ipa-client/ipa-install/ipa-client-install | 81 |
1 files changed, 47 insertions, 34 deletions
diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install index d29f550c2..0d6037bd1 100755 --- a/ipa-client/ipa-install/ipa-client-install +++ b/ipa-client/ipa-install/ipa-client-install @@ -247,6 +247,38 @@ def get_cert_path(cert_path): return None + +def save_state(service): + enabled = service.is_enabled() + running = service.is_running() + + if enabled or running: + statestore.backup_state(service.service_name, 'enabled', enabled) + statestore.backup_state(service.service_name, 'running', running) + + +def restore_state(service): + enabled = statestore.restore_state(service.service_name, 'enabled') + running = statestore.restore_state(service.service_name, 'running') + + if enabled: + try: + service.enable() + except Exception: + root_logger.warning( + "Failed to configure automatic startup of the %s daemon", + service.service_name + ) + if running: + try: + service.start() + except Exception: + root_logger.warning( + "Failed to restart the %s daemon", + service.service_name + ) + + # Checks whether nss_ldap or nss-pam-ldapd is installed. If anyone of mandatory files was found returns True and list of all files found. def nssldap_exists(): files_to_check = [{'function':'configure_ldap_conf', 'mandatory':['/etc/ldap.conf','/etc/nss_ldap.conf','/etc/libnss-ldap.conf'], 'optional':['/etc/pam_ldap.conf']}, @@ -565,42 +597,17 @@ def uninstall(options, env): ipautil.restore_hostname(statestore) nscd = ipaservices.knownservices.nscd - if nscd.is_installed(): - try: - nscd.restart() - except Exception: - root_logger.warning( - "Failed to restart the %s daemon", nscd.service_name) - - try: - nscd.enable() - except Exception: - root_logger.warning( - "Failed to configure automatic startup of the %s daemon", - nscd.service_name) - else: - # this is optional service, just log - root_logger.info("%s daemon is not installed, skip configuration", - nscd.service_name) - nslcd = ipaservices.knownservices.nslcd - if nslcd.is_installed(): - try: - nslcd.stop() - except Exception: - root_logger.warning( - "Failed to stop the %s daemon", nslcd.service_name) - try: - nslcd.disable() - except Exception: - root_logger.warning( - "Failed to disable automatic startup of the %s daemon", - nslcd.service_name) - else: - # this is optional service, just log - root_logger.info("%s daemon is not installed, skip configuration", - nslcd.service_name) + for service in (nscd, nslcd): + if service.is_installed(): + restore_state(service) + else: + # this is an optional service, just log + root_logger.info( + "%s daemon is not installed, skip configuration", + service.service_name + ) ntp_configured = statestore.has_state('ntp') if ntp_configured: @@ -2524,6 +2531,8 @@ def install(options, env, fstore, statestore): #Name Server Caching Daemon. Disable for SSSD, use otherwise (if installed) nscd = ipaservices.knownservices.nscd if nscd.is_installed(): + save_state(nscd) + try: if options.sssd: nscd_service_action = 'stop' @@ -2561,6 +2570,10 @@ def install(options, env, fstore, statestore): root_logger.info("%s daemon is not installed, skip configuration", nscd.service_name) + nslcd = ipaservices.knownservices.nslcd + if nscd.is_installed(): + save_state(nslcd) + retcode, conf, filename = (0, None, None) if not options.no_ac: |