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# $FreeBSD$ 24 25# 26# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zfs_acl_cpio_001_pos.ksh 1.2 07/01/09 SMI" 30# 31. $STF_SUITE/tests/acl/acl_common.kshlib 32 33################################################################################ 34# 35# __stc_assertion_start 36# 37# ID: zfs_acl_cpio_001_pos 38# 39# DESCRIPTION: 40# Verify that '$CPIO' command with -P option supports to archive ZFS ACLs 41# 42# STRATEGY: 43# 1. Create file and directory in zfs filesystem 44# 2. Add new ACE in ACL or change mode of file and directory 45# 3. Use $CPIO to archive file and directory 46# 4. Extract the archive file 47# 5. Verify that the restored ACLs of file and directory identify 48# with the origional ones. 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2005-09-26) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60verify_runnable "both" 61 62function cleanup 63{ 64 if datasetexists $TESTPOOL/$TESTFS1; then 65 log_must $ZFS destroy -f $TESTPOOL/$TESTFS1 66 fi 67 if (( ${#orig_dir} != 0 )); then 68 cd $orig_dir 69 fi 70 [[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1 71 [[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/* 72} 73 74log_assert "Verify that '$CPIO' command supports to archive ZFS ACLs." 75log_onexit cleanup 76 77test_requires ZFS_ACL 78 79set -A ops "A+everyone@:execute:allow" \ 80 "A3+user:$ZFS_ACL_OTHER1:write_data:deny" \ 81 "A5+group:$ZFS_ACL_OTHER_GROUP:read_data:deny" \ 82 "A0+user:$ZFS_ACL_OTHER1:write_data:deny" \ 83 "A1=user:$ZFS_ACL_STAFF1:write_data:deny" \ 84 "A5=group:$ZFS_ACL_STAFF_GROUP:write_data:deny" 85 86log_note "Create second zfs file system to restore the cpio archive." 87log_must $ZFS create $TESTPOOL/$TESTFS1 88log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1 89log_must $CHMOD 777 $TESTDIR1 90 91# Define test fine and record the original directory. 92CPIOFILE=cpiofile.${TESTCASE_ID} 93file=$TESTFILE0 94dir=dir.${TESTCASE_ID} 95orig_dir=$PWD 96 97typeset user 98for user in root $ZFS_ACL_STAFF1; do 99 # Set the current user 100 log_must set_cur_usr $user 101 102 typeset -i i=0 103 while (( i < ${#ops[*]} )); do 104 log_note "Create file $file and directory $dir " \ 105 "in zfs filesystem. " 106 cd $TESTDIR 107 log_must usr_exec $TOUCH $file 108 log_must usr_exec $MKDIR $dir 109 110 log_note "Change the ACLs of file and directory with " \ 111 "'$CHMOD ${ops[i]}'." 112 for obj in $file $dir; do 113 log_must usr_exec $CHMOD ${ops[i]} $obj 114 done 115 116 log_note "Archive the file and directory." 117 cd $TESTDIR 118 log_must eval "usr_exec $LS | " \ 119 "usr_exec $CPIO -ocP -O $CPIOFILE > /dev/null 2>&1" 120 121 log_note "Restore the cpio archive." 122 log_must usr_exec $MV $CPIOFILE $TESTDIR1 123 cd $TESTDIR1 124 log_must eval "usr_exec $CAT $CPIOFILE | " \ 125 "usr_exec $CPIO -icP > /dev/null 2>&1" 126 127 log_note "Verify that the ACLs of restored file/directory " \ 128 "have no changes." 129 for obj in $file $dir; do 130 log_must compare_modes $TESTDIR/$obj $TESTDIR1/$obj 131 log_must compare_acls $TESTDIR/$obj $TESTDIR1/$obj 132 done 133 134 log_must usr_exec $RM -rf $TESTDIR/* $TESTDIR1/* 135 136 (( i = i + 1 )) 137 done 138done 139 140log_pass "'$CPIO' command succeeds to support ZFS ACLs." 141