Linux Test Project
 help / color / mirror / Atom feed
From: Avinesh Kumar via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] tst_security.sh: quote variables in selinux helper functions
Date: Tue, 30 Jun 2026 20:08:54 +0200	[thread overview]
Message-ID: <20260630180855.159467-1-avinesh.kumar@suse.com> (raw)

From: Avinesh Kumar <avinesh.kumar@suse.com>

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 <pvorel@suse.cz>
Signed-off-by: Avinesh Kumar <avinesh.kumar@suse.com>
---
 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

             reply	other threads:[~2026-06-30 18:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 18:08 Avinesh Kumar via ltp [this message]
2026-06-30 19:58 ` [LTP] tst_security.sh: quote variables in selinux helper functions linuxtestproject.agent
2026-06-30 22:52 ` [LTP] [PATCH] " Wei Gao via ltp
2026-07-01  5:37 ` Li Wang

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=20260630180855.159467-1-avinesh.kumar@suse.com \
    --to=ltp@lists.linux.it \
    --cc=avinesh.kumar@suse.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