From: Darrick J. Wong Date: Mon, 3 Feb 2025 22:00:27 +0000 (-0800) Subject: common/rc: create a wrapper for the su command X-Git-Tag: v2025.02.23~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=77548e6066fd44e328d0785ffb65714483e666eb;p=xfstests-dev.git common/rc: create a wrapper for the su command Create a _su wrapper around the su command so that the next patch can fix all the pkill isolation code so that this test can only kill processes started for this test. Signed-off-by: "Darrick J. Wong" Reviewed-by: Dave Chinner Signed-off-by: Zorro Lang --- diff --git a/common/rc b/common/rc index c4c934ed..1f1d75e9 100644 --- a/common/rc +++ b/common/rc @@ -2726,6 +2726,11 @@ _require_user_exists() [ "$?" == "0" ] || _notrun "$user user not defined." } +_su() +{ + su "$@" +} + # check if a user exists and is able to execute commands. # Uses 'fsgqa' user as default. # @@ -2736,7 +2741,7 @@ _require_user() qa_user=$1 fi _require_user_exists $qa_user - echo /bin/true | su $qa_user + echo /bin/true | _su $qa_user [ "$?" == "0" ] || _notrun "$qa_user cannot execute commands." } @@ -2798,7 +2803,7 @@ s,^\s*$,,; _user_do() { - echo $1 | su -s /bin/bash $qa_user 2>&1 | _filter_user_do + echo $1 | _su -s /bin/bash $qa_user 2>&1 | _filter_user_do } _require_xfs_io_command() diff --git a/tests/generic/093 b/tests/generic/093 index c4e866da..047cc821 100755 --- a/tests/generic/093 +++ b/tests/generic/093 @@ -62,7 +62,7 @@ chmod ugo+w $TEST_DIR # don't use $here/src/writemod, as we're running it as a regular user, and # $here may contain path component that a regular user doesn't have search # permission -su $qa_user -c "src/writemod $file" | filefilter +_su $qa_user -c "src/writemod $file" | filefilter cat $file # success, all done diff --git a/tests/generic/125 b/tests/generic/125 index e2bc5fa1..011a51e8 100755 --- a/tests/generic/125 +++ b/tests/generic/125 @@ -32,7 +32,7 @@ chmod a+rw $TESTFILE # don't use $here/src/ftrunc, as we're running it as a regular user, and $here # may contain path component that a regular user doesn't have search permission -su $qa_user -c "./src/ftrunc -f $TESTFILE" +_su $qa_user -c "./src/ftrunc -f $TESTFILE" if [ "$?" != "0" ]; then echo src/ftrunc returned non 0 status! diff --git a/tests/generic/128 b/tests/generic/128 index f931ca06..5a497cde 100755 --- a/tests/generic/128 +++ b/tests/generic/128 @@ -26,7 +26,7 @@ cp "$(type -P ls)" $SCRATCH_MNT chmod 700 $SCRATCH_MNT/nosuid chmod 4755 $SCRATCH_MNT/ls -su -s/bin/bash - $qa_user -c "$SCRATCH_MNT/ls $SCRATCH_MNT/nosuid >/dev/null 2>&1" +_su -s/bin/bash - $qa_user -c "$SCRATCH_MNT/ls $SCRATCH_MNT/nosuid >/dev/null 2>&1" if [ $? -eq 0 ] ; then echo "Error: we shouldn't be able to ls the directory" fi diff --git a/tests/generic/193 b/tests/generic/193 index d251d3a5..ba557428 100755 --- a/tests/generic/193 +++ b/tests/generic/193 @@ -69,17 +69,17 @@ echo _create_files echo "user: chown root owned file to qa_user (should fail)" -su ${qa_user} -c "chown ${qa_user} $test_root" 2>&1 | _filter_files +_su ${qa_user} -c "chown ${qa_user} $test_root" 2>&1 | _filter_files echo "user: chown root owned file to root (should fail)" -su ${qa_user} -c "chown root $test_root" 2>&1 | _filter_files +_su ${qa_user} -c "chown root $test_root" 2>&1 | _filter_files echo "user: chown qa_user owned file to qa_user (should succeed)" -su ${qa_user} -c "chown ${qa_user} $test_user" +_su ${qa_user} -c "chown ${qa_user} $test_user" # this would work without _POSIX_CHOWN_RESTRICTED echo "user: chown qa_user owned file to root (should fail)" -su ${qa_user} -c "chown root $test_user" 2>&1 | _filter_files +_su ${qa_user} -c "chown root $test_user" 2>&1 | _filter_files _cleanup_files @@ -93,19 +93,19 @@ echo _create_files echo "user: chgrp root owned file to root (should fail)" -su ${qa_user} -c "chgrp root $test_root" 2>&1 | _filter_files +_su ${qa_user} -c "chgrp root $test_root" 2>&1 | _filter_files echo "user: chgrp qa_user owned file to root (should fail)" -su ${qa_user} -c "chgrp root $test_user" 2>&1 | _filter_files +_su ${qa_user} -c "chgrp root $test_user" 2>&1 | _filter_files echo "user: chgrp root owned file to qa_user (should fail)" -su ${qa_user} -c "chgrp ${qa_user} $test_root" 2>&1 | _filter_files +_su ${qa_user} -c "chgrp ${qa_user} $test_root" 2>&1 | _filter_files echo "user: chgrp qa_user owned file to qa_user (should succeed)" -su ${qa_user} -c "chgrp ${qa_user} $test_user" +_su ${qa_user} -c "chgrp ${qa_user} $test_user" #echo "user: chgrp qa_user owned file to secondary group (should succeed)" -#su ${qa_user} -c "chgrp ${group2} $test_user" +#_su ${qa_user} -c "chgrp ${group2} $test_user" _cleanup_files @@ -119,10 +119,10 @@ echo _create_files echo "user: chmod a+r on qa_user owned file (should succeed)" -su ${qa_user} -c "chmod a+r $test_user" +_su ${qa_user} -c "chmod a+r $test_user" echo "user: chmod a+r on root owned file (should fail)" -su ${qa_user} -c "chmod a+r $test_root" 2>&1 | _filter_files +_su ${qa_user} -c "chmod a+r $test_root" 2>&1 | _filter_files # # Setup a file owned by the qa_user, but with a group ID that @@ -143,7 +143,7 @@ chown ${qa_user}:root $test_user chmod g+s $test_user # and let the qa_user change permission bits -su ${qa_user} -c "chmod a+w $test_user" +_su ${qa_user} -c "chmod a+w $test_user" stat -c '%A' $test_user # @@ -220,7 +220,7 @@ echo "with no exec perm" echo frobnozzle >> $test_user chmod ug+s $test_user echo -n "before: "; stat -c '%A' $test_user -su ${qa_user} -c "echo > $test_user" +_su ${qa_user} -c "echo > $test_user" echo -n "after: "; stat -c '%A' $test_user echo "with user exec perm" @@ -228,7 +228,7 @@ echo frobnozzle >> $test_user chmod ug+s $test_user chmod u+x $test_user echo -n "before: "; stat -c '%A' $test_user -su ${qa_user} -c "echo > $test_user" +_su ${qa_user} -c "echo > $test_user" echo -n "after: "; stat -c '%A' $test_user echo "with group exec perm" @@ -237,7 +237,7 @@ chmod ug+s $test_user chmod g+x $test_user chmod u-x $test_user echo -n "before: "; stat -c '%A' $test_user -su ${qa_user} -c "echo > $test_user" +_su ${qa_user} -c "echo > $test_user" echo -n "after: "; stat -c '%A' $test_user echo "with user+group exec perm" @@ -245,7 +245,7 @@ echo frobnozzle >> $test_user chmod ug+s $test_user chmod ug+x $test_user echo -n "before: "; stat -c '%A' $test_user -su ${qa_user} -c "echo > $test_user" +_su ${qa_user} -c "echo > $test_user" echo -n "after: "; stat -c '%A' $test_user # @@ -258,10 +258,10 @@ echo _create_files echo "user: touch qa_user file (should succeed)" -su ${qa_user} -c "touch $test_user" +_su ${qa_user} -c "touch $test_user" echo "user: touch root file (should fail)" -su ${qa_user} -c "touch $test_root" 2>&1 | _filter_files +_su ${qa_user} -c "touch $test_root" 2>&1 | _filter_files _cleanup_files diff --git a/tests/generic/230 b/tests/generic/230 index ba95fbe7..18e20f4b 100755 --- a/tests/generic/230 +++ b/tests/generic/230 @@ -33,13 +33,13 @@ test_enforcement() echo "--- initiating IO..." >>$seqres.full # Firstly fit below block soft limit echo "Write 225 blocks..." - su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((225 * $BLOCK_SIZE))' -c fsync \ + _su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((225 * $BLOCK_SIZE))' -c fsync \ $SCRATCH_MNT/file1" 2>&1 >>$seqres.full | \ _filter_xfs_io_error | tee -a $seqres.full repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 # Secondly overcome block soft limit echo "Rewrite 250 blocks plus 1 byte..." - su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((250 * $BLOCK_SIZE + 1))' -c fsync \ + _su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((250 * $BLOCK_SIZE + 1))' -c fsync \ $SCRATCH_MNT/file1" 2>&1 >>$seqres.full | \ _filter_xfs_io_error | tee -a $seqres.full repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 @@ -49,14 +49,14 @@ test_enforcement() # scratch device that may leed to grace time exceed. setquota -$type $qa_user -T $grace $grace $SCRATCH_MNT 2>/dev/null echo "Write 250 blocks..." - su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((250 * $BLOCK_SIZE))' -c fsync \ + _su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((250 * $BLOCK_SIZE))' -c fsync \ $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | \ _filter_xfs_io_error | tee -a $seqres.full repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 # Now sleep for grace time and check that softlimit got enforced sleep $((grace+1)) echo "Write 1 block..." - su $qa_user -c "$XFS_IO_PROG -c 'truncate 0' -c 'pwrite 0 $BLOCK_SIZE' \ + _su $qa_user -c "$XFS_IO_PROG -c 'truncate 0' -c 'pwrite 0 $BLOCK_SIZE' \ $SCRATCH_MNT/file2" 2>&1 >>$seqres.full | \ _filter_xfs_io_error | tee -a $seqres.full repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 @@ -65,7 +65,7 @@ test_enforcement() # space reservations on XFS setquota -$type $qa_user 0 0 3 5 $SCRATCH_MNT echo "Touch 3+4" - su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \ + _su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \ 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 # Try to exceed inode hardlimit @@ -74,14 +74,14 @@ test_enforcement() # scratch device that may leed to grace time exceed. setquota -$type $qa_user -T $grace $grace $SCRATCH_MNT 2>/dev/null echo "Touch 5+6" - su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \ + _su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \ 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 # Wait and check grace time enforcement rm -f $SCRATCH_MNT/file5 >>$seqres.full 2>&1 sleep $((grace+1)) echo "Touch 5" - su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seqres.full | + _su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 echo "--- completed IO ($type)" >>$seqres.full diff --git a/tests/generic/231 b/tests/generic/231 index ef3ea45d..8dda926d 100755 --- a/tests/generic/231 +++ b/tests/generic/231 @@ -24,7 +24,7 @@ _fsx() for (( i = 1; i <= $tasks; i++ )); do SEED=$RANDOM echo "ltp/fsx $FSX_ARGS -S $SEED $SCRATCH_MNT/fsx_file$i" >>$seqres.full - su $qa_user -c "ltp/fsx $FSX_ARGS -S $SEED \ + _su $qa_user -c "ltp/fsx $FSX_ARGS -S $SEED \ $FSX_AVOID $SCRATCH_MNT/fsx_file$i" >$tmp.output$i 2>&1 & done diff --git a/tests/generic/233 b/tests/generic/233 index b4c804ff..df67b390 100755 --- a/tests/generic/233 +++ b/tests/generic/233 @@ -43,7 +43,7 @@ _fsstress() # temporarily. ulimit -l unlimited echo "fsstress $args" >> $seqres.full - if ! su $qa_user -c "$FSSTRESS_PROG $args" | tee -a $seqres.full | _filter_num + if ! _su $qa_user -c "$FSSTRESS_PROG $args" | tee -a $seqres.full | _filter_num then echo " fsstress $args returned $?" cat $tmp.out | tee -a $seqres.full diff --git a/tests/generic/270 b/tests/generic/270 index 342ac8b5..d74971bb 100755 --- a/tests/generic/270 +++ b/tests/generic/270 @@ -37,14 +37,14 @@ _workout() # io_uring_queue_init fail on ENOMEM, set max locked memory to unlimited # temporarily. ulimit -l unlimited - su $qa_user -c "$_FSSTRESS_PROG $args" > /dev/null 2>&1 & + _su $qa_user -c "$_FSSTRESS_PROG $args" > /dev/null 2>&1 & _FSSTRESS_PID=$! echo "Run dd writers in parallel" for ((i=0; i < num_iterations; i++)) do # File will be opened with O_TRUNC each time - su $qa_user -c "dd if=/dev/zero \ + _su $qa_user -c "dd if=/dev/zero \ of=$SCRATCH_MNT/SPACE_CONSUMER bs=1M " \ >> $seqres.full 2>&1 sleep $enospc_time diff --git a/tests/generic/314 b/tests/generic/314 index 5fbc6424..65f7f9d9 100755 --- a/tests/generic/314 +++ b/tests/generic/314 @@ -27,7 +27,7 @@ chown $qa_user:12345 $TEST_DIR/$seq-dir chmod 2775 $TEST_DIR/$seq-dir # Make subdir -su $qa_user -c "umask 022; mkdir $TEST_DIR/$seq-dir/subdir" +_su $qa_user -c "umask 022; mkdir $TEST_DIR/$seq-dir/subdir" # Subdir should have inherited sgid _ls_l $TEST_DIR/$seq-dir/ | grep -v total | _filter_test_dir | awk '{print $1,$NF}' diff --git a/tests/generic/327 b/tests/generic/327 index 2323e1e6..18cfcd1f 100755 --- a/tests/generic/327 +++ b/tests/generic/327 @@ -47,7 +47,7 @@ _report_quota_blocks $SCRATCH_MNT echo "Try to reflink again" touch $testdir/file3 chown $qa_user $testdir/file3 -su $qa_user -c "cp --reflink=always -f $testdir/file1 $testdir/file3" 2>&1 | _filter_scratch +_su $qa_user -c "cp --reflink=always -f $testdir/file1 $testdir/file3" 2>&1 | _filter_scratch _report_quota_blocks $SCRATCH_MNT # success, all done diff --git a/tests/generic/328 b/tests/generic/328 index 7071ded2..fa33bdb7 100755 --- a/tests/generic/328 +++ b/tests/generic/328 @@ -47,12 +47,12 @@ setquota -u $qa_user 0 1024 0 0 $SCRATCH_MNT _report_quota_blocks $SCRATCH_MNT echo "Try to dio write the whole file" -su $qa_user -c '$XFS_IO_PROG -d -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \ +_su $qa_user -c '$XFS_IO_PROG -d -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \ _filter_xfs_io_error _report_quota_blocks $SCRATCH_MNT echo "Try to write the whole file" -su $qa_user -c '$XFS_IO_PROG -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \ +_su $qa_user -c '$XFS_IO_PROG -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \ _filter_xfs_io_error _report_quota_blocks $SCRATCH_MNT diff --git a/tests/generic/355 b/tests/generic/355 index b0f8fc45..6b4f7eba 100755 --- a/tests/generic/355 +++ b/tests/generic/355 @@ -22,7 +22,7 @@ rm -f $testfile do_io() { - su $qa_user -c "$XFS_IO_PROG -d -c 'pwrite 0 4k' $testfile" \ + _su $qa_user -c "$XFS_IO_PROG -d -c 'pwrite 0 4k' $testfile" \ >>$seqres.full } diff --git a/tests/generic/453 b/tests/generic/453 index b7e686f3..04945ad1 100755 --- a/tests/generic/453 +++ b/tests/generic/453 @@ -196,7 +196,7 @@ setf "job offer\xef\xb9\x92pdf" "small full stop" setf "job offer\xef\xbc\x8epdf" "fullwidth full stop" setf "job offer\xdc\x81pdf" "syriac supralinear full stop" setf "job offer\xdc\x82pdf" "syriac sublinear full stop" -setf "job offer\xea\x93\xb8pdf" "lisu letter tone mya ti" +setf "job offer\xea\x93\xb8pdf" "li_su letter tone mya ti" setf "job offer.pdf" "actual period" # encoding hidden tag characters in filenames to create confusing names @@ -270,7 +270,7 @@ testf "job offer\xef\xb9\x92pdf" "small full stop" testf "job offer\xef\xbc\x8epdf" "fullwidth full stop" testf "job offer\xdc\x81pdf" "syriac supralinear full stop" testf "job offer\xdc\x82pdf" "syriac sublinear full stop" -testf "job offer\xea\x93\xb8pdf" "lisu letter tone mya ti" +testf "job offer\xea\x93\xb8pdf" "li_su letter tone mya ti" testf "job offer.pdf" "actual period" testf "llamapirate\xf3\xa0\x80\x81\xf3\xa0\x81\x94\xf3\xa0\x81\xa8\xf3\xa0\x81\xa5\xf3\xa0\x80\xa0\xf3\xa0\x81\xb3\xf3\xa0\x81\xa1\xf3\xa0\x81\xac\xf3\xa0\x81\xa5\xf3\xa0\x81\xb3\xf3\xa0\x80\xa0\xf3\xa0\x81\xa6\xf3\xa0\x81\xaf\xf3\xa0\x81\xb2\xf3\xa0\x80\xa0\xf3\xa0\x81\x93\xf3\xa0\x81\xa5\xf3\xa0\x81\xa1\xf3\xa0\x81\xb4\xf3\xa0\x81\xb4\xf3\xa0\x81\xac\xf3\xa0\x81\xa5\xf3\xa0\x80\xa0\xf3\xa0\x81\xb7\xf3\xa0\x81\xa5\xf3\xa0\x81\xb2\xf3\xa0\x81\xa5\xf3\xa0\x80\xa0\xf3\xa0\x81\x95\xf3\xa0\x81\x93\xf3\xa0\x81\x84\xf3\xa0\x80\xa0\xf3\xa0\x80\xb1\xf3\xa0\x80\xb2\xf3\xa0\x80\xb0\xf3\xa0\x80\xb0\xf3\xa0\x80\xb0\xf3\xa0\x80\xb0\xf3\xa0\x81\xbf" @@ -307,7 +307,7 @@ if _check_xfs_scrub_does_unicode "$SCRATCH_MNT" "$SCRATCH_DEV"; then grep -q "job offer.xef.xbc.x8epdf" $tmp.scrub || echo "No complaints about fullwidth full stop?" grep -q "job offer.xdc.x81pdf" $tmp.scrub || echo "No complaints about syriac supralinear full stop?" grep -q "job offer.xdc.x82pdf" $tmp.scrub || echo "No complaints about syriac sublinear full stop?" - grep -q "job offer.xea.x93.xb8pdf" $tmp.scrub || echo "No complaints about lisu letter tone mya ti?" + grep -q "job offer.xea.x93.xb8pdf" $tmp.scrub || echo "No complaints about li_su letter tone mya ti?" grep -q "job offer.*could be confused with" $tmp.scrub || echo "No complaints about confusing job offers?" grep -q "job offer.xe2.x80.xa4.xe2.x80.x8dpdf" $tmp.scrub || echo "No complaints about one dot leader with invisible space?" grep -q "llamapirate" $tmp.scrub || echo "No complaints about hidden llm instructions in filenames?" diff --git a/tests/generic/514 b/tests/generic/514 index 7f3d9c16..a2086a25 100755 --- a/tests/generic/514 +++ b/tests/generic/514 @@ -21,7 +21,7 @@ _scratch_mount chmod a+rwx $SCRATCH_MNT $XFS_IO_PROG -f -c "pwrite -S 0x18 0 1m" $SCRATCH_MNT/foo >>$seqres.full -su -s/bin/bash - $qa_user -c "ulimit -f 64 ; $XFS_IO_PROG -f -c \"reflink $SCRATCH_MNT/foo\" $SCRATCH_MNT/bar" >> $seqres.full 2>&1 +_su -s/bin/bash - $qa_user -c "ulimit -f 64 ; $XFS_IO_PROG -f -c \"reflink $SCRATCH_MNT/foo\" $SCRATCH_MNT/bar" >> $seqres.full 2>&1 sz="$(_get_filesize $SCRATCH_MNT/bar)" if [ "$sz" -ne 0 ] && [ "$sz" -ne 65536 ]; then diff --git a/tests/generic/573 b/tests/generic/573 index b310fccb..d3f3296c 100755 --- a/tests/generic/573 +++ b/tests/generic/573 @@ -56,7 +56,7 @@ $CHATTR_PROG -i $fsv_file _fsv_scratch_begin_subtest "FS_IOC_MEASURE_VERITY doesn't require root" _fsv_create_enable_file $fsv_file >> $seqres.full chmod 444 $fsv_file -su $qa_user -c "$FSVERITY_PROG measure $fsv_file" >> $seqres.full +_su $qa_user -c "$FSVERITY_PROG measure $fsv_file" >> $seqres.full # success, all done status=0 diff --git a/tests/generic/600 b/tests/generic/600 index 43f75376..31c83225 100755 --- a/tests/generic/600 +++ b/tests/generic/600 @@ -33,7 +33,7 @@ setquota -t -u 0 1 $SCRATCH_MNT # Soft inode limit 1, hard limit 5 setquota -u $qa_user 0 0 1 5 $SCRATCH_MNT # Run qa user over soft limit and go over grace period -su $qa_user -c "touch $SCRATCH_MNT/file1 $SCRATCH_MNT/file2" +_su $qa_user -c "touch $SCRATCH_MNT/file1 $SCRATCH_MNT/file2" sleep 3 # Extend grace to now + 100s now=`date +%s` diff --git a/tests/generic/601 b/tests/generic/601 index 78b6a4aa..320ac0c7 100755 --- a/tests/generic/601 +++ b/tests/generic/601 @@ -42,7 +42,7 @@ $XFS_QUOTA_PROG -x -c "timer -u -i -d 1" $SCRATCH_MNT # Soft inode limit 1, hard limit 5 $XFS_QUOTA_PROG -x -c "limit -u isoft=1 ihard=5 $qa_user" $SCRATCH_MNT # Run qa user over soft limit and go over grace period -su $qa_user -c "touch $SCRATCH_MNT/file1 $SCRATCH_MNT/file2" +_su $qa_user -c "touch $SCRATCH_MNT/file1 $SCRATCH_MNT/file2" sleep 3 # Extend grace to now + 100s now=`date +%s` diff --git a/tests/generic/603 b/tests/generic/603 index 2a75cf9e..b199f801 100755 --- a/tests/generic/603 +++ b/tests/generic/603 @@ -66,13 +66,13 @@ test_grace() echo "--- Test block quota ---" # Firstly fit below block soft limit echo "Write 225 blocks..." - su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((225 * $BLOCK_SIZE))' \ + _su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((225 * $BLOCK_SIZE))' \ -c fsync $dir/file1" 2>&1 >>$seqres.full | \ _filter_xfs_io_error | tee -a $seqres.full repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 # Secondly overcome block soft limit echo "Rewrite 250 blocks plus 1 byte, over the block softlimit..." - su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((250 * $BLOCK_SIZE + 1))' \ + _su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((250 * $BLOCK_SIZE + 1))' \ -c fsync $dir/file1" 2>&1 >>$seqres.full | \ _filter_xfs_io_error | tee -a $seqres.full repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 @@ -81,7 +81,7 @@ test_grace() # Now sleep enough grace time and check that softlimit got enforced sleep $((bgrace + 1)) echo "Try to write 1 one more block after grace..." - su $qa_user -c "$XFS_IO_PROG -c 'truncate 0' -c 'pwrite 0 $BLOCK_SIZE' \ + _su $qa_user -c "$XFS_IO_PROG -c 'truncate 0' -c 'pwrite 0 $BLOCK_SIZE' \ $dir/file2" 2>&1 >>$seqres.full | _filter_xfs_io_error | \ filter_enospc_edquot $type | tee -a $seqres.full repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 @@ -91,7 +91,7 @@ test_grace() # space reservations on XFS setquota -$type $qa_user 0 0 3 100 $SCRATCH_MNT echo "Create 2 more files, over the inode softlimit..." - su $qa_user -c "touch $dir/file3 $dir/file4" 2>&1 >>$seqres.full | \ + _su $qa_user -c "touch $dir/file3 $dir/file4" 2>&1 >>$seqres.full | \ _filter_scratch | tee -a $seqres.full repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 # Reset grace time here, make below grace time test more accurate @@ -99,7 +99,7 @@ test_grace() # Wait and check grace time enforcement sleep $((igrace+1)) echo "Try to create one more inode after grace..." - su $qa_user -c "touch $dir/file5" 2>&1 >>$seqres.full | \ + _su $qa_user -c "touch $dir/file5" 2>&1 >>$seqres.full | \ filter_enospc_edquot $type | _filter_scratch | \ tee -a $seqres.full repquota -v -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 diff --git a/tests/generic/673 b/tests/generic/673 index 8f6def9c..6c54ade8 100755 --- a/tests/generic/673 +++ b/tests/generic/673 @@ -39,7 +39,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c 'reflink $SCRATCH_MNT/b 0 0 1m' $SCRATCH_MNT/a" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/674 b/tests/generic/674 index 1b711f27..41fbdeb7 100755 --- a/tests/generic/674 +++ b/tests/generic/674 @@ -42,7 +42,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c 'dedupe $SCRATCH_MNT/b 0 0 1m' $SCRATCH_MNT/a" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/675 b/tests/generic/675 index e66de84b..87dfbdfe 100755 --- a/tests/generic/675 +++ b/tests/generic/675 @@ -44,7 +44,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c 'reflink $SCRATCH_MNT/b 0 0 1m' $SCRATCH_MNT/a" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/680 b/tests/generic/680 index 07048db5..1a418fa3 100755 --- a/tests/generic/680 +++ b/tests/generic/680 @@ -38,7 +38,7 @@ chmod 0644 $localfile cp $here/src/splice2pipe $tmp.splice2pipe # Test unprivileged user's privilege escalation echo "Test unprivileged user:" -su ${qa_user} -c "$tmp.splice2pipe $localfile 1 AAAAAAAABBBBBBBB" +_su ${qa_user} -c "$tmp.splice2pipe $localfile 1 AAAAAAAABBBBBBBB" _hexdump $localfile # success, all done diff --git a/tests/generic/681 b/tests/generic/681 index aef54205..dc425201 100755 --- a/tests/generic/681 +++ b/tests/generic/681 @@ -55,7 +55,7 @@ ls -sld $scratchdir >> $seqres.full echo "fail quota" >> $seqres.full for ((i = 0; i < dirents; i++)); do name=$(printf "y%0254d" $i) - su - "$qa_user" -c "ln $scratchfile $scratchdir/$name" 2>&1 | \ + _su - "$qa_user" -c "ln $scratchfile $scratchdir/$name" 2>&1 | \ _filter_scratch | sed -e 's/y[0-9]*/yXXX/g' test "${PIPESTATUS[0]}" -ne 0 && break done diff --git a/tests/generic/682 b/tests/generic/682 index 3572af17..6914a549 100755 --- a/tests/generic/682 +++ b/tests/generic/682 @@ -65,7 +65,7 @@ echo "fail quota" >> $seqres.full for ((i = 0; i < dirents; i++)); do name=$(printf "y%0254d" $i) ln $scratchfile $stagedir/$name - su - "$qa_user" -c "mv $stagedir/$name $scratchdir/$name" 2>&1 | \ + _su - "$qa_user" -c "mv $stagedir/$name $scratchdir/$name" 2>&1 | \ _filter_scratch | _filter_mv_output test "${PIPESTATUS[0]}" -ne 0 && break done diff --git a/tests/generic/683 b/tests/generic/683 index cc9a9786..883905da 100755 --- a/tests/generic/683 +++ b/tests/generic/683 @@ -49,7 +49,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c '$command $start $end' $junk_file" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/684 b/tests/generic/684 index 2ca036fe..9cdfe4ab 100755 --- a/tests/generic/684 +++ b/tests/generic/684 @@ -49,7 +49,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c '$command $start $end' $junk_file" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/685 b/tests/generic/685 index de07a798..55672550 100755 --- a/tests/generic/685 +++ b/tests/generic/685 @@ -49,7 +49,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c '$command $start $end' $junk_file" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/686 b/tests/generic/686 index fc6761fe..a3fa8e06 100755 --- a/tests/generic/686 +++ b/tests/generic/686 @@ -49,7 +49,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c '$command $start $end' $junk_file" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/687 b/tests/generic/687 index 82dce88b..0c4b09d2 100755 --- a/tests/generic/687 +++ b/tests/generic/687 @@ -49,7 +49,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c '$command $start $end' $junk_file" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/688 b/tests/generic/688 index e491d5cf..77db2946 100755 --- a/tests/generic/688 +++ b/tests/generic/688 @@ -51,7 +51,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c 'falloc 0 64k' $junk_file" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/691 b/tests/generic/691 index f33d6edf..30ae4a1e 100755 --- a/tests/generic/691 +++ b/tests/generic/691 @@ -75,11 +75,11 @@ exercise() setquota -${type} -t 86400 86400 $SCRATCH_MNT repquota -v -${type} $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1 # Exceed the soft quota limit a bit at first - su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 2m' -c fsync ${file}.0" >>$seqres.full + _su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 2m' -c fsync ${file}.0" >>$seqres.full # Write more data more times under soft quota limit exhausted condition, # but not reach hard limit. To make sure each write won't trigger EDQUOT. for ((i=1; i<=100; i++));do - su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.$i" >>$seqres.full + _su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.$i" >>$seqres.full if [ $? -ne 0 ];then echo "Unexpected error (type=$type)!" break @@ -89,9 +89,9 @@ exercise() # As we've tested soft limit, now exceed the hard limit and give it a # test in passing. - su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 100m' -c fsync ${file}.hard.0" 2>&1 >/dev/null | filter_quota $type + _su $qa_user -c "$XFS_IO_PROG -f -t -c 'pwrite 0 100m' -c fsync ${file}.hard.0" 2>&1 >/dev/null | filter_quota $type for ((i=1; i<=10; i++));do - su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.hard.$i" 2>&1 | filter_quota $type + _su "$qa_user" -c "$XFS_IO_PROG -f -c 'pwrite 0 1m' -c fsync ${file}.hard.$i" 2>&1 | filter_quota $type done } diff --git a/tests/generic/721 b/tests/generic/721 index a9565f18..75d5063c 100755 --- a/tests/generic/721 +++ b/tests/generic/721 @@ -52,7 +52,7 @@ cmd="$XFS_IO_PROG \ -c 'pwrite -S 0x60 44k 55k -b 1m' \ -c 'commitupdate -q' \ \"$dir/a\"" -su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir +_su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir filesnap "after commit" $dir/a echo @@ -67,7 +67,7 @@ cmd="$XFS_IO_PROG \ -c 'pwrite -S 0x60 0 55k' \ -c 'commitupdate -q' \ \"$dir/a\"" -su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir +_su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir filesnap "after shorten commit" $dir/a echo @@ -81,7 +81,7 @@ cmd="$XFS_IO_PROG \ -c \"pwrite -S 0x60 0 $(( (blksz * nrblks) + 37373 ))\" \ -c 'commitupdate -q' \ \"$dir/a\"" -su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir +_su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir filesnap "after lengthen commit" $dir/a echo @@ -96,7 +96,7 @@ cmd="$XFS_IO_PROG \ -c 'pwrite -S 0x60 44k 55k -b 1m' \ -c 'cancelupdate' \ \"$dir/a\"" -su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir +_su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir filesnap "after cancel" $dir/a echo @@ -115,7 +115,7 @@ cmd="$XFS_IO_PROG \ -c 'pwrite -S 0x61 22k 11k -b 1m' \ -c 'commitupdate -q' \ \"$dir/a\"" -su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir +_su -s /bin/bash -c "$cmd" $qa_user 2>&1 | _filter_xfs_io | _filter_test_dir filesnap "after fail commit" $dir/a echo diff --git a/tests/generic/726 b/tests/generic/726 index 131ac5b5..d2a2a2ce 100755 --- a/tests/generic/726 +++ b/tests/generic/726 @@ -46,7 +46,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c 'startupdate' -c 'pwrite -S 0x57 0 1m' -c 'commitupdate' $SCRATCH_MNT/a" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/generic/727 b/tests/generic/727 index ee7ed976..9551e47c 100755 --- a/tests/generic/727 +++ b/tests/generic/727 @@ -54,7 +54,7 @@ commit_and_check() { local cmd="$XFS_IO_PROG -c 'startupdate' -c 'pwrite -S 0x57 0 1m' -c 'commitupdate' $SCRATCH_MNT/a" if [ -n "$user" ]; then - su - "$user" -c "$cmd" >> $seqres.full + _su - "$user" -c "$cmd" >> $seqres.full else $SHELL -c "$cmd" >> $seqres.full fi diff --git a/tests/xfs/720 b/tests/xfs/720 index f928cc43..68a6c7f6 100755 --- a/tests/xfs/720 +++ b/tests/xfs/720 @@ -61,7 +61,7 @@ $XFS_QUOTA_PROG -x -c 'report -u' $SCRATCH_MNT >> $seqres.full # Fail at appending the file as qa_user to ensure quota enforcement works echo "fail quota" >> $seqres.full -su - "$qa_user" -c "$XFS_IO_PROG -c 'pwrite 10g 1' $scratchfile" >> $seqres.full +_su - "$qa_user" -c "$XFS_IO_PROG -c 'pwrite 10g 1' $scratchfile" >> $seqres.full $XFS_QUOTA_PROG -x -c 'report -u' $SCRATCH_MNT >> $seqres.full # success, all done diff --git a/tests/xfs/795 b/tests/xfs/795 index 5a67f02e..217f9609 100755 --- a/tests/xfs/795 +++ b/tests/xfs/795 @@ -63,7 +63,7 @@ $XFS_QUOTA_PROG -x -c 'report -u' $SCRATCH_MNT >> $seqres.full echo "fail quota" >> $seqres.full for ((i = 0; i < dirents; i++)); do name=$(printf "y%0254d" $i) - su - "$qa_user" -c "ln $scratchfile $scratchdir/$name" 2>&1 | \ + _su - "$qa_user" -c "ln $scratchfile $scratchdir/$name" 2>&1 | \ _filter_scratch | sed -e 's/y[0-9]*/yXXX/g' test "${PIPESTATUS[0]}" -ne 0 && break done diff --git a/tests/xfs/803 b/tests/xfs/803 index e3277181..4e5a58c4 100755 --- a/tests/xfs/803 +++ b/tests/xfs/803 @@ -88,7 +88,7 @@ echo set too long value $XFS_IO_PROG -c "setfsprops $propname=$longpropval" $TEST_DIR echo not enough permissions -su - "$qa_user" -c "$XFS_IO_PROG -c \"setfsprops $propname=$propval\" $TEST_DIR" 2>&1 | _filter_test_dir +_su - "$qa_user" -c "$XFS_IO_PROG -c \"setfsprops $propname=$propval\" $TEST_DIR" 2>&1 | _filter_test_dir echo "*** DB TEST ***"