forked from ungleich-public/cdist
		
	__acl: fix always check first if path exists
This commit is contained in:
		
					parent
					
						
							
								53c963b2ee
							
						
					
				
			
			
				commit
				
					
						e04d647d8e
					
				
			
		
					 4 changed files with 31 additions and 11 deletions
				
			
		| 
						 | 
					@ -18,9 +18,7 @@
 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					# 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 ! command -v getfacl > /dev/null
 | 
					if ! command -v getfacl > /dev/null
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
| 
						 | 
					@ -28,6 +26,6 @@ then
 | 
				
			||||||
    exit 1
 | 
					    exit 1
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
getfacl "$acl_path" 2>/dev/null \
 | 
					getfacl "/$__object_id" 2>/dev/null \
 | 
				
			||||||
    | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \
 | 
					    | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \
 | 
				
			||||||
    || true
 | 
					    || true
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										24
									
								
								cdist/conf/type/__acl/explorer/file_exists
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										24
									
								
								cdist/conf/type/__acl/explorer/file_exists
									
										
									
									
									
										Executable 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
 | 
				
			||||||
| 
						 | 
					@ -18,11 +18,9 @@
 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					# 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 "/$__object_id" ]
 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ -d "$acl_path" ]
 | 
					 | 
				
			||||||
then echo 1
 | 
					then echo 1
 | 
				
			||||||
else echo 0
 | 
					else echo 0
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,9 +18,7 @@
 | 
				
			||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
					# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					
 | 
				
			||||||
acl_path="/$__object_id"
 | 
					[ "$( cat "$__object/explorer/file_exists" )" = '0' ] && exit 0
 | 
				
			||||||
 | 
					 | 
				
			||||||
[ ! -e "$acl_path" ] && exit 0
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
os="$( cat "$__global/explorer/os" )"
 | 
					os="$( cat "$__global/explorer/os" )"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,6 +26,8 @@ is_dir="$( cat "$__object/explorer/is_dir" )"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
acl_is="$( cat "$__object/explorer/acl_is" )"
 | 
					acl_is="$( cat "$__object/explorer/acl_is" )"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					acl_path="/$__object_id"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
acl_should="$( for parameter in user group
 | 
					acl_should="$( for parameter in user group
 | 
				
			||||||
do
 | 
					do
 | 
				
			||||||
    if [ ! -f "$__object/parameter/$parameter" ]
 | 
					    if [ ! -f "$__object/parameter/$parameter" ]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue