From c861ce5a1634b43b04c3d38d49d5b3e4e599b7d7 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 29 Apr 2024 16:35:00 -0400 Subject: [PATCH] Add SELinux module checking to hsm_validator Don't blow up if the expected module is not installed but warn about it. Hopefully users will actually read the output and/or the installation log. This is done by looking for strings in the path. Not great but it's at least something. Related: https://pagure.io/freeipa/issue/9273 Signed-off-by: Rob Crittenden Reviewed-By: Florence Blanc-Renaud --- ipaserver/install/ca.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ipaserver/install/ca.py b/ipaserver/install/ca.py index 56b060f55..d1d103a6d 100644 --- a/ipaserver/install/ca.py +++ b/ipaserver/install/ca.py @@ -246,6 +246,23 @@ def hsm_validator(token_name, token_library, token_password): raise ValueError( "Validating HSM password failed: %s" % result.error_output ) + # validate that the appropriate SELinux module is installed + # Only warn in case the expected paths don't match. + if 'nfast' in token_library: + module = 'ipa-selinux-nfast' + elif 'luna' in token_library: + module = 'ipa-selinux-nfast' + else: + module = None + if module: + args = [paths.SEMODULE, "-l"] + result = ipautil.run(args, cwd=tempnssdb.secdir, + capture_output=True, raiseonerr=False) + if module not in result.output: + logger.info('\nWARNING: The associated SELinux module ,%s, ' + 'for this HSM was not detected.\nVerify ' + 'that the appropriate subpackage is installed ' + 'for this HSM\n', module) def set_subject_base_in_config(subject_base):