Commit ca09fda1 authored by Sebastien Buisson's avatar Sebastien Buisson Committed by Oleg Drokin
Browse files

LU-13580 tests: fix retrieval of SELinux context



Use 'stat' command instead of 'ls -lZ' to retrieve SELinux security
context, to make it more portable.

Test-Parameters: trivial clientselinux testlist=sanity-selinux mdtcount=2 clientcount=2
Signed-off-by: default avatarSebastien Buisson <sbuisson@ddn.com>
Change-Id: I61bc0efb1e8ae0427d05827e2933eb0b848fb442
Reviewed-on: https://review.whamcloud.com/38648

Reviewed-by: default avatarAndreas Dilger <adilger@whamcloud.com>
Tested-by: default avatarjenkins <devops@whamcloud.com>
Tested-by: default avatarMaloo <maloo@whamcloud.com>
Reviewed-by: default avatarJohn L. Hammond <jhammond@whamcloud.com>
Reviewed-by: default avatarOleg Drokin <green@whamcloud.com>
parent adf46db9
......@@ -93,6 +93,13 @@ check_selinux_xattr() {
echo $xattrval
}
get_sel_ctx() {
local file=$1
[ -n "$file" ] || return;
[ -f $file ] || return;
stat $file | awk '$1 == "Context:" {print $2}'
}
test_1() {
local devname=$(mdsdevname 1)
......@@ -230,7 +237,7 @@ test_5() {
# get sec context
ls -lZ $filename
local secctxseen=$(ls -lZ $filename | awk '{print $4}' | cut -d: -f3)
local secctxseen=$(get_sel_ctx $filename | cut -d: -f3)
[ "$newsecctx" == "$secctxseen" ] ||
error "sec context seen from 1st mount point is not correct"
......@@ -254,7 +261,7 @@ test_10() {
# get sec context from 1st mount point
ls -lZ $filename1
local secctxseen=$(ls -lZ $filename1 | awk '{print $4}' | cut -d: -f3)
local secctxseen=$(get_sel_ctx $filename1 | cut -d: -f3)
[ "$newsecctx" == "$secctxseen" ] ||
error_ignore LU-6784 \
......@@ -288,12 +295,12 @@ test_20a() {
# get sec info on second mount point
if [ -e "$filename2" ]; then
secinfo2=$(ls -lZ $filename2 | awk '{print $4}')
secinfo2=$(get_sel_ctx $filename2)
fi
# get sec info on first mount point
wait $touchpid
secinfo1=$(ls -lZ $filename1 | awk '{print $4}')
secinfo1=$(get_sel_ctx $filename1)
# compare sec contexts
[ -z "$secinfo2" -o "$secinfo1" == "$secinfo2" ] ||
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment