1689N/A#!/bin/ksh -p
1689N/A#
1689N/A# CDDL HEADER START
1689N/A#
1689N/A# The contents of this file are subject to the terms of the
1689N/A# Common Development and Distribution License (the "License").
1689N/A# You may not use this file except in compliance with the License.
1689N/A#
1689N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1689N/A# or http://www.opensolaris.org/os/licensing.
1689N/A# See the License for the specific language governing permissions
1689N/A# and limitations under the License.
1689N/A#
1689N/A# When distributing Covered Code, include this CDDL HEADER in each
1689N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1689N/A# If applicable, add the following below this CDDL HEADER, with the
1689N/A# fields enclosed by brackets "[]" replaced with your own identifying
1689N/A# information: Portions Copyright [yyyy] [name of copyright owner]
1689N/A#
1689N/A# CDDL HEADER END
1689N/A#
1689N/A
1689N/A#
1689N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
4114N/A# Use is subject to license terms.
1689N/A#
1689N/A
1689N/A#
2086N/A# Copyright (c) 2016 by Delphix. All rights reserved.
2086N/A#
2086N/A
1689N/A. $STF_SUITE/tests/functional/acl/acl_common.kshlib
1689N/A
1689N/A#
3853N/A# DESCRIPTION:
1689N/A# Verify that '/usr/bin/cp [-p]' supports ZFS ACL
1689N/A#
1689N/A# STRATEGY:
3352N/A# 1. Create file and directory in zfs filesystem
1689N/A# 2. Set special ACE to the file and directory
1689N/A# 3. Copy the file/directory within and across zfs file system
3853N/A# 4. Verify that the ACL of file/directroy is not changed, when you are
1689N/A# inserting an ACL with a user: or group: entry on the top.
1689N/A# (abstractions entry are treated special, since they represent the
1689N/A# traditional permission bit mapping.)
3352N/A#
1689N/A
1689N/Averify_runnable "both"
1689N/A
1689N/Afunction cleanup
1689N/A{
1689N/A if datasetexists $TESTPOOL/$TESTFS1; then
1689N/A log_must zfs destroy -f $TESTPOOL/$TESTFS1
1689N/A fi
1689N/A [[ -d $TESTDIR1 ]] && log_must rm -rf $TESTDIR1
2086N/A [[ -d $TESTDIR ]] && log_must rm -rf $TESTDIR/*
1689N/A}
1689N/A
1689N/Alog_assert "Verify that 'cp [-p]' supports ZFS ACLs."
1689N/Alog_onexit cleanup
1689N/A
1689N/Alog_note "Create the second zfs file system: $TESTPOOL/$TESTFS1."
1689N/Alog_must zfs create $TESTPOOL/$TESTFS1
1689N/Alog_must zfs set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1
1689N/Alog_must zfs set aclmode=passthrough $TESTPOOL/$TESTFS1
1689N/Alog_must chmod 777 $TESTDIR1
1689N/A
1689N/A# Define target directory.
1689N/Adstdir=$TESTDIR1/dstdir.$$
1689N/A
1689N/Afor user in root $ZFS_ACL_STAFF1; do
1689N/A # Set the current user
1689N/A log_must set_cur_usr $user
1689N/A
1689N/A for obj in $testfile $testdir; do
1689N/A # Create source object and target directroy
1689N/A log_must usr_exec touch $testfile
1689N/A log_must usr_exec mkdir $testdir $dstdir
1689N/A
1689N/A # Add the new ACE on the head.
1689N/A log_must usr_exec chmod \
1689N/A A0+user:$ZFS_ACL_OTHER1:read_acl:deny $obj
1689N/A
1689N/A cmd_str="cp -p"
1689N/A [[ -d $obj ]] && cmd_str="cp -rp"
1689N/A log_must usr_exec $cmd_str $obj $dstdir
1689N/A log_must usr_exec $cmd_str $obj $TESTDIR1
1689N/A
1689N/A for dir in $dstdir $TESTDIR1; do
1689N/A log_must compare_modes $obj $dir/${obj##*/}
1689N/A log_must compare_acls $obj $dir/${obj##*/}
1689N/A done
1689N/A
1689N/A # Delete all the test file and directory
1689N/A log_must usr_exec rm -rf $TESTDIR/* $TESTDIR1/*
1689N/A done
1689N/Adone
1689N/A
1689N/Alog_pass "'cp [-p]' succeeds to support ZFS ACLs."
1689N/A