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