Add the ZFS Test Suite

Add the ZFS Test Suite and test-runner framework from illumos.
This is a continuation of the work done by Turbo Fredriksson to
port the ZFS Test Suite to Linux.  While this work was originally
conceived as a stand alone project integrating it directly with
the ZoL source tree has several advantages:

  * Allows the ZFS Test Suite to be packaged in zfs-test package.
    * Facilitates easy integration with the CI testing.
    * Users can locally run the ZFS Test Suite to validate ZFS.
      This testing should ONLY be done on a dedicated test system
      because the ZFS Test Suite in its current form is destructive.
  * Allows the ZFS Test Suite to be run directly in the ZoL source
    tree enabled developers to iterate quickly during development.
  * Developers can easily add/modify tests in the framework as
    features are added or functionality is changed.  The tests
    will then always be in sync with the implementation.

Full documentation for how to run the ZFS Test Suite is available
in the tests/README.md file.

Warning: This test suite is designed to be run on a dedicated test
system.  It will make modifications to the system including, but
not limited to, the following.

  * Adding new users
  * Adding new groups
  * Modifying the following /proc files:
    * /proc/sys/kernel/core_pattern
    * /proc/sys/kernel/core_uses_pid
  * Creating directories under /

Notes:
  * Not all of the test cases are expected to pass and by default
    these test cases are disabled.  The failures are primarily due
    to assumption made for illumos which are invalid under Linux.
  * When updating these test cases it should be done in as generic
    a way as possible so the patch can be submitted back upstream.
    Most existing library functions have been updated to be Linux
    aware, and the following functions and variables have been added.
    * Functions:
      * is_linux          - Used to wrap a Linux specific section.
      * block_device_wait - Waits for block devices to be added to /dev/.
    * Variables:            Linux          Illumos
      * ZVOL_DEVDIR         "/dev/zvol"    "/dev/zvol/dsk"
      * ZVOL_RDEVDIR        "/dev/zvol"    "/dev/zvol/rdsk"
      * DEV_DSKDIR          "/dev"         "/dev/dsk"
      * DEV_RDSKDIR         "/dev"         "/dev/rdsk"
      * NEWFS_DEFAULT_FS    "ext2"         "ufs"
  * Many of the disabled test cases fail because 'zfs/zpool destroy'
    returns EBUSY.  This is largely causes by the asynchronous nature
    of device handling on Linux and is expected, the impacted test
    cases will need to be updated to handle this.
  * There are several test cases which have been disabled because
    they can trigger a deadlock.  A primary example of this is to
    recursively create zpools within zpools.  These tests have been
    disabled until the root issue can be addressed.
  * Illumos specific utilities such as (mkfile) should be added to
    the tests/zfs-tests/cmd/ directory.  Custom programs required by
    the test scripts can also be added here.
  * SELinux should be either is permissive mode or disabled when
    running the tests.  The test cases should be updated to conform
    to a standard policy.
  * Redundant test functionality has been removed (zfault.sh).
  * Existing test scripts (zconfig.sh) should be migrated to use
    the framework for consistency and ease of testing.
  * The DISKS environment variable currently only supports loopback
    devices because of how the ZFS Test Suite expects partitions to
    be named (p1, p2, etc).  Support must be added to generate the
    correct partition name based on the device location and name.
  * The ZFS Test Suite is part of the illumos code base at:
    https://github.com/illumos/illumos-gate/tree/master/usr/src/test

Original-patch-by: Turbo Fredriksson <turbo@bayour.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #6
Closes #1534
This commit is contained in:
Brian Behlendorf
2015-07-01 15:23:09 -07:00
parent 887d1e60ef
commit 6bb24f4dc7
1243 changed files with 89497 additions and 1042 deletions
@@ -0,0 +1,46 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/misc
dist_pkgdata_SCRIPTS = \
misc.cfg \
setup.ksh \
cleanup.ksh \
zdb_001_neg.ksh \
zfs_001_neg.ksh \
zfs_allow_001_neg.ksh \
zfs_clone_001_neg.ksh \
zfs_create_001_neg.ksh \
zfs_destroy_001_neg.ksh \
zfs_get_001_neg.ksh \
zfs_inherit_001_neg.ksh \
zfs_mount_001_neg.ksh \
zfs_promote_001_neg.ksh \
zfs_receive_001_neg.ksh \
zfs_rename_001_neg.ksh \
zfs_rollback_001_neg.ksh \
zfs_send_001_neg.ksh \
zfs_set_001_neg.ksh \
zfs_share_001_neg.ksh \
zfs_snapshot_001_neg.ksh \
zfs_unallow_001_neg.ksh \
zfs_unmount_001_neg.ksh \
zfs_unshare_001_neg.ksh \
zfs_upgrade_001_neg.ksh \
zpool_001_neg.ksh \
zpool_add_001_neg.ksh \
zpool_attach_001_neg.ksh \
zpool_clear_001_neg.ksh \
zpool_create_001_neg.ksh \
zpool_destroy_001_neg.ksh \
zpool_detach_001_neg.ksh \
zpool_export_001_neg.ksh \
zpool_get_001_neg.ksh \
zpool_history_001_neg.ksh \
zpool_import_001_neg.ksh \
zpool_import_002_neg.ksh \
zpool_offline_001_neg.ksh \
zpool_online_001_neg.ksh \
zpool_remove_001_neg.ksh \
zpool_replace_001_neg.ksh \
zpool_scrub_001_neg.ksh \
zpool_set_001_neg.ksh \
zpool_status_001_neg.ksh \
zpool_upgrade_001_neg.ksh
+50
View File
@@ -0,0 +1,50 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
if poolexists $TESTPOOL.virt
then
log_must $ZPOOL destroy $TESTPOOL.virt
fi
if poolexists v1-pool
then
log_must $ZPOOL destroy v1-pool
fi
if [[ -f /tmp/zfstest_datastream.dat ]]
then
log_must $RM -f /tmp/zfstest_datastream.dat
fi
default_cleanup
@@ -0,0 +1,71 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
# these are the set of setable ZFS properties
PROP_NAMES="\
aclinherit aclmode atime \
checksum compression devices \
exec mountpoint quota readonly \
recordsize reservation setuid sharenfs \
snapdir"
# these are a set of values we apply, for use when testing the
# zfs get/set subcommands - ordered as per the list above so we
# can iterate over both sets in an array
PROP_VALS="\
secure discard on \
fletcher2 on on \
on legacy none on \
128k none on on \
visible"
# these are an alternate set of property values
PROP_ALTVALS="\
noallow groupmask off \
fletcher4 lzjb off \
off /tmp/zfstest 100m off \
512 10m off off \
hidden"
# additional properties to worry about: canmount copies xattr zoned version
POOL_PROPS="\
failmode autoreplace"
POOL_VALS="\
continue on"
POOL_ALTVALS="\
panic off"
export TESTSNAP=testsnap-misc
export TESTCLCT=testclct-misc
+161
View File
@@ -0,0 +1,161 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
# This setup script is moderately complex, as it creates scenarios for all
# of the tests included in this directory. Usually we'd want each test case
# to setup/teardown it's own configuration, but this would be time consuming
# given the nature of these tests. However, as a side-effect, one test
# leaving the system in an unknown state could impact other test cases.
DISK=${DISKS%% *}
VOLSIZE=150m
TESTVOL=testvol
# Create a default setup that includes a volume
default_setup_noexit "$DISK" "" "volume"
#
# The rest of this setup script creates a ZFS filesystem configuration
# that is used to test the rest of the zfs subcommands in this directory.
#
# create a snapshot and a clone to test clone promote
log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap
log_must $ZFS clone $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS/clone
# create a file in the filesystem that isn't in the above snapshot
$TOUCH /$TESTDIR/file.txt
# create a non-default property and a child we can use to test inherit
log_must $ZFS create $TESTPOOL/$TESTFS/$TESTFS2
log_must $ZFS set snapdir=hidden $TESTPOOL/$TESTFS
# create an unmounted filesystem to test unmount
log_must $ZFS create $TESTPOOL/$TESTFS/$TESTFS2.unmounted
log_must $ZFS unmount $TESTPOOL/$TESTFS/$TESTFS2.unmounted
# send our snapshot to a known file in /tmp
$ZFS send $TESTPOOL/$TESTFS@snap > /tmp/zfstest_datastream.dat
if [ ! -s /tmp/zfstest_datastream.dat ]
then
log_fail "ZFS send datafile was not created!"
fi
log_must $CHMOD 644 /tmp/zfstest_datastream.dat
# create a filesystem that has particular properties to test set/get
log_must $ZFS create -o version=1 $TESTPOOL/$TESTFS/prop
set -A props $PROP_NAMES
set -A prop_vals $PROP_VALS
typeset -i i=0
while [[ $i -lt ${#props[*]} ]]
do
prop_name=${props[$i]}
prop_val=${prop_vals[$i]}
log_must $ZFS set $prop_name=$prop_val $TESTPOOL/$TESTFS/prop
i=$(( $i + 1 ))
done
# create a filesystem we don't mind renaming
log_must $ZFS create $TESTPOOL/$TESTFS/renameme
if is_global_zone
then
# create a filesystem we can share
log_must $ZFS create $TESTPOOL/$TESTFS/unshared
log_must $ZFS set sharenfs=off $TESTPOOL/$TESTFS/unshared
# create a filesystem that we can unshare
log_must $ZFS create $TESTPOOL/$TESTFS/shared
log_must $ZFS set sharenfs=on $TESTPOOL/$TESTFS/shared
fi
log_must $ZFS create -o version=1 $TESTPOOL/$TESTFS/version1
log_must $ZFS create -o version=1 $TESTPOOL/$TESTFS/allowed
log_must $ZFS allow everyone create $TESTPOOL/$TESTFS/allowed
if is_global_zone
then
# Now create several virtual disks to test zpool with
$MKFILE 100m /$TESTDIR/disk1.dat
$MKFILE 100m /$TESTDIR/disk2.dat
$MKFILE 100m /$TESTDIR/disk3.dat
$MKFILE 100m /$TESTDIR/disk-additional.dat
$MKFILE 100m /$TESTDIR/disk-export.dat
$MKFILE 100m /$TESTDIR/disk-offline.dat
$MKFILE 100m /$TESTDIR/disk-spare1.dat
$MKFILE 100m /$TESTDIR/disk-spare2.dat
# and create a pool we can perform attach remove replace,
# etc. operations with
log_must $ZPOOL create $TESTPOOL.virt mirror /$TESTDIR/disk1.dat \
/$TESTDIR/disk2.dat /$TESTDIR/disk3.dat /$TESTDIR/disk-offline.dat \
spare /$TESTDIR/disk-spare1.dat
# Offline one of the disks to test online
log_must $ZPOOL offline $TESTPOOL.virt /$TESTDIR/disk-offline.dat
# create an exported pool to test import
log_must $ZPOOL create $TESTPOOL.exported /$TESTDIR/disk-export.dat
log_must $ZPOOL export $TESTPOOL.exported
set -A props $POOL_PROPS
set -A prop_vals $POOL_VALS
typeset -i i=0
while [[ $i -lt ${#props[*]} ]]
do
prop_name=${props[$i]}
prop_val=${prop_vals[$i]}
log_must $ZPOOL set $prop_name=$prop_val $TESTPOOL
i=$(( $i + 1 ))
done
# copy a v1 pool from cli_root
$CP $STF_SUITE/tests/functional/cli_root/zpool_upgrade/blockfiles/zfs-pool-v1.dat.bz2 \
/$TESTDIR
log_must $BUNZIP2 /$TESTDIR/zfs-pool-v1.dat.bz2
log_must $ZPOOL import -d /$TESTDIR v1-pool
fi
log_pass
@@ -0,0 +1,82 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zdb can't run as a user on datasets, but can run without arguments
#
# STRATEGY:
# 1. Run zdb as a user, it should print information
# 2. Run zdb as a user on different datasets, it should fail
#
function check_zdb
{
$@ > /tmp/zdb.$$
$GREP "Dataset mos" /tmp/zdb.$$
if [ $? -eq 0 ]
then
log_fail "$@ exited 0 when run as a non root user!"
fi
$RM /tmp/zdb.$$
}
function cleanup
{
if [ -e /tmp/zdb_001_neg.$$.txt ]
then
$RM /tmp/zdb_001_neg.$$.txt
fi
}
verify_runnable "global"
log_assert "zdb can't run as a user on datasets, but can run without arguments"
log_onexit cleanup
log_must eval "$ZDB > /tmp/zdb_001_neg.$$.txt"
# verify the output looks okay
log_must $GREP pool_guid /tmp/zdb_001_neg.$$.txt
log_must $RM /tmp/zdb_001_neg.$$.txt
# we shouldn't able to run it on any dataset
check_zdb $ZDB $TESTPOOL
check_zdb $ZDB $TESTPOOL/$TESTFS
check_zdb $ZDB $TESTPOOL/$TESTFS@snap
check_zdb $ZDB $TESTPOOL/$TESTFS.clone
log_pass "zdb can't run as a user on datasets, but can run without arguments"
@@ -0,0 +1,59 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs shows a usage message when run as a user
#
# STRATEGY:
# 1. Run zfs as a user
# 2. Verify it produces a usage message
#
function cleanup
{
if [ -e /tmp/zfs_001_neg.$$.txt ]
then
$RM /tmp/zfs_001_neg.$$.txt
fi
}
log_onexit cleanup
log_assert "zfs shows a usage message when run as a user"
eval "$ZFS > /tmp/zfs_001_neg.$$.txt 2>&1"
log_must $GREP "usage: zfs command args" /tmp/zfs_001_neg.$$.txt
log_pass "zfs shows a usage message when run as a user"
@@ -0,0 +1,67 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs allow returns an error when run as a user
#
# STRATEGY:
#
# 1. Verify that trying to show allows works as a user
# 2. Verify that trying to set allows fails as a user
#
#
# check to see if we have zfs allow
$ZFS 2>&1 | $GREP "allow" > /dev/null
if (($? != 0)) then
log_unsupported "ZFS allow not supported on this machine."
fi
log_assert "zfs allow returns an error when run as a user"
log_must $ZFS allow $TESTPOOL/$TESTFS
log_mustnot $ZFS allow $($LOGNAME) create $TESTPOOL/$TESTFS
# now verify that the above command actually did nothing by
# checking for any allow output. ( if no allows are granted,
# nothing should be output )
OUTPUT=$($ZFS allow $TESTPOOL/$TESTFS | $GREP "Local+Descendent" )
if [ -n "$OUTPUT" ]
then
log_fail "zfs allow permissions were granted on $TESTPOOL/$TESTFS"
fi
log_pass "zfs allow returns an error when run as a user"
@@ -0,0 +1,54 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs clone returns an error when run as a user
#
# STRATEGY:
#
# 1. Verify that we're unable to clone snapshots as a user
#
#
log_assert "zfs clone returns an error when run as a user"
log_mustnot $ZFS clone $TESTPOOL/$TESTFS@snap $TESTPOOL/$TESTFS.myclone
# check to see that the above command really did nothing
if datasetexists $TESTPOOL/$TESTFS.myclone
then
log_fail "Dataset $TESTPOOL/$TESTFS.myclone should not exist!"
fi
log_pass "zfs clone returns an error when run as a user"
@@ -0,0 +1,61 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Executing various badly formed 'zfs create' should fail.
#
# STRATEGY:
# 1. Create an array of badly formed sub-commands.
# 2. Execute each element of the array.
# 3. Verify an error code is returned.
#
verify_runnable "both"
set -A args "" "create $TESTPOOL/$TESTFS" \
"create $TESTPOOL/$TESTFS@$TESTSNAP" \
"create $TESTPOOL/$TESTCLCT/$TESTFS" \
"create $TESTFS/$TESTPOOL/$TESTCLCT"
log_assert "Verify zfs create without parameters fails."
typeset -i i=0
while [[ $i -lt ${#args[*]} ]]; do
log_mustnot $ZFS ${args[i]}
((i = i + 1))
done
log_pass "The sub-command 'create' fails as non-root."
@@ -0,0 +1,67 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Verify that 'zfs destroy' fails as non-root.
#
# STRATEGY:
# 1. Create an array of options.
# 2. Execute each element of the array.
# 3. Verify an error code is returned.
#
verify_runnable "both"
set -A args "destroy" "destroy $TESTPOOL/$TESTFS" \
"destroy -f" "destroy -f $TESTPOOL/$TESTFS" \
"destroy -r" "destroy -r $TESTPOOL/$TESTFS" \
"destroy -rf $TESTPOOL/$TESTFS" \
"destroy -fr $TESTPOOL/$TESTFS" \
"destroy $TESTPOOL/$TESTFS@$TESTSNAP" \
"destroy -f $TESTPOOL/$TESTFS@$TESTSNAP" \
"destroy -r $TESTPOOL/$TESTFS@$TESTSNAP" \
"destroy -rf $TESTPOOL/$TESTFS@$TESTSNAP" \
"destroy -fr $TESTPOOL/$TESTFS@$TESTSNAP"
log_assert "zfs destroy [-f|-r] [fs|snap]"
typeset -i i=0
while [[ $i -lt ${#args[*]} ]]; do
log_mustnot $ZFS ${args[i]}
((i = i + 1))
done
log_pass "The sub-command 'destroy' fails as non-root."
@@ -0,0 +1,65 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs get works when run as a user
#
# STRATEGY:
# 1. Run zfs get with an array of different arguments
# 2. Verify for each property, we get the value that's expected
#
#
log_assert "zfs get works when run as a user"
typeset -i i=0
set -A props $PROP_NAMES
set -A prop_vals $PROP_VALS
while [[ $i -lt ${#args[*]} ]]
do
PROP=${props[$i]}
EXPECTED=${prop_vals[$i]}
ACTUAL=$( $ZFS get $PROP -o value -H snapdir $TESTPOOl/$TESTFS/prop )
if [ "$ACTUAL" != "$EXPECTED" ]
then
log_fail "Property $PROP value was $ACTUAL, expected $EXPECTED"
fi
i=$(( $i + 1 ))
done
log_pass "zfs get works when run as a user"
@@ -0,0 +1,56 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs inherit returns an error when run as a user
#
# STRATEGY:
#
# 1. Verify that we can't inherit a property when running as a user
#
#
log_assert "zfs inherit returns an error when run as a user"
log_mustnot $ZFS inherit snapdir $TESTPOOL/$TESTFS/$TESTFS2
# check to see that the above command really did nothing
PROP=$($ZFS get snapdir $TESTPOOL/$TESTFS)
if [ "$PROP" = "visible" ]
then
log_fail "snapdir property inherited from the $TESTPOOL/$TESTFS!"
fi
log_pass "zfs inherit returns an error when run as a user"
@@ -0,0 +1,57 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs mount returns an error when run as a user
#
# STRATEGY:
#
# 1. Verify that we can't mount the unmounted filesystem created in setup
#
#
log_assert "zfs mount returns an error when run as a user"
log_mustnot $ZFS mount $TESTPOOL/$TESTFS/$TESTFS2.unmounted
# now verify that the above command didn't do anything
MOUNTED=$($MOUNT | $GREP $TESTPOOL/$TESTFS/$TESTFS2.unmounted)
if [ -n "$MOUNTED" ]
then
log_fail "Filesystem $TESTPOOL/$TESTFS/$TESTFS2.unmounted was mounted!"
fi
log_pass "zfs mount returns an error when run as a user"
@@ -0,0 +1,56 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs promote returns an error when run as a user
#
# STRATEGY:
#
# 1. Verify we don't have permissions to promote a clone
#
#
log_assert "zfs promote returns an error when run as a user"
log_mustnot $ZFS promote $TESTPOOL/$TESTFS/clone
# Now verify that the above command didn't do anything
if datasetexists $TESTPOOL/$TESTFS/clone@snap
then
log_fail "Clone $TESTPOOl/$TESTFS/clone was actually promoted!"
fi
log_pass "zfs promote returns an error when run as a user"
@@ -0,0 +1,58 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs receive returns an error when run as a user
#
# STRATEGY:
#
# 1. Attempt to receive a datastream as a user
# 2. Verify that the dataset wasn't created
#
log_assert "zfs receive returns an error when run as a user"
log_mustnot eval "$ZFS receive -d $TESTPOOL/$TESTFS/$TESTFS2 \
< /tmp/zfstest_datastream.dat"
# verify that command actually did nothing
if datasetexists $TESTPOOL/$TESTFS/$TESTFS2/$TESTFS
then
log_fail "$TESTPOOL/$TESTFS/$TESTFS2/$TESTFS was received!"
fi
log_pass "zfs receive returns an error when run as a user"
@@ -0,0 +1,56 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs rename returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to rename a dataset
# 2. Verify that the renamed dataset does not exist.
#
#
log_assert "zfs rename returns an error when run as a user"
log_mustnot $ZFS rename $TESTPOOL/$TESTFS/renameme $TESTPOOL/$TESTFS/renameme1
# now verify the above command didn't actually do anything
if datasetexists $TESTPOOL/$TESTFS/renameme1
then
log_fail "The dataset $TESTPOOL/$TESTFS/renameme was renamed!"
fi
log_pass "zfs rename returns an error when run as a user"
@@ -0,0 +1,60 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs rollback returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to rollback a snapshot
# 2. Verify that a file which doesn't exist in the snapshot still exists
# (showing the snapshot rollback failed)
#
#
log_assert "zfs rollback returns an error when run as a user"
log_mustnot $ZFS rollback $TESTPOOL/$TESTFS@snap
# now verify the above command didn't actually do anything
# in the above filesystem there's a file that should not exist once
# the snapshot is rolled back - we check for it
if [ ! -e /$TESTDIR/file.txt ]
then
log_fail "Rollback of snapshot $TESTPOOL/$TESTFS@snap succeeded!"
fi
log_pass "zfs rollback returns an error when run as a user"
@@ -0,0 +1,67 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs send returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to send a dataset to a file
# 2. Verify the file created has zero-size
#
#
function cleanup
{
if [ -e /tmp/zfstest_datastream.$$ ]
then
log_must $RM /tmp/zfstest_datastream.$$
fi
}
log_assert "zfs send returns an error when run as a user"
log_onexit cleanup
log_mustnot eval "$ZFS send $TESTPOOL/$TESTFS@snap > /tmp/zfstest_datastream.$$"
# Now check that the above command actually did nothing
# We should have a non-zero-length file in /tmp
if [ -s /tmp/zfstest_datastream.$$ ]
then
log_fail "A zfs send file was created in /tmp/zfstest_datastream.$$ !"
fi
log_pass "zfs send returns an error when run as a user"
@@ -0,0 +1,70 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs set returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to set an array of properties on a dataset
# 2. Verify that those properties were not set and retain their original values.
#
#
log_assert "zfs set returns an error when run as a user"
typeset -i i=0
set -A props $PROP_NAMES
set -A prop_vals $PROP_VALS
set -A prop_new $PROP_ALTVALS
while [[ $i -lt ${#args[*]} ]]
do
PROP=${props[$i]}
EXPECTED=${prop_vals[$i]}
NEW=${prop_new[$i]}
log_mustnot $ZFS set $PROP=$NEW $TESTPOOL/$TESTFS/prop
# Now verify that the above command did nothing
ACTUAL=$($ZFS get $PROP -o value -H snapdir $TESTPOOl/$TESTFS/prop )
if [ "$ACTUAL" != "$EXPECTED" ]
then
log_fail "Property $PROP was set to $ACTUAL, expected $EXPECTED"
fi
i=$(( $i + 1 ))
done
log_pass "zfs set returns an error when run as a user"
@@ -0,0 +1,63 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs share returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to share a dataset
# 2. Verify the dataset was not shared.
#
#
verify_runnable "global"
log_assert "zfs share returns an error when run as a user"
if is_shared $TESTDIR/unshared
then
log_fail "$TESTPOOL/$TESTFS/unshared was incorrectly shared initially!"
fi
log_mustnot $ZFS share $TESTPOOL/$TESTFS/unshared
# Now verify that the above command didn't actually do anything
if is_shared $TESTDIR/unshared
then
log_fail "$TESTPOOL/$TESTFS/unshared was actually shared!"
fi
log_pass "zfs share returns an error when run as a user"
@@ -0,0 +1,56 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs snapshot returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to snapshot a dataset
# 2. Verify the snapshot wasn't taken
#
#
log_assert "zfs snapshot returns an error when run as a user"
log_mustnot $ZFS snapshot $TESTPOOL/$TESTFS@usersnap1
# Now verify that the above command didn't actually do anything
if datasetexists $TESTPOOL/$TESTFS@usersnap1
then
log_fail "Snapshot $TESTPOOL/$TESTFS@usersnap1 was taken !"
fi
log_pass "zfs snapshot returns an error when run as a user"
@@ -0,0 +1,64 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs unallow returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to unallow a set of permissions
# 2. Verify the unallow wasn't performed
#
#
# check to see if we have zfs unallow
$ZFS 2>&1 | $GREP "unallow" > /dev/null
if (($? != 0)) then
log_unsupported "ZFS unallow not supported on this machine."
fi
log_assert "zfs unallow returns an error when run as a user"
log_mustnot $ZFS unallow everyone $TESTPOOL/$TESTFS/allowed
# now check with zfs allow to see if the permissions are still there
OUTPUT=$($ZFS allow $TESTPOOL/$TESTFS/allowed | $GREP "Local+Descendent" )
if [ -z "$OUTPUT" ]
then
log_fail "Error - create permissions were unallowed on \
$TESTPOOL/$TESTFS/allowed"
fi
log_pass "zfs unallow returns an error when run as a user"
@@ -0,0 +1,65 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Verify that 'zfs umount' and its variants fail as non-root.
#
# STRATEGY:
# 1. Create an array of options.
# 2. Execute each element of the array.
# 3. Verify that the commands fail with an error code.
#
verify_runnable "both"
set -A args "umount" "umount -f" "unmount" "unmount -f" \
"umount $TESTPOOL/$TESTFS" "umount -f $TESTPOOL/$TESTFS" \
"unmount $TESTPOOL/$TESTFS" "unmount -f $TESTPOOL/$TESTFS" \
"umount $TESTPOOL/$TESTFS@$TESTSNAP" \
"umount -f $TESTPOOL/$TESTFS@$TESTSNAP" \
"unmount $TESTPOOL/$TESTFS@$TESTSNAP" \
"unmount -f $TESTPOOL/$TESTFS@$TESTSNAP" \
"umount $TESTDIR" "umount -f $TESTDIR" \
"unmount $TESTDIR" "unmount -f $TESTDIR"
log_assert "zfs u[n]mount [-f] [mountpoint|fs|snap]"
typeset -i i=0
while [[ $i -lt ${#args[*]} ]]; do
log_mustnot $ZFS ${args[i]}
((i = i + 1))
done
log_pass "The sub-command 'u[n]mount' fails as non-root."
@@ -0,0 +1,64 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs unshare returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to unshare a shared dataset
# 2. Verify the dataset is still shared
#
#
verify_runnable "global"
log_assert "zfs unshare returns an error when run as a user"
# verify that the filesystem was shared initially
if not_shared $TESTDIR/shared
then
log_fail "$TESTPOOL/$TESTFS/shared was not shared initially at all!"
fi
log_mustnot $ZFS unshare $TESTPOOL/$TESTFS/shared
# now verify that the above command didn't do anything
if not_shared $TESTDIR/shared
then
log_fail "$TESTPOOL/$TESTFS/shared was actually unshared!"
fi
log_pass "zfs unshare returns an error when run as a user"
@@ -0,0 +1,67 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zfs upgrade returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to upgrade a version1 dataset
# 2. Verify the dataset wasn't upgraded
#
#
# check to see if we have upgrade capability
$ZFS upgrade > /dev/null 2>&1
HAS_UPGRADE=$?
if [ $HAS_UPGRADE -ne 0 ]
then
log_unsupported "Zfs upgrade not supported"
fi
log_assert "zfs upgrade returns an error when run as a user"
log_mustnot $ZFS upgrade $TESTPOOL/$TESTFS/version1
# now check to see the above command didn't do anything
VERSION=$($ZFS upgrade $TESTPOOL/$TESTFS/version1 2>&1 \
| $GREP "already at this version")
if [ -n "$VERSION" ]
then
log_fail "A filesystem was upgraded!"
fi
log_pass "zfs upgrade returns an error when run as a user"
@@ -0,0 +1,60 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool shows a usage message when run as a user
#
# STRATEGY:
# 1. Run the zpool command
# 2. Verify that a usage message is produced
#
#
function cleanup
{
if [ -e /tmp/zpool_001_neg.$$.txt ]
then
$RM /tmp/zpool_001_neg.$$.txt
fi
}
log_onexit cleanup
log_assert "zpool shows a usage message when run as a user"
eval "$ZPOOL > /tmp/zpool_001_neg.$$.txt 2>&1"
log_must $GREP "usage: zpool command args" /tmp/zpool_001_neg.$$.txt
log_pass "zpool shows a usage message when run as a user"
@@ -0,0 +1,69 @@
#!/bin/ksh -p
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Verify that 'zpool add' fails as non-root.
#
# STRATEGY:
# 1. Create an array of options.
# 2. Execute each element of the array.
# 3. Verify that an error is returned.
#
verify_runnable "global"
ADD_DISK="${DISKS%% }"
ADD_DISK="${ADD_DISK##* }"
[[ -z $ADD_DISK ]] && \
log_fail "No spare disks available."
set -A args "add" "add -f" "add -n" \
"add $TESTPOOL" "add -f $TESTPOOL" "add -n $TESTPOOL" \
"add -fn $TESTPOOL" "add -nf $TESTPOOL" \
"add $TESTPOOL $ADD_DISK" "add -f $TESTPOOL $ADD_DISK" \
"add -n $TESTPOOL $ADD_DISK" \
"add -fn $TESTPOOL $ADD_DISK" \
"add -nf $TESTPOOL $ADD_DISK" \
log_assert "zpool add [-fn] pool_name vdev"
typeset -i i=0
while [[ $i -lt ${#args[*]} ]]; do
log_mustnot $ZPOOL ${args[i]}
((i = i + 1))
done
log_pass "The sub-command 'add' and its options fail as non-root."
@@ -0,0 +1,67 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool attach returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to attach a disk to a pool
# 2.Verify that the attach failed
#
#
function check_for_attach
{
RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-additional.dat)
if [ -n "$RESULT" ]
then
log_fail "A disk was attached to the pool!"
fi
}
verify_runnable "global"
log_assert "zpool attach returns an error when run as a user"
log_mustnot $ZPOOL attach $TESTPOOL.virt /$TESTDIR/disk1.dat \
/$TESTDIR/disk-additional.dat
check_for_attach
log_mustnot $ZPOOL attach -f $TESTPOOL.virt /$TESTDIR/disk1.dat \
/$TESTDIR/disk-additional.dat
check_for_attach
log_pass "zpool attach returns an error when run as a user"
@@ -0,0 +1,52 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool clear returns an error when run as a user
#
# STRATEGY:
#
# 1. Attempt to clear errors on a zpool
# 2. Verify that the command fails
#
verify_runnable "global"
log_assert "zpool clear returns an error when run as a user"
log_mustnot $ZPOOL clear $TESTPOOL
log_pass "zpool clear returns an error when run as a user"
@@ -0,0 +1,69 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Verify that 'zpool create' fails as a non-root user.
#
# STRATEGY:
# 1. Create an array of options.
# 2. Execute each element of the array.
# 3. Verify that an error is returned.
#
verify_runnable "global"
ADD_DISK="${DISKS%% }"
ADD_DISK="${ADD_DISK##* }"
[[ -z $ADD_DISK ]] && \
log_fail "No spare disks available."
set -A args "create" "create -f" "create -n" \
"create $TESTPOOL" "create -f $TESTPOOL" "create -n $TESTPOOL" \
"create -fn $TESTPOOL" "create -nf $TESTPOOL" \
"create $TESTPOOL $ADD_DISK" "create -f $TESTPOOL $ADD_DISK" \
"create -n $TESTPOOL $ADD_DISK" \
"create -fn $TESTPOOL $ADD_DISK" \
"create -nf $TESTPOOL $ADD_DISK"
log_assert "zpool create [-fn] pool_name vdev"
typeset -i i=0
while [[ $i -lt ${#args[*]} ]]; do
log_mustnot $ZPOOL ${args[i]}
((i = i + 1))
done
log_pass "The sub-command 'create' and its options fail as non-root."
@@ -0,0 +1,59 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Verify that 'zpool destroy' fails as non-root.
#
# STRATEGY:
# 1. Create an array of options.
# 2. Execute each element of the array.
# 3. Verify an error is returned.
#
verify_runnable "global"
set -A args "destroy" "destroy -f" \
"destroy $TESTPOOL" "destroy -f $TESTPOOL" \
"destroy $TESTPOOL $TESTPOOL"
log_assert "zpool destroy [-f] [pool_name ...]"
typeset -i i=0
while [[ $i -lt ${#args[*]} ]]; do
log_mustnot $ZPOOL ${args[i]}
((i = i + 1))
done
log_pass "The sub-command 'destroy' and its options fail as non-root."
@@ -0,0 +1,58 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool detach returns an error when run as a user
#
# STRATEGY:
#
# 1. Attempt to detach a device from a pool
# 2. Verify the command fails
#
verify_runnable "global"
log_assert "zpool detach returns an error when run as a user"
log_mustnot $ZPOOL detach $TESTPOOL.virt /$TESTDIR/disk1.dat
RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk1.dat)
if [ -z "$RESULT" ]
then
log_fail "A disk was detached from the pool!"
fi
log_pass "zpool detach returns an error when run as a user"
@@ -0,0 +1,65 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool export returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to export a pool
# 2. Verify the command fails
#
function check_for_export
{
RESULT=$($ZPOOL list | $GREP $TESTPOOL.virt )
if [ -z "$RESULT" ]
then
log_fail "A pool was exported!"
fi
}
verify_runnable "global"
log_assert "zpool export returns an error when run as a user"
log_mustnot $ZPOOL export $TESTPOOL.virt
check_for_export
log_mustnot $ZPOOL export -f $TESTPOOL.virt
check_for_export
log_pass "zpool export returns an error when run as a user"
@@ -0,0 +1,67 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool get works when run as a user
#
# STRATEGY:
#
# 1. For each property, get that property
# 2. Verify the property was the same as that set in setup
#
verify_runnable "global"
log_assert "zpool get works when run as a user"
set -A props $POOL_PROPS
set -A prop_vals $POOL_VALS
while [[ $i -lt ${#args[*]} ]]
do
PROP=${props[$i]}
EXPECTED=${prop_vals[$i]}
ACTUAL=$( $ZPOOL get $PROP $TESTPOOL | $GREP $PROP | $AWK '{print $1}' )
if [ "$ACTUAL" != "$EXPECTED" ]
then
log_fail "Property $PROP value was $ACTUAL, expected $EXPECTED"
fi
i=$(( $i + 1 ))
done
log_must $ZPOOL get all $TESTPOOL
log_pass "zpool get works when run as a user"
@@ -0,0 +1,55 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool history works when run as a user
#
# STRATEGY:
# 1. Attempt to get history on a test pool
# 2. Verify the command fails
#
verify_runnable "global"
log_assert "zpool history returns an error when run as a user"
log_mustnot $ZPOOL history
log_mustnot $ZPOOL history $TESTPOOL
log_mustnot $ZPOOL history -i $TESTPOOL
log_mustnot $ZPOOL history -l $TESTPOOL
log_mustnot $ZPOOL history -il $TESTPOOL
log_assert "zpool history returns an error when run as a user"
@@ -0,0 +1,66 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool import returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to import an exported pool
# 2. Verify the command fails
#
#
function check_for_import
{
RESULT=$($ZPOOL list -H -o name | $GREP $TESTPOOL.exported)
if [ -n "$RESULT" ]
then
log_fail "Pool $TESTPOOL.export was successfully imported!"
fi
}
verify_runnable "global"
log_assert "zpool import returns an error when run as a user"
log_mustnot $ZPOOL import
log_mustnot $ZPOOL import -a
check_for_import
log_mustnot $ZPOOL import -d /$TESTDIR $TESTPOOL.exported
check_for_import
log_pass "zpool import returns an error when run as a user"
@@ -0,0 +1,64 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Executing 'zpool import' as regular user should denied.
#
# STRATEGY:
# 1. Create an array of options try to detect exported/destroyed pools.
# 2. Execute 'zpool import' with each element of the array by regular user.
# 3. Verify an error code is returned.
#
verify_runnable "both"
typeset testpool
if is_global_zone ; then
testpool=$TESTPOOL.exported
else
testpool=${TESTPOOL%%/*}
fi
set -A args "" "-D" "-Df" "-f" "-f $TESTPOOL" "-Df $TESTPOOL" "-a"
log_assert "Executing 'zpool import' by regular user fails"
typeset -i i=0
while [[ $i -lt ${#args[*]} ]]; do
log_mustnot $ZPOOL import ${args[i]}
((i = i + 1))
done
log_pass "Executing 'zpool import' by regular user fails as expected."
@@ -0,0 +1,66 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool offline returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to offline a device in a pool
# 2. Verify that the command fails
#
#
function check_for_offline
{
RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-1.dat \
| $GREP OFFLINE )
if [ -n "$RESULT" ]
then
log_fail "A disk was taken offline!"
fi
}
verify_runnable "global"
log_assert "zpool offline returns an error when run as a user"
log_mustnot $ZPOOL offline $TESTPOOL.virt /$TESTDIR/disk-1.dat
check_for_offline
log_mustnot $ZPOOL offline -t $TESTPOOL.virt /$TESTDIR/disk-1.dat
check_for_offline
log_pass "zpool offline returns an error when run as a user"
@@ -0,0 +1,66 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool online returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to online a device in a pool
# 2. Verify the command fails
#
#
function check_for_online
{
RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-offline.dat \
| $GREP ONLINE )
if [ -n "$RESULT" ]
then
log_fail "A disk was brough online!"
fi
}
verify_runnable "global"
log_assert "zpool online returns an error when run as a user"
log_mustnot $ZPOOL online $TESTPOOL.virt /$TESTDIR/disk-offline.dat
check_for_online
log_mustnot $ZPOOL online -t $TESTPOOL.virt /$TESTDIR/disk-offline.dat
check_for_online
log_pass "zpool online returns an error when run as a user"
@@ -0,0 +1,59 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool remove returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to remove a device from a pool
# 2. Verify the command fails
#
#
verify_runnable "global"
log_assert "zpool remove returns an error when run as a user"
log_mustnot $ZPOOL remove $TESTPOOL.virt /$TESTDIR/disk-spare1.dat
RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-spare1.dat)
if [ -z "$RESULT" ]
then
log_fail "A disk was removed from the pool!"
fi
log_pass "zpool remove returns an error when run as a user"
@@ -0,0 +1,68 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool replace returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to replace a device in a pool
# 2. Verify the command fails
#
#
function check_for_replace
{
$SLEEP 10
RESULT=$($ZPOOL status -v $TESTPOOL.virt | $GREP disk-additional.dat)
if [ -n "$RESULT" ]
then
log_fail "A disk was replaced in the pool!"
fi
}
verify_runnable "global"
log_assert "zpool replace returns an error when run as a user"
log_mustnot $ZPOOL replace $TESTPOOL.virt /$TESTDIR/disk-1.dat \
/$TESTDIR/disk-additional.dat
check_for_replace
log_mustnot $ZPOOL replace -f $TESTPOOL.virt /$TESTDIR/disk-1.dat \
/$TESTDIR/disk-additional.dat
check_for_replace
log_pass "zpool replace returns an error when run as a user"
@@ -0,0 +1,53 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool scrub returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to start a scrub on a pool
# 2. Verify the command fails
#
#
verify_runnable "global"
log_assert "zpool scrub returns an error when run as a user"
log_mustnot $ZPOOL scrub $TESTPOOL
log_mustnot $ZPOOL scrub -s $TESTPOOL
log_pass "zpool scrub returns an error when run as a user"
@@ -0,0 +1,71 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool set returns an error when run as a user
#
# STRATEGY:
# 1. Attempt to set some properties on a pool
# 2. Verify the command fails
#
#
verify_runnable "global"
log_assert "zpool set returns an error when run as a user"
set -A props $POOL_NAMES
set -A prop_vals $POOL_VALS
set -A prop_new $POOL_ALTVALS
while [[ $i -lt ${#args[*]} ]]
do
PROP=${props[$i]}
EXPECTED=${prop_vals[$i]}
NEW=${prop_new[$i]}
log_mustnot $POOL set $PROP=$NEW $TESTPOOL
# Now verify that the above command did nothing
ACTUAL=$( $ZPOOL get $PROP $TESTPOOL | $GREP $PROP | $AWK '{print $1}' )
if [ "$ACTUAL" != "$EXPECTED" ]
then
log_fail "Property $PROP was set to $ACTUAL, expected $EXPECTED"
fi
i=$(( $i + 1 ))
done
log_pass "zpool set returns an error when run as a user"
@@ -0,0 +1,76 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool status works when run as a user
#
# STRATEGY:
#
# 1. Run zpool status as a user
# 2. Verify we get output
#
function check_pool_status
{
RESULT=$($GREP "pool:" /tmp/pool-status.$$)
if [ -z "$RESULT" ]
then
log_fail "No pool: string found in zpool status output!"
fi
$RM /tmp/pool-status.$$
}
verify_runnable "global"
log_assert "zpool status works when run as a user"
log_must eval "$ZPOOL status > /tmp/pool-status.$$"
check_pool_status
log_must eval "$ZPOOL status -v > /tmp/pool-status.$$"
check_pool_status
log_must eval "$ZPOOL status $TESTPOOL> /tmp/pool-status.$$"
check_pool_status
log_must eval "$ZPOOL status -v $TESTPOOL > /tmp/pool-status.$$"
check_pool_status
# $TESTPOOL.virt has an offline device, so -x will show it
log_must eval "$ZPOOL status -x $TESTPOOL.virt > /tmp/pool-status.$$"
check_pool_status
log_pass "zpool status works when run as a user"
@@ -0,0 +1,65 @@
#!/bin/ksh -p
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
#
. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool upgrade returns an error when run as a user
#
# STRATEGY:
#
# 1. Attempt to upgrade a pool
# 2. Verify the command fails
#
verify_runnable "global"
log_assert "zpool upgrade returns an error when run as a user"
log_onexit cleanup
# zpool upgrade returns 0 when it can't do anything
log_must $ZPOOL upgrade $TESTPOOL.virt
# Now try to upgrade our version 1 pool
log_mustnot $ZPOOL upgrade v1-pool
# if the pool has been upgraded, then v1-pool won't be listed in the output
# of zpool upgrade anymore
RESULT=$($ZPOOL upgrade | $GREP v1-pool)
if [ -z "$RESULT" ]
then
log_fail "A pool was upgraded successfully!"
fi
log_pass "zpool upgrade returns an error when run as a user"