[AUTH-9218] Clean ups and improve readability

This commit is contained in:
Michael Boelen 2016-07-31 13:34:17 +02:00
parent 23e400ea9e
commit 2b4d7a1e85

View File

@ -153,7 +153,7 @@
# Test : AUTH-9218 # Test : AUTH-9218
# Description : Check login shells for passwordless accounts # Description : Check login shells for passwordless accounts
# Notes : Results should be checked # Notes : Results should be checked
Register --test-no AUTH-9218 --os FreeBSD --weight L --network NO --category security --description "Check harmful login shells" Register --test-no AUTH-9218 --os FreeBSD --weight L --network NO --category security --description "Check login shells for passwordless accounts"
if [ ${SKIPTEST} -eq 0 ]; then if [ ${SKIPTEST} -eq 0 ]; then
FOUND=0 FOUND=0
LogText "Test: Checking login shells" LogText "Test: Checking login shells"
@ -161,34 +161,35 @@
# Check for all shells, except: (/usr)/sbin/nologin /nonexistent # Check for all shells, except: (/usr)/sbin/nologin /nonexistent
FIND=`grep "[a-z]:\*:" /etc/master.passwd | egrep -v '^#|/sbin/nologin|/usr/sbin/nologin|/nonexistent' | sed 's/ /!space!/g'` FIND=`grep "[a-z]:\*:" /etc/master.passwd | egrep -v '^#|/sbin/nologin|/usr/sbin/nologin|/nonexistent' | sed 's/ /!space!/g'`
if [ "${FIND}" = "" ]; then if [ "${FIND}" = "" ]; then
Display --indent 2 --text "- Checking login shells" --result "${STATUS_OK}" --color GREEN Display --indent 2 --text "- Login shells" --result "${STATUS_OK}" --color GREEN
else else
Display --indent 2 --text "- Checking login shells" --result "${STATUS_WARNING}" --color RED Display --indent 2 --text "- Login shells" --result "${STATUS_WARNING}" --color RED
for I in ${FIND}; do for LINE in ${FIND}; do
I=`echo ${I} | sed 's/!space!/ /g'` LINE=$(echo ${LINE} | sed 's/!space!/ /g')
J=`echo ${I} | awk -F: '{ print $10 }'` SHELL=$(echo ${LINE} | awk -F: '{ print $10 }')
LogText "Output: ${I}" LogText "Output: ${LINE}"
if [ "${J}" = "" ]; then if [ -z "${SHELL}" ]; then
LogText "Result: found no shell on line" LogText "Result: found no shell on line"
else else
LogText "Result: found possible harmful shell ${J}" LogText "Result: found possible harmful shell ${SHELL}"
if [ -f ${J} ]; then if [ -f ${SHELL} ]; then
LogText "Result: shell ${J} does exist" LogText "Result: shell ${SHELL} does exist"
FOUND=1 FOUND=1
else else
LogText "Result: shell ${J} does not exist" LogText "Result: shell ${SHELL} does not exist"
ReportSuggestion ${TEST_NO} "Determine if account is needed, as shell ${J} does not exist" ReportSuggestion ${TEST_NO} "Determine if account is needed, as shell ${SHELL} does not exist"
fi fi
fi fi
done done
if [ ${FOUND} -eq 1 ]; then if [ ${FOUND} -eq 1 ]; then
ReportWarning ${TEST_NO} "H" "Possible harmful shell found (for passwordless account!)" ReportWarning ${TEST_NO} "Possible harmful shell found (for passwordless account!)"
fi fi
fi fi
else else
Display --indent 2 --text "- Checking login shells" --result "${STATUS_SKIPPED}" --color WHITE Display --indent 2 --text "- Login shells" --result "${STATUS_SKIPPED}" --color WHITE
LogText "Result: No /etc/master.passwd file found" LogText "Result: No /etc/master.passwd file found"
fi fi
unset LINE SHELL
fi fi
# #
################################################################################# #################################################################################