mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
fstests: Add / use _require_runas and _runas
Add _require_runas and _runas functions instead of open-coding it in test cases. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
committed by
Eryu Guan
parent
12132c4b5f
commit
9d93ce7ddd
+23
-25
@@ -27,7 +27,6 @@ seqres=$RESULT_DIR/$seq
|
||||
|
||||
here=`pwd`
|
||||
tmp=/tmp/$$
|
||||
runas=$here/src/runas
|
||||
status=1 # FAILure is the default!
|
||||
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||
|
||||
@@ -71,8 +70,7 @@ _cleanup()
|
||||
_supported_fs xfs udf
|
||||
_supported_os Linux
|
||||
_require_test
|
||||
|
||||
[ -x $runas ] || _notrun "$runas executable not found"
|
||||
_require_runas
|
||||
|
||||
rm -f $seqres.full
|
||||
|
||||
@@ -128,35 +126,35 @@ chacl u::r-x,g::---,o::--- file1 2>&1
|
||||
chacl -l file1 | _acl_filter_id
|
||||
# change to owner
|
||||
echo "Expect to PASS"
|
||||
$runas -u $acl1 -g $acl1 ./file1 2>&1
|
||||
_runas -u $acl1 -g $acl1 ./file1 2>&1
|
||||
echo "Expect to FAIL"
|
||||
$runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
|
||||
echo ""
|
||||
echo "--- Test group permissions ---"
|
||||
chacl u::---,g::r-x,o::--- file1 2>&1
|
||||
chacl -l file1 | _acl_filter_id
|
||||
echo "Expect to FAIL - acl1 is owner"
|
||||
$runas -u $acl1 -g $acl1 ./file1 2>&1
|
||||
_runas -u $acl1 -g $acl1 ./file1 2>&1
|
||||
echo "Expect to PASS - acl2 matches group"
|
||||
$runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
echo "Expect to PASS - acl2 matches sup group"
|
||||
$runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
|
||||
echo "Expect to FAIL - acl3 is not in group"
|
||||
$runas -u $acl3 -g $acl3 ./file1 2>&1
|
||||
_runas -u $acl3 -g $acl3 ./file1 2>&1
|
||||
|
||||
echo ""
|
||||
echo "--- Test other permissions ---"
|
||||
chacl u::---,g::---,o::r-x file1 2>&1
|
||||
chacl -l file1 | _acl_filter_id
|
||||
echo "Expect to FAIL - acl1 is owner"
|
||||
$runas -u $acl1 -g $acl1 ./file1 2>&1
|
||||
_runas -u $acl1 -g $acl1 ./file1 2>&1
|
||||
echo "Expect to FAIL - acl2 is in group"
|
||||
$runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
echo "Expect to FAIL - acl2 is in sup. group"
|
||||
$runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl3 -s $acl2 ./file1 2>&1
|
||||
echo "Expect to PASS - acl3 is not owner or in group"
|
||||
$runas -u $acl3 -g $acl3 ./file1 2>&1
|
||||
_runas -u $acl3 -g $acl3 ./file1 2>&1
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
@@ -172,9 +170,9 @@ chacl -l file1 | _acl_filter_id
|
||||
echo "Expect to PASS - USER ACE matches user"
|
||||
chacl u::---,g::---,o::---,u:$acl2:r-x,m::rwx file1 2>&1
|
||||
chacl -l file1 | _acl_filter_id
|
||||
$runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
echo "Expect to FAIL - USER ACE does not match user"
|
||||
$runas -u $acl3 -g $acl3 ./file1 2>&1
|
||||
_runas -u $acl3 -g $acl3 ./file1 2>&1
|
||||
|
||||
echo ""
|
||||
echo "--- Test adding a GROUP ACE ---"
|
||||
@@ -185,11 +183,11 @@ chacl -l file1 | _acl_filter_id
|
||||
chacl u::---,g::---,o::---,g:$acl2:r-x,m::rwx file1 2>&1
|
||||
chacl -l file1 | _acl_filter_id
|
||||
echo "Expect to PASS - GROUP ACE matches group"
|
||||
$runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
echo "Expect to PASS - GROUP ACE matches sup group"
|
||||
$runas -u $acl2 -g $acl1 -s $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl1 -s $acl2 ./file1 2>&1
|
||||
echo "Expect to FAIL - GROUP ACE does not match group"
|
||||
$runas -u $acl3 -g $acl3 ./file1 2>&1
|
||||
_runas -u $acl3 -g $acl3 ./file1 2>&1
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
@@ -200,17 +198,17 @@ echo "--- Test MASK ---"
|
||||
chacl u::---,g::---,o::---,g:$acl2:r-x,m::-w- file1 2>&1
|
||||
chacl -l file1 | _acl_filter_id
|
||||
echo "Expect to FAIL as MASK prohibits execution"
|
||||
$runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
|
||||
# user
|
||||
chacl u::---,g::---,o::---,u:$acl2:r-x,m::-w- file1 2>&1
|
||||
echo "Expect to FAIL as MASK prohibits execution"
|
||||
$runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
|
||||
# user
|
||||
chacl u::---,g::---,o::---,u:$acl2:r-x,m::r-x file1 2>&1
|
||||
echo "Expect to PASS as MASK allows execution"
|
||||
$runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
@@ -219,11 +217,11 @@ echo "--- Test ACE priority ---"
|
||||
|
||||
chacl o::rwx,g::rwx,u:$acl1:rwx,u::---,m::rwx file1 2>&1
|
||||
echo "Expect to FAIL as should match on owner"
|
||||
$runas -u $acl1 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl1 -g $acl2 ./file1 2>&1
|
||||
|
||||
chacl o::---,g::---,u:$acl2:rwx,u::---,m::rwx file1 2>&1
|
||||
echo "Expect to PASS as should match on user"
|
||||
$runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
_runas -u $acl2 -g $acl2 ./file1 2>&1
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
@@ -293,10 +291,10 @@ done
|
||||
popd >/dev/null
|
||||
chown -R 12345.54321 root
|
||||
echo "Change #1..."
|
||||
$runas -u 12345 -g 54321 -- chacl -r u::rwx,g::-w-,o::--x root
|
||||
_runas -u 12345 -g 54321 -- chacl -r u::rwx,g::-w-,o::--x root
|
||||
find root -print | xargs chacl -l
|
||||
echo "Change #2..."
|
||||
$runas -u 12345 -g 54321 -- chacl -r u::---,g::---,o::--- root
|
||||
_runas -u 12345 -g 54321 -- chacl -r u::---,g::---,o::--- root
|
||||
find root -print | xargs chacl -l
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user