X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-selinux.sh;h=4427a2e151050df1692cde62f7287fae9992e670;hb=8e563553c0a26f0d8e8caf2a44b44a7f552531e9;hp=8f0869adb2cc785bae8970f2ab37e1bb5ed1cccd;hpb=f1761cbe6b1243edd7a69c68c401d7285f7f3b38;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-selinux.sh b/lustre/tests/sanity-selinux.sh index 8f0869a..4427a2e 100755 --- a/lustre/tests/sanity-selinux.sh +++ b/lustre/tests/sanity-selinux.sh @@ -15,23 +15,20 @@ set -e ONLY=${ONLY:-"$*"} -# bug number for skipped test: -ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"$SANITY_SELINUX_EXCEPT"} -# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! - -SRCDIR=$(dirname $0) -SAVE_PWD=$PWD LUSTRE=${LUSTRE:-$(dirname $0)/..} . $LUSTRE/tests/test-framework.sh -init_test_env $@ -. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} +init_test_env "$@" init_logging -require_dsh_mds || exit 0 +ALWAYS_EXCEPT="$SANITY_SELINUX_EXCEPT" [ "$SLOW" = "no" ] && EXCEPT_SLOW="xxx" +build_test_filter + +require_dsh_mds || exit 0 + RUNAS_CMD=${RUNAS_CMD:-runas} # $RUNAS_ID may get set incorrectly somewhere else [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && @@ -69,8 +66,6 @@ rm -rf $DIR/[df][0-9]* check_runas_id $RUNAS_ID $RUNAS_ID $RUNAS -build_test_filter - umask 077 check_selinux_xattr() { @@ -93,6 +88,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) @@ -118,7 +120,7 @@ test_2a() { mds_path=${mds_path#/} - $LFS setdirstripe -i0 -c1 ${DIR}/$tdir || error "create dir failed" + mkdir_on_mdt0 ${DIR}/$tdir || error "create dir failed" mkdir $dirname || error "cannot mkdir $dirname" local xattrval=$(check_selinux_xattr "mds1" $mds_path) @@ -230,7 +232,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 +256,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 +290,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" ] || @@ -461,6 +463,36 @@ test_20d() { } run_test 20d "[atomicity] avoid getxattr for security context" +test_20e() { + [ "$CLIENT_VERSION" -lt $(version_code 2.13.54) ] && + skip "Need client version >= 2.13.54" + local filename1=$DIR/$tdir/df20e + local delay=5 + local evict + local unconctx="-u unconfined_u -r unconfined_r -t unconfined_t -l s0" + + mkdir -p $DIR/$tdir + chmod 777 $DIR/$tdir + #define OBD_FAIL_LLITE_CREATE_FILE_PAUSE2 0x1416 + do_facet client "$LCTL set_param fail_val=$delay fail_loc=0x80001416" + + # create file on first mount point + $RUNAS_CMD -u $RUNAS_ID runcon $unconctx touch $filename1 & + local touchpid=$! + sleep 1 + cancel_lru_locks mdc + sysctl -w vm.drop_caches=2 + $RUNAS_CMD -u $RUNAS_ID runcon $unconctx stat $DIR/$tdir & + + wait $touchpid + + evict=$($LCTL get_param mdc.$FSNAME-MDT*.state | + awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }') + + [ -z "$evict" ] || [[ $evict -le $before ]] || error "eviction happened" +} +run_test 20e "client deadlock and eviction form MDS" + check_nodemap() { local nm=$1 local key=$2 @@ -512,7 +544,9 @@ create_nodemap() { check_nodemap $nm trusted_nodemap 1 sleep 10 + l_getsepol || error "cannot get sepol" sepol=$(l_getsepol | cut -d':' -f2- | xargs) + [ -n "$sepol" ] || error "sepol is empty" do_facet mgs $LCTL set_param -P nodemap.$nm.sepol="$sepol" check_nodemap $nm sepol $sepol @@ -605,9 +639,12 @@ test_21b() { [ "$MDS1_VERSION" -lt $(version_code 2.11.56) ] && skip "Need MDS >= 2.11.56" + stack_trap "restore_opencache" EXIT + disable_opencache + local sepol - mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir" + mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir" echo test > $DIR/$tdir/toopen || error "failed to write to $DIR/$tdir/toopen" touch $DIR/$tdir/ftoremove || @@ -717,7 +754,9 @@ test_21b() { ln $DIR/$tdir/toopen $DIR/$tdir/toopen_hl3 && error "hardlink (3)" # reset correct sepol + l_getsepol || error "cannot get sepol" sepol=$(l_getsepol | cut -d':' -f2- | xargs) + [ -n "$sepol" ] || error "sepol is empty" do_facet mgs $LCTL set_param -P nodemap.c0.sepol="$sepol" check_nodemap c0 sepol $sepol