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# 24# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 29# Copyright 2016 Nexenta Systems, Inc. 30# Copyright 2023 RackTop Systems, Inc. 31# 32 33. $STF_SUITE/tests/functional/acl/acl_common.kshlib 34 35# DESCRIPTION: 36# Verify aclinherit=passthrough-x will inherit the execute permission only if 37# file creation mode requests it. 38# 39# STRATEGY: 40# 1. Use both super user and non-super user to run the test case. 41# 2. Set aclinherit=passthrough-x 42# 3. Create basedir and a set of files, one with 644 and one with 755 mode. 43# 4. Verify that execute permission is inherited only if file creation mode 44# requests them. 45 46verify_runnable "both" 47 48function cleanup 49{ 50 [[ -d $basedir ]] && log_must rm -rf $basedir 51} 52 53log_assert "aclinherit=passthrough-x should inherit the execute permission" \ 54 "only if file creation mode requests it" 55log_onexit cleanup 56 57set -A aces \ 58 "owner@:rwxpC:f:allow" \ 59 "group@:rxp:f:allow" \ 60 "everyone@:rxp:f:allow" 61 62typeset basedir="$TESTDIR/basedir" 63typeset nfile1="$basedir/nfile1" nfile2="$basedir/nfile2" 64 65function check_execute_bit 66{ 67 typeset ace 68 typeset file=$1 69 typeset -i i=0 70 71 while ((i < 6)); do 72 ace=$(get_ACE $file $i) 73 if [[ "$ace" == *"execute"* ]]; then 74 return 0 75 fi 76 ((i = i + 1)) 77 done 78 79 return 1 80} 81 82function verify_inherit 83{ 84 typeset -i i=0 85 86 log_must usr_exec mkdir $basedir 87 88 # Modify owner@, group@ and everyone@ ACEs to include execute 89 # permission (see above), and make them file-inheritable 90 while ((i < ${#aces[*]})); do 91 log_must usr_exec chmod A$i=${aces[i]} $basedir 92 ((i = i + 1)) 93 done 94 95 # Create file with 644 mode 96 log_must usr_exec touch $nfile1 97 # Check that execute permission wasn't inherited 98 log_mustnot check_execute_bit $nfile1 99 100 # Use cp(1) to copy over /usr/bin/true 101 log_must usr_exec cp /usr/bin/true $nfile2 102 # Check that execute permission was inherited 103 log_must check_execute_bit $nfile2 104} 105 106log_must zfs set aclmode=passthrough $TESTPOOL/$TESTFS 107log_must zfs set aclinherit=passthrough-x $TESTPOOL/$TESTFS 108 109for user in root $ZFS_ACL_STAFF1; do 110 log_must set_cur_usr $user 111 verify_inherit 112 cleanup 113done 114 115log_pass "aclinherit=passthrough-x should inherit the execute permission" \ 116 "only if file creation mode requests it" 117