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