Skip to contentSkip to conversation

tst_security.sh: quote variables in selinux helper functions

PATCH Applied Avinesh Kumar via ltp 3 participants 4 messages Jun 30 – Jul 1

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tst_security.sh: quote variables in selinux helper functions

From: Avinesh Kumar <[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")
---
 testcases/lib/tst_security.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/lib/tst_security.sh +4 -4
index 03b744fb3d42..a7dd9de63339 100644
@@ -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"
 }
Signature · 5 lines
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Avinesh,

Quoted 1 line · Avinesh Kumar

tst_security.sh: quote variables in selinux helper functions

Verdict - Reviewed

---
Note:

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author Reviewed-by Wei Gao on v1 1/1
#2 lore raw
In reply to Avinesh Kumar via ltp
Quoted 27 lines · Avinesh Kumar via ltp

From: Avinesh Kumar <[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")
---
 testcases/lib/tst_security.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/lib/tst_security.sh +1 -1
index 03b744fb3d42..a7dd9de63339 100644
@@ -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

testcases/lib/tst_security.sh tst_update_selinux_state() · line 153

Quoted 10 lines
testcases/lib/tst_security.sh +3 -3
@@ -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"

Thanks.

Quoted 7 lines
testcases/lib/tst_security.sh +0 -0
 }
Signature · 5 lines
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp