OpenZFS 7290 - ZFS test suite needs to control what utilities it can run

Authored by: John Wren Kennedy <john.kennedy@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Gordon Ross <gordon.w.ross@gmail.com>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
Ported-by: George Melikov <mail@gmelikov.ru>

Porting Notes:
- Utilities which aren't available under Linux have been removed.
- Because of sudo's default secure path behavior PATH must be
  explicitly reset at the top of libtest.shlib.  This avoids the
  need for all users to customize secure path on their system.
- Updated ZoL infrastructure to manage constrained path
- Updated all test cases
- Check permissions for usergroup tests
- When testing in-tree create links under bin/
- Update fault cleanup such that missing files during
  cleanup aren't fatal.
- Configure su environment with constrained path

OpenZFS-issue: https://www.illumos.org/issues/7290
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/1d32ba6
Closes #5903
This commit is contained in:
John Wren Kennedy
2017-04-05 20:18:22 -04:00
committed by Brian Behlendorf
parent 7a4500a101
commit c1d9abf905
797 changed files with 8038 additions and 7458 deletions
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -51,11 +51,11 @@ log_assert "Ensure that pool names can use the ASCII subset of UTF-8"
function cleanup
{
if [[ -n $name ]] && poolexists $name ; then
log_must $ZPOOL destroy $name
log_must zpool destroy $name
fi
if [[ -d $TESTDIR ]]; then
log_must $RM -rf $TESTDIR
log_must rm -rf $TESTDIR
fi
}
@@ -64,7 +64,7 @@ log_onexit cleanup
DISK=${DISKS%% *}
if [[ ! -e $TESTDIR ]]; then
log_must $MKDIR $TESTDIR
log_must mkdir $TESTDIR
fi
log_note "Ensure letters of the alphabet are allowable"
@@ -76,12 +76,12 @@ for name in A B C D E F G H I J K L M \
a b c d e f g h i j k l m \
n o p q r s t u v w x y z
do
log_must $ZPOOL create -m $TESTDIR $name $DISK
log_must zpool create -m $TESTDIR $name $DISK
if ! poolexists $name; then
log_fail "Could not create a pool called '$name'"
fi
log_must $ZPOOL destroy $name
log_must zpool destroy $name
done
log_note "Ensure a variety of unusual names passes"
@@ -95,7 +95,7 @@ for name in "a.............................." "a_" "a-" "a:" \
"spar3-p00l" "hiddenmirrorpool" "hiddenraidzpool" \
"hiddensparepool"
do
log_must $ZPOOL create -m $TESTDIR $name $DISK
log_must zpool create -m $TESTDIR $name $DISK
if ! poolexists $name; then
log_fail "Could not create a pool called '$name'"
fi
@@ -104,13 +104,13 @@ do
# Since the naming convention applies to datasets too,
# create datasets with the same names as above.
#
log_must $ZFS create $name/$name
log_must $ZFS snapshot $name/$name@$name
log_must $ZFS clone $name/$name@$name $name/clone_$name
log_must $ZFS create -V 150m $name/$name/$name
log_must zfs create $name/$name
log_must zfs snapshot $name/$name@$name
log_must zfs clone $name/$name@$name $name/clone_$name
log_must zfs create -V 150m $name/$name/$name
block_device_wait
log_must $ZPOOL destroy $name
log_must zpool destroy $name
done
log_pass "Valid pool names were accepted correctly."
@@ -26,7 +26,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -53,27 +53,27 @@ POOLNAME=""
function cleanup
{
if poolexists $POOLNAME; then
log_must $ZPOOL destroy $POOLNAME
log_must zpool destroy $POOLNAME
fi
if [[ -d $TESTDIR ]]; then
log_must $RM -rf $TESTDIR
log_must rm -rf $TESTDIR
fi
}
log_onexit cleanup
typeset exclude=`eval $ECHO \"'(${KEEP})'\"`
for pool in $($ZPOOL list -H -o name | \
$EGREP -v "$exclude" | \
$GREP -v "$TESTPOOL" | \
$EGREP -v "$NO_POOLS"); do
log_must $ZPOOL destroy $pool
typeset exclude=`eval echo \"'(${KEEP})'\"`
for pool in $(zpool list -H -o name | \
egrep -v "$exclude" | \
grep -v "$TESTPOOL" | \
egrep -v "$NO_POOLS"); do
log_must zpool destroy $pool
done
DISK=${DISKS%% *}
if [[ ! -e $TESTDIR ]]; then
log_must $MKDIR $TESTDIR
log_must mkdir $TESTDIR
fi
log_note "Ensure invalid characters fail"
@@ -83,12 +83,12 @@ for POOLNAME in "!" "\"" "#" "$" "%" "&" "'" "(" ")" \
":" ";" "<" "=" ">" "\?" "@" \
"[" "]" "^" "_" "\`" "{" "|" "}" "~"
do
log_mustnot $ZPOOL create -m $TESTDIR $POOLNAME $DISK
log_mustnot zpool create -m $TESTDIR $POOLNAME $DISK
if poolexists $POOLNAME; then
log_fail "Unexpectedly created pool: '$POOLNAME'"
fi
log_mustnot $ZPOOL destroy $POOLNAME
log_mustnot zpool destroy $POOLNAME
done
log_note "Check that invalid octal values fail"
@@ -99,12 +99,12 @@ for oct in "\000" "\001" "\002" "\003" "\004" "\005" "\006" "\007" \
"\040" "\177"
do
POOLNAME=`eval "echo x | tr 'x' '$oct'"`
log_mustnot $ZPOOL create -m $TESTDIR $POOLNAME $DISK
log_mustnot zpool create -m $TESTDIR $POOLNAME $DISK
if poolexists $POOLNAME; then
log_fail "Unexpectedly created pool: '$POOLNAME'"
fi
log_mustnot $ZPOOL destroy $POOLNAME
log_mustnot zpool destroy $POOLNAME
done
log_note "Verify invalid pool names fail"
@@ -118,12 +118,12 @@ if verify_slog_support ; then
fi
typeset -i i=0
while ((i < ${#POOLNAME[@]})); do
log_mustnot $ZPOOL create -m $TESTDIR ${POOLNAME[$i]} $DISK
log_mustnot zpool create -m $TESTDIR ${POOLNAME[$i]} $DISK
if poolexists ${POOLNAME[$i]}; then
log_fail "Unexpectedly created pool: '${POOLNAME[$i]}'"
fi
log_mustnot $ZPOOL destroy ${POOLNAME[$i]}
log_mustnot zpool destroy ${POOLNAME[$i]}
((i += 1))
done