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. $STF_SUITE/tests/functional/acl/acl_common.kshlib 30 31# 32# DESCRIPTION: 33# Verify that '$CPIO' command with -P option supports to archive ZFS ACLs 34# 35# STRATEGY: 36# 1. Create file and directory in zfs filesystem 37# 2. Add new ACE in ACL or change mode of file and directory 38# 3. Use $CPIO to archive file and directory 39# 4. Extract the archive file 40# 5. Verify that the restored ACLs of file and directory identify 41# with the origional ones. 42# 43 44verify_runnable "both" 45 46function cleanup 47{ 48 if datasetexists $TESTPOOL/$TESTFS1; then 49 log_must $ZFS destroy -f $TESTPOOL/$TESTFS1 50 fi 51 if (( ${#orig_dir} != 0 )); then 52 cd $orig_dir 53 fi 54 [[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1 55 [[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/* 56} 57 58log_assert "Verify that '$CPIO' command supports to archive ZFS ACLs." 59log_onexit cleanup 60 61set -A ops "A+user:$ZFS_ACL_OTHER1:execute:allow" \ 62 "A3+user:$ZFS_ACL_OTHER1:write_data:deny" \ 63 "A0+user:$ZFS_ACL_OTHER1:write_data:deny" \ 64 "A3+group:$ZFS_ACL_OTHER_GROUP:read_data:deny" \ 65 "A1=user:$ZFS_ACL_STAFF1:write_data:deny" \ 66 "A1=group:$ZFS_ACL_STAFF_GROUP:write_data:deny" 67 68log_note "Create second zfs file system to restore the cpio archive." 69log_must $ZFS create $TESTPOOL/$TESTFS1 70log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1 71log_must $CHMOD 777 $TESTDIR1 72 73# Define test fine and record the original directory. 74CPIOFILE=cpiofile.$$ 75file=$TESTFILE0 76dir=dir.$$ 77orig_dir=$PWD 78 79typeset user 80for user in root $ZFS_ACL_STAFF1; do 81 # Set the current user 82 log_must set_cur_usr $user 83 84 typeset -i i=0 85 while (( i < ${#ops[*]} )); do 86 log_note "Create file $file and directory $dir " \ 87 "in zfs filesystem. " 88 cd $TESTDIR 89 log_must usr_exec $TOUCH $file 90 log_must usr_exec $MKDIR $dir 91 92 log_note "Change the ACLs of file and directory with " \ 93 "'$CHMOD ${ops[i]}'." 94 for obj in $file $dir; do 95 log_must usr_exec $CHMOD ${ops[i]} $obj 96 done 97 98 log_note "Archive the file and directory." 99 cd $TESTDIR 100 log_must eval "usr_exec $LS | " \ 101 "usr_exec $CPIO -ocP -O $CPIOFILE > /dev/null 2>&1" 102 103 log_note "Restore the cpio archive." 104 log_must usr_exec $MV $CPIOFILE $TESTDIR1 105 cd $TESTDIR1 106 log_must eval "usr_exec $CAT $CPIOFILE | " \ 107 "usr_exec $CPIO -icP > /dev/null 2>&1" 108 109 log_note "Verify that the ACLs of restored file/directory " \ 110 "have no changes." 111 for obj in $file $dir; do 112 log_must compare_modes $TESTDIR/$obj $TESTDIR1/$obj 113 log_must compare_acls $TESTDIR/$obj $TESTDIR1/$obj 114 done 115 116 log_must usr_exec $RM -rf $TESTDIR/* $TESTDIR1/* 117 118 (( i = i + 1 )) 119 done 120done 121 122log_pass "'$CPIO' command succeeds to support ZFS ACLs." 123