xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/acl/trivial/zfs_acl_find_002_neg.ksh (revision b6805bf78d2bbbeeaea8909a05623587b42d58b3)
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
28. $STF_SUITE/tests/functional/acl/acl_common.kshlib
29
30#
31# DESCRIPTION:
32#	Verifies ability to find files with attribute with -xattr flag and using
33#	"-exec runat ls".
34#
35# STRATEGY:
36#	1. In directory A, create several files and add attribute files for them
37#	2. Delete all the attribute files.
38#	2. Verify all the specified files can not be found with '-xattr',
39#	3. Verify all the attribute files can not be found with '-exec runat ls'
40#
41
42verify_runnable "both"
43
44log_assert "verifies -xattr doesn't include files without " \
45		"attribute and using '-exec runat ls'"
46log_onexit cleanup
47
48for user in root $ZFS_ACL_STAFF1; do
49	log_must set_cur_usr $user
50
51	log_must create_files $TESTDIR
52
53	initfiles=$($LS -R $INI_DIR/*)
54	typeset -i i=0
55	while (( i < NUM_FILE )); do
56		f=$(getitem $i $initfiles)
57		usr_exec $RUNAT $f $RM attribute*
58		(( i += 1 ))
59	done
60
61	i=0
62	while (( i < NUM_FILE )); do
63		f=$(getitem $i $initfiles)
64		ff=$(usr_exec $FIND $INI_DIR -type f -name ${f##*/} \
65			-xattr -print)
66		if [[ $ff == $f ]]; then
67			log_fail "find not containing attribute should fail."
68		fi
69
70		typeset -i j=0
71		while (( j < NUM_ATTR )); do
72			fa=$(usr_exec $FIND $INI_DIR -type f -name ${f##*/} \
73				-xattr -exec $RUNAT {} $LS attribute.$j \\\;)
74			if [[ $fa == attribute.$j ]]; then
75				log_fail "find file attribute should fail."
76			fi
77			(( j += 1 ))
78		done
79		log_note "Failed to find $f and its attribute file as expected."
80
81		(( i += 1 ))
82	done
83
84	log_must cleanup
85done
86
87log_pass "find files which have no attrabute files with -xattr passed."
88