From 7266ec7cb447f6ce3170ca0afad2e3abd851b0fe Mon Sep 17 00:00:00 2001 From: Sebastien BLAISOT Date: Tue, 30 Nov 2021 18:42:33 +0100 Subject: [PATCH] Honor --set-log-level parameter (#127) Co-authored-by: GoldenKiwi --- bin/hardening.sh | 10 +++++----- lib/main.sh | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/hardening.sh b/bin/hardening.sh index 5fa98d4..68d446b 100755 --- a/bin/hardening.sh +++ b/bin/hardening.sh @@ -308,19 +308,19 @@ for SCRIPT in $(find "$CIS_ROOT_DIR"/bin/hardening/ -name "*.sh" | sort -V); do info "Treating $SCRIPT" if [ "$CREATE_CONFIG" = 1 ]; then debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --create-config-files-only" - "$SCRIPT" --create-config-files-only "$BATCH_MODE" + LOGLEVEL=$LOGLEVEL "$SCRIPT" --create-config-files-only "$BATCH_MODE" elif [ "$AUDIT" = 1 ]; then debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit $SUDO_MODE $BATCH_MODE" - "$SCRIPT" --audit "$SUDO_MODE" "$BATCH_MODE" + LOGLEVEL=$LOGLEVEL "$SCRIPT" --audit "$SUDO_MODE" "$BATCH_MODE" elif [ "$AUDIT_ALL" = 1 ]; then debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE" - "$SCRIPT" --audit-all "$SUDO_MODE" "$BATCH_MODE" + LOGLEVEL=$LOGLEVEL "$SCRIPT" --audit-all "$SUDO_MODE" "$BATCH_MODE" elif [ "$AUDIT_ALL_ENABLE_PASSED" = 1 ]; then debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE" - "$SCRIPT" --audit-all "$SUDO_MODE" "$BATCH_MODE" + LOGLEVEL=$LOGLEVEL "$SCRIPT" --audit-all "$SUDO_MODE" "$BATCH_MODE" elif [ "$APPLY" = 1 ]; then debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT" - "$SCRIPT" + LOGLEVEL=$LOGLEVEL "$SCRIPT" fi SCRIPT_EXITCODE=$? diff --git a/lib/main.sh b/lib/main.sh index ef2fad1..330dcf0 100644 --- a/lib/main.sh +++ b/lib/main.sh @@ -10,9 +10,16 @@ BATCH_OUTPUT="" status="" forcedstatus="" SUDO_CMD="" +SAVED_LOGLEVEL="" +if [ -n "${LOGLEVEL:-}" ]; then + SAVED_LOGLEVEL=$LOGLEVEL +fi # shellcheck source=../etc/hardening.cfg [ -r "$CIS_ROOT_DIR"/etc/hardening.cfg ] && . "$CIS_ROOT_DIR"/etc/hardening.cfg +if [ -n "$SAVED_LOGLEVEL" ]; then + LOGLEVEL=$SAVED_LOGLEVEL +fi # shellcheck source=../lib/common.sh [ -r "$CIS_ROOT_DIR"/lib/common.sh ] && . "$CIS_ROOT_DIR"/lib/common.sh # shellcheck source=../lib/utils.sh