Return-Path: Received: from relay.sgi.com (relay2.corp.sgi.com [137.38.102.29]) by oss.sgi.com (Postfix) with ESMTP id 6BA877CBA for ; Wed, 9 Mar 2016 06:06:59 -0600 (CST) Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by relay2.corp.sgi.com (Postfix) with ESMTP id 3D483304039 for ; Wed, 9 Mar 2016 04:06:59 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id 8bAiV7rUicAl6wsJ (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 09 Mar 2016 04:06:54 -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 5D62864D26 for ; Wed, 9 Mar 2016 12:06:53 +0000 (UTC) From: Andreas Gruenbacher Subject: [XFSTESTS v4 4/4] generic/338: Add richacl tests Date: Wed, 9 Mar 2016 13:06:39 +0100 Message-Id: <1457525199-15355-6-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 as generic/338. The new test requires SCRATCH_DEV and SCRATCH_MNT to be set. It tries to create and mount a scratch filesystem with richacl support before running the tests; if that fails, the richacl tests will be skipped. Signed-off-by: Andreas Gruenbacher --- Makefile | 2 +- common/rc | 32 ++++++++ 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 | 78 +++++++++++++++++++ tests/generic/group | 1 + 16 files changed, 1093 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 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..61e85ad 100644 --- a/common/rc +++ b/common/rc @@ -1908,6 +1908,38 @@ _require_xfs_db_command() _notrun "xfs_db $command support is missing" } +_require_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" + _scratch_unmount +} + +__require_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" + _scratch_unmount +} + +_require_scratch_richacl() +{ + case "$FSTYP" in + xfs) _require_scratch_richacl_xfs + ;; + ext4) __require_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..8d19d1a --- /dev/null +++ b/richacl/Makefile @@ -0,0 +1,23 @@ +# +# Copyright (C) 2015 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]} -ne 0 ]; then + cat $tmp.${file##*/} + failure=true + fi + _scratch_unmount +done + +$failure || status=0 diff --git a/tests/generic/group b/tests/generic/group index 727648c..0388b44 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -340,3 +340,4 @@ 335 auto quick metadata 336 auto quick metadata 337 auto quick metadata +338 richacl auto -- 2.5.0 _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs