diff options
Diffstat (limited to 'tests/zfs-tests/tests/functional/cli_user/misc')
49 files changed, 3170 insertions, 0 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am b/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am new file mode 100644 index 000000000000..2d38e65777f7 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/Makefile.am @@ -0,0 +1,52 @@ +pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_user/misc +dist_pkgdata_SCRIPTS = \ + 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 \ + arcstat_001_pos.ksh \ + arc_summary_001_pos.ksh \ + arc_summary_002_neg.ksh \ + zpool_wait_privilege.ksh + +dist_pkgdata_DATA = \ + misc.cfg diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh new file mode 100755 index 000000000000..a445fbb48cf3 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_001_pos.ksh @@ -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 (c) 2015 by Lawrence Livermore National Security, LLC. +# All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +log_assert "arc_summary generates output and doesn't return an error code" + +# Depending on which version of arc_summary is installed some command +# line options may not be available. The python3 version includes +# several additional flags. +python3 -V 2>&1 > /dev/null +if (( $? )); then + # Some systems have Python 3 installed, but only older versions + # that don't have the subprocess.run() functionality. We catch + # these with a separate test. Remove this when all systems have + # reached 3.5 or greater + VERSIONPYTEST=$(python3 -V) + if [[ ${VERSIONPYTEST:9:1} -lt 5 ]]; then + set -A args "" "-a" "-d" "-p 1" + else + set -A args "" "-a" "-d" "-p 1" "-g" "-s arc" "-r" + fi +else + set -A args "" "-a" "-d" "-p 1" +fi + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_must eval "arc_summary ${args[i]} > /dev/null" + ((i = i + 1)) +done + +log_must eval "arc_summary | head > /dev/null" +log_must eval "arc_summary | head -1 > /dev/null" + +log_pass "arc_summary generates output and doesn't return an error code" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh new file mode 100755 index 000000000000..de747fba89d1 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/arc_summary_002_neg.ksh @@ -0,0 +1,38 @@ +#!/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 (c) 2015 by Lawrence Livermore National Security, LLC. +# All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +typeset args=("-x" "-5" "-p 7" "--err" "-@") + +log_assert "arc_summary generates an error code with invalid options" + +for arg in "${args[@]}"; do + log_mustnot eval "arc_summary $arg > /dev/null" +done + +log_pass "arc_summary generates an error code with invalid options" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh new file mode 100755 index 000000000000..ab574731fed9 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/arcstat_001_pos.ksh @@ -0,0 +1,41 @@ +#! /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 (c) 2015 by Lawrence Livermore National Security, LLC. +# All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +set -A args "" "-s \",\"" "-x" "-v" \ + "-f time,hit%,dh%,ph%,mh%" + +log_assert "arcstat generates output and doesn't return an error code" + +typeset -i i=0 +while [[ $i -lt ${#args[*]} ]]; do + log_must eval "arcstat ${args[i]} > /dev/null" + ((i = i + 1)) +done +log_pass "arcstat generates output and doesn't return an error code" + diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/cleanup.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/cleanup.ksh new file mode 100755 index 000000000000..e3dc8c179c0a --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/cleanup.ksh @@ -0,0 +1,51 @@ +#!/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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +if poolexists $TESTPOOL.virt; then + log_must zpool destroy $TESTPOOL.virt +fi + +if poolexists v1-pool; then + log_must zpool destroy v1-pool +fi + +log_must rm -f $TEST_BASE_DIR/zfstest_datastream.dat +log_must rm -f $TEST_BASE_DIR/disk1.dat $TEST_BASE_DIR/disk2.dat \ + $TEST_BASE_DIR/disk3.dat $TEST_BASE_DIR/disk-additional.dat \ + $TEST_BASE_DIR/disk-export.dat $TEST_BASE_DIR/disk-offline.dat \ + $TEST_BASE_DIR/disk-spare1.dat $TEST_BASE_DIR/disk-spare2.dat +log_must rm -f $TEST_BASE_DIR/zfs-pool-v1.dat \ + $TEST_BASE_DIR/zfs-pool-v1.dat.bz2 + +default_cleanup diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/misc.cfg b/tests/zfs-tests/tests/functional/cli_user/misc/misc.cfg new file mode 100644 index 000000000000..af867ded5374 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/misc.cfg @@ -0,0 +1,123 @@ +# +# 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. +# + +if is_linux; then + # these are the set of setable ZFS properties + PROP_NAMES="\ + acltype atime \ + checksum compression devices \ + exec mountpoint quota readonly \ + recordsize reservation setuid \ + 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="\ + posixacl on \ + fletcher2 on on \ + on legacy none on \ + 128K none on \ + visible" + + # these are an alternate set of property values + PROP_ALTVALS="\ + noacl off \ + fletcher4 lzjb off \ + off /tmp/zfstest 100M off \ + 512 10m off \ + hidden" +elif is_freebsd; then + PROP_NAMES="\ + acltype atime \ + checksum compression devices \ + exec mountpoint quota readonly \ + recordsize reservation setuid \ + 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="\ + posixacl on \ + fletcher2 on on \ + on legacy none on \ + 128K none on \ + visible" + + # these are an alternate set of property values + PROP_ALTVALS="\ + noacl off \ + fletcher4 lzjb off \ + off /tmp/zfstest 100M off \ + 512 10m off \ + hidden" + +else + # 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="\ + passthrough discard on \ + fletcher2 on on \ + on legacy none on \ + 128K none on on \ + visible" + + # these are an alternate set of property values + PROP_ALTVALS="\ + passthrough-x groupmask off \ + fletcher4 lzjb off \ + off /tmp/zfstest 100M off \ + 512 10m off off \ + hidden" +fi + +# 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 diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/setup.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/setup.ksh new file mode 100755 index 000000000000..fc0ebde10025 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/setup.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# 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 its 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 > $TEST_BASE_DIR/zfstest_datastream.dat +if [ ! -s $TEST_BASE_DIR/zfstest_datastream.dat ] +then + log_fail "ZFS send datafile was not created!" +fi +log_must chmod 644 $TEST_BASE_DIR/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 && ! is_linux +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 $MINVDEVSIZE $TEST_BASE_DIR/disk1.dat + mkfile $MINVDEVSIZE $TEST_BASE_DIR/disk2.dat + mkfile $MINVDEVSIZE $TEST_BASE_DIR/disk3.dat + mkfile $MINVDEVSIZE $TEST_BASE_DIR/disk-additional.dat + mkfile $MINVDEVSIZE $TEST_BASE_DIR/disk-export.dat + mkfile $MINVDEVSIZE $TEST_BASE_DIR/disk-offline.dat + mkfile $MINVDEVSIZE $TEST_BASE_DIR/disk-spare1.dat + mkfile $MINVDEVSIZE $TEST_BASE_DIR/disk-spare2.dat + + # and create a pool we can perform attach remove replace, + # etc. operations with + log_must zpool create $TESTPOOL.virt mirror $TEST_BASE_DIR/disk1.dat \ + $TEST_BASE_DIR/disk2.dat $TEST_BASE_DIR/disk3.dat \ + $TEST_BASE_DIR/disk-offline.dat spare $TEST_BASE_DIR/disk-spare1.dat + + + # Offline one of the disks to test online + log_must zpool offline $TESTPOOL.virt $TEST_BASE_DIR/disk-offline.dat + + + # create an exported pool to test import + log_must zpool create $TESTPOOL.exported $TEST_BASE_DIR/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 \ + $TEST_BASE_DIR/ + log_must bunzip2 $TEST_BASE_DIR/zfs-pool-v1.dat.bz2 + log_must zpool import -d $TEST_BASE_DIR/ v1-pool +fi +log_pass diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh new file mode 100755 index 000000000000..3adfc59f51ce --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zdb_001_neg.ksh @@ -0,0 +1,78 @@ +#!/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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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 +{ + $@ > $TEST_BASE_DIR/zdb.$$ + grep "Dataset mos" $TEST_BASE_DIR/zdb.$$ + if [ $? -eq 0 ] + then + log_fail "$@ exited 0 when run as a non root user!" + fi + rm $TEST_BASE_DIR/zdb.$$ +} + + +function cleanup +{ + rm -f $TEST_BASE_DIR/zdb_001_neg.$$.txt $TEST_BASE_DIR/zdb.$$ +} + +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 > $TEST_BASE_DIR/zdb_001_neg.$$.txt" +# verify the output looks okay +log_must grep pool_guid $TEST_BASE_DIR/zdb_001_neg.$$.txt +log_must rm $TEST_BASE_DIR/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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh new file mode 100755 index 000000000000..bfe8cf4bb29a --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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 +{ + rm -f "$TEMPFILE" +} + +log_onexit cleanup +log_assert "zfs shows a usage message when run as a user" + +TEMPFILE="$TEST_BASE_DIR/zfs_001_neg.$$.txt" + +zfs > $TEMPFILE 2>&1 +log_must grep "usage: zfs command args" "$TEMPFILE" + +log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE" + +log_pass "zfs shows a usage message when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh new file mode 100755 index 000000000000..56a74e4ae427 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_allow_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_clone_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_clone_001_neg.ksh new file mode 100755 index 000000000000..7497553ed8a5 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_clone_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_create_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_create_001_neg.ksh new file mode 100755 index 000000000000..aa74bcf40c1f --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_create_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_destroy_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_destroy_001_neg.ksh new file mode 100755 index 000000000000..fabba4f13e9c --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_destroy_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_get_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_get_001_neg.ksh new file mode 100755 index 000000000000..0657b9143670 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_get_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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 ${#props[*]} ]] +do + PROP=${props[$i]} + EXPECTED=${prop_vals[$i]} + ACTUAL=$(zfs get -H -o value $PROP $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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_inherit_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_inherit_001_neg.ksh new file mode 100755 index 000000000000..284c9f76dff1 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_inherit_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_mount_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_mount_001_neg.ksh new file mode 100755 index 000000000000..8e4c39bfce75 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_mount_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_promote_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_promote_001_neg.ksh new file mode 100755 index 000000000000..dd92f534d3a1 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_promote_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_receive_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_receive_001_neg.ksh new file mode 100755 index 000000000000..38c11a051028 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_receive_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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 \ + < $TEST_BASE_DIR/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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rename_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rename_001_neg.ksh new file mode 100755 index 000000000000..ac275b01e5f9 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rename_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rollback_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rollback_001_neg.ksh new file mode 100755 index 000000000000..51b5162decfc --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_rollback_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_send_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_send_001_neg.ksh new file mode 100755 index 000000000000..6ecb66a3584c --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_send_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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 $TEST_BASE_DIR/zfstest_datastream.$$ ] + then + log_must rm $TEST_BASE_DIR/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 > $TEST_BASE_DIR/zfstest_datastream.$$" + +# Now check that the above command actually did nothing + +# We should have a non-zero-length file in /tmp +if [ -s $TEST_BASE_DIR/zfstest_datastream.$$ ] +then + log_fail "A zfs send file was created in $TEST_BASE_DIR/zfstest_datastream.$$ !" +fi + +log_pass "zfs send returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_set_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_set_001_neg.ksh new file mode 100755 index 000000000000..9cfb79210b11 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_set_001_neg.ksh @@ -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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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 ${#props[*]} ]] +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 -H -o value $PROP $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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh new file mode 100755 index 000000000000..14c35b3da664 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_share_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" + +if is_linux || is_freebsd; then + log_unsupported "Requires additional dependencies" +fi + +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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_snapshot_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_snapshot_001_neg.ksh new file mode 100755 index 000000000000..232d9574b51c --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_snapshot_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh new file mode 100755 index 000000000000..98383a08762e --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unallow_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unmount_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unmount_001_neg.ksh new file mode 100755 index 000000000000..5b0a773f15a9 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unmount_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh new file mode 100755 index 000000000000..7ae86fc4ec76 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_unshare_001_neg.ksh @@ -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 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# Copyright (c) 2013, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" + +if is_linux || is_freebsd; then + log_unsupported "Requires additional dependencies" +fi + +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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zfs_upgrade_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_upgrade_001_neg.ksh new file mode 100755 index 000000000000..fd65feb8c001 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zfs_upgrade_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh new file mode 100755 index 000000000000..0fddc08b25db --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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 "$TEMPFILE" ] + then + rm -f "$TEMPFILE" + fi +} + +TEMPFILE="$TEST_BASE_DIR/zpool_001_neg.$$.txt" + +log_onexit cleanup +log_assert "zpool shows a usage message when run as a user" + +eval "zpool > $TEMPFILE 2>&1" +log_must grep "usage: zpool command args" "$TEMPFILE" + +log_must eval "awk '{if (length(\$0) > 80) exit 1}' < $TEMPFILE" + +log_pass "zpool shows a usage message when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_add_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_add_001_neg.ksh new file mode 100755 index 000000000000..7bcd911543ed --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_add_001_neg.ksh @@ -0,0 +1,77 @@ +#!/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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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." + +# Under Linux dry-run commands have no legitimate reason to fail. +if is_linux; then + 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" +else + 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" +fi + +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." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_attach_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_attach_001_neg.ksh new file mode 100755 index 000000000000..b0fadca8c9fe --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_attach_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_clear_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_clear_001_neg.ksh new file mode 100755 index 000000000000..5d6ef5ff3e4d --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_clear_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_create_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_create_001_neg.ksh new file mode 100755 index 000000000000..77d08ee39009 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_create_001_neg.ksh @@ -0,0 +1,77 @@ +#!/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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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." + +# Under Linux dry-run commands have no legitimate reason to fail. +if is_linux; then + 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" +else + 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" +fi + +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." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_destroy_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_destroy_001_neg.ksh new file mode 100755 index 000000000000..acc93fe74826 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_destroy_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_detach_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_detach_001_neg.ksh new file mode 100755 index 000000000000..dbc540cebbe7 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_detach_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_export_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_export_001_neg.ksh new file mode 100755 index 000000000000..9bca4668d3d1 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_export_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh new file mode 100755 index 000000000000..7415cebf236b --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_get_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_history_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_history_001_neg.ksh new file mode 100755 index 000000000000..47082e3524e3 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_history_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_001_neg.ksh new file mode 100755 index 000000000000..09fd775ff4cc --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_002_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_002_neg.ksh new file mode 100755 index 000000000000..f3460186725c --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_import_002_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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." diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_offline_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_offline_001_neg.ksh new file mode 100755 index 000000000000..523883c6f0dd --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_offline_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_online_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_online_001_neg.ksh new file mode 100755 index 000000000000..cd290515357f --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_online_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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 brought 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_remove_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_remove_001_neg.ksh new file mode 100755 index 000000000000..1168e6bdac9f --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_remove_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_replace_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_replace_001_neg.ksh new file mode 100755 index 000000000000..6211e6575540 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_replace_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_scrub_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_scrub_001_neg.ksh new file mode 100755 index 000000000000..bf9ee4cfadb0 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_scrub_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# Copyright (c) 2017 Datto Inc. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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 -p $TESTPOOL +log_mustnot zpool scrub -s $TESTPOOL + +log_pass "zpool scrub returns an error when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh new file mode 100755 index 000000000000..941e20c0010e --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_set_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_status_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_status_001_neg.ksh new file mode 100755 index 000000000000..9cd811a5487c --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_status_001_neg.ksh @@ -0,0 +1,72 @@ +#!/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/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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:" $TEST_BASE_DIR/pool-status.$$) + if [ -z "$RESULT" ] + then + log_fail "No pool: string found in zpool status output!" + fi + rm $TEST_BASE_DIR/pool-status.$$ +} + +verify_runnable "global" + +log_assert "zpool status works when run as a user" + +log_must eval "zpool status > $TEST_BASE_DIR/pool-status.$$" +check_pool_status + +log_must eval "zpool status -v > $TEST_BASE_DIR/pool-status.$$" +check_pool_status + +log_must eval "zpool status $TESTPOOL> $TEST_BASE_DIR/pool-status.$$" +check_pool_status + +log_must eval "zpool status -v $TESTPOOL > $TEST_BASE_DIR/pool-status.$$" +check_pool_status + +log_pass "zpool status works when run as a user" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_upgrade_001_neg.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_upgrade_001_neg.ksh new file mode 100755 index 000000000000..aa380010574f --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_upgrade_001_neg.ksh @@ -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, 2016 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/cli_user/misc/misc.cfg + +# +# 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" + +# 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" diff --git a/tests/zfs-tests/tests/functional/cli_user/misc/zpool_wait_privilege.ksh b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_wait_privilege.ksh new file mode 100755 index 000000000000..42a2dd2c63ee --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_user/misc/zpool_wait_privilege.ksh @@ -0,0 +1,35 @@ +#!/bin/ksh -p +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2019 by Delphix. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# DESCRIPTION: +# +# zpool wait works when run as an unprivileged user +# + +verify_runnable "global" + +log_must zpool wait $TESTPOOL + +# Make sure printing status works as unprivileged user. +output=$(zpool wait -H $TESTPOOL 1) || \ + log_fail "'zpool wait -H $TESTPOOL 1' failed" +# There should be one line of status output in a pool with no activity. +log_must eval '[[ $(wc -l <<<$output) -ge 1 ]]' + +log_pass "zpool wait works when run as a user" |