From 2938a3075b554393065f0a90f428306d1595f505 Mon Sep 17 00:00:00 2001 From: Samson-W Date: Thu, 26 Sep 2019 23:31:48 +0800 Subject: [PATCH] Fix a bug for 6.18 and update how_to_creating_and_making_an_AMI_public.mkd --- ...ure_virusscan_program_update_is_enabled.sh | 48 ++++++++----------- ...w_to_creating_and_making_an_AMI_public.mkd | 4 +- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/bin/hardening/6.18_ensure_virusscan_program_update_is_enabled.sh b/bin/hardening/6.18_ensure_virusscan_program_update_is_enabled.sh index d7956ec..ee75c75 100755 --- a/bin/hardening/6.18_ensure_virusscan_program_update_is_enabled.sh +++ b/bin/hardening/6.18_ensure_virusscan_program_update_is_enabled.sh @@ -13,48 +13,38 @@ set -e # One error, it's over set -u # One variable unset, it's over HARDENING_LEVEL=4 -VIRULSERVER='clamav-daemon' CLAMAVCONF_DIR='/etc/clamav/clamd.conf' UPDATE_SERVER='clamav-freshclam' # This function will be called if the script status is on enabled / audit mode audit () { - if [ $(systemctl | grep $VIRULSERVER | grep "active running" | wc -l) -ne 1 ]; then - crit "$VIRULSERVER is not runing" - FNRET=1 - else - ok "$VIRULSERVER is runing" - UPDATE_DIR=$(grep -i databasedirectory "$CLAMAVCONF_DIR" | awk '{print $2}') - if [ -d $UPDATE_DIR -a -e $CLAMAVCONF_DIR ]; then - NOWTIME=$(date +"%s") - # This file extension name maybe change to .cvd or .cld - VIRUSTIME=$(stat -c "%Y" "$UPDATE_DIR"/daily.*) - INTERVALTIME=$((${NOWTIME}-${VIRUSTIME})) - if [ "${INTERVALTIME}" -ge 604800 ];then - crit "Database file has a date older than seven days from the current date" - FNRET=3 - else - ok "Database file has a date less than seven days from the current date" - FNRET=0 - fi - else - crit "Clamav config file or update dir is not exist" - FNRET=2 - fi - fi + UPDATE_DIR=$(grep -i databasedirectory "$CLAMAVCONF_DIR" | awk '{print $2}') + if [ -d $UPDATE_DIR -a -e $CLAMAVCONF_DIR ]; then + NOWTIME=$(date +"%s") + # This file extension name maybe change to .cvd or .cld + VIRUSTIME=$(stat -c "%Y" "$UPDATE_DIR"/daily.*) + INTERVALTIME=$((${NOWTIME}-${VIRUSTIME})) + if [ "${INTERVALTIME}" -ge 604800 ];then + crit "Clamav database file has a date older than seven days from the current date" + FNRET=3 + else + ok "Clamav database file has a date less than seven days from the current date" + FNRET=0 + fi + else + crit "Clamav config file or update dir is not exist" + FNRET=2 + fi } # This function will be called if the script status is on enabled mode apply () { if [ $FNRET = 0 ]; then - ok "Database file has a date less than seven days from the current date" - elif [ $FNRET = 1 ]; then - warn "Install $VIRULSERVER" - apt-get install -y $VIRULSERVER + ok "Clamav database file has a date less than seven days from the current date" elif [ $FNRET = 2 ]; then warn "Clamav config file or update dir is not exist, please check that is exist or check config" elif [ $FNRET = 3 ]; then - warn "Database file has a date older than seven days from the current date, start clamav-freshclam.service to update" + warn "Clamav database file has a date older than seven days from the current date, start clamav-freshclam.service to update" apt-get install -y $UPDATE_SERVER systemctl start $UPDATE_SERVER fi diff --git a/docs/complianced_image/AMI/how_to_creating_and_making_an_AMI_public.mkd b/docs/complianced_image/AMI/how_to_creating_and_making_an_AMI_public.mkd index db6700d..4476cfc 100644 --- a/docs/complianced_image/AMI/how_to_creating_and_making_an_AMI_public.mkd +++ b/docs/complianced_image/AMI/how_to_creating_and_making_an_AMI_public.mkd @@ -77,11 +77,11 @@ admin@ip:/opt/harbian-audit-master# exit Apply need to apply twice items and that items of must apply after first apply: ``` -admin@ip:/opt/harbian-audit-master$ sudo sed -i 's/^status=.*/status=enabled/' etc/conf.d/8.1.32_freeze_auditd_conf.cfg -admin@ip:/opt/harbian-audit-master$ sudo ./bin/hardening.sh --apply --only 8.1.32 admin@ip:/opt/harbian-audit-master$ sudo ./bin/hardening.sh --apply --only 8.1.1.2 admin@ip:/opt/harbian-audit-master$ sudo ./bin/hardening.sh --apply --only 8.1.1.3 admin@ip:/opt/harbian-audit-master$ sudo ./bin/hardening.sh --apply --only 8.1.12 +admin@ip:/opt/harbian-audit-master$ sudo sed -i 's/^status=.*/status=enabled/' etc/conf.d/8.1.32_freeze_auditd_conf.cfg +admin@ip:/opt/harbian-audit-master$ sudo ./bin/hardening.sh --apply --only 8.1.32 admin@ip:/opt/harbian-audit-master$ sudo ./bin/hardening.sh --apply --only 4.5 admin@ip:/opt/harbian-audit-master$ sudo reboot ```