Return-Path: Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id EDEFC7CA0 for ; Wed, 9 Mar 2016 06:06:56 -0600 (CST) Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by relay1.corp.sgi.com (Postfix) with ESMTP id 860728F8035 for ; Wed, 9 Mar 2016 04:06:56 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id ktTuHgWknEF7bX5l (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 09 Mar 2016 04:06:51 -0800 (PST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 6C888A2028 for ; Wed, 9 Mar 2016 12:06:51 +0000 (UTC) From: Andreas Gruenbacher Subject: [XFSTESTS v4 4/4] Add richacl tests Date: Wed, 9 Mar 2016 13:06:38 +0100 Message-Id: <1457525199-15355-5-git-send-email-agruenba@redhat.com> In-Reply-To: <1457525199-15355-1-git-send-email-agruenba@redhat.com> References: <1457525199-15355-1-git-send-email-agruenba@redhat.com> List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com To: xfs@oss.sgi.com Cc: Andreas Gruenbacher Add the Rich Access Control List tests from the richacl package. The tests requires SCRATCH_DEV and SCRATCH_MNT to be set. They try to create and mount a scratch filesystem with richacl support; if that fails, the tests will be skipped. Signed-off-by: Andreas Gruenbacher --- Makefile | 2 +- common/rc | 36 +++++++ richacl/Makefile | 23 +++++ richacl/apply-masks | 163 ++++++++++++++++++++++++++++++ richacl/auto-inheritance | 191 ++++++++++++++++++++++++++++++++++++ richacl/basic | 97 ++++++++++++++++++ richacl/chmod | 40 ++++++++ richacl/chown | 42 ++++++++ richacl/create | 36 +++++++ richacl/ctime | 35 +++++++ richacl/delete | 89 +++++++++++++++++ richacl/setrichacl-modify | 57 +++++++++++ richacl/test-lib.sh | 154 +++++++++++++++++++++++++++++ richacl/write-vs-append | 54 ++++++++++ tests/generic/338 | 67 +++++++++++++ tests/generic/339-apply-masks | 1 + tests/generic/340-auto-inheritance | 1 + tests/generic/341-basic | 1 + tests/generic/342-chmod | 1 + tests/generic/343-chown | 1 + tests/generic/344-create | 1 + tests/generic/345-ctime | 1 + tests/generic/346-delete | 1 + tests/generic/347-setrichacl-modify | 1 + tests/generic/348-write-vs-append | 1 + tests/generic/group | 10 ++ 26 files changed, 1105 insertions(+), 1 deletion(-) create mode 100644 richacl/Makefile create mode 100755 richacl/apply-masks create mode 100755 richacl/auto-inheritance create mode 100755 richacl/basic create mode 100755 richacl/chmod create mode 100755 richacl/chown create mode 100755 richacl/create create mode 100755 richacl/ctime create mode 100755 richacl/delete create mode 100755 richacl/setrichacl-modify create mode 100644 richacl/test-lib.sh create mode 100755 richacl/write-vs-append create mode 100755 tests/generic/338 create mode 120000 tests/generic/339-apply-masks create mode 120000 tests/generic/340-auto-inheritance create mode 120000 tests/generic/341-basic create mode 120000 tests/generic/342-chmod create mode 120000 tests/generic/343-chown create mode 120000 tests/generic/344-create create mode 120000 tests/generic/345-ctime create mode 120000 tests/generic/346-delete create mode 120000 tests/generic/347-setrichacl-modify create mode 120000 tests/generic/348-write-vs-append diff --git a/Makefile b/Makefile index 30d8747..3eec26f 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ TOOL_SUBDIRS += dmapi endif export TESTS_DIR = tests -SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) $(TESTS_DIR) +SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) $(TESTS_DIR) richacl default: include/builddefs $(DMAPI_MAKEFILE) ifeq ($(HAVE_BUILDDEFS), no) diff --git a/common/rc b/common/rc index 16f5a43..155e8b2 100644 --- a/common/rc +++ b/common/rc @@ -1908,6 +1908,42 @@ _require_xfs_db_command() _notrun "xfs_db $command support is missing" } +_setup_scratch_richacl_xfs() +{ + _scratch_mkfs_xfs_supported -m richacl=1 >/dev/null 2>&1 \ + || _notrun "mkfs.xfs doesn't have richacl feature" + + _scratch_mkfs_xfs -m richacl=1 >/dev/null 2>&1 + _scratch_mount >/dev/null 2>&1 \ + || _notrun "kernel doesn't support richacl feature" +} + +__setup_scratch_richacl() +{ + _scratch_mkfs -O richacl >/dev/null 2>&1 \ + || _notrun "can't mkfs $FSTYP with option -O richacl" + _scratch_mount >/dev/null 2>&1 \ + || _notrun "kernel doesn't support richacl feature on $FSTYP" +} + +_setup_scratch_richacl() +{ + GETRICHACL_PROG=`set_prog_path getrichacl` + _require_command "$GETRICHACL_PROG" getrichacl + SETRICHACL_PROG=`set_prog_path setrichacl` + _require_command "$SETRICHACL_PROG" setrichacl + + _require_scratch + case "$FSTYP" in + xfs) _setup_scratch_richacl_xfs + ;; + ext4) __setup_scratch_richacl + ;; + *) _notrun "this test requires richacl support on \$SCRATCH_DEV" + ;; + esac +} + # check that kernel and filesystem support direct I/O _require_odirect() { diff --git a/richacl/Makefile b/richacl/Makefile new file mode 100644 index 0000000..6c25d18 --- /dev/null +++ b/richacl/Makefile @@ -0,0 +1,23 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# + +TESTS = apply-masks basic chmod chown create delete setrichacl-modify \ + write-vs-append ctime auto-inheritance + +LSRCFILES = test-lib.sh $(TESTS) + +TOPDIR = .. +include $(TOPDIR)/include/builddefs + +TARGET_DIR = $(PKG_LIB_DIR)/richacl + +include $(BUILDRULES) + +install: + $(INSTALL) -m 755 -d $(TARGET_DIR) + $(INSTALL) -m 755 $(TESTS) $(TARGET_DIR) + $(INSTALL) -m 644 test-lib.sh $(TARGET_DIR) + +# Nothing. +install-dev install-lib: diff --git a/richacl/apply-masks b/richacl/apply-masks new file mode 100755 index 0000000..8d3493d --- /dev/null +++ b/richacl/apply-masks @@ -0,0 +1,163 @@ +#! /bin/bash + +. ${0%/*}/test-lib.sh + +require_richacls +use_testdir + +ncheck "touch x" +ncheck "setrichacl --set 'owner@:rwp::allow group@:rwp::allow everyone@:r::allow' x" +check "getrichacl x" < acl.txt" +check "cat acl.txt" </dev/null + rm -rf "$testdir" || exit 2 + fi + mkdir "$testdir" || exit 2 + cd "$testdir" +} + +require_runas() { + if ! $here/src/runas -u 99 -g 99 true ; then + echo "This test must be run as root" >&2 + exit 77 + fi +} + +require_richacls() { + if [ -e $here/src/require-richacls ]; then + $here/src/require-richacls || exit $? + fi + if ! type -f getrichacl setrichacl > /dev/null; then + echo "This test requires the getrichacl and setrichacl utilities" >&2 + exit 77 + fi +} + +require_getfattr() { + if ! type -f getfattr > /dev/null ; then + echo "This test requires the getfattr utility" >&2 + exit 77 + fi +} + +_RUNAS= +runas() { + _start_test -1 runas "$*" + if [ $# = 0 ]; then + _RUNAS= + else + _RUNAS="$here/src/runas $* --" + fi + echo "ok" +} + +if diff -u -L expected -L got /dev/null /dev/null 2> /dev/null; then + eval '_compare() { + diff -u -L expected -L got "$1" "$2" + }' +else + eval '_compare() { + echo "expected:" + cat "$1" + echo "got:" + cat "$2" + }' +fi + +_check() { + local frame=$1 + shift + _start_test "$frame" "$*" + expected=`cat` + if got=`set +x; eval "$_RUNAS $*" 3>&2 &1` && \ + test "$expected" = "$got" ; then + echo "ok" + checks_succeeded="$checks_succeeded + 1" + else + echo "FAILED" + if test "$expected" != "$got" ; then + echo "$expected" > expected~ + echo "$got" > got~ + _compare expected~ got~ + rm -f expected~ got~ + fi + checks_failed="$checks_failed + 1" + fi +} + +check() { + _check 0 "$@" +} + +ncheck() { + _check 0 "$@" < /dev/null +} + +parent_check() { + _check 1 "$@" +} + +parent_ncheck() { + _check 1 "$@" < /dev/null +} + +cleanup() { + status=$? + checks_succeeded=`expr $checks_succeeded` + checks_failed=`expr $checks_failed` + checks_total=`expr $checks_succeeded + $checks_failed` + if test $checks_total -gt 0 ; then + if test $checks_failed -gt 0 && test $status -eq 0 ; then + status=1 + fi + echo "$checks_total tests ($checks_succeeded passed," \ + "$checks_failed failed)" + fi + if test $status = 0 -a -n "$testdir"; then + chmod -R u+rwx "$testdir" 2>/dev/null + cd / && rm -rf "$testdir" + fi + exit $status +} + +if test -z "`echo -n`"; then + if eval 'test -n "${BASH_LINENO[0]}" 2>/dev/null'; then + eval ' + _start_test() { + local frame=$1 + shift + printf "[${BASH_LINENO[2+frame]}] $* -- " + }' + else + eval ' + _start_test() { + shift + printf "* $* -- " + }' + fi +else + eval ' + _start_test() { + shift + printf "* $*\\n" + }' +fi + +if ! type cat > /dev/null 2> /dev/null; then + echo "This test requires the cat utility" >&2 + exit 77 +fi + +export PATH=$here/src:$PATH + +checks_succeeded=0 +checks_failed=0 +trap cleanup 0 diff --git a/richacl/write-vs-append b/richacl/write-vs-append new file mode 100755 index 0000000..3e8c156 --- /dev/null +++ b/richacl/write-vs-append @@ -0,0 +1,54 @@ +#! /bin/bash + +. ${0%/*}/test-lib.sh + +require_runas +require_richacls +use_testdir + +export LC_ALL=C + +ncheck "touch a b c d e f" +ncheck "setrichacl --set 'owner@:rwp::allow' a" +ncheck "setrichacl --set 'owner@:rwp::allow u:99:w::allow' b" +ncheck "setrichacl --set 'owner@:rwp::allow u:99:p::allow' c" +ncheck "setrichacl --set 'owner@:rwp::allow u:99:wp::allow' d" +ncheck "setrichacl --set 'u:99:a::deny owner@:rwp::allow u:99:w::allow' e" +ncheck "setrichacl --set 'u:99:w::deny owner@:rwp::allow u:99:p::allow' f" + +runas -u 99 -g 99 +check "sh -c 'echo a > a' || :" < b' || :" +check "sh -c 'echo c > c' || :" < d' || :" +ncheck "sh -c 'echo e > e' || :" +check "sh -c 'echo f > f' || :" <> a' || :" <> b' || :" <> c' || :" +ncheck "sh -c 'echo D >> d' || :" +check "sh -c 'echo E >> e' || :" <> f' || :" + +runas +check "cat a b c d e f" <$tmp.${file##*/} +if [ ${PIPESTATUS[0]} -eq 0 ]; then + status=0 +else + cat $tmp.${file##*/} +fi diff --git a/tests/generic/339-apply-masks b/tests/generic/339-apply-masks new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/339-apply-masks @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/340-auto-inheritance b/tests/generic/340-auto-inheritance new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/340-auto-inheritance @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/341-basic b/tests/generic/341-basic new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/341-basic @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/342-chmod b/tests/generic/342-chmod new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/342-chmod @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/343-chown b/tests/generic/343-chown new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/343-chown @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/344-create b/tests/generic/344-create new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/344-create @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/345-ctime b/tests/generic/345-ctime new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/345-ctime @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/346-delete b/tests/generic/346-delete new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/346-delete @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/347-setrichacl-modify b/tests/generic/347-setrichacl-modify new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/347-setrichacl-modify @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/348-write-vs-append b/tests/generic/348-write-vs-append new file mode 120000 index 0000000..4b74f22 --- /dev/null +++ b/tests/generic/348-write-vs-append @@ -0,0 +1 @@ +338 \ No newline at end of file diff --git a/tests/generic/group b/tests/generic/group index 727648c..d65341f 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -340,3 +340,13 @@ 335 auto quick metadata 336 auto quick metadata 337 auto quick metadata +339-apply-masks richacl auto +340-auto-inheritance richacl auto +341-basic richacl auto +342-chmod richacl auto +343-chown richacl auto +344-create richacl auto +345-ctime richacl auto +346-delete richacl auto +347-setrichacl-modify richacl auto +348-write-vs-append richacl auto -- 2.5.0 _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs