1d583b39bSJohn Wren Kennedy#!/bin/ksh -p 2d583b39bSJohn Wren Kennedy# 3d583b39bSJohn Wren Kennedy# CDDL HEADER START 4d583b39bSJohn Wren Kennedy# 5d583b39bSJohn Wren Kennedy# The contents of this file are subject to the terms of the 6d583b39bSJohn Wren Kennedy# Common Development and Distribution License (the "License"). 7d583b39bSJohn Wren Kennedy# You may not use this file except in compliance with the License. 8d583b39bSJohn Wren Kennedy# 9d583b39bSJohn Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10d583b39bSJohn Wren Kennedy# or http://www.opensolaris.org/os/licensing. 11d583b39bSJohn Wren Kennedy# See the License for the specific language governing permissions 12d583b39bSJohn Wren Kennedy# and limitations under the License. 13d583b39bSJohn Wren Kennedy# 14d583b39bSJohn Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each 15d583b39bSJohn Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16d583b39bSJohn Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the 17d583b39bSJohn Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying 18d583b39bSJohn Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner] 19d583b39bSJohn Wren Kennedy# 20d583b39bSJohn Wren Kennedy# CDDL HEADER END 21d583b39bSJohn Wren Kennedy# 22d583b39bSJohn Wren Kennedy 23d583b39bSJohn Wren Kennedy# 24d583b39bSJohn Wren Kennedy# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25d583b39bSJohn Wren Kennedy# Use is subject to license terms. 26d583b39bSJohn Wren Kennedy# 27d583b39bSJohn Wren Kennedy 281d32ba66SJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved. 29232f5a2eSYuri Pankov# Copyright 2016 Nexenta Systems, Inc. 30*6990962cSToomas Soome# Copyright 2023 RackTop Systems, Inc. 31d583b39bSJohn Wren Kennedy# 32d583b39bSJohn Wren Kennedy 33d583b39bSJohn Wren Kennedy. $STF_SUITE/tests/functional/acl/acl_common.kshlib 34d583b39bSJohn Wren Kennedy 35d583b39bSJohn Wren Kennedy# DESCRIPTION: 36232f5a2eSYuri Pankov# Verify aclinherit=passthrough-x will inherit the execute permission only if 37232f5a2eSYuri Pankov# file creation mode requests it. 38d583b39bSJohn Wren Kennedy# 39d583b39bSJohn Wren Kennedy# STRATEGY: 40232f5a2eSYuri Pankov# 1. Use both super user and non-super user to run the test case. 41232f5a2eSYuri Pankov# 2. Set aclinherit=passthrough-x 42232f5a2eSYuri Pankov# 3. Create basedir and a set of files, one with 644 and one with 755 mode. 43232f5a2eSYuri Pankov# 4. Verify that execute permission is inherited only if file creation mode 44232f5a2eSYuri Pankov# requests them. 45d583b39bSJohn Wren Kennedy 46d583b39bSJohn Wren Kennedyverify_runnable "both" 47d583b39bSJohn Wren Kennedy 48d583b39bSJohn Wren Kennedyfunction cleanup 49d583b39bSJohn Wren Kennedy{ 501d32ba66SJohn Wren Kennedy [[ -d $basedir ]] && log_must rm -rf $basedir 51d583b39bSJohn Wren Kennedy} 52d583b39bSJohn Wren Kennedy 53232f5a2eSYuri Pankovlog_assert "aclinherit=passthrough-x should inherit the execute permission" \ 54232f5a2eSYuri Pankov "only if file creation mode requests it" 55d583b39bSJohn Wren Kennedylog_onexit cleanup 56d583b39bSJohn Wren Kennedy 57d583b39bSJohn Wren Kennedyset -A aces \ 58*6990962cSToomas Soome "owner@:rwxpC:f:allow" \ 59232f5a2eSYuri Pankov "group@:rxp:f:allow" \ 60232f5a2eSYuri Pankov "everyone@:rxp:f:allow" 61d583b39bSJohn Wren Kennedy 62232f5a2eSYuri Pankovtypeset basedir="$TESTDIR/basedir" 63232f5a2eSYuri Pankovtypeset nfile1="$basedir/nfile1" nfile2="$basedir/nfile2" 64d583b39bSJohn Wren Kennedy 65232f5a2eSYuri Pankovfunction check_execute_bit 66d583b39bSJohn Wren Kennedy{ 67232f5a2eSYuri Pankov typeset ace 68232f5a2eSYuri Pankov typeset file=$1 69d583b39bSJohn Wren Kennedy typeset -i i=0 70232f5a2eSYuri Pankov 71232f5a2eSYuri Pankov while ((i < 6)); do 72232f5a2eSYuri Pankov ace=$(get_ACE $file $i) 73232f5a2eSYuri Pankov if [[ "$ace" == *"execute"* ]]; then 74232f5a2eSYuri Pankov return 0 75d583b39bSJohn Wren Kennedy fi 76d583b39bSJohn Wren Kennedy ((i = i + 1)) 77d583b39bSJohn Wren Kennedy done 78d583b39bSJohn Wren Kennedy 79232f5a2eSYuri Pankov return 1 80d583b39bSJohn Wren Kennedy} 81d583b39bSJohn Wren Kennedy 82232f5a2eSYuri Pankovfunction verify_inherit 83232f5a2eSYuri Pankov{ 84232f5a2eSYuri Pankov typeset -i i=0 85232f5a2eSYuri Pankov 861d32ba66SJohn Wren Kennedy log_must usr_exec mkdir $basedir 87232f5a2eSYuri Pankov 88232f5a2eSYuri Pankov # Modify owner@, group@ and everyone@ ACEs to include execute 89232f5a2eSYuri Pankov # permission (see above), and make them file-inheritable 90232f5a2eSYuri Pankov while ((i < ${#aces[*]})); do 911d32ba66SJohn Wren Kennedy log_must usr_exec chmod A$i=${aces[i]} $basedir 92232f5a2eSYuri Pankov ((i = i + 1)) 93232f5a2eSYuri Pankov done 94232f5a2eSYuri Pankov 95232f5a2eSYuri Pankov # Create file with 644 mode 961d32ba66SJohn Wren Kennedy log_must usr_exec touch $nfile1 97232f5a2eSYuri Pankov # Check that execute permission wasn't inherited 98232f5a2eSYuri Pankov log_mustnot check_execute_bit $nfile1 99232f5a2eSYuri Pankov 100232f5a2eSYuri Pankov # Use cp(1) to copy over /usr/bin/true 1011d32ba66SJohn Wren Kennedy log_must usr_exec cp /usr/bin/true $nfile2 102232f5a2eSYuri Pankov # Check that execute permission was inherited 103232f5a2eSYuri Pankov log_must check_execute_bit $nfile2 104232f5a2eSYuri Pankov} 105d583b39bSJohn Wren Kennedy 1061d32ba66SJohn Wren Kennedylog_must zfs set aclmode=passthrough $TESTPOOL/$TESTFS 1071d32ba66SJohn Wren Kennedylog_must zfs set aclinherit=passthrough-x $TESTPOOL/$TESTFS 108d583b39bSJohn Wren Kennedy 109d583b39bSJohn Wren Kennedyfor user in root $ZFS_ACL_STAFF1; do 110d583b39bSJohn Wren Kennedy log_must set_cur_usr $user 111232f5a2eSYuri Pankov verify_inherit 112d583b39bSJohn Wren Kennedy cleanup 113d583b39bSJohn Wren Kennedydone 114d583b39bSJohn Wren Kennedy 115232f5a2eSYuri Pankovlog_pass "aclinherit=passthrough-x should inherit the execute permission" \ 116232f5a2eSYuri Pankov "only if file creation mode requests it" 117