ipa-client-install: enable and start oddjobd if mkhomedir

Since the switch to authselect, the service oddjobd is not
automatically enabled when ipa client is installed with
--mkhomedir.
The fix makes sure that the service is enabled/started, and
stores the pre-install state in sysrestore.state, in order
to revert to the pre-install state when uninstall is called

Fixes:
https://pagure.io/freeipa/issue/7604

Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Florence Blanc-Renaud 2018-06-27 17:56:48 +02:00 committed by Christian Heimes
parent d622be295a
commit a39f656340

View File

@ -2969,6 +2969,20 @@ def _install(options):
statestore=statestore,
sudo=options.conf_sudo
)
# if mkhomedir, make sure oddjobd is enabled and started
if options.mkhomedir:
oddjobd = services.service('oddjobd', api)
running = oddjobd.is_running()
enabled = oddjobd.is_enabled()
statestore.backup_state('oddjobd', 'running', running)
statestore.backup_state('oddjobd', 'enabled', enabled)
try:
if not enabled:
oddjobd.enable()
if not running:
oddjobd.start()
except Exception as e:
logger.critical("Unable to start oddjobd: %s", str(e))
logger.info("%s enabled", "SSSD" if options.sssd else "LDAP")
@ -3213,6 +3227,20 @@ def uninstall(options):
logger.error(
"Failed to remove Kerberos service principals: %s", str(e))
# Restore oddjobd to its original state
oddjobd = services.service('oddjobd', api)
if not statestore.restore_state('oddjobd', 'running'):
try:
oddjobd.stop()
except Exception:
pass
if not statestore.restore_state('oddjobd', 'enabled'):
try:
oddjobd.disable()
except Exception:
pass
logger.info("Disabling client Kerberos and LDAP configurations")
was_sssd_installed = False
was_sshd_configured = False