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# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23# Use is subject to license terms. 24 25. $STF_SUITE/include/libtest.kshlib 26. $STF_SUITE/tests/xattr/xattr_common.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: xattr_008_pos 33# 34# DESCRIPTION: 35# We verify that the special . and .. dirs work as expected for xattrs. 36# 37# STRATEGY: 38# 1. Create a file and an xattr on that file 39# 2. List the . directory, verifying the output 40# 3. Verify we're unable to list the ../ directory 41# 42# TESTABILITY: explicit 43# 44# TEST_AUTOMATION_LEVEL: automated 45# 46# CODING_STATUS: COMPLETED (2006-12-05) 47# 48# __stc_assertion_end 49# 50################################################################################ 51 52function cleanup { 53 typeset file 54 55 for file in $TMPDIR/output.${TESTCASE_ID} $TMPDIR/expected-output.${TESTCASE_ID} \ 56 $TESTDIR/myfile.${TESTCASE_ID} ; do 57 log_must $RM -f $file 58 done 59} 60 61log_assert "special . and .. dirs work as expected for xattrs" 62log_onexit cleanup 63 64test_requires RUNAT 65 66# create a file, and an xattr on it 67log_must $TOUCH $TESTDIR/myfile.${TESTCASE_ID} 68create_xattr $TESTDIR/myfile.${TESTCASE_ID} passwd /etc/passwd 69 70if check_version "5.10" 71then 72 # listing the directory . should show one file 73 OUTPUT=$($RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS .) 74 if [ "$OUTPUT" != "passwd" ] 75 then 76 log_fail "Listing the . directory doesn't show \"passwd\" as expected." 77 fi 78 # list the directory . long form 79 log_must eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS -a . > $TMPDIR/output.${TESTCASE_ID}" 80 # create a file that should be the same as the command above 81 create_expected_output $TMPDIR/expected-output.${TESTCASE_ID} . .. passwd 82 # compare them 83 log_must $DIFF $TMPDIR/output.${TESTCASE_ID} $TMPDIR/expected-output.${TESTCASE_ID} 84else 85 # listing the directory . 86 log_must eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS . > $TMPDIR/output.${TESTCASE_ID}" 87 create_expected_output $TMPDIR/expected-output.${TESTCASE_ID} \ 88 SUNWattr_ro SUNWattr_rw passwd 89 log_must $DIFF $TMPDIR/output.${TESTCASE_ID} $TMPDIR/expected-output.${TESTCASE_ID} 90 # list the directory . long form 91 log_must eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS -a . > $TMPDIR/output.${TESTCASE_ID}" 92 create_expected_output $TMPDIR/expected-output.${TESTCASE_ID} . .. \ 93 SUNWattr_ro SUNWattr_rw passwd 94 log_must $DIFF $TMPDIR/output.${TESTCASE_ID} $TMPDIR/expected-output.${TESTCASE_ID} 95fi 96 97# list the directory .. expecting one file 98OUTPUT=$($RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS ..) 99if [ "$OUTPUT" != ".." ] 100then 101 log_fail "Listing the .. directory doesn't show \"..\" as expected." 102fi 103 104# verify we can't list ../ 105log_mustnot eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $LS ../ > /dev/null 2>&1" 106 107log_pass "special . and .. dirs work as expected for xattrs" 108