1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
#
#
# ID: xattr_008
#
# DESCRIPTION:
# Verify basic applications work with xattrs: cpio cp find mv pax tar
#
# STRATEGY:
# 1. For each application
# 2. Create an xattr and archive/move/copy/find files with xattr support
# 3. Also check that when appropriate flag is not used, the xattr
# doesn't get copied
#
. $STF_SUITE/include/libtest.ksh
tc_id=xattr_008
tc_desc="Verify basic applications work with xattrs: cpio cp find mv pax tar"
print_test_case $tc_id - $tc_desc
if [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
set -x
fi
server=$(server_name) || return
CDIR=$(pwd)
testdir_init $TDIR
smbmount_clean $TMNT
smbmount_init $TMNT
cmd="mount -F smbfs //$TUSER:$TPASS@$server/public $TMNT"
cti_execute -i '' FAIL $cmd
if [[ $? != 0 ]]; then
cti_fail "FAIL: smbmount can't mount the public share unexpectedly"
return
else
cti_report "PASS: smbmount can mount the public share as expected"
fi
smbmount_getmntopts $TMNT |grep /xattr/ >/dev/null
if [[ $? != 0 ]]; then
smbmount_clean $TMNT
cti_unsupported "UNSUPPORTED (no xattr in this mount)"
return
fi
# Create a file, and set an xattr on it. This file is used in several of the
# test scenarios below.
cti_execute_cmd "touch $TMNT/test_file"
create_xattr $TMNT/test_file passwd /etc/passwd
# For the archive applications below (tar, cpio, pax)
# we create two archives, one with xattrs, one without
# and try various cpio options extracting the archives
# with and without xattr support, checking for correct behaviour
cpio_xattr=$CDIR/xattr.cpio
cpio_noxattr=$CDIR/noxattr.cpio
cti_report "Checking cpio"
cti_execute_cmd "touch $TMNT/cpio_test"
create_xattr $TMNT/cpio_test passwd /etc/passwd
cti_execute_cmd "echo cpio_test| (cd $TMNT; cpio -oc@ -O $cpio_xattr)"
cti_execute_cmd "echo cpio_test| (cd $TMNT; cpio -oc -O $cpio_noxattr)"
cti_execute_cmd "rm -rf $TMNT/cpio_test"
# we should have no xattr here
cti_execute_cmd "(cd $TMNT; cpio -iu -I $cpio_xattr)"
cti_execute_cmd "runat $TMNT/cpio_test cat passwd"
if [[ $? == 0 ]]
then
cti_fail "Fail: we have xattr here unexpectedly"
return
fi
cti_execute_cmd "rm -rf $TMNT/cpio_test"
# we should have an xattr here
cti_execute_cmd "(cd $TMNT; cpio -iu@ -I $cpio_xattr)"
verify_xattr $TMNT/cpio_test passwd /etc/passwd
cti_execute_cmd "rm -rf $TMNT/cpio_test"
#do the same for the second time
cti_execute_cmd "(cd $TMNT; cpio -iu@ -I $cpio_xattr)"
verify_xattr $TMNT/cpio_test passwd /etc/passwd
cti_execute_cmd "rm -rf $TMNT/cpio_test"
# we should have no xattr here
cti_execute_cmd "(cd $TMNT; cpio -iu -I $cpio_noxattr)"
cti_execute_cmd "runat $TMNT/cpio_test cat passwd"
if [[ $? == 0 ]]
then
cti_fail "Fail: we have xattr here unexpectedly"
return
fi
cti_execute_cmd "rm -rf $TMNT/cpio_test"
# we should have no xattr here
cti_execute_cmd "(cd $TMNT; cpio -iu@ -I $cpio_noxattr)"
cti_execute_cmd "runat $TMNT/cpio_test cat passwd"
if [[ $? == 0 ]]
then
cti_fail "Fail: we have xattr here unexpectedly"
return
fi
cti_execute_cmd "rm -rf $TMNT/cpio_test"
cti_execute_cmd "rm -rf $cpio_xattr"
cti_execute_cmd "rm -rf $cpio_noxattr"
cti_report "Checking cp"
# check that with the right flag, the xattr is preserved
cti_execute_cmd "(cd $TMNT; cp -@ test_file test_file1)"
compare_xattrs $TMNT/test_file $TMNT/test_file1 passwd
cti_execute_cmd "rm -rf $TMNT/test_file1"
# without the right flag, there should be no xattr (ls should fail)
cti_execute_cmd "(cd $TMNT; cp test_file test_file1)"
cti_execute_cmd "runat $TMNT/cpio_test ls passwd"
if [[ $? == 0 ]]
then
cti_fail "Fail: we have xattr here unexpectedly"
return
fi
cti_execute_cmd "rm -rf $TMNT/test_file1"
# create a file without xattrs, and check that find -xattr only finds
# our test file that has an xattr.
cti_report "Checking find"
cti_execute_cmd "mkdir $TMNT/noxattrs"
cti_execute_cmd "touch $TMNT/noxattrs/no-xattr"
cti_execute_cmd "find $TMNT -xattr | grep test_file"
if [ $? -ne 0 ]
then
cti_fail "find -xattr didn't find our file that had an xattr unexpectedly"
fi
cti_execute_cmd "find $TMNT -xattr | grep no-xattr"
if [ $? -eq 0 ]
then
cti_fail "find -xattr found a file that didn't have an xattr unexpectedly"
fi
cti_execute_cmd "rm -rf $TMNT/noxattrs"
# mv doesn't have any flags to preserve/ommit xattrs - they're
# always moved.
cti_report "Checking mv"
cti_execute_cmd "touch $TMNT/mvtest"
create_xattr $TMNT/mvtest passwd /etc/passwd
cti_execute_cmd "(cd $TMNT; mv mvtest mvtest2)"
verify_xattr $TMNT/mvtest2 passwd /etc/passwd
cti_execute_cmd "rm $TMNT/mvtest"
cti_execute_cmd "rm $TMNT/mvtest2"
pax_xattr=$CDIR/xattr.pax
pax_noxattr=$CDIR/noxattr.pax
cti_report "Checking pax"
cti_execute_cmd "touch $TMNT/pax_test"
create_xattr $TMNT/pax_test passwd /etc/passwd
cti_execute_cmd "(cd $TMNT; pax -w -f $pax_noxattr pax_test)"
cti_execute_cmd "(cd $TMNT; pax -w@ -f $pax_xattr pax_test)"
cti_execute_cmd "rm $TMNT/pax_test"
# we should have no xattr here
cti_execute_cmd "(cd $TMNT; pax -r -f $pax_noxattr)"
cti_execute_cmd "runat $TMNT/pax_test cat passwd"
if [[ $? == 0 ]]; then
cti_fail "FAIL: we have xattr here unexpectedly"
return
else
cti_report "PASS: we should have no xattr here as expected"
fi
cti_execute_cmd "rm $TMNT/pax_test"
# we should have no xattr here
cti_execute_cmd "(cd $TMNT; pax -r@ -f $pax_noxattr)"
cti_execute_cmd "runat $TMNT/pax_test cat passwd"
if [[ $? == 0 ]]; then
cti_fail "FAIL: we have xattr here unexpectedly"
return
else
cti_report "PASS: we should have no xattr here as expected"
fi
cti_execute_cmd "rm $TMNT/pax_test"
# we should have an xattr here
cti_execute_cmd "(cd $TMNT; pax -r@ -f $pax_xattr)"
verify_xattr $TMNT/pax_test passwd /etc/passwd
cti_execute_cmd "rm $TMNT/pax_test"
# we should have no xattr here
cti_execute_cmd "(cd $TMNT; pax -r -f $pax_xattr)"
cti_execute_cmd "runat $TMNT/pax_test cat passwd"
if [[ $? == 0 ]]; then
cti_fail "FAIL: we have xattr here unexpectedly"
return
else
cti_report "PASS: we should have no xattr here as expected"
fi
cti_execute_cmd "rm $TMNT/pax_test"
cti_execute_cmd "rm $pax_noxattr"
cti_execute_cmd "rm $pax_xattr"
tar_xattr=$CDIR/xattr.tar
tar_noxattr=$CDIR/noxattr.tar
cti_report "Checking tar"
cti_execute_cmd "touch $TMNT/tar_test"
create_xattr $TMNT/tar_test passwd /etc/passwd
cti_execute_cmd "(cd $TMNT; tar cf $tar_noxattr tar_test)"
cti_execute_cmd "(cd $TMNT; tar c@f $tar_xattr tar_test)"
cti_execute_cmd "rm $TMNT/tar_test"
# we should have no xattr here
cti_execute_cmd "(cd $TMNT; tar xf $tar_xattr)"
cti_execute_cmd "runat $TMNT/tar_test cat passwd"
if [[ $? == 0 ]]; then
cti_fail "FAIL: we have xattr here unexpectedly"
return
else
cti_report "PASS: we should have no xattr here as expected"
fi
cti_execute_cmd "rm $TMNT/tar_test"
# we should have an xattr here
cti_execute_cmd "(cd $TMNT; tar x@f $tar_xattr)"
verify_xattr $TMNT/tar_test passwd /etc/passwd
cti_execute_cmd "rm $TMNT/tar_test"
# we should have no xattr here
cti_execute_cmd "(cd $TMNT; tar xf $tar_noxattr)"
cti_execute_cmd "runat $TMNT/tar_test cat passwd"
if [[ $? == 0 ]]; then
cti_fail "FAIL: we have xattr here unexpectedly"
return
else
cti_report "PASS: we should have no xattr here as expected"
fi
cti_execute_cmd "rm $TMNT/tar_test"
# we should have no xattr here
cti_execute_cmd "(cd $TMNT; tar x@f $tar_noxattr)"
cti_execute_cmd "runat $TMNT/tar_test cat passwd"
if [[ $? == 0 ]]; then
cti_fail "FAIL: we have xattr here unexpectedly"
return
else
cti_report "PASS: we should have no xattr here as expected"
fi
cti_execute_cmd "rm $TMNT/tar_test"
cti_execute_cmd "rm $tar_noxattr"
cti_execute_cmd "rm $tar_xattr"
cti_execute_cmd "rm -rf $TMNT/*"
smbmount_clean $TMNT
cti_pass "$tc_id: PASS"
|