tidy up a bit

This commit is contained in:
Tim Shimmin
2001-02-20 08:07:09 +00:00
parent afff975f08
commit f5b4f28d63
3 changed files with 60 additions and 41 deletions
+22 -20
View File
@@ -62,26 +62,20 @@ _ls()
ls -ln $* | awk '{ print $1, $3, $4, $NF }' | _filter_id
}
_get_newid()
{
cat /etc/passwd /etc/group $tmp.ids | gawk -F: '
{ ids[$3]=1 }
END {
for(i=1;i<1000000;i++){
if (! (i in ids)) {
print i;
exit
}
}
}'
}
_setup_ids()
{
touch $tmp.ids
acl1=`_get_newid`; echo "::$acl1" >>$tmp.ids
acl2=`_get_newid`; echo "::$acl2" >>$tmp.ids
acl3=`_get_newid`; echo "::$acl3" >>$tmp.ids
eval `cat /etc/passwd /etc/group | gawk -F: '
{ ids[$3]=1 }
END {
j=1
for(i=1; i<1000000 && j<=3;i++){
if (! (i in ids)) {
printf "acl%d=%d;", j, i;
j++
}
}
}'`
}
_filter_id()
@@ -95,7 +89,7 @@ _filter_id()
-e "s/g:$acl3/g:id3/" \
-e "s/ $acl1 / id1 /" \
-e "s/ $acl2 / id2 /" \
-e "s/ $acl3 / id3 /" \
-e "s/ $acl3 / id3 /"
}
# -----
@@ -152,6 +146,9 @@ echo ""
echo "=== Test minimal ACE ==="
echo "Setup file"
# Note: as this is a shell script,
# will need read and execute permission set
# in order to execute it.
touch file1
cat <<EOF >file1
#!/bin/sh
@@ -252,14 +249,19 @@ $runas -u $acl3 -g $acl3 ./file1 2>&1
echo ""
echo "--- Test MASK ---"
chacl u::---,g::---,o::---,g:$acl2:r-x,m::-wx file1 2>&1
# group
chacl u::---,g::---,o::---,g:$acl2:r-x,m::-w- file1 2>&1
chacl -l file1 | _filter_id
echo "Expect to FAIL as MASK prohibits execution"
$runas -u $acl2 -g $acl2 ./file1 2>&1
chacl u::---,g::---,o::---,u:$acl2:r-x,m::-wx 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
# 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