[LTP] [PATCH v3 03/10] IMA: Move requirement check to ima_setup.sh
Petr Vorel
pvorel@suse.cz
Tue Jan 14 12:29:08 CET 2025
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
.../kernel/security/integrity/ima/tests/evm_overlay.sh | 3 +--
.../kernel/security/integrity/ima/tests/ima_measurements.sh | 6 +++---
testcases/kernel/security/integrity/ima/tests/ima_setup.sh | 6 +++++-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/security/integrity/ima/tests/evm_overlay.sh b/testcases/kernel/security/integrity/ima/tests/evm_overlay.sh
index 12b2a28c25..6a48f63aaa 100755
--- a/testcases/kernel/security/integrity/ima/tests/evm_overlay.sh
+++ b/testcases/kernel/security/integrity/ima/tests/evm_overlay.sh
@@ -9,6 +9,7 @@
TST_SETUP="setup"
TST_CLEANUP="cleanup"
TST_CNT=4
+REQUIRED_BUILTIN_POLICY="appraise_tcb"
setup()
{
@@ -17,8 +18,6 @@ setup()
[ -f "$EVM_FILE" ] || tst_brk TCONF "EVM not enabled in kernel"
[ $(cat $EVM_FILE) -eq 1 ] || tst_brk TCONF "EVM not enabled for this boot"
- require_ima_policy_cmdline "appraise_tcb"
-
lower="$TST_MNTPOINT/lower"
upper="$TST_MNTPOINT/upper"
work="$TST_MNTPOINT/work"
diff --git a/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh b/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh
index 1da2aa6a51..ca9d73b4aa 100755
--- a/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh
@@ -1,19 +1,19 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2009 IBM Corporation
-# Copyright (c) 2018-2021 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2018-2025 Petr Vorel <pvorel@suse.cz>
# Author: Mimi Zohar <zohar@linux.ibm.com>
#
# Verify that measurements are added to the measurement list based on policy.
+# Test requires ima_policy=tcb.
TST_NEEDS_CMDS="awk cut sed"
TST_SETUP="setup"
TST_CNT=3
+REQUIRED_BUILTIN_POLICY="tcb"
setup()
{
- require_ima_policy_cmdline "tcb"
-
TEST_FILE="$PWD/test.txt"
[ -f "$IMA_POLICY" ] || tst_res TINFO "not using default policy"
}
diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
index fc0e769729..2a578ceb45 100644
--- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2009 IBM Corporation
-# Copyright (c) 2018-2020 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2018-2025 Petr Vorel <pvorel@suse.cz>
# Author: Mimi Zohar <zohar@linux.ibm.com>
TST_TESTFUNC="test"
@@ -180,6 +180,10 @@ ima_setup()
cd "$TST_MNTPOINT"
fi
+ if [ "$REQUIRED_BUILTIN_POLICY" ]; then
+ require_ima_policy_cmdline "$REQUIRED_BUILTIN_POLICY"
+ fi
+
[ -n "$TST_SETUP_CALLER" ] && $TST_SETUP_CALLER
}
--
2.47.1
More information about the ltp
mailing list