[LTP] [PATCH] tst_security.sh: quote variables in selinux helper functions
Wei Gao
wegao@suse.com
Wed Jul 1 00:52:49 CEST 2026
On Tue, Jun 30, 2026 at 08:08:54PM +0200, Avinesh Kumar via ltp wrote:
> 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"
Thanks.
Reviewed-by: Wei Gao <wegao@suse.com>
> }
> --
> 2.54.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
More information about the ltp
mailing list