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_cp_003_neg.ksh 1.2 07/01/09 SMI" 30# 31 32. $STF_SUITE/tests/acl/acl_common.kshlib 33 34################################################################################# 35# 36# __stc_assertion_start 37# 38# ID: zfs_acl_cp_003_neg 39# 40# DESCRIPTION: 41# Verifies that cp will not be able to include file attribute when 42# attribute is unreadable (unless the user is root) 43# 44# STRATEGY: 45# 1. In directory A, create several files and add attribute files for them 46# 2. chmod all files'the attribute files to '000'. 47# 3. Implement 'cp -@p' to files. 48# 4. Verify attribute files are not existing for non-root user. 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2006-06-01) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60verify_runnable "both" 61 62log_assert "Verifies that cp won't be able to include file attribute when " \ 63 "attribute is unreadable (except root)" 64log_onexit cleanup 65 66test_requires RUNAT ZFS_ACL ZFS_XATTR 67 68function test_unreadable_attr 69{ 70 typeset initfiles=$($LS -R $INI_DIR/*) 71 72 typeset -i i=0 73 while (( i < NUM_FILE )); do 74 typeset f=$(getitem $i $initfiles) 75 typeset -i j=0 76 while (( j < NUM_ATTR )); do 77 # chmod all the attribute files to '000'. 78 usr_exec $RUNAT $f $CHMOD 000 attribute.$j 79 80 (( j += 1 )) 81 done 82 83 # 84 # Implement 'cp -@p' to the file whose attribute files 85 # models are '000'. 86 # 87 usr_exec $CP -@p $f $TST_DIR > /dev/null 2>&1 88 89 typeset testfiles=$($LS -R $TST_DIR/*) 90 typeset tf=$(getitem $i $testfiles) 91 typeset ls_attr=$(usr_exec $LS -@ $tf | \ 92 $AWK '{print substr($1, 11, 1)}') 93 94 case $ZFS_ACL_CUR_USER in 95 root) 96 case $ls_attr in 97 @) 98 log_note "SUCCESS: root enable to cp attribute"\ 99 "when attribute files is unreadable" 100 break ;; 101 *) 102 log_fail "root should enable to cp attribute " \ 103 "when attribute files is unreadable" 104 break ;; 105 esac 106 ;; 107 $ZFS_ACL_STAFF1) 108 case $ls_attr in 109 @) 110 log_fail "non-root shouldn't enable to cp " \ 111 "attribute when attribute files is " \ 112 "unreadable." 113 break ;; 114 *) 115 log_note "SUCCESS: non-root doesn't enable to "\ 116 "cp attribute when attribute files is "\ 117 "unreadable." 118 break ;; 119 esac 120 ;; 121 *) 122 esac 123 124 125 (( i += 1 )) 126 done 127} 128 129for user in root $ZFS_ACL_STAFF1; do 130 log_must set_cur_usr $user 131 132 log_must create_files $TESTDIR 133 test_unreadable_attr 134 135 log_must cleanup 136done 137 138log_pass "'cp -@p' won't include file attribute passed." 139