aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2018-05-18 10:02:39 +0200
committerEryu Guan <guaneryu@gmail.com>2018-05-21 16:12:39 +0800
commit968ccf32e411591baa62a065f4f5460cb5be9c24 (patch)
treef78763710398213c8609b04d1814a4dc2d02a3db
parentc3c9630968a66891a134b60ed2a06d71c7a71c3f (diff)
downloadxfstests-dev-968ccf32e411591baa62a065f4f5460cb5be9c24.tar.gz
generic: Handle missing [gs]etcap tools
Add proper requires for getcap and setcap tools to tests that need them. Also define standard variables GETCAP_PROG and SETCAP_PROG. Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rw-r--r--common/config2
-rwxr-xr-xtests/generic/09310
-rwxr-xr-xtests/generic/2706
-rwxr-xr-xtests/xfs/2968
4 files changed, 15 insertions, 11 deletions
diff --git a/common/config b/common/config
index af360cefc8..02c378a96f 100644
--- a/common/config
+++ b/common/config
@@ -205,6 +205,8 @@ export THIN_CHECK_PROG="$(set_prog_path thin_check)"
export PYTHON2_PROG="`set_prog_path python2`"
export SQLITE3_PROG="`set_prog_path sqlite3`"
export TIMEOUT_PROG="`set_prog_path timeout`"
+export SETCAP_PROG="`set_prog_path setcap`"
+export GETCAP_PROG="`set_prog_path getcap`"
# use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
# newer systems have udevadm command but older systems like RHEL5 don't.
diff --git a/tests/generic/093 b/tests/generic/093
index 197e6722f2..e70273bca7 100755
--- a/tests/generic/093
+++ b/tests/generic/093
@@ -54,6 +54,8 @@ _require_test
_require_attrs
_require_user
_require_test_program "writemod"
+_require_command "$SETCAP_PROG" "setcap"
+_require_command "$GETCAP_PROG" "getcap"
rm -f $seqres.full
@@ -65,15 +67,15 @@ rm -f $file
touch $file
echo "**** Verifying that appending to file clears capabilities ****"
-setcap cap_chown+ep $file
-getcap $file | filefilter
+$SETCAP_PROG cap_chown+ep $file
+$GETCAP_PROG $file | filefilter
echo data1 >> $file
cat $file
-getcap $file | filefilter
+$GETCAP_PROG $file | filefilter
echo
echo "**** Verifying that appending to file doesn't clear other xattrs ****"
-setcap cap_chown+ep $file
+$SETCAP_PROG cap_chown+ep $file
$SETFATTR_PROG -n trusted.name -v value $file
echo data2 >> $file
cat $file
diff --git a/tests/generic/270 b/tests/generic/270
index f5026ba0cd..d597ab4942 100755
--- a/tests/generic/270
+++ b/tests/generic/270
@@ -51,10 +51,7 @@ _workout()
echo "fsstress $args" >> $seqres.full
# Grant chown capability
cp $FSSTRESS_PROG $tmp.fsstress.bin
- if [ "`whereis setcap`" == "setcap:" ]; then
- _notrun "setcap not installed."
- fi
- setcap cap_chown=epi $tmp.fsstress.bin
+ $SETCAP_PROG cap_chown=epi $tmp.fsstress.bin
(su $qa_user -c "$tmp.fsstress.bin $args" &) > /dev/null 2>&1
pid=$!
@@ -80,6 +77,7 @@ _require_quota
_require_user
_require_scratch
_require_command "$KILLALL_PROG" killall
+_require_command "$SETCAP_PROG" setcap
rm -f $seqres.full
_scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full 2>&1
diff --git a/tests/xfs/296 b/tests/xfs/296
index 610c2ec426..8baf97abdd 100755
--- a/tests/xfs/296
+++ b/tests/xfs/296
@@ -47,6 +47,8 @@ _cleanup()
_supported_fs xfs
_supported_os Linux
_require_scratch
+_require_command "$SETCAP_PROG" setcap
+_require_command "$GETCAP_PROG" getcap
rm -f $seqres.full
@@ -57,12 +59,12 @@ echo test > $dump_dir/testfile
# Set a generic xattr
setfattr -n user.name -v value $dump_dir/testfile
# Now set the cap (which is also an xattr)
-setcap cap_setgid,cap_setuid+ep $dump_dir/testfile
+$SETCAP_PROG cap_setgid,cap_setuid+ep $dump_dir/testfile
# And make sure they are there on the source
echo "Checking for xattr on source file"
getfattr --absolute-names -m user.name $dump_dir/testfile | _dir_filter
echo "Checking for capability on source file"
-getcap $dump_dir/testfile | _dir_filter
+$GETCAP_PROG $dump_dir/testfile | _dir_filter
getfattr --absolute-names -m security.capability $dump_dir/testfile | _dir_filter
_do_dump_file -f $tmp.df.0
@@ -75,7 +77,7 @@ _diff_compare
echo "Checking for xattr on restored file"
getfattr --absolute-names -m user.name $restore_dir/$dump_sdir/testfile | _dir_filter
echo "Checking for capability on restored file"
-getcap $restore_dir/$dump_sdir/testfile | _dir_filter
+$GETCAP_PROG $restore_dir/$dump_sdir/testfile | _dir_filter
getfattr --absolute-names -m security.capability $restore_dir/$dump_sdir/testfile | _dir_filter
status=0