mirror of
https://github.com/ovh/debian-cis.git
synced 2025-06-22 18:53:42 +02:00
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:
40
lib/utils.sh
40
lib/utils.sh
@ -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" $*
|
||||
}
|
||||
|
Reference in New Issue
Block a user