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/delegate/delegate_common.kshlib
28
29#################################################################################
30#
31# __stc_assertion_start
32#
33# ID: zfs_allow_005_pos
34#
35# DESCRIPTION:
36#	Verify option '-c' will be granted locally to the creator on any
37#	newly-created descendent file systems.
38#
39# STRATEGY:
40#	1. Allow create permissions to everyone on $ROOT_TESTFS locally.
41#	2. Allow '-c' create to $ROOT_TESTFS.
42#	3. chmod 777 the mountpoint of $ROOT_TESTFS
43#	4. Verify only creator can create descendent dataset on
44#	   $ROOT_TESTFS/$user.
45#
46# TESTABILITY: explicit
47#
48# TEST_AUTOMATION_LEVEL: automated
49#
50# CODING_STATUS: COMPLETED (2006-09-19)
51#
52# __stc_assertion_end
53#
54################################################################################
55
56verify_runnable "both"
57
58log_assert "Verify option '-c' will be granted locally to the creator."
59log_onexit restore_root_datasets
60
61eval set -A dataset $DATASETS
62enc=$(get_prop encryption $dataset)
63if [[ $? -eq 0 ]] && [[ -n "$enc" ]] && [[ "$enc" != "off" ]]; then
64	typeset perms="snapshot,reservation,compression,allow,\
65userprop"
66else
67	typeset perms="snapshot,reservation,compression,checksum,\
68allow,userprop"
69fi
70
71if check_version "5.10" ; then
72	perms="${perms},send"
73fi
74
75log_must $ZFS allow -l everyone create,mount $ROOT_TESTFS
76log_must $ZFS allow -c $perms $ROOT_TESTFS
77
78mntpnt=$(get_prop mountpoint $ROOT_TESTFS)
79log_must $CHMOD 777 $mntpnt
80
81for user in $EVERYONE; do
82	childfs=$ROOT_TESTFS/$user
83
84	user_run $user $ZFS create $childfs
85
86	for other in $EVERYONE; do
87		#
88		# Verify only the creator has the $perm time permissions.
89		#
90		if [[ $other == $user ]]; then
91			log_must verify_perm $childfs $perms $user
92		else
93			log_must verify_noperm $childfs $perms $other
94		fi
95	done
96done
97
98log_pass "Verify option '-c' will be granted locally to the creator passed."
99