FIX(8.2.x): fix grep and find in audit scripts

This commit is contained in:
Charles Herlin 2019-03-18 16:19:05 +01:00
parent d5d5a39109
commit 02673826a0
3 changed files with 3 additions and 4 deletions

View File

@ -31,7 +31,7 @@ audit () {
warn "$FILE does not exist"
else
FOUND_EXC=0
if grep "$FILE" <(tr ' ' '\n' <<< "$EXCEPTIONS" | cut -d ":" -f 1); then
if grep -q "$FILE" <(tr ' ' '\n' <<< "$EXCEPTIONS" | cut -d ":" -f 1); then
debug "$FILE is found in exceptions"
debug "Setting special user:group:perm"
FOUND_EXC=1
@ -73,7 +73,7 @@ apply () {
filedir=$(dirname "${FILE#/var/log/}")
if [ ! "$filedir" = "." ] && [ ! -d /var/log/"$filedir" ]; then
debug "Creating /var/log/$filedir for $FILE"
debug "mkdir -p /var/log/"$filedir""
debug "mkdir -p /var/log/$filedir"
mkdir -p /var/log/"$filedir"
fi
touch "$FILE"

View File

@ -19,7 +19,7 @@ PATTERN='destination[[:alnum:][:space:]*{]+(tcp|udp)[[:space:]]*\(\"[[:alnum:].]
# This function will be called if the script status is on enabled / audit mode
audit () {
FOUND=0
FILES="$SYSLOG_BASEDIR/syslog-ng.conf $(find -L $SYSLOG_BASEDIR/conf.d/ -type f)"
FILES="$SYSLOG_BASEDIR/syslog-ng.conf $($SUDO_CMD find -L $SYSLOG_BASEDIR/conf.d/ -type f)"
for FILE in $FILES; do
does_pattern_exist_in_file_multiline "$FILE" "$PATTERN"
if [ $FNRET = 0 ]; then

View File

@ -1,6 +1,5 @@
# run-shellcheck
test_audit() {
#set -x
describe Running on blank host
register_test retvalshouldbe 1