Fix a bug for 8.1.16

This commit is contained in:
Samson-W 2019-04-21 06:30:22 +08:00
parent 6157ec0bfc
commit 6412559d7d

View File

@ -41,22 +41,26 @@ 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 # define custom IFS and save default one
warn "file $SUDOLOG is not exist! Set default logfile path in /etc/sudoers." d_IFS=$IFS
sed -i '$aDefaults logfile="/var/log/sudo.log"' /etc/sudoers IFS=$'\n'
does_pattern_exist_in_file $FILE "$AUDIT_VALUE" if [ $FNRET = 1 ]; then
if [ $FNRET != 0 ]; then warn "file $SUDOLOG is not exist! Set default logfile path in /etc/sudoers."
warn "$AUDIT_VALUE is not in file $FILE, adding it" sed -i '$aDefaults logfile="/var/log/sudo.log"' /etc/sudoers
add_end_of_file $FILE $AUDIT_VALUE does_pattern_exist_in_file $FILE "$AUDIT_VALUE"
eval $(pkill -HUP -P 1 auditd) if [ $FNRET != 0 ]; then
fi warn "$AUDIT_VALUE is not in file $FILE, adding it"
elif [ $FNRET = 2 ]; then
warn "$AUDIT_VALUE is not in file $FILE, adding it"
add_end_of_file $FILE $AUDIT_VALUE add_end_of_file $FILE $AUDIT_VALUE
eval $(pkill -HUP -P 1 auditd) eval $(pkill -HUP -P 1 auditd)
else fi
ok "$AUDIT_VALUE is present in $FILE" elif [ $FNRET = 2 ]; then
fi warn "$AUDIT_VALUE is not in file $FILE, adding it"
add_end_of_file $FILE $AUDIT_VALUE
eval $(pkill -HUP -P 1 auditd)
else
ok "$AUDIT_VALUE is present in $FILE"
fi
IFS=$d_IFS
} }
# This function will check config parameters required # This function will check config parameters required