linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] ima_measurements.sh: Use /proc/uptime instead of date
@ 2022-01-12 15:01 Petr Vorel
  2022-01-14  1:11 ` Mimi Zohar
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vorel @ 2022-01-12 15:01 UTC (permalink / raw)
  To: ltp
  Cc: Petr Vorel, linux-integrity, Mimi Zohar, Alex Henrie,
	alexhenrie24, Cyril Hrubis

It fixes more iterations (e.g. -i2) which is more precise.
date +%s could be used, but it's better use procfs file instead
requiring binary.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi all,

I hope to get this merged into upcoming release (git freeze is going to
be at January the 14), i.e. this Friday.

Kind regards,
Petr

 .../security/integrity/ima/tests/ima_measurements.sh      | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh b/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh
index a83c416de0..6c184f3960 100755
--- a/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh
@@ -55,7 +55,7 @@ check_iversion_support()
 test1()
 {
 	tst_res TINFO "verify adding record to the IMA measurement list"
-	ROD echo "$(date) this is a test file" \> $TEST_FILE
+	ROD echo "$(cat /proc/uptime) this is a test file" \> $TEST_FILE
 	ima_check $TEST_FILE
 }
 
@@ -64,7 +64,7 @@ test2()
 
 	tst_res TINFO "verify updating record in the IMA measurement list"
 	check_iversion_support || return
-	ROD echo "$(date) modified file" \> $TEST_FILE
+	ROD echo "$(cat /proc/uptime) modified file" \> $TEST_FILE
 	ima_check $TEST_FILE
 }
 
@@ -83,11 +83,11 @@ test3()
 		return
 	fi
 
-	mkdir -m 0700 $dir
+	[ -d "$dir" ] || mkdir -m 0700 $dir
 	chown $user $dir
 	cd $dir
 	# need to read file to get updated $ASCII_MEASUREMENTS
-	sudo -n -u $user sh -c "echo $(date) user file > $file; cat $file > /dev/null"
+	sudo -n -u $user sh -c "echo $(cat /proc/uptime) user file > $file; cat $file > /dev/null"
 	cd ..
 
 	EXPECT_FAIL "grep $file $ASCII_MEASUREMENTS"
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-14  8:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-12 15:01 [PATCH 1/1] ima_measurements.sh: Use /proc/uptime instead of date Petr Vorel
2022-01-14  1:11 ` Mimi Zohar
2022-01-14  8:53   ` Petr Vorel

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).