Add --configured-only option to lynis show settings

This commit is contained in:
Michael Boelen 2016-07-05 19:57:11 +02:00
parent 1655b5728b
commit 13c228fd2d
1 changed files with 15 additions and 5 deletions

View File

@ -96,7 +96,7 @@ UPDATE_HELP="
"
SHOW_SETTINGS_ARGS="--brief --nocolors"
SHOW_SETTINGS_ARGS="--brief --configured-only --nocolors"
SHOW_TESTS_ARGS="skipped"
COMMANDS_AUDIT_SYSTEM_USAGE="Usage: lynis audit system"
@ -181,11 +181,14 @@ if [ $# -gt 0 ]; then
"releasedate") ${ECHOCMD} "${PROGRAM_RELEASE_DATE}" ;;
"settings")
BRIEF_OUTPUT=0
COLORED_OUTPUT=1
CONFIGURED_ONLY_OUTPUT=0
while [ $# -gt 1 ]; do
shift
case $1 in
"--brief") BRIEF_OUTPUT=1 ;;
"--nocolors") GRAY=""; WHITE=""; CYAN="" ;;
"--brief" | "--br") BRIEF_OUTPUT=1 ;;
"--configured-only" | "--co") CONFIGURED_ONLY_OUTPUT=1 ;;
"--nocolors" | "--nc") COLORED_OUTPUT=0 ;;
*)
${ECHOCMD} "${RED}Error${NORMAL}: Invalid argument provided to 'lynis show settings'\n\n"
${ECHOCMD} "Suggestions:"
@ -194,6 +197,7 @@ if [ $# -gt 0 ]; then
;;
esac
done
if [ ${COLORED_OUTPUT} -eq 0 ]; then BLUE=""; CYAN=""; GRAY=""; WHITE=""; fi
# Sort all settings and display them
SETTINGS=$(sort ${SETTINGS_FILE} | sed 's/ /:space:/g')
for LINE in ${SETTINGS}; do
@ -202,14 +206,20 @@ if [ $# -gt 0 ]; then
DESCRIPTION=$(echo ${LINE} | awk -F';' '{print $3}' | sed 's/:space:/ /g')
LINESIZE=$(echo "${SETTING}=${VALUE}" | wc -m | tr -d ' ')
SPACES=$((60 - ${LINESIZE}))
# Only show configured settings
if [ -z "${VALUE}" -a ${CONFIGURED_ONLY_OUTPUT} -eq 0 ]; then VALUE="${GRAY}[not configured]${NORMAL}"; fi
if [ ! -z "${VALUE}" ]; then
if [ ${BRIEF_OUTPUT} -eq 0 ]; then ${ECHOCMD} "${GRAY}# ${DESCRIPTION}${NORMAL}"; fi
${ECHOCMD} "${WHITE}${SETTING}${NORMAL}=${CYAN}${VALUE}${NORMAL}"
if [ ${BRIEF_OUTPUT} -eq 0 ]; then ${ECHOCMD} ""; fi
fi
done
if [ ${BRIEF_OUTPUT} -eq 0 ]; then DisplayToolTip "add --brief to show just the settings, --nocolors to remove colors"; fi
if [ ${BRIEF_OUTPUT} -eq 0 -a ${CONFIGURED_ONLY_OUTPUT} -eq 0 -a ${COLORED_OUTPUT} -eq 1 ]; then
if [ ${COLORS} -eq 1 ]; then
DisplayToolTip "Add --brief to hide descriptions, --configured-only to show configured items only, or --nocolors to remove colors"
else
DisplayToolTip "Add --brief to hide descriptions, --configured-only to show configured items only"
fi
fi
;;
"tests")