1#!/usr/local/bin/ksh93 -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# 24# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27# ident "@(#)zfs_acl_chmod_inherit_004_pos.ksh 1.1 09/05/19 SMI" 28# 29 30. $STF_SUITE/tests/acl/acl_common.kshlib 31 32################################################################################# 33# 34# __stc_assertion_start 35# 36# ID: zfs_acl_chmod_inherit_004_pos 37# 38# DESCRIPTION: 39# Verify aclinherit=passthrough-x will inherit the 'x' bits while mode request. 40# 41# STRATEGY: 42# 1. Loop super user and non-super user to run the test case. 43# 2. Create basedir and a set of subdirectores and files within it. 44# 3. Set aclinherit=passthrough-x 45# 4. Verify only passthrough-x will inherit the 'x' bits while mode request. 46# 47# TESTABILITY: explicit 48# 49# TEST_AUTOMATION_LEVEL: automated 50# 51# CODING_STATUS: COMPLETED (2009-04-29) 52# 53# __stc_assertion_end 54# 55################################################################################ 56 57verify_runnable "both" 58 59function cleanup 60{ 61 if [[ -d $basedir ]]; then 62 log_must $RM -rf $basedir 63 fi 64} 65 66$ZPOOL upgrade -v | $GREP "passthrough\-x aclinherit support" > /dev/null 2>&1 67if (( $? != 0 )) ; then 68 log_unsupported "passthrough-x aclinherit not supported." 69fi 70 71log_assert "Verify aclinherit=passthrough-x will inherit the 'x' bits while mode request." 72log_onexit cleanup 73 74set -A aces "owner@:read_data/write_data/add_subdirectory/append_data/execute:dir_inherit/inherit_only:allow" \ 75 "owner@:read_data/write_data/add_subdirectory/append_data/execute::allow" \ 76 "group@:add_subdirectory/append_data/execute:dir_inherit/inherit_only:allow" \ 77 "group@:add_subdirectory/append_data/execute::allow" \ 78 "everyone@:add_subdirectory/append_data/execute:dir_inherit/inherit_only:allow" \ 79 "everyone@:add_subdirectory/append_data/execute::allow" \ 80 "owner@:read_data/write_data/add_subdirectory/append_data/execute:file_inherit/inherit_only:allow" \ 81 "group@:read_data/add_subdirectory/append_data/execute:file_inherit/inherit_only:allow" \ 82 "everyone@:read_data/add_subdirectory/append_data/execute:file_inherit/inherit_only:allow" 83 84# Defile the based directory and file 85basedir=$TESTDIR/basedir 86 87test_requires ZFS_ACL 88 89# 90# According to inherited flag, verify subdirectories and files within it has 91# correct inherited access control. 92# 93function verify_inherit # <object> 94{ 95 typeset obj=$1 96 97 # Define the files and directories will be created after chmod 98 ndir1=$obj/ndir1; ndir2=$ndir1/ndir2 99 nfile1=$ndir1/nfile1.c; nfile2=$ndir1/nfile2 100 101 log_must usr_exec $MKDIR -p $ndir1 102 103 typeset -i i=0 104 while (( i < ${#aces[*]} )) ; do 105 if (( i < 6 )) ; then 106 log_must usr_exec $CHMOD A$i=${aces[i]} $ndir1 107 else 108 log_must usr_exec $CHMOD A$i+${aces[i]} $ndir1 109 fi 110 (( i = i + 1 )) 111 done 112 log_must usr_exec $MKDIR -p $ndir2 113 log_must usr_exec $TOUCH $nfile1 114 115 $CAT > $nfile1 <<EOF 116#include <stdlib.h> 117#include <stdio.h> 118int main() 119{ return 0; } 120EOF 121 122 mode=$(get_mode $ndir2) 123 if [[ $mode != "drwx--x--x"* ]] ; then 124 log_fail "Unexpect mode of $ndir2, expect: drwx--x--x, current: $mode" 125 fi 126 127 mode=$(get_mode $nfile1) 128 if [[ $mode != "-rw-r--r--"* ]] ; then 129 log_fail "Unexpect mode of $nfile1, expect: -rw-r--r--, current: $mode" 130 fi 131 132 if [[ -x /usr/sfw/bin/gcc ]] ; then 133 log_must /usr/sfw/bin/gcc -o $nfile2 $nfile1 134 mode=$(get_mode $nfile2) 135 if [[ $mode != "-rwxr-xr-x"* ]] ; then 136 log_fail "Unexpect mode of $nfile2, expect: -rwxr-xr-x, current: $mode" 137 fi 138 fi 139} 140 141# 142# Set aclmode=passthrough to make sure 143# the acl will not change during chmod. 144# A general testing should verify the combination of 145# aclmode/aclinherit works well, 146# here we just simple test them separately. 147# 148 149log_must $ZFS set aclmode=passthrough $TESTPOOL/$TESTFS 150log_must $ZFS set aclinherit=passthrough-x $TESTPOOL/$TESTFS 151 152for user in root $ZFS_ACL_STAFF1; do 153 log_must set_cur_usr $user 154 155 verify_inherit $basedir 156 157 cleanup 158done 159 160log_pass "Verify aclinherit=passthrough-x will inherit the 'x' bits while mode request." 161