[PATCH] tst_security.sh: quote variables in selinux helper functions

Avinesh Kumar via ltp <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
From: Avinesh Kumar <avinesh.kumar-IBi9RG/[email protected]>

Quote variables in tst_disable_selinux() and tst_update_selinux_state()
to follow shell quoting best practices.

Fixes: cc9206e612b2 ("tst_security.sh: Use enforce toggle to trigger SELinux measurement")

Suggested-by: Petr Vorel <[email protected]>
Signed-off-by: Avinesh Kumar <avinesh.kumar-IBi9RG/[email protected]>
---
 testcases/lib/tst_security.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/testcases/lib/tst_security.sh b/testcases/lib/tst_security.sh
index 03b744fb3d42..a7dd9de63339 100644
--- a/testcases/lib/tst_security.sh
+++ b/testcases/lib/tst_security.sh
@@ -119,7 +119,7 @@ tst_disable_selinux()
 
 	local f="$(tst_get_enforce)"
 
-	[ -f "$f" ] && echo 0 > $f
+	[ -f "$f" ] && echo 0 > "$f"
 }
 
 # Get SELinux directory path
@@ -147,8 +147,8 @@ tst_update_selinux_state()
 	[ -n "$dir" ] || return 1
 
 	# Toggle enforce to trigger SELinux state measurement
-	orig_val=$(cat $dir/enforce)
+	orig_val=$(cat "$dir/enforce")
 	val=$((1 - orig_val))
-	echo $val > $dir/enforce
-	echo $orig_val > $dir/enforce
+	echo "$val" > "$dir/enforce"
+	echo "$orig_val" > "$dir/enforce"
 }
-- 
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.