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