7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# CDDL HEADER START
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# The contents of this file are subject to the terms of the
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# Common Development and Distribution License (the "License").
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# You may not use this file except in compliance with the License.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# See the License for the specific language governing permissions
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# and limitations under the License.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# CDDL HEADER END
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# Copyright (c) 2013 by Paul B. Henson <henson@acm.org>. All rights reserved.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy. $STF_SUITE/tests/functional/acl/acl_common.kshlib
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# Verify chmod permission settings on files and directories, as both root
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# and non-root users, with aclmode set to restricted.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# 1. Loop root and $ZFS_ACL_STAFF1 as root and non-root users.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# 2. Create test file and directory in zfs filesystem.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# 3. Execute 'chmod' with specified options.
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# 4. Check 'ls -l' output and compare with expect results.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs set aclmode=discard $TESTPOOL/$TESTFS
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# "init_map" "options" "expect_map"
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "000" "a+rw" "rw-rw-rw-" "000" "a+rwx" "rwxrwxrwx" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "000" "u+xr" "r-x------" "000" "gu-xw" "---------" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "644" "a-r" "-w-------" "644" "augo-x" "rw-r--r--" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "644" "=x" "--x--x--x" "644" "u-rw" "---r--r--" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "644" "uo+x" "rwxr--r-x" "644" "ga-wr" "---------" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "777" "augo+x" "rwxrwxrwx" "777" "go-xr" "rwx-w--w-" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "777" "o-wx" "rwxrwxr--" "777" "ou-rx" "-w-rwx-w-" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "777" "a+rwx" "rwxrwxrwx" "777" "u=rw" "rw-rwxrwx" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "000" "123" "--x-w--wx" "000" "412" "r----x-w-" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "231" "562" "r-xrw--w-" "712" "000" "---------" \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "777" "121" "--x-w---x" "123" "775" "rwxrwxr-x"
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedylog_assert " Verify chmod permission settings on files and directories for " \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy "aclmode=restricted"
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# Verify file or directory have correct map after chmod
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# $1 file or directory
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy typeset -i i=0
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_note "usr_exec chmod ${argv[i]} $node"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_note "usr_exec chmod ${argv[((i + 1))]} $node"
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy if [[ $mode != "-${argv[((i + 2))]}"* && \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy log_fail "FAIL: '${argv[i]}' '${argv[((i + 1))]}' \
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy '${argv[((i + 2))]}'"
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedy# set aclmode=restricted
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedylog_must zfs set aclmode=restricted $TESTPOOL/$TESTFS
7b1753e64ab6c8c68e7cd79acbedfdfba12bd7f8John Wren Kennedylog_pass "Setting permissions using 'chmod' for aclmode=restricted completed " \