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# $FreeBSD$
24
25#
26# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29# ident	"@(#)history_010_pos.ksh	1.4	09/01/12 SMI"
30#
31
32. $STF_SUITE/tests/history/history_common.kshlib
33
34#################################################################################
35#
36# __stc_assertion_start
37#
38# ID: history_010_pos
39#
40# DESCRIPTION:
41#	Verify internal long history information are correct.
42#
43# STRATEGY:
44#	1. Create non-root test user and group.
45#	2. Do some zfs operation test by root and non-root user.
46#	3. Verify the long history information are correct.
47#
48# TESTABILITY: explicit
49#
50# TEST_AUTOMATION_LEVEL: automated
51#
52# CODING_STATUS: COMPLETED (2006-12-27)
53#
54# __stc_assertion_end
55#
56################################################################################
57
58verify_runnable "global"
59
60$ZFS 2>&1 | $GREP "allow" > /dev/null
61(($? != 0)) && log_unsupported
62
63function cleanup
64{
65	[[ -f $REAL_HISTORY ]] && $RM -f $REAL_HISTORY
66	[[ -f $EXPECT_HISTORY ]] && $RM -f $EXPECT_HISTORY
67
68	del_user $HIST_USER
69	del_group $HIST_GROUP
70
71	datasetexists $root_testfs && log_must $ZFS destroy -rf $root_testfs
72}
73
74log_assert "Verify internal long history information are correct."
75log_onexit cleanup
76
77root_testfs=$TESTPOOL/$TESTFS1
78
79# Create history test group and user and get user id and group id
80add_group $HIST_GROUP
81add_user $HIST_GROUP $HIST_USER
82uid=$($ID $HIST_USER | $AWK -F= '{print $2}'| $AWK -F"(" '{print $1}' )
83gid=$($ID $HIST_USER | $AWK -F= '{print $3}'| $AWK -F"(" '{print $1}' )
84
85# Get original long history
86format_history $TESTPOOL $EXPECT_HISTORY "-l"
87
88exec_record -l $ZFS create $root_testfs
89exec_record -l $ZFS allow $HIST_GROUP snapshot,mount $root_testfs
90exec_record -l $ZFS allow $HIST_USER destroy,mount $root_testfs
91exec_record -l $ZFS allow $HIST_USER reservation $root_testfs
92exec_record -l $ZFS allow $HIST_USER allow $root_testfs
93
94exec_record -l -u $HIST_USER "$ZFS snapshot $root_testfs@snap"
95exec_record -l -u $HIST_USER "$ZFS destroy $root_testfs@snap"
96exec_record -l -u $HIST_USER "$ZFS reservation=64M $root_testfs"
97exec_record -l -u $HIST_USER "$ZFS allow $HIST_USER reservation $root_testfs"
98exec_record -l $ZFS unallow $HIST_USER create $root_testfs
99exec_record -l $ZFS unallow $HIST_GROUP snapshot $root_testfs
100exec_record -l $ZFS destroy -r $root_testfs
101
102format_history $TESTPOOL $REAL_HISTORY "-l"
103log_must $DIFF $REAL_HISTORY $EXPECT_HISTORY
104
105del_user $HIST_USER
106del_group $HIST_GROUP
107
108log_pass "Verify internal long history information pass."
109