1#!/bin/ksh -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# Copyright (c) 2012 by Marcelo Leal. All rights reserved. 28# 29 30. $STF_SUITE/tests/functional/acl/acl_common.kshlib 31 32# 33# DESCRIPTION: 34# Verify that '$TAR' command with -p@ option supports to archive ZFS ACLs 35# & xattrs 36# 37# STRATEGY: 38# 1. Create file and directory in zfs filesystem 39# 2. Add new ACE in ACL of file and directory 40# 3. Create xattr of the file and directory 41# 4. Use $TAR cf@ to archive file and directory 42# 5. Use $TAR xf@ to extract the archive file 43# 6. Verify that the restored ACLs & xttrs of file and directory identify 44# with the origional ones. 45# 46 47verify_runnable "both" 48 49function cleanup 50{ 51 if datasetexists $TESTPOOL/$TESTFS1; then 52 log_must $ZFS destroy -f $TESTPOOL/$TESTFS1 53 fi 54 55 (( ${#cwd} != 0 )) && cd $cwd 56 [[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1 57 [[ -d $TESTDIR/ ]] && log_must $RM -rf $TESTDIR/* 58} 59 60log_assert "Verify that '$TAR' command supports to archive ZFS ACLs & xattrs." 61 62log_onexit cleanup 63 64set -A ops " A+user:other1:add_file:allow" "A+everyone@:execute:allow" "a-x" \ 65 "777" 66mytestfile=/kernel/drv/zfs 67 68TARFILE=tarfile.$$.tar 69cwd=$PWD 70 71log_note "Create second zfs file system to restore the tar archive." 72log_must $ZFS create $TESTPOOL/$TESTFS1 73[[ ! -d $TESTDIR1 ]] && \ 74 log_must $MKDIR -p $TESTDIR1 75log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1 76 77log_note "Create a file: $testfile, and directory: $testdir, in zfs " \ 78 "filesystem. And prepare for there xattr files." 79 80for user in root $ZFS_ACL_STAFF1; do 81 # Set the current user 82 log_must set_cur_usr $user 83 84 # Create source object and target directroy 85 cd $TESTDIR 86 log_must usr_exec $TOUCH $testfile 87 log_must usr_exec $MKDIR $testdir 88 89 log_must usr_exec $RUNAT $testfile $CP $mytestfile attr.0 90 log_must usr_exec $RUNAT $testdir $CP $mytestfile attr.0 91 92 # Add the new ACE on the head. 93 log_note "Change the ACLs of file and directory with " \ 94 "'$CHMOD ${ops[0]}'." 95 log_must usr_exec $CHMOD ${ops[0]} $testfile 96 log_must usr_exec $CHMOD ${ops[0]} $testdir 97 98 log_note "Archive the file and directory." 99 log_must $TAR cpf@ $TARFILE ${testfile#$TESTDIR/} ${testdir#$TESTDIR/} 100 101 log_note "Restore the tar archive." 102 cd $TESTDIR1 103 log_must $TAR xpf@ $TESTDIR/$TARFILE 104 105 log_note "Verify the ACLs of restored file/directory have no changes." 106 for obj in $testfile $testdir; do 107 log_must compare_modes $obj $TESTDIR1/${obj##*/} 108 log_must compare_acls $obj $TESTDIR1/${obj##*/} 109 log_must compare_xattrs $obj $TESTDIR1/${obj##*/} 110 done 111 112 log_must $RM -rf $TESTDIR/* $TESTDIR1/* 113done 114 115log_pass "'$TAR' command succeeds to support ZFS ACLs." 116