diff --git a/bin/hardening/8.2.5_rsyslog_remote_host.sh b/bin/hardening/8.2.5_rsyslog_remote_host.sh new file mode 100755 index 0000000..bfcd8e5 --- /dev/null +++ b/bin/hardening/8.2.5_rsyslog_remote_host.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# +# harbian audit 7/8/9 Hardening +# + +# +# 8.2.5 Configure rsyslog to Send Logs to a Remote Log Host (Scored) +# Author : Samson wen, Samson +# + +set -e # One error, it's over +set -u # One variable unset, it's over + +HARDENING_LEVEL=3 + +PATTERN='^*.*[^I][^I]*@' + +# This function will be called if the script status is on enabled / audit mode +audit () { + FILES="$SYSLOG_BASEDIR/rsyslog.conf $SYSLOG_BASEDIR/rsyslog.d/*.conf" + does_pattern_exist_in_file "$FILES" "$PATTERN" + if [ $FNRET != 0 ]; then + crit "$PATTERN is not present in $FILES" + else + ok "$PATTERN is present in $FILES" + fi +} + +# This function will be called if the script status is on enabled mode +apply () { + FILES="$SYSLOG_BASEDIR/rsyslog.conf $SYSLOG_BASEDIR/rsyslog.d/*.conf" + does_pattern_exist_in_file "$FILES" "$PATTERN" + if [ $FNRET != 0 ]; then + crit "$PATTERN is not present in $FILES, please manual operation set a remote host to send your logs" + else + ok "$PATTERN is present in $FILES" + fi +} + +# This function will create the config file for this check with default values +create_config() { + cat < /dev/null 2>&1 - update-rc.d $SERVICE_NAME defaults > /dev/null 2>&1 - else - ok "$SERVICE_NAME is enabled" - fi + is_pkg_installed $SERVICE_NAME_R + if [ $FNRET = 0 ]; then + ok "$SERVICE_NAME_R has installed, so pass." + FNRET=0 + else + info "Checking if $SERVICE_NAME is enabled" + is_service_enabled $SERVICE_NAME + if [ $FNRET != 0 ]; then + info "Enabling $SERVICE_NAME" + update-rc.d $SERVICE_NAME remove > /dev/null 2>&1 + update-rc.d $SERVICE_NAME defaults > /dev/null 2>&1 + else + ok "$SERVICE_NAME is enabled" + fi + fi } # This function will check config parameters required