1 #! /usr/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 2006 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # NFSv4 named attributes: 
  28 # a: Verify that "-o noxattr" disables attribute creation from
  29 #    the client using runat command, expect FAIL
  30 #
  31 
  32 funcs="./attrcmds_funcs"
  33 [ ! -r $funcs ] && echo "$0 ERROR: cannot source $funcs" && exit $UNINITIATED
  34 . $funcs
  35 
  36 setup
  37 
  38 # Assume that xattr mount option is set by default on UFS filesystems
  39 # Use pre-mounted filesystem previously setup by nfs4_gen framework
  40 
  41 # Start test
  42 # ---------------------------------------------------------------------
  43 # a: Verify that "-o noxattr" disables attribute creation from \
  44 # the client using runat command, expect FAIL
  45 ASSERTION="Verify that \"-o noxattr\" disables attribute creation from \
  46 the client using runat command"
  47 ASSERTION="$ASSERTION, expect FAIL to create attribute"
  48 echo "$NAME{a}: $ASSERTION"
  49 
  50 mkdir -m 0777 $TMPmnt 2>&1 > $TMPDIR/mount.out.$$
  51 ret=$?
  52 ckreturn $ret "mkdir $TMPmnt failed, returned $ret" $TMPDIR/mount.out.$$ \
  53         UNINITIATED
  54 [ $? -ne 0 ] && cleanup $UNINITIATED
  55 
  56 # mount using -o noxattr option
  57 mount -o vers=4,noxattr $SERVER:$BASEDIR $TMPmnt > $TMPDIR/mount.out.$$ 2>&1
  58 ret=$?
  59 ckreturn $ret "mount -o vers=4,noxattr failed, exit non-zero." \
  60         $TMPDIR/$NAME.out.$$ UNINITIATED 
  61 [ $? -ne 0 ] && cleanup $UNINITIATED
  62 
  63 #Check mount point works
  64 ls $TMPmnt > /dev/null 2> $TMPDIR/$NAME.out.$$
  65 ret=$?
  66 ckreturn $ret "mount point $TMPmnt not accessible (ret=$ret)" \
  67         $TMPDIR/$NAME.out.$$ UNINITIATED
  68 [ $? -ne 0 ] && cleanup $UNINITIATED
  69 
  70 #Ensure that test file doesn't already exist
  71 rm -f $TMPmnt/$TESTFILE 2>&1 
  72 
  73 # Create a test file
  74 echo "This is a file" > $TMPmnt/$TESTFILE 2> $TMPDIR/$NAME.out.$$
  75 ret=$?
  76 ckreturn $ret "Cannot create [$TESTFILE] exit non-zero." \
  77         $TMPDIR/$NAME.out.$$ UNINITIATED
  78 [ $? -ne 0 ] && cleanup $UNINITIATED
  79 
  80 # Now try to Create a named attribute for file object 
  81 echo "This is an attribute" | runat $TMPmnt/$TESTFILE "cat > attr" \
  82         > $TMPDIR/$NAME.out.$$ 2>&1
  83 ret=$?
  84 ckreturn -r $ret "named attr creation not disabled, returned $ret" \
  85         $TMPDIR/$NAME.out.$$
  86 # May want to check snoop traffic here
  87 [ $? -eq 0 ] && cleanup $FAIL
  88 
  89 # Verify named attribute was not created
  90 runat $TMPmnt/$TESTFILE ls attr > $TMPDIR/$NAME.out.$$ 2>&1
  91 ret=$?
  92 ckreturn -r $ret "named attr was create unexpectedly, returned $ret" \
  93         $TMPDIR/$NAME.out.$$
  94 [ $? -eq 0 ] && cleanup $FAIL
  95 
  96 echo "\tTest PASS"
  97 
  98 # Cleanup test files
  99 cleanup $PASS
 100 exit $PASS