f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#!/bin/ksh -p
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# CDDL HEADER START
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# The contents of this file are subject to the terms of the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Common Development and Distribution License (the "License").
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# You may not use this file except in compliance with the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# See the License for the specific language governing permissions
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# and limitations under the License.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# CDDL HEADER END
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Use is subject to license terms.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy. $STF_SUITE/tests/functional/history/history_common.kshlib
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# DESCRIPTION:
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Verify internal long history information are correct.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# STRATEGY:
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# 1. Create non-root test user and group.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# 2. Do some zfs operations as a root and non-root user.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# 3. Verify the long history information is correct.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyverify_runnable "global"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyfunction cleanup
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy{
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy del_user $HIST_USER
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy del_group $HIST_GROUP
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy datasetexists $root_testfs && log_must zfs destroy -rf $root_testfs
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy}
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_assert "Verify internal long history information are correct."
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_onexit cleanup
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyroot_testfs=$TESTPOOL/$TESTFS1
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Create history test group and user and get user id and group id
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyadd_group $HIST_GROUP
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyadd_user $HIST_GROUP $HIST_USER
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs create $root_testfs" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs allow $HIST_GROUP snapshot,mount $root_testfs" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs allow $HIST_USER destroy,mount $root_testfs" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs allow $HIST_USER reservation $root_testfs" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs allow $HIST_USER allow $root_testfs" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify -u "$HIST_USER" "zfs snapshot $root_testfs@snap" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify -u "$HIST_USER" "zfs destroy $root_testfs@snap" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify -u "$HIST_USER" "zfs set reservation=64M $root_testfs" "-l"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyrun_and_verify -u "$HIST_USER" \
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy "zfs allow $HIST_USER reservation $root_testfs" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs unallow $HIST_USER create $root_testfs" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs unallow $HIST_GROUP snapshot $root_testfs" "-l"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedyrun_and_verify "zfs destroy -r $root_testfs" "-l"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_pass "Verify internal long history information pass."