Update OpenZFS to 2.0.0-rc3-gbd565f
[freebsd.git] / tests / zfs-tests / tests / functional / acl / posix / posix_003_pos.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 . $STF_SUITE/include/libtest.shlib
24
25 #
26 # DESCRIPTION:
27 #       Verify that ACLs survive remount.
28 #
29 # STRATEGY:
30 #       1. Test presence of default and regular ACLs after remount
31 #          a. Can set and list ACL before remount
32 #          b. Can list ACL after remount
33 #
34
35 verify_runnable "both"
36 log_assert "Verify regular and default POSIX ACLs survive  remount"
37
38 typeset acl_str1="^group:$ZFS_ACL_STAFF_GROUP:-wx$"
39 typeset acl_str2="^default:group:$ZFS_ACL_STAFF_GROUP:-wx$"
40 typeset ACLDIR="$TESTDIR/dir.1"
41
42 log_note "Testing access to DIRECTORY"
43 log_must mkdir $ACLDIR
44 log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $ACLDIR
45 log_must setfacl -d -m g:$ZFS_ACL_STAFF_GROUP:wx $ACLDIR
46 getfacl $ACLDIR 2> /dev/null | egrep -q "$acl_str1"
47 if [ "$?" -eq "0" ]; then
48         getfacl $ACLDIR 2> /dev/null | egrep -q "$acl_str2"
49 fi
50
51 if [ "$?" -eq "0" ]; then
52         log_must zfs unmount $TESTPOOL/$TESTFS
53         log_must zfs mount $TESTPOOL/$TESTFS
54         log_must eval "getfacl $ACLDIR 2> /dev/null | egrep -q \"$acl_str1\""
55         log_must eval "getfacl $ACLDIR 2> /dev/null | egrep -q \"$acl_str2\""
56         log_pass "POSIX ACLs survive remount"
57 else
58         log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have 'rwx'"
59 fi