1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 # NFSv4 ACL attributes:
  27 #
  28 # a: Test setting ACL type attr ACE4_SYSTEM_AUDIT_ACE_TYPE expect ATTRNOTSUPP 
  29 # b: Test setting ACL type attr ACE4_SYSTEM_ALARM_ACE_TYPE expect ATTRNOTSUPP 
  30 #
  31 
  32 set TESTROOT $env(TESTROOT)
  33 
  34 # include common code and init section
  35 source [file join ${TESTROOT} tcl.init]
  36 source [file join ${TESTROOT} testproc]
  37 source [file join ${TESTROOT} acltools]
  38 
  39 # connect to the test server
  40 Connect
  41 
  42 # setting local variables
  43 set TNAME $argv0
  44 
  45 # Set params relating to test file
  46 set filename "newfile.[pid]"
  47 set fpath [file join ${BASEDIR} ${filename}]
  48 
  49 # Create the test file and get its handle.
  50 set tfh "[creatv4_file $fpath 777]"
  51 if {$tfh == $NULL} {
  52         putmsg stdout 0 "$TNAME: test setup"
  53         putmsg stderr 0 "\t Test UNRESOLVED: failed to create tmp file=($filename)" 
  54         putmsg stderr 0 "\t\t status=($status)."
  55         Disconnect
  56         exit $UNRESOLVED
  57 }
  58 
  59 # Get handle for base directory
  60 set bfh [get_fh "$BASEDIRS"]
  61 
  62 
  63 # Start testing
  64 # ------------------------------------------------------------------------
  65 #a: Test set ACL type attr ACE4_SYSTEM_AUDIT_ACE_TYPE ; expect ATTRNOTSUPP
  66 
  67 set tag "$TNAME{a}"
  68 set ASSERTION "Test set ACL type attr ACE4_SYSTEM_AUDIT_ACE_TYPE expect ATTRNOTSUPP"
  69 putmsg stdout 0 "$tag: $ASSERTION"
  70 
  71 set ACE4_SYSTEM_AUDIT_ACE_TYPE 2
  72 set sid {0 0}
  73 
  74 # get the initial ACL settings.
  75 set expcode "OK"
  76 set initial_acl [compound {Putfh $tfh; \
  77         Getattr acl }]
  78 
  79 ckres "Getattr acl" $status $expcode $initial_acl $FAIL
  80 
  81 #
  82 # Break the string returned from the Geattr acl command into
  83 # a list and then extract the actual ACL settings.
  84 #
  85 set acl_list [extract_acl_list $initial_acl]
  86 putmsg stderr 1 "$tag: initial ACL : $acl_list"
  87 
  88 # Create the new ACL settings by replacing the appropriate entries.
  89 #
  90 # Order of entries in the list is as follows:
  91 # <OWNER><OWNER><GROUP><GROUP><GROUP><EVERYONE><EVERYONE>
  92 #
  93 # The <OWNER> block is itself composed of 4 fields <type><flag><mask><who>
  94 # so we need to extract the <type> field and replace it with the TYPE we
  95 # are testing.
  96 #
  97 set owner [lindex $acl_list 0]
  98 set new_owner [lreplace [split $owner] 0 0 "$ACE4_SYSTEM_AUDIT_ACE_TYPE"]
  99 
 100 # Replace the original OWNER block with the one we have modified.
 101 set acl_list [lreplace $acl_list 0 0 $new_owner]
 102 putmsg stderr 1 "$tag: new ACL : $acl_list"
 103 
 104 # Attempt to set the new ACL values, expect this to fail.
 105 set expcode "ATTRNOTSUPP"
 106 set res [compound {Putfh $tfh; \
 107         Setattr $sid { {acl \
 108         { $acl_list } } } } ]
 109 
 110 ckres "Setattr" $status $expcode $res $PASS
 111 
 112 puts ""
 113 
 114 # ------------------------------------------------------------------------
 115 #b: Test set ACL type attr ACE4_SYSTEM_ALARM_ACE_TYPE ; expect ATTRNOTSUPP
 116 
 117 set tag "$TNAME{b}"
 118 set ASSERTION "Test set ACL type attr ACE4_SYSTEM_ALARM_ACE_TYPE expect ATTRNOTSUPP"
 119 putmsg stdout 0 "$tag: $ASSERTION"
 120 
 121 set ACE4_SYSTEM_ALARM_ACE_TYPE 3
 122 set sid {0 0}
 123 
 124 # get the initial ACL settings.
 125 set expcode "OK"
 126 set initial_acl [compound {Putfh $tfh; \
 127         Getattr acl }]
 128 
 129 ckres "Getattr acl" $status $expcode $initial_acl $FAIL
 130 
 131 #
 132 # Break the string returned from the Geattr acl command into
 133 # a list and then extract the actual ACL settings.
 134 #
 135 set acl_list [extract_acl_list $initial_acl]
 136 putmsg stderr 1 "$tag: new ACL : $acl_list"
 137 
 138 # Create the new ACL settings by replacing the appropriate entries.
 139 #
 140 # Order of entries in the list is as follows:
 141 # <OWNER><OWNER><GROUP><GROUP><GROUP><EVERYONE><EVERYONE>
 142 #
 143 # The <OWNER> block is itself composed of 4 fields <type><flag><mask><who>
 144 # so we ned to extract the <type> field and replace it with the TYPE we
 145 # are testing.
 146 #
 147 set owner [lindex $acl_list 0]
 148 set new_owner [lreplace [split $owner] 0 0 "$ACE4_SYSTEM_ALARM_ACE_TYPE"]
 149 
 150 # Replace the original OWNER block with the one we have modified.
 151 set acl_list [lreplace $acl_list 0 0 $new_owner]
 152 putmsg stderr 1 "$tag: new ACL : $acl_list"
 153 
 154 # Attempt to set the new ACL values, expect this to fail.
 155 set expcode "ATTRNOTSUPP"
 156 set res [compound {Putfh $tfh; \
 157         Setattr $sid { {acl \
 158         { $acl_list } } } } ]
 159 
 160 ckres "Setattr" $status $expcode $res $PASS
 161 
 162 puts ""
 163 
 164 #
 165 # Cleanup
 166 #
 167 set tag "$TNAME-cleanup"
 168 set res2 [compound {Putfh $bfh; Remove $filename}]
 169 if {$status != "OK"} {
 170         putmsg stderr 0 "\t WARNING: cleanup to remove created tmp file failed"
 171         putmsg stderr 0 "\t          status=$status; please cleanup manually."
 172         putmsg stderr 1 "\t   res=($res2)"
 173         putmsg stderr 1 "  "
 174         Disconnect 
 175         exit $WARNING
 176 }
 177 
 178 Disconnect 
 179 exit $PASS