@@ -47,10 +47,7 @@ setup()
tst_brk TCONF "kernel image not found, specify path in \$IMA_KEXEC_IMAGE"
fi
- if check_policy_readable; then
- require_ima_policy_content "$REQUIRED_POLICY"
- policy_readable=1
- fi
+ require_ima_policy_content_if_readable "$REQUIRED_POLICY"
}
kexec_failure_hint()
@@ -97,8 +94,7 @@ kexec_test()
ROD kexec -su
if ! measure "$cmdline"; then
- if [ "$policy_readable" != 1 ]; then
- tst_res TWARN "policy not readable, it might not contain required policy '$REQUIRED_POLICY'"
+ if ! check_policy_readable; then
res=TBROK
fi
tst_brk $res "unable to find a correct measurement"
@@ -101,6 +101,16 @@ check_ima_policy_content()
fi
}
+require_ima_policy_content_if_readable()
+{
+ local pattern="$1"
+ local grep_params="${2--q}"
+
+ if ! check_ima_policy_content "$pattern" "$grep_params"; then
+ tst_brk TCONF "IMA policy does not specify '$pattern'"
+ fi
+}
+
require_ima_policy_content()
{
local pattern="$1"
It will be reused. Signed-off-by: Petr Vorel <pvorel@suse.cz> --- .../kernel/security/integrity/ima/tests/ima_kexec.sh | 8 ++------ .../kernel/security/integrity/ima/tests/ima_setup.sh | 10 ++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-)