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
@@ -25,7 +25,7 @@
#
#
# Copyright (c) 2013 by Delphix. All rights reserved.
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
@@ -55,7 +55,7 @@ function _check_used # dataset
function check_used # dataset
{
typeset dataset=$1
for child in $($ZFS list -rH -t filesystem,volume -o name $dataset)
for child in $(zfs list -rH -t filesystem,volume -o name $dataset)
do
_check_used $child
done
@@ -66,7 +66,7 @@ function check_usedbychildren # dataset
typeset dataset=$1
typeset -i usedbychildren_sum=0
typeset -i parent_usedbychildren=0
for child in $($ZFS list -rH -t filesystem,volume -o name $dataset)
for child in $(zfs list -rH -t filesystem,volume -o name $dataset)
do
if [[ "$(get_prop type $child)" == "snapshot" ]]; then
continue
@@ -120,7 +120,7 @@ function _check_usedbydataset # dataset
function check_usedbydataset # dataset
{
typeset dataset=$1
for child in $($ZFS list -rH -t filesystem,volume -o name $dataset)
for child in $(zfs list -rH -t filesystem,volume -o name $dataset)
do
_check_usedbydataset $child
done
@@ -146,7 +146,7 @@ function _check_usedbyrefreservation # dataset
function check_usedbyrefreservation # dataset
{
typeset dataset=$1
for child in $($ZFS list -rH -t filesystem,volume -o name $dataset)
for child in $(zfs list -rH -t filesystem,volume -o name $dataset)
do
_check_usedbyrefreservation $child
done
@@ -157,7 +157,7 @@ function check_usedbysnapshots # dataset
typeset dataset=$1
typeset -i usedbysnapshots_sum=0
typeset -i parent_usedbysnapshots=0
for child in $($ZFS list -rH -t filesystem,volume,snapshot -o name $dataset)
for child in $(zfs list -rH -t filesystem,volume,snapshot -o name $dataset)
do
# parent
if [[ "$child" == "$dataset" ]]; then
@@ -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,13 +51,13 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rR $USEDTEST
log_must zfs destroy -rR $USEDTEST
}
log_assert "Verify used is correct."
log_onexit cleanup
log_must $ZFS create $USEDTEST
log_must zfs create $USEDTEST
check_used $USEDTEST
typeset -i i=0
@@ -67,21 +67,21 @@ while ((i < 5)); do
((r_size=(i+1)*16))
#usedbyrefreservation
log_must $ZFS set refreservation="$r_size"M $USEDTEST
log_must zfs set refreservation="$r_size"M $USEDTEST
#usedbydataset
log_must $MKFILE 16M $mntpnt/file$i
log_must mkfile 16M $mntpnt/file$i
#usedbychildren
log_must $ZFS create $USEDTEST/fs$i
log_must $MKFILE 16M $mntpnt/fs$i/file$i
log_must zfs create $USEDTEST/fs$i
log_must mkfile 16M $mntpnt/fs$i/file$i
if is_global_zone; then
log_must $ZFS create -V 16M $USEDTEST/vol$i
log_must zfs create -V 16M $USEDTEST/vol$i
fi
#usedbysnapshots
log_must $ZFS snapshot -r $USEDTEST@snap$i
log_must zfs snapshot -r $USEDTEST@snap$i
check_used $USEDTEST
@@ -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
@@ -49,13 +49,13 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rR $USEDTEST
log_must zfs destroy -rR $USEDTEST
}
log_assert "Verify usedbychildren is correct."
log_onexit cleanup
log_must $ZFS create $USEDTEST
log_must zfs create $USEDTEST
check_usedbychildren $USEDTEST
typeset -i i=0
@@ -64,15 +64,15 @@ mntpnt=$(get_prop mountpoint $USEDTEST)
while ((i < 5)); do
((r_size=(i+1)*16))
log_must $ZFS create $USEDTEST/fs$i
log_must $ZFS set reservation="$r_size"M $USEDTEST/fs$i
log_must $MKFILE 48M $mntpnt/fs$i/file$i
log_must zfs create $USEDTEST/fs$i
log_must zfs set reservation="$r_size"M $USEDTEST/fs$i
log_must mkfile 48M $mntpnt/fs$i/file$i
if is_global_zone; then
log_must $ZFS create -V 32M $USEDTEST/vol$i
log_must zfs create -V 32M $USEDTEST/vol$i
fi
log_must $ZFS snapshot -r $USEDTEST@snap$i
log_must zfs snapshot -r $USEDTEST@snap$i
check_usedbychildren $USEDTEST
@@ -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
@@ -48,13 +48,13 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rR $USEDTEST
log_must zfs destroy -rR $USEDTEST
}
log_assert "Verify usedbydataset is correct."
log_onexit cleanup
log_must $ZFS create $USEDTEST
log_must zfs create $USEDTEST
check_usedbydataset $USEDTEST
typeset -i i=0
@@ -63,16 +63,16 @@ mntpnt=$(get_prop mountpoint $USEDTEST)
while ((i < 5)); do
((r_size=(i+1)*16))
log_must $MKFILE 16M $mntpnt/file$i
log_must $MKFILE "$r_size"M $mntpnt/file_var$i
log_must $ZFS snapshot -r $USEDTEST@snap$i
log_must mkfile 16M $mntpnt/file$i
log_must mkfile "$r_size"M $mntpnt/file_var$i
log_must zfs snapshot -r $USEDTEST@snap$i
log_must $ZFS clone $USEDTEST@snap$i $USEDTEST/cln$i
log_must $ZFS set is:cloned=yes $USEDTEST/cln$i
log_must zfs clone $USEDTEST@snap$i $USEDTEST/cln$i
log_must zfs set is:cloned=yes $USEDTEST/cln$i
mntpnt_cln=$(get_prop mountpoint $USEDTEST/cln$i)
log_must $MKFILE 16M $mntpnt_cln/file_cln$i
log_must $MKFILE "$r_size"M $mntpnt_cln/file_cln_var$i
log_must mkfile 16M $mntpnt_cln/file_cln$i
log_must mkfile "$r_size"M $mntpnt_cln/file_cln_var$i
check_usedbydataset $USEDTEST
@@ -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,13 +53,13 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rR $USEDTEST
log_must zfs destroy -rR $USEDTEST
}
log_assert "Verify usedbyrefreservation is correct."
log_onexit cleanup
log_must $ZFS create $USEDTEST
log_must zfs create $USEDTEST
check_usedbyrefreservation $USEDTEST
typeset -i i=0
@@ -67,25 +67,25 @@ typeset -i r_size=0
mntpnt=$(get_prop mountpoint $USEDTEST)
while ((i < 5)); do
((r_size=(i+1)*16))
log_must $ZFS set refreservation="$r_size"M $USEDTEST
log_must zfs set refreservation="$r_size"M $USEDTEST
log_must $MKFILE 16M $mntpnt/file$i
log_must mkfile 16M $mntpnt/file$i
log_must $ZFS create $USEDTEST/fs$i
log_must $ZFS set refreservation="$r_size"M $USEDTEST/fs$i
log_must $MKFILE 16M $mntpnt/fs$i/file$i
log_must zfs create $USEDTEST/fs$i
log_must zfs set refreservation="$r_size"M $USEDTEST/fs$i
log_must mkfile 16M $mntpnt/fs$i/file$i
if is_global_zone; then
log_must $ZFS create -V 16M $USEDTEST/vol$i
log_must zfs create -V 16M $USEDTEST/vol$i
fi
log_must $ZFS snapshot -r $USEDTEST@snap$i
log_must zfs snapshot -r $USEDTEST@snap$i
log_must $ZFS clone $USEDTEST@snap$i $USEDTEST/cln$i
log_must zfs clone $USEDTEST@snap$i $USEDTEST/cln$i
mntpnt_cln=$(get_prop mountpoint $USEDTEST/cln$i)
log_must $ZFS set refreservation="$r_size"M $USEDTEST/cln$i
log_must $MKFILE 16M $mntpnt_cln/file_cln$i
log_must zfs set refreservation="$r_size"M $USEDTEST/cln$i
log_must mkfile 16M $mntpnt_cln/file_cln$i
check_usedbyrefreservation $USEDTEST
@@ -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
@@ -47,13 +47,13 @@ verify_runnable "both"
function cleanup
{
log_must $ZFS destroy -rR $USEDTEST
log_must zfs destroy -rR $USEDTEST
}
log_assert "Verify usedbysnapshots is correct."
log_onexit cleanup
log_must $ZFS create $USEDTEST
log_must zfs create $USEDTEST
check_usedbysnapshots $USEDTEST
typeset -i i=0
@@ -62,9 +62,9 @@ mntpnt=$(get_prop mountpoint $USEDTEST)
while ((i < 5)); do
((r_size=(i+1)*16))
log_must $MKFILE "$r_size"M $mntpnt/file$i
log_must mkfile "$r_size"M $mntpnt/file$i
log_must $ZFS snapshot $USEDTEST@snap$i
log_must zfs snapshot $USEDTEST@snap$i
check_usedbysnapshots $USEDTEST
((i = i + 1))