Skip to content

Commit

Permalink
Improve PKI subsystem detection
Browse files Browse the repository at this point in the history
The dogtaginstance.is_installed() method currently relies on
the presence of the directory /var/lib/pki/pki-tomcat/{ca|kra},
even if it is empty.
An unwanted consequence is ipa-server-upgrade wrongly assuming the KRA
is installed and crashing when trying to upgrade a not-installed
component.

The fix relies on the command "pki-server subsystem-show {ca|kra}" to
detect if a subsystem is installed. The command does not require PKI
to be running (hence can be called anytime) and is delivered by
the pki-server package which is already required by ipa server pkg.

Fixes: https://pagure.io/freeipa/issue/8596
  • Loading branch information
flo-renaud committed Nov 26, 2020
1 parent 0da6a57 commit 968a7f5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ipaserver/install/dogtaginstance.py
Expand Up @@ -177,8 +177,13 @@ def is_installed(self):
Returns True/False
"""
return os.path.exists(os.path.join(
paths.VAR_LIB_PKI_TOMCAT_DIR, self.subsystem.lower()))
try:
ipautil.run(
['pki-server', 'subsystem-show', self.subsystem.lower()])
# if the command is successful, the subsystem is installed
return True
except ipautil.CalledProcessError:
return False

def spawn_instance(self, cfg_file, nolog_list=()):
"""
Expand Down

0 comments on commit 968a7f5

Please sign in to comment.