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 2007 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/delegate/delegate_common.kshlib
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# DESCRIPTION:
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Scan the following permissions one by one to verify privileged user
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# has correct permission delegation in datasets.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# STRATEGY:
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# 1. Delegate all the permission one by one to user on dataset.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# 2. Verify privileged user has correct permission without any other
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# permissions allowed.
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyverify_runnable "both"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_assert "Verify privileged user has correct permissions once which was "\
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy "delegated to him in datasets"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_onexit restore_root_datasets
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Results in Results in
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy# Permission Filesystem Volume
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy#
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyset -A perms create true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy snapshot true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy mount true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy send true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy allow true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy quota true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy reservation true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy recordsize true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy mountpoint true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy checksum true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy compression true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy canmount true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy atime true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy devices true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy exec true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy volsize false true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy setuid true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy readonly true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy snapdir true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy userprop true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy aclmode true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy aclinherit true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy rollback true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy clone true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy rename true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy promote true true \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy zoned true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy xattr true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy receive true false \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy destroy true true
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyif is_global_zone; then
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy typeset -i n=${#perms[@]}
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy perms[((n))]="sharenfs"; perms[((n+1))]="true"; perms[((n+2))]="false"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy perms[((n+3))]="share"; perms[((n+4))]="true"; perms[((n+5))]="false"
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyfi
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedyfor dtst in $DATASETS; do
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy typeset -i k=1
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy typeset type=$(get_prop type $dtst)
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy [[ $type == "volume" ]] && k=2
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy typeset -i i=0
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy while (( i < ${#perms[@]} )); do
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must zfs allow $STAFF1 ${perms[$i]} $dtst
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy if [[ ${perms[((i+k))]} == "true" ]]; then
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy log_must verify_perm $dtst ${perms[$i]} $STAFF1
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy else
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy log_must verify_noperm $dtst ${perms[$i]} $STAFF1
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy fi
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy log_must restore_root_datasets
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy ((i += 3))
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy done
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedydone
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedylog_pass "Verify privileged user has correct permissions " \
f38cb554a534c6df738be3f4d23327e69888e634John Wren Kennedy "in datasets passed."