__acl: add nice oneliners and move default ACL decision out of the loop

This commit is contained in:
ander 2019-04-19 13:30:50 +03:00
parent 0f3c162696
commit 86f45db1b9

View file

@ -28,6 +28,13 @@ acl_is="$( cat "$__object/explorer/acl_is" )"
acl_path="/$__object_id"
if [ -f "$__object/parameter/default" ] && [ "$is_dir" = '1' ]
then
set_default=1
else
set_default=0
fi
acl_should="$( for parameter in user group mask other
do
if [ ! -f "$__object/parameter/$parameter" ]
@ -39,30 +46,16 @@ do
do
if echo "$acl" | awk -F: '{ print $NF }' | grep -Fq 'X'
then
if [ "$is_dir" = '1' ]
then
rep=x
else
rep=-
fi
[ "$is_dir" = '1' ] && rep=x || rep=-
acl="$( echo "$acl" | sed "s/\(.*\)X/\1$rep/" )"
fi
if echo "$parameter" | grep -Eq '(mask|other)'
then
sep=::
else
sep=:
fi
echo "$parameter" | grep -Eq '(mask|other)' && sep=:: || sep=:
echo "$parameter$sep$acl"
if [ -f "$__object/parameter/default" ] \
&& [ "$is_dir" = '1' ]
then
echo "default:$parameter$sep$acl"
fi
[ "$set_default" = '1' ] && echo "default:$parameter$sep$acl"
done \
< "$__object/parameter/$parameter"
done )"