Using return codes for file permission checks

This commit is contained in:
mboelen 2015-03-25 17:30:13 +01:00
parent c94269c1d1
commit 30bc903c5a
1 changed files with 6 additions and 7 deletions

View File

@ -5,7 +5,7 @@
# Lynis
# ------------------
#
# Copyright 2007-2015, CISOfy & Michael Boelen, The Netherlands
# 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
@ -548,7 +548,7 @@
for J in ${FIND}; do
logtext "Test: checking permissions of file ${J}"
IsWorldWritable ${J}
if [ "${FileIsWorldWritable}" = "TRUE" ]; then
if [ $? -eq 1 ]; then
logtext "Result: warning, file ${J} is world writable"
FOUND=1
else
@ -570,7 +570,7 @@
FIND=`find /etc/rc${NO}.d -type f -print`
for I in ${FIND}; do
IsWorldWritable ${I}
if [ "${FileIsWorldWritable}" = "TRUE" ]; then
if [ $? -eq 1 ]; then
logtext "Result: warning, file ${I} is world writable"
FOUND=1
else
@ -586,7 +586,7 @@
if [ -f ${I} ]; then
logtext "Test: Checking ${I} file for writable bit"
IsWorldWritable ${I}
if [ "${FileIsWorldWritable}" = "TRUE" ]; then
if [ $? -eq 1 ]; then
ReportWarning ${TEST_NO} "H" "Found writable startup script ${I}"
FOUND=1
logtext "Result: warning, file ${I} is world writable"
@ -599,8 +599,7 @@
# Check results
if [ ${FOUND} -eq 1 ]; then
Display --indent 2 --text "- Check startup files (permissions)" --result "WARNING" --color RED
ReportWarning ${TEST_NO} "H" "One or more startup files can be overwritten by all users"
ReportSuggestion ${TEST_NO} "Check startup scripts for world write access and change permissions if needed"
ReportWarning ${TEST_NO} "H" "Found world writable startup scripts"
logtext "Result: found one or more scripts which are possibly writable by other users"
AddHP 0 3
else
@ -730,4 +729,4 @@ wait_for_keypress
#
#================================================================================
# Lynis - Copyright 2007-2015, Michael Boelen - www.rootkit.nl - The Netherlands
# Lynis - Copyright 2007-2015, Michael Boelen, CISOfy - https://cisofy.com