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_tar_002_pos 34# 35# DESCRIPTION: 36# Verify that '$TAR' command with -p@ option supports to archive ZFS ACLs 37# & xattrs 38# 39# STRATEGY: 40# 1. Create file and directory in zfs filesystem 41# 2. Add new ACE in ACL of file and directory 42# 3. Create xattr of the file and directory 43# 4. Use $TAR cf@ to archive file and directory 44# 5. Use $TAR xf@ to extract the archive file 45# 6. Verify that the restored ACLs & xttrs of file and directory identify 46# with the origional ones. 47# 48# TESTABILITY: explicit 49# 50# TEST_AUTOMATION_LEVEL: automated 51# 52# CODING_STATUS: COMPLETED (2005-12-16) 53# 54# __stc_assertion_end 55# 56################################################################################ 57 58verify_runnable "both" 59 60function cleanup 61{ 62 if datasetexists $TESTPOOL/$TESTFS1; then 63 log_must $ZFS destroy -f $TESTPOOL/$TESTFS1 64 fi 65 66 (( ${#cwd} != 0 )) && cd $cwd 67 [[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1 68 [[ -d $TESTDIR/ ]] && log_must $RM -rf $TESTDIR/* 69} 70 71log_assert "Verify that '$TAR' 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" "a-x" "777" 77MYTESTFILE=$STF_SUITE/include/default.cfg 78 79TARFILE=tarfile.${TESTCASE_ID}.tar 80cwd=$PWD 81 82log_note "Create second zfs file system to restore the tar archive." 83log_must $ZFS create $TESTPOOL/$TESTFS1 84[[ ! -d $TESTDIR1 ]] && \ 85 log_must $MKDIR -p $TESTDIR1 86log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1 87 88log_note "Create a file: $testfile, and directory: $testdir, in zfs filesystem. " \ 89 "And prepare for there xattr files." 90 91for user in root $ZFS_ACL_STAFF1; do 92 # Set the current user 93 log_must set_cur_usr $user 94 95 # Create source object and target directroy 96 cd $TESTDIR 97 log_must usr_exec $TOUCH $testfile 98 log_must usr_exec $MKDIR $testdir 99 100 log_must usr_exec $RUNAT $testfile $CP $MYTESTFILE attr.0 101 log_must usr_exec $RUNAT $testdir $CP $MYTESTFILE attr.0 102 103 # Add the new ACE on the head. 104 log_note "Change the ACLs of file and directory with " \ 105 "'$CHMOD ${ops[0]}'." 106 log_must usr_exec $CHMOD ${ops[0]} $testfile 107 log_must usr_exec $CHMOD ${ops[0]} $testdir 108 109 log_note "Archive the file and directory." 110 log_must $TAR cpf@ $TARFILE ${testfile#$TESTDIR/} ${testdir#$TESTDIR/} 111 112 log_note "Restore the tar archive." 113 cd $TESTDIR1 114 log_must $TAR xpf@ $TESTDIR/$TARFILE 115 116 log_note "Verify the ACLs of restored file/directory have no changes." 117 for obj in $testfile $testdir; do 118 log_must compare_modes $obj $TESTDIR1/${obj##*/} 119 log_must compare_acls $obj $TESTDIR1/${obj##*/} 120 log_must compare_xattrs $obj $TESTDIR1/${obj##*/} 121 done 122 123 log_must $RM -rf $TESTDIR/* $TESTDIR1/* 124done 125 126log_pass "'$TAR' command succeeds to support ZFS ACLs." 127