From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Cc: Petr Vorel <pvorel@suse.cz>, Mimi Zohar <zohar@linux.ibm.com>,
linux-integrity@vger.kernel.org
Subject: [PATCH 2/2] ima_setup.sh: Check 'cat' exit code when loading policy
Date: Wed, 19 Feb 2025 19:19:25 +0100 [thread overview]
Message-ID: <20250219181926.2620960-2-pvorel@suse.cz> (raw)
In-Reply-To: <20250219181926.2620960-1-pvorel@suse.cz>
Parsing stderr should be enough, but check also 'cat' exit code
in case of error message change or other problem.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
New in v2.
testcases/kernel/security/integrity/ima/tests/ima_setup.sh | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
index 9732aa7b43..83fcefb4fc 100644
--- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
@@ -209,6 +209,7 @@ verify_ima_policy()
load_ima_policy()
{
local file="$TST_DATAROOT/$REQUIRED_POLICY_CONTENT"
+ local ret
if [ "$LTP_IMA_LOAD_POLICY" != 1 ]; then
if [ "$IMA_MISSING_POLICY_CONTENT" = 1 ]; then
@@ -228,6 +229,7 @@ load_ima_policy()
fi
cat "$file" 2> log > $IMA_POLICY
+ ret=$?
if grep -q "Device or resource busy" log; then
tst_brk TBROK "loading policy failed"
fi
@@ -236,6 +238,10 @@ load_ima_policy()
tst_brk TCONF "loading unsigned policy failed"
fi
+ if [ $ret -ne 0 ]; then
+ tst_brk TBROK "loading policy failed"
+ fi
+
IMA_POLICY_LOADED=1
tst_res TINFO "example policy successfully loaded"
--
2.47.2
next prev parent reply other threads:[~2025-02-19 18:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 18:19 [PATCH 1/2] ima_setup.sh: Postpone loading policy after test setup Petr Vorel
2025-02-19 18:19 ` Petr Vorel [this message]
2025-03-06 18:23 ` [PATCH 2/2] ima_setup.sh: Check 'cat' exit code when loading policy Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250219181926.2620960-2-pvorel@suse.cz \
--to=pvorel@suse.cz \
--cc=linux-integrity@vger.kernel.org \
--cc=ltp@lists.linux.it \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox