FIX(8.2.4): script crashed when touching a logfile in subdir of /var/log

Treating filename to check if it is in a /var/log subdirectory and
creates needed subdirectories
This commit is contained in:
Charles Herlin 2019-03-01 13:08:07 +01:00
parent 9ada868f43
commit 455e58899d

View File

@ -70,6 +70,12 @@ apply () {
does_file_exist "$FILE" does_file_exist "$FILE"
if [ "$FNRET" != 0 ]; then if [ "$FNRET" != 0 ]; then
info "$FILE does not exist" info "$FILE does not exist"
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""
mkdir -p /var/log/"$filedir"
fi
touch "$FILE" touch "$FILE"
fi fi
FOUND_EXC=0 FOUND_EXC=0