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 2008 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_001_pos
34#
35# DESCRIPTION:
36# 	"everyone" is interpreted as the keyword "everyone" whatever the same
37# 	name user or group is existing.
38#
39# STRATEGY:
40#	1. Create user 'everyone'.
41#	2. Verify 'everyone' is interpreted as keywords.
42#	3. Create group 'everyone'.
43#	4. Verify 'everyone' is interpreted as keywords.
44#
45# TESTABILITY: explicit
46#
47# TEST_AUTOMATION_LEVEL: automated
48#
49# CODING_STATUS: COMPLETED (2006-09-14)
50#
51# __stc_assertion_end
52#
53################################################################################
54
55verify_runnable "both"
56
57function cleanup
58{
59	if [[ $user_added == "TRUE" ]] ; then
60		del_user everyone
61	fi
62	if [[ $group_added == "TRUE" ]] ; then
63		del_group everyone
64	fi
65}
66
67log_assert "everyone' is interpreted as a keyword even if a user " \
68	"or group named 'everyone' exists."
69log_onexit cleanup
70
71eval set -A dataset $DATASETS
72enc=$(get_prop encryption $dataset)
73if [[ $? -eq 0 ]] && [[ -n "$enc" ]] && [[ "$enc" != "off" ]]; then
74	typeset perms="snapshot,reservation,compression,send,allow,\
75userprop"
76else
77	typeset perms="snapshot,reservation,compression,checksum,\
78send,allow,userprop"
79fi
80
81log_note "Create a user called 'everyone'."
82if ! $ID everyone > /dev/null 2>&1; then
83	user_added="TRUE"
84	log_must $USERADD everyone
85fi
86for dtst in $DATASETS ; do
87	log_must $ZFS allow everyone $perms $dtst
88	log_must verify_perm $dtst $perms $EVERYONE "everyone"
89done
90log_must restore_root_datasets
91if [[ $user_added == "TRUE" ]]; then
92	log_must $USERDEL everyone
93fi
94
95log_note "Created a group called 'everyone'."
96if ! $CAT /etc/group | $AWK -F: '{print $1}' | \
97	$GREP -w 'everyone' > /dev/null 2>&1
98then
99	group_added="TRUE"
100	log_must $GROUPADD everyone
101fi
102
103for dtst in $DATASETS ; do
104	log_must $ZFS allow everyone $perms $dtst
105	log_must verify_perm $dtst $perms $EVERYONE
106done
107if [[ $group_added == "TRUE" ]]; then
108	log_must $GROUPDEL everyone
109fi
110
111log_pass "everyone is always interpreted as keyword passed."
112