xref: /illumos-gate/usr/src/test/smbclient-tests/tests/smbfs/xattr/tp_xattr_005.ksh (revision 96c8483a3fb53529bbf410957b0ad69cfb5d9229)
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 2010 Sun Microsystems, Inc.  All rights reserved.
25#
26
27#
28# ID:  xattr_005
29#
30# DESCRIPTION:
31# Verify special . and .. dirs work as expected for xattrs
32#
33# STRATEGY:
34#	1. Create a file and an xattr on that file
35#	2. List the . directory, verifying the output
36#	3. Verify we're unable to list the ../ directory
37#
38
39. $STF_SUITE/include/libtest.ksh
40
41tc_id=xattr_005
42tc_desc="Verify special . and .. dirs work as expected for xattrs"
43print_test_case $tc_id - $tc_desc
44
45if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
46	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
47    set -x
48fi
49
50server=$(server_name) || return
51
52testdir_init $TDIR
53smbmount_clean $TMNT
54smbmount_init $TMNT
55
56cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $TMNT"
57cti_execute -i '' FAIL $cmd
58if [[ $? != 0 ]]; then
59	cti_fail "FAIL: smbmount can't mount the public share unexpectedly"
60	return
61else
62	cti_report "PASS: smbmount can mount the public share as expected"
63fi
64
65smbmount_getmntopts $TMNT |grep /xattr/ >/dev/null
66if [[ $? != 0 ]]; then
67	smbmount_clean $TMNT
68	cti_unsupported "UNSUPPORTED (no xattr in this mount)"
69	return
70fi
71
72# create a file, and an xattr on it
73
74cti_execute_cmd "touch $TMNT/test_file"
75create_xattr $TMNT/test_file passwd /etc/passwd
76
77# listing the directory . should show one file
78
79OUTPUT=$(runat $TMNT/test_file ls |grep -v SUNWattr_)
80if [ "$OUTPUT" != "passwd" ]
81then
82        cti_fail "Listing the . directory doesn't show \"passwd\" as expected."
83fi
84# list the directory . long form
85
86cti_execute_cmd "runat $TMNT/test_file ls -a . |grep -v SUNWattr_"
87cp cti_stdout output
88
89# create a file that should be the same as the command above
90create_expected_output expected-output  .  ..   passwd
91# compare them
92
93cti_execute_cmd "diff output expected-output"
94if [[ $? != 0 ]]; then
95        cti_fail "FAIL: special . dirs do not work as expected for xattrs"
96	cti_reportfile output
97        return
98else
99        cti_report "PASS: special . dirs work as expected for xattrs"
100fi
101
102# list the directory .. expecting one file
103
104OUTPUT=$(runat $TMNT/test_file ls ..)
105if [ $? != 0 ]
106then
107	cti_fail "runat test file ls .. failed with return val =$? unexpectedly"
108	return
109fi
110
111if [ "$OUTPUT" != ".." ]
112then
113	cti_fail "Listing the .. directory doesn't show \"..\" as expected"
114	return
115fi
116
117# verify we can't list ../
118
119cti_execute_cmd "runat $TMNT/test_file ls  ../"
120if [[ $? == 0 ]]; then
121	cti_fail "FAIL: can be able to list the ../ directory unexpectedly"
122	return
123else
124	cti_report "PASS: unable to list the ../ directory as expected"
125fi
126
127cti_execute_cmd "rm output expected-output"
128cti_execute_cmd "rm -rf $TDIR/*"
129
130smbmount_clean $TMNT
131cti_pass "$tc_id: PASS"
132