__acl: fix always check first if path exists

This commit is contained in:
ander 2019-04-16 18:09:47 +03:00
parent 53c963b2ee
commit e04d647d8e
4 changed files with 31 additions and 11 deletions

View file

@ -18,9 +18,7 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
acl_path="/$__object_id"
[ ! -e "$acl_path" ] && exit 0
[ ! -e "/$__object_id" ] && exit 0
if ! command -v getfacl > /dev/null
then
@ -28,6 +26,6 @@ then
exit 1
fi
getfacl "$acl_path" 2>/dev/null \
getfacl "/$__object_id" 2>/dev/null \
| grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \
|| true

View file

@ -0,0 +1,24 @@
#!/bin/sh -e
#
# 2018 Ander Punnar (ander-at-kvlt-dot-ee)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
if [ -e "/$__object_id" ]
then echo 1
else echo 0
fi

View file

@ -18,11 +18,9 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
acl_path="/$__object_id"
[ ! -e "/$__object_id" ] && exit 0
[ ! -e "$acl_path" ] && exit 0
if [ -d "$acl_path" ]
if [ -d "/$__object_id" ]
then echo 1
else echo 0
fi

View file

@ -18,9 +18,7 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
acl_path="/$__object_id"
[ ! -e "$acl_path" ] && exit 0
[ "$( cat "$__object/explorer/file_exists" )" = '0' ] && exit 0
os="$( cat "$__global/explorer/os" )"
@ -28,6 +26,8 @@ is_dir="$( cat "$__object/explorer/is_dir" )"
acl_is="$( cat "$__object/explorer/acl_is" )"
acl_path="/$__object_id"
acl_should="$( for parameter in user group
do
if [ ! -f "$__object/parameter/$parameter" ]