diff options
| author | Pádraig Brady <P@draigBrady.com> | 2024-11-12 11:34:07 +0000 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2024-11-12 11:43:45 +0000 |
| commit | fc0ea5cb87e893f0dc4bc36d606d63c4f3317c50 (patch) | |
| tree | 9b01e970d0e0f470a5fe047b880c4ad0422ec1b4 /tests | |
| parent | tests: avoid false failure with --disable-selinux (diff) | |
| download | coreutils-fc0ea5cb87e893f0dc4bc36d606d63c4f3317c50.tar.gz coreutils-fc0ea5cb87e893f0dc4bc36d606d63c4f3317c50.zip | |
tests: ls: also test security context output for symlinks
* tests/ls/selinux.sh: Test symlinks as well as files.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/ls/selinux.sh | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/tests/ls/selinux.sh b/tests/ls/selinux.sh index 7b3ad6af3..364e32d9b 100755 --- a/tests/ls/selinux.sh +++ b/tests/ls/selinux.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Test selinux output +# Test ls SELinux file context output # Copyright (C) 2024 Free Software Foundation, Inc. @@ -20,21 +20,26 @@ print_ver_ ls require_selinux_ -touch f || framework_failure_ -case $(stat --printf='%C' f) in +touch file || framework_failure_ +ln -s file link || framework_failure_ + +case $(stat --printf='%C' file) in *:*:*:*) ;; *) skip_ 'unable to match default security context';; esac -# ensure that ls -l output includes the "." -test "$(ls -l f|cut -c11)" = . || fail=1 +for f in file link; do -# ensure that ls -lZ output includes context -ls_output=$(LC_ALL=C ls -lnZ f) || fail=1 -set x $ls_output -case $6 in - *:*:*:*) ;; - *) fail=1 ;; -esac + # ensure that ls -l output includes the "." + test "$(ls -l $f | cut -c11)" = . || fail=1 + + # ensure that ls -lZ output includes context + ls_output=$(LC_ALL=C ls -lnZ "$f") || fail=1 + set x $ls_output + case $6 in + *:*:*:*) ;; + *) fail=1 ;; + esac +done Exit $fail |
