Whamcloud - gitweb
LU-12267 tests: filter trailing '.' for SELinux 58/35958/2
authorJames Nunez <jnunez@whamcloud.com>
Fri, 31 May 2019 21:28:20 +0000 (15:28 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 12 Sep 2019 03:47:46 +0000 (03:47 +0000)
When SELinux is enforced, sanity test 420 fails due to
the "ls -n" command producing an extra '.' at the end of
the file/directory permissions to indicate extra security
attributes are set.

We need to filter out the trailing '.' in the 'ls -n'
output for testing to pass when SELinux is enabled.

Lustre-change: https://review.whamcloud.com/35026
Lustre-commit: f000996069acc7d535b7574a9d9a4ab65e753ff0

Test-Parameters: trivial envdefinitions=ONLY=420 testlist=sanity
Test-Parameters: clientselinux envdefinitions=ONLY=420 testlist=sanity
Signed-off-by: James Nunez <jnunez@whamcloud.com>
Change-Id: I4a2f199d2ef4a7b1b6a1b381041b384bb0077cc6
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/35958
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/tests/sanity.sh

index f3010bf..ffdc471 100755 (executable)
@@ -19634,14 +19634,17 @@ test_420()
        umask 0000
        mkdir -m03777 $dir/testdir
        ls -dn $dir/testdir
-       local dirperms=$(ls -dn $dir/testdir | awk '{print $1}')
+       # Need to remove trailing '.' when SELinux is enabled
+       local dirperms=$(ls -dn $dir/testdir |
+                        awk '{ sub(/\.$/, "", $1); print $1}')
        [ $dirperms == "drwxrwsrwt" ] ||
                error "incorrect perms on $dir/testdir"
 
        su - $uname -c "PATH=$LUSTRE/tests:\$PATH; \
                openfile -f O_RDONLY:O_CREAT -m 02755 $dir/testdir/testfile"
        ls -n $dir/testdir/testfile
-       local fileperms=$(ls -n $dir/testdir/testfile | awk '{print $1}')
+       local fileperms=$(ls -n $dir/testdir/testfile |
+                         awk '{ sub(/\.$/, "", $1); print $1}')
        [ $fileperms == "-rwxr-xr-x" ] ||
                error "incorrect perms on $dir/testdir/testfile"