From ab954ffbcf285d3d83b7e61070468afc8cab1610 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 14:44:32 +0300 Subject: [PATCH] __acl: always check first if path exists --- cdist/conf/type/__acl/explorer/acl_is | 13 +++++++------ cdist/conf/type/__acl/explorer/file_type | 15 ++++++++------- cdist/conf/type/__acl/gencode-remote | 6 ++++-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index bb1db89d..c5d8468d 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -18,15 +18,16 @@ # along with cdist. If not, see . # +acl_path="/$__object_id" + +[ ! -e "$acl_path" ] && exit 0 + if ! command -v getfacl 2>/dev/null then echo 'getfacl not available' >&2 exit 1 fi -if [ -e "/$__object_id" ] -then - getfacl "/$__object_id" 2>/dev/null \ - | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \ - || true -fi +getfacl "$acl_path" 2>/dev/null \ + | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \ + || true diff --git a/cdist/conf/type/__acl/explorer/file_type b/cdist/conf/type/__acl/explorer/file_type index 0d1edb7d..f45e302b 100755 --- a/cdist/conf/type/__acl/explorer/file_type +++ b/cdist/conf/type/__acl/explorer/file_type @@ -18,11 +18,12 @@ # along with cdist. If not, see . # -if [ -e "/$__object_id" ] -then - if [ -d "/$__object_id" ] - then echo d - elif [ -f "/$__object_id" ] - then echo f - fi +acl_path="/$__object_id" + +[ ! -e "$acl_path" ] && exit 0 + +if [ -d "$acl_path" ] +then echo d +elif [ -f "$acl_path" ] +then echo f fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 355cc88e..88fc8ce0 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -18,12 +18,14 @@ # along with cdist. If not, see . # +acl_path="/$__object_id" + +[ ! -e "$acl_path" ] && exit 0 + os="$( cat "$__global/explorer/os" )" file_type="$( cat "$__object/explorer/file_type" )" -acl_path="/$__object_id" - acl_is="$( cat "$__object/explorer/acl_is" )" acl_should="$( for parameter in user group