From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Cc: Petr Vorel <pvorel@suse.cz>,
Lachlan Sneff <t-josne@linux.microsoft.com>,
Lakshmi Ramasubramanian <nramas@linux.microsoft.com>,
Mimi Zohar <zohar@linux.vnet.ibm.com>,
balajib@linux.microsoft.com, linux-integrity@vger.kernel.org
Subject: [PATCH v5 2/4] IMA: Add policy related helpers
Date: Tue, 28 Jul 2020 00:30:39 +0200 [thread overview]
Message-ID: <20200727223041.13110-3-pvorel@suse.cz> (raw)
In-Reply-To: <20200727223041.13110-1-pvorel@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
New in v5.
.../security/integrity/ima/tests/ima_setup.sh | 39 +++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
index 975ce9cbb..c46f273ab 100644
--- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh
@@ -54,6 +54,45 @@ compute_digest()
return 1
}
+check_policy_readable()
+{
+ if [ -f $IMA_POLICY ]; then
+ tst_res TINFO "missing $IMA_POLICY (reboot or CONFIG_IMA_WRITE_POLICY=y required)"
+ return 1
+ fi
+ cat $IMA_POLICY > /dev/null 2>/dev/null
+}
+
+require_policy_readable()
+{
+ if [ -f $IMA_POLICY ]; then
+ tst_brk TCONF "missing $IMA_POLICY (reboot or CONFIG_IMA_WRITE_POLICY=y required)"
+ fi
+ if ! check_policy_readable; then
+ tst_brk TCONF "cannot read IMA policy (CONFIG_IMA_READ_POLICY=y required)"
+ fi
+}
+
+check_ima_policy_content()
+{
+ local pattern="$1"
+ local grep_params="${2--q}"
+
+ check_policy_readable || return 1
+ grep $grep_params "$pattern" $IMA_POLICY
+}
+
+require_ima_policy_content()
+{
+ local pattern="$1"
+ local grep_params="${2--q}"
+
+ require_policy_readable
+ if ! grep $grep_params "$pattern" $IMA_POLICY; then
+ tst_brk TCONF "IMA policy does not specify '$pattern'"
+ fi
+}
+
require_ima_policy_cmdline()
{
local policy="$1"
--
2.27.0
next prev parent reply other threads:[~2020-07-27 22:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-27 22:30 [PATCH v5 0/4] IMA: kexec cmdline measurement Petr Vorel
2020-07-27 22:30 ` [PATCH v5 1/4] IMA: Rename helper to require_ima_policy_cmdline Petr Vorel
2020-07-27 22:30 ` Petr Vorel [this message]
2020-07-30 19:50 ` [PATCH v5 2/4] IMA: Add policy related helpers Mimi Zohar
2020-07-31 5:26 ` Petr Vorel
2020-07-27 22:30 ` [PATCH v5 3/4] IMA/ima_keys.sh: Fix policy readability check Petr Vorel
2020-07-27 22:30 ` [PATCH v5 4/4] IMA: Add test for kexec cmdline measurement Petr Vorel
2020-07-27 22:42 ` Lachlan Sneff
2020-07-27 23:13 ` Petr Vorel
2020-07-30 20:03 ` [PATCH v5 0/4] IMA: " Mimi Zohar
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=20200727223041.13110-3-pvorel@suse.cz \
--to=pvorel@suse.cz \
--cc=balajib@linux.microsoft.com \
--cc=linux-integrity@vger.kernel.org \
--cc=ltp@lists.linux.it \
--cc=nramas@linux.microsoft.com \
--cc=t-josne@linux.microsoft.com \
--cc=zohar@linux.vnet.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;
as well as URLs for NNTP newsgroup(s).