From 9978e5c824a7f9e12a400ca8d73d77f240ff750f Mon Sep 17 00:00:00 2001 From: mboelen Date: Wed, 25 Mar 2015 17:31:17 +0100 Subject: Using return codes and minor cleanups of code --- include/tests_banners | 78 +++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'include/tests_banners') diff --git a/include/tests_banners b/include/tests_banners index 16620a8a..1bc1bbd0 100644 --- a/include/tests_banners +++ b/include/tests_banners @@ -5,8 +5,8 @@ # Lynis # ------------------ # -# Copyright 2007-2015, Michael Boelen (michael@rootkit.nl), The Netherlands -# Web site: http://www.rootkit.nl +# Copyright 2007-2015, Michael Boelen, CISOfy (michael.boelen@cisofy.com) +# Web site: https://cisofy.com # # Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are # welcome to redistribute it under the terms of the GNU General Public License. @@ -45,7 +45,7 @@ fi if [ -f /etc/COPYRIGHT ]; then - Display --indent 2 --text "- /etc/COPYRIGHT" --result FOUND --color GREEN + Display --indent 2 --text "- /etc/COPYRIGHT" --result FOUND --color GREEN if [ -s /etc/COPYRIGHT ]; then logtext "Result: /etc/COPYRIGHT available and contains text" else @@ -65,24 +65,24 @@ if [ ${SKIPTEST} -eq 0 ]; then logtext "Test: Testing existence /etc/motd" if [ -f /etc/motd ]; then - logtext "Result: file /etc/motd exists" - Display --indent 2 --text "- /etc/motd" --result FOUND --color GREEN - if [ ! -L /etc/motd ]; then - IsWorldWritable /etc/motd - if [ "${FileIsWorldWritable}" = "TRUE" ]; then - Display --indent 4 --text "- /etc/motd permissions" --result WARNING --color RED - logtext "Result: /etc/motd is world writable. Users can change this file!" - ReportWarning ${TEST_NO} "H" "/etc/motd is world writable" - else - Display --indent 4 --text "- /etc/motd permissions" --result OK --color GREEN - logtext "Result: /etc/motd is not world writable." - fi - else - logtext "Result: file /etc/motd is symlink" - fi - else - logtext "Result: File /etc/motd not found" - Display --indent 2 --text "- /etc/motd" --result "NOT FOUND" --color WHITE + logtext "Result: file /etc/motd exists" + Display --indent 2 --text "- /etc/motd" --result FOUND --color GREEN + if [ ! -L /etc/motd ]; then + IsWorldWritable /etc/motd + if [ $? -eq 1 ]; then + Display --indent 4 --text "- /etc/motd permissions" --result WARNING --color RED + logtext "Result: /etc/motd is world writable. Users can change this file!" + ReportWarning ${TEST_NO} "H" "/etc/motd is world writable" + else + Display --indent 4 --text "- /etc/motd permissions" --result OK --color GREEN + logtext "Result: /etc/motd is not world writable." + fi + else + logtext "Result: file /etc/motd is symlink" + fi + else + logtext "Result: File /etc/motd not found" + Display --indent 2 --text "- /etc/motd" --result "NOT FOUND" --color WHITE fi fi # @@ -97,23 +97,23 @@ N=0 logtext "Test: Checking file /etc/motd contents for legal key words" for I in ${LEGAL_BANNER_STRINGS}; do - FIND=`grep -i "${I}" /etc/motd` - if [ ! "${FIND}" = "" ]; then - logtext "Result: found string '${I}'" - N=`expr ${N} + 1` - fi - done - # Check if we have 5 or more key words - if [ ${N} -gt 4 ]; then - logtext "Result: Found ${N} key words, to warn unauthorized users" - Display --indent 4 --text "- /etc/motd contents" --result OK --color GREEN - AddHP 2 2 - else - logtext "Result: Found only ${N} key words, to warn unauthorized users and could be increased" - Display --indent 4 --text "- /etc/motd contents" --result WEAK --color YELLOW - ReportSuggestion ${TEST_NO} "Add legal banner to /etc/motd, to warn unauthorized users" - AddHP 0 1 - fi + FIND=`grep -i "${I}" /etc/motd` + if [ ! "${FIND}" = "" ]; then + logtext "Result: found string '${I}'" + N=`expr ${N} + 1` + fi + done + # Check if we have 5 or more key words + if [ ${N} -gt 4 ]; then + logtext "Result: Found ${N} key words, to warn unauthorized users" + Display --indent 4 --text "- /etc/motd contents" --result OK --color GREEN + AddHP 2 2 + else + logtext "Result: Found only ${N} key words, to warn unauthorized users and could be increased" + Display --indent 4 --text "- /etc/motd contents" --result WEAK --color YELLOW + ReportSuggestion ${TEST_NO} "Add legal banner to /etc/motd, to warn unauthorized users" + AddHP 0 1 + fi fi # ################################################################################# @@ -246,4 +246,4 @@ wait_for_keypress # HPUX: /etc/copyright # #================================================================================ -# Lynis - Copyright 2007-2015, Michael Boelen - www.rootkit.nl - The Netherlands +# Lynis - Copyright 2007-2015, Michael Boelen, CISOfy - https://cisofy.com -- cgit v1.2.3