FIX: add becho to send batch output to syslog too

becho stands for batch echo
formats the log line for syslog

Also logs audit summary into syslog (in batch mode only)
This commit is contained in:
Charles Herlin 2019-02-06 17:25:16 +01:00
parent 6cea326921
commit d014405e1f
3 changed files with 9 additions and 4 deletions

View File

@ -272,7 +272,7 @@ if [ $BATCH_MODE ]; then
else else
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:N.A" # No check runned, avoid division by 0 BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:N.A" # No check runned, avoid division by 0
fi fi
echo $BATCH_SUMMARY becho $BATCH_SUMMARY
else else
printf "%40s\n" "################### SUMMARY ###################" printf "%40s\n" "################### SUMMARY ###################"
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS" printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"

View File

@ -46,11 +46,16 @@ _logger() {
COLOR=$1 COLOR=$1
shift shift
test -z "$SCRIPT_NAME" && SCRIPT_NAME=$(basename $0) test -z "$SCRIPT_NAME" && SCRIPT_NAME=$(basename $0)
builtin echo "$*" | /usr/bin/logger -t "[CIS_Hardening] $SCRIPT_NAME" -p "user.info" builtin echo "$*" | /usr/bin/logger -t "CIS_Hardening[$$] $SCRIPT_NAME" -p "user.info"
SCRIPT_NAME_FIXEDLEN=$(printf "%-25.25s" "$SCRIPT_NAME") SCRIPT_NAME_FIXEDLEN=$(printf "%-25.25s" "$SCRIPT_NAME")
cecho $COLOR "$SCRIPT_NAME_FIXEDLEN $*" cecho $COLOR "$SCRIPT_NAME_FIXEDLEN $*"
} }
becho() {
builtin echo "$*" | /usr/bin/logger -t "CIS_Hardening[$$]" -p "user.info"
builtin echo "$*"
}
cecho () { cecho () {
COLOR=$1 COLOR=$1
shift shift

View File

@ -113,7 +113,7 @@ esac
if [ $CRITICAL_ERRORS_NUMBER -eq 0 ]; then if [ $CRITICAL_ERRORS_NUMBER -eq 0 ]; then
if [ $BATCH_MODE -eq 1 ]; then if [ $BATCH_MODE -eq 1 ]; then
BATCH_OUTPUT="OK $SCRIPT_NAME $BATCH_OUTPUT" BATCH_OUTPUT="OK $SCRIPT_NAME $BATCH_OUTPUT"
echo $BATCH_OUTPUT becho $BATCH_OUTPUT
else else
ok "Check Passed" ok "Check Passed"
fi fi
@ -121,7 +121,7 @@ if [ $CRITICAL_ERRORS_NUMBER -eq 0 ]; then
else else
if [ $BATCH_MODE -eq 1 ]; then if [ $BATCH_MODE -eq 1 ]; then
BATCH_OUTPUT="KO $SCRIPT_NAME $BATCH_OUTPUT" BATCH_OUTPUT="KO $SCRIPT_NAME $BATCH_OUTPUT"
echo $BATCH_OUTPUT becho $BATCH_OUTPUT
else else
crit "Check Failed" crit "Check Failed"
fi fi