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 23# 24# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/tests/history/history_common.kshlib 28 29################################################################################# 30# 31# __stc_assertion_start 32# 33# ID: history_009_pos 34# 35# DESCRIPTION: 36# Verify the delegation internal history are correctly. 37# 38# ul$<id> identifies permssions granted locally for this userid. 39# ud$<id> identifies permissions granted on descendent datasets for 40# this userid. 41# 42# Ul$<id> identifies permission sets granted locally for this userid. 43# Ud$<id> identifies permission sets granted on descendent datasets for 44# this userid. 45# 46# gl$<id> identifies permissions granted locally for this groupid. 47# gd$<id> identifies permissions granted on descendent datasets for 48# this groupid. 49# 50# Gl$<id> identifies permission sets granted locally for this groupid. 51# Gd$<id> identifies permission sets granted on descendent datasets for 52# this groupid. 53# 54# el$ identifies permissions granted locally for everyone. 55# ed$ identifies permissions granted on descendent datasets for 56# everyone. 57# 58# El$ identifies permission sets granted locally for everyone. 59# Ed$ identifies permission sets granted to descendent datasets 60# for everyone. 61# 62# c-$ identifies permission to create at dataset creation time. 63# C-$ identifies permission sets to grant locally at dataset 64# creation time. 65# 66# s-$@<name> permissions defined in specified set @<name> 67# S-$@<name> Sets defined in named set @<name> 68# 69# STRATEGY: 70# 1. Create test group and user. 71# 2. Define permission sets and verify the internal history correctly. 72# 3. Separately verify the internal history above is correct. 73# 74# TESTABILITY: explicit 75# 76# TEST_AUTOMATION_LEVEL: automated 77# 78# CODING_STATUS: COMPLETED (2006-12-26) 79# 80# __stc_assertion_end 81# 82################################################################################ 83 84verify_runnable "global" 85 86$ZFS 2>&1 | $GREP "allow" > /dev/null 87(($? != 0)) && log_unsupported 88 89function cleanup 90{ 91 if [[ -f $REAL_HISTORY ]]; then 92 log_must $RM -f $REAL_HISTORY 93 fi 94 if [[ -f $ADD_HISTORY ]]; then 95 log_must $RM -f $ADD_HISTORY 96 fi 97 del_user $HIST_USER 98 del_group $HIST_GROUP 99} 100 101log_assert "Verify the delegation internal history are correctly." 102log_onexit cleanup 103 104testfs=$TESTPOOL/$TESTFS 105# Create history test group and user and get user id and group id 106add_group $HIST_GROUP 107add_user $HIST_GROUP $HIST_USER 108 109uid=$($ID $HIST_USER | $AWK -F= '{print $2}'| $AWK -F"(" '{print $1}' ) 110gid=$($ID $HIST_USER | $AWK -F= '{print $3}'| $AWK -F"(" '{print $1}' ) 111 112# Initial original $REAL_HISTORY 113format_history $TESTPOOL $REAL_HISTORY -i 114 115# 116# Keyword subcmd operating allow_options 117# 118set -A array \ 119 "s-\$@basic" "allow" "-s @basic snapshot" \ 120 "S-\$@set" "allow" "-s @set @basic" \ 121 "c-\\$" "allow" "-c create" \ 122 "c-\\$" "unallow" "-c create" \ 123 "C-\\$ @set" "allow" "-c @set" \ 124 "C-\\$ @set" "unallow" "-c @set" \ 125 "ul\$$uid" "allow" "-l -u $HIST_USER snapshot" \ 126 "ul\$$uid" "allow" "-u $HIST_USER snapshot" \ 127 "ul\$$uid" "unallow" "-u $HIST_USER snapshot" \ 128 "Ul\$$uid" "allow" "-l -u $HIST_USER @set" \ 129 "Ul\$$uid" "allow" "-u $HIST_USER @set" \ 130 "Ul\$$uid" "unallow" "-u $HIST_USER @set" \ 131 "ud\$$uid" "allow" "-d -u $HIST_USER snapshot" \ 132 "ud\$$uid" "allow" "-u $HIST_USER snapshot" \ 133 "ud\$$uid" "unallow" "-u $HIST_USER snapshot" \ 134 "Ud\$$uid" "allow" "-d -u $HIST_USER @set" \ 135 "Ud\$$uid" "allow" "-u $HIST_USER @set" \ 136 "Ud\$$uid" "unallow" "-u $HIST_USER @set" \ 137 "gl\$$gid" "allow" "-l -g $HIST_GROUP snapshot" \ 138 "gl\$$gid" "allow" "-g $HIST_GROUP snapshot" \ 139 "gl\$$gid" "unallow" "-g $HIST_GROUP snapshot" \ 140 "Gl\$$gid" "allow" "-l -g $HIST_GROUP @set" \ 141 "Gl\$$gid" "allow" "-g $HIST_GROUP @set" \ 142 "Gl\$$gid" "unallow" "-g $HIST_GROUP @set" \ 143 "gd\$$gid" "allow" "-d -g $HIST_GROUP snapshot" \ 144 "gd\$$gid" "allow" "-g $HIST_GROUP snapshot" \ 145 "gd\$$gid" "unallow" "-g $HIST_GROUP snapshot" \ 146 "Gd\$$gid" "allow" "-d -g $HIST_GROUP @set" \ 147 "Gd\$$gid" "allow" "-g $HIST_GROUP @set" \ 148 "Gd\$$gid" "unallow" "-g $HIST_GROUP @set" \ 149 "el\\$" "allow" "-l -e snapshot" \ 150 "el\\$" "allow" "-e snapshot" \ 151 "el\\$" "unallow" "-e snapshot" \ 152 "El\\$" "allow" "-l -e @set" \ 153 "El\\$" "allow" "-e @set" \ 154 "El\\$" "unallow" "-e @set" \ 155 "ed\\$" "allow" "-d -e snapshot" \ 156 "ed\\$" "allow" "-e snapshot" \ 157 "ed\\$" "unallow" "-e snapshot" \ 158 "Ed\\$" "allow" "-d -e @set" \ 159 "Ed\\$" "allow" "-e @set" \ 160 "Ed\\$" "unallow" "-e @set" 161 162typeset -i i=0 163while ((i < ${#array[@]})); do 164 keyword=${array[$i]} 165 subcmd=${array[((i+1))]} 166 options=${array[((i+2))]} 167 168 log_must $ZFS $subcmd $options $testfs 169 additional_history $TESTPOOL $ADD_HISTORY -i 170 log_must verify_history $ADD_HISTORY $subcmd $testfs $keyword 171 172 ((i += 3)) 173done 174 175log_pass "Verify the delegation internal history are correctly." 176