FIX(5.2.2,5.2.3) find was not working properly

I removed the functions in utils and replace them with loops, so that
there is no more problems with the options arrays.
This commit is contained in:
Thibault Ayanides
2020-10-27 12:47:11 +01:00
parent 97bb1927c3
commit 20f432765d
4 changed files with 132 additions and 102 deletions

View File

@ -84,29 +84,6 @@ has_file_correct_ownership() {
fi
}
have_files_in_dir_correct_ownership(){
local DIR=$1
local USER=$2
local GROUP=$3
local name=$4[@]
local OPTIONS=("${!name}")
local USERID=$(id -u $USER)
local GROUPID=$(getent group $GROUP | cut -d: -f3)
FNRET=0
OIFS="$IFS"
IFS=$'\n' # prevents word splitting
for owner in $("$SUDO_CMD find $DIR" "${OPTIONS[@]}" "-exec stat -c '%u %g' {} \;");
do
if [ "$owner" != "$USERID $GROUPID" ]; then
FNRET=1
break
fi
done
IFS="$OIFS"
}
has_file_correct_permissions() {
local FILE=$1
local PERMISSIONS=$2
@ -118,23 +95,6 @@ has_file_correct_permissions() {
fi
}
have_files_in_dir_correct_permissions(){
local DIR=$1
local PERMISSIONS=$2
local name=$3[@]
local OPTIONS=("${!name}")
FNRET=0
for perm in $("$SUDO_CMD find $DIR" "${OPTIONS[@]}" "-exec stat -L -c '%a' {} \;");
do
echo "$perm ttt $PERMISSIONS"
if [ "$perm" != "$PERMISSIONS" ]; then
FNRET=1
break
fi
done
}
does_pattern_exist_in_file_nocase() {
_does_pattern_exist_in_file "-Ei" $*
}