mirror of
https://github.com/hardenedlinux/harbian-audit.git
synced 2025-07-30 17:15:45 +02:00
Fix bug for 8.2.4: when create file if dir is not, create file is fail.
This commit is contained in:
parent
449c818e22
commit
f23c662b7c
@ -49,15 +49,16 @@ audit () {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply () {
|
apply () {
|
||||||
if [ $FNRET = 1 ]; then
|
does_file_exist "$SYSLOG_BASEDIR/syslog-ng.conf"
|
||||||
|
if [ $FNRET != 0 ]; then
|
||||||
warn "$SYSLOG_BASEDIR/syslog-ng.conf is not exist! "
|
warn "$SYSLOG_BASEDIR/syslog-ng.conf is not exist! "
|
||||||
else
|
else
|
||||||
FILES=$(grep "file(" $SYSLOG_BASEDIR/syslog-ng.conf | grep '"' | cut -d'"' -f 2)
|
FILES=$(grep "file(" $SYSLOG_BASEDIR/syslog-ng.conf | grep '"' | cut -d'"' -f 2)
|
||||||
for FILE in $FILES; do
|
for FILE in $FILES; do
|
||||||
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, create $FILE"
|
||||||
touch $FILE
|
extend_touch_file $FILE
|
||||||
fi
|
fi
|
||||||
has_file_correct_ownership $FILE $USER $GROUP
|
has_file_correct_ownership $FILE $USER $GROUP
|
||||||
if [ $FNRET = 0 ]; then
|
if [ $FNRET = 0 ]; then
|
||||||
|
11
lib/utils.sh
11
lib/utils.sh
@ -822,3 +822,14 @@ check_input_with_established_is_accept()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extend_touch_file()
|
||||||
|
{
|
||||||
|
NEWFILEALLPATH=$1
|
||||||
|
if [ ! -d $(dirname ${NEWFILEALLPATH}) ]; then
|
||||||
|
mkdir -p "$(dirname ${NEWFILEALLPATH})"
|
||||||
|
touch ${NEWFILEALLPATH}
|
||||||
|
else
|
||||||
|
touch ${NEWFILEALLPATH}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user