Hello, This patch addresses ticket https://fedorahosted.org/freeipa/ticket/3790.
-- Regards, Ana Krivokapic Associate Software Engineer FreeIPA team Red Hat Inc.
From ca950b2f6efe9c73288818667bfd618f4a2fd689 Mon Sep 17 00:00:00 2001 From: Ana Krivokapic <[email protected]> Date: Thu, 7 Nov 2013 17:18:32 +0100 Subject: [PATCH] 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 --- ipa-client/ipa-install/ipa-client-install | 81 ++++++++++++++++++------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/ipa-client/ipa-install/ipa-client-install b/ipa-client/ipa-install/ipa-client-install index 1f66ae5d635d98ba45df13d92ca7982068d94752..dd5b8933b4eabc0d99fb5e40677d1b42dd5ca527 100755 --- a/ipa-client/ipa-install/ipa-client-install +++ b/ipa-client/ipa-install/ipa-client-install @@ -237,6 +237,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']}, @@ -555,42 +587,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: @@ -2415,6 +2422,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' @@ -2452,6 +2461,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: -- 1.8.3.1
_______________________________________________ Freeipa-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/freeipa-devel
