From 455e58899dc1cd86c5331ab3130a7e02db99b0d0 Mon Sep 17 00:00:00 2001 From: Charles Herlin Date: Fri, 1 Mar 2019 13:08:07 +0100 Subject: [PATCH] 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 --- bin/hardening/8.2.4_set_logfile_perm.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/hardening/8.2.4_set_logfile_perm.sh b/bin/hardening/8.2.4_set_logfile_perm.sh index 72257e5..b7c6de6 100755 --- a/bin/hardening/8.2.4_set_logfile_perm.sh +++ b/bin/hardening/8.2.4_set_logfile_perm.sh @@ -70,6 +70,12 @@ apply () { does_file_exist "$FILE" if [ "$FNRET" != 0 ]; then 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" fi FOUND_EXC=0