mirror of https://github.com/CISOfy/lynis.git
Add --configured-only option to lynis show settings
This commit is contained in:
parent
1655b5728b
commit
13c228fd2d
|
@ -96,7 +96,7 @@ UPDATE_HELP="
|
||||||
|
|
||||||
"
|
"
|
||||||
|
|
||||||
SHOW_SETTINGS_ARGS="--brief --nocolors"
|
SHOW_SETTINGS_ARGS="--brief --configured-only --nocolors"
|
||||||
SHOW_TESTS_ARGS="skipped"
|
SHOW_TESTS_ARGS="skipped"
|
||||||
|
|
||||||
COMMANDS_AUDIT_SYSTEM_USAGE="Usage: lynis audit system"
|
COMMANDS_AUDIT_SYSTEM_USAGE="Usage: lynis audit system"
|
||||||
|
@ -181,11 +181,14 @@ if [ $# -gt 0 ]; then
|
||||||
"releasedate") ${ECHOCMD} "${PROGRAM_RELEASE_DATE}" ;;
|
"releasedate") ${ECHOCMD} "${PROGRAM_RELEASE_DATE}" ;;
|
||||||
"settings")
|
"settings")
|
||||||
BRIEF_OUTPUT=0
|
BRIEF_OUTPUT=0
|
||||||
|
COLORED_OUTPUT=1
|
||||||
|
CONFIGURED_ONLY_OUTPUT=0
|
||||||
while [ $# -gt 1 ]; do
|
while [ $# -gt 1 ]; do
|
||||||
shift
|
shift
|
||||||
case $1 in
|
case $1 in
|
||||||
"--brief") BRIEF_OUTPUT=1 ;;
|
"--brief" | "--br") BRIEF_OUTPUT=1 ;;
|
||||||
"--nocolors") GRAY=""; WHITE=""; CYAN="" ;;
|
"--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} "${RED}Error${NORMAL}: Invalid argument provided to 'lynis show settings'\n\n"
|
||||||
${ECHOCMD} "Suggestions:"
|
${ECHOCMD} "Suggestions:"
|
||||||
|
@ -194,6 +197,7 @@ if [ $# -gt 0 ]; then
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
if [ ${COLORED_OUTPUT} -eq 0 ]; then BLUE=""; CYAN=""; GRAY=""; WHITE=""; fi
|
||||||
# Sort all settings and display them
|
# Sort all settings and display them
|
||||||
SETTINGS=$(sort ${SETTINGS_FILE} | sed 's/ /:space:/g')
|
SETTINGS=$(sort ${SETTINGS_FILE} | sed 's/ /:space:/g')
|
||||||
for LINE in ${SETTINGS}; do
|
for LINE in ${SETTINGS}; do
|
||||||
|
@ -202,14 +206,20 @@ if [ $# -gt 0 ]; then
|
||||||
DESCRIPTION=$(echo ${LINE} | awk -F';' '{print $3}' | sed 's/:space:/ /g')
|
DESCRIPTION=$(echo ${LINE} | awk -F';' '{print $3}' | sed 's/:space:/ /g')
|
||||||
LINESIZE=$(echo "${SETTING}=${VALUE}" | wc -m | tr -d ' ')
|
LINESIZE=$(echo "${SETTING}=${VALUE}" | wc -m | tr -d ' ')
|
||||||
SPACES=$((60 - ${LINESIZE}))
|
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 [ ! -z "${VALUE}" ]; then
|
||||||
if [ ${BRIEF_OUTPUT} -eq 0 ]; then ${ECHOCMD} "${GRAY}# ${DESCRIPTION}${NORMAL}"; fi
|
if [ ${BRIEF_OUTPUT} -eq 0 ]; then ${ECHOCMD} "${GRAY}# ${DESCRIPTION}${NORMAL}"; fi
|
||||||
${ECHOCMD} "${WHITE}${SETTING}${NORMAL}=${CYAN}${VALUE}${NORMAL}"
|
${ECHOCMD} "${WHITE}${SETTING}${NORMAL}=${CYAN}${VALUE}${NORMAL}"
|
||||||
if [ ${BRIEF_OUTPUT} -eq 0 ]; then ${ECHOCMD} ""; fi
|
if [ ${BRIEF_OUTPUT} -eq 0 ]; then ${ECHOCMD} ""; fi
|
||||||
fi
|
fi
|
||||||
done
|
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")
|
"tests")
|
||||||
|
|
Loading…
Reference in New Issue