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_tar_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_tar_001_pos 38# 39# DESCRIPTION: 40# Verify that '$TAR' 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 of file and directory 45# 3. Use $TAR 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 68 (( ${#cwd} != 0 )) && cd $cwd 69 [[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1 70 [[ -d $TESTDIR/ ]] && log_must $RM -rf $TESTDIR/* 71} 72 73log_assert "Verify that '$TAR' command supports to archive ZFS ACLs." 74log_onexit cleanup 75 76test_requires ZFS_ACL 77 78set -A ops " A+everyone@:execute:allow" "a-x" "777" 79 80TARFILE=tarfile.${TESTCASE_ID}.tar 81file=$TESTFILE0 82dir=dir.${TESTCASE_ID} 83cwd=$PWD 84 85log_note "Create second zfs file system to restore the tar archive." 86log_must $ZFS create $TESTPOOL/$TESTFS1 87[[ ! -d $TESTDIR1 ]] && \ 88 log_must $MKDIR -p $TESTDIR1 89log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1 90 91log_note "Create a file: $file, and directory: $dir, in zfs filesystem. " 92cd $TESTDIR 93log_must $TOUCH $file 94log_must $MKDIR $dir 95 96typeset -i i=0 97while (( i < ${#ops[*]} )) 98do 99 log_note "Change the ACLs of file and directory with " \ 100 "'$CHMOD ${ops[i]}'." 101 cd $TESTDIR 102 for obj in $file $dir; do 103 log_must $CHMOD ${ops[i]} $obj 104 done 105 log_note "Archive the file and directory." 106 log_must $TAR cpf $TARFILE $file $dir 107 108 log_note "Restore the tar archive." 109 log_must $MV $TARFILE $TESTDIR1 110 cd $TESTDIR1 111 log_must $TAR xpf $TARFILE 112 113 log_note "Verify the ACLs of restored file/directory have no changes." 114 for obj in $file $dir; do 115 log_must compare_modes $TESTDIR/$obj $TESTDIR1/$obj 116 log_must compare_acls $TESTDIR/$obj $TESTDIR1/$obj 117 done 118 119 log_must $RM -rf $TESTDIR1/* 120 121 (( i = i + 1 )) 122done 123 124log_pass "'$TAR' command succeeds to support ZFS ACLs." 125