mirror of https://github.com/CISOfy/lynis.git
Add return value to SearchItem() function
This commit is contained in:
parent
ed4dd3bf60
commit
bba7cfe200
|
@ -2209,12 +2209,13 @@
|
||||||
# Description : Search if a specific string exists in in a file
|
# Description : Search if a specific string exists in in a file
|
||||||
#
|
#
|
||||||
# Input : $1 = search key (string), $2 = file (string)
|
# Input : $1 = search key (string), $2 = file (string)
|
||||||
# Returns : <nothing>
|
# Returns : True (0) or False (1)
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
SearchItem() {
|
SearchItem() {
|
||||||
ITEM_FOUND=0
|
ITEM_FOUND=0
|
||||||
if [ $# -eq 2 ]; then
|
RETVAL=1
|
||||||
|
if [ $# -eq 2 ]; then
|
||||||
# Don't search in /dev/null, it's too empty there
|
# Don't search in /dev/null, it's too empty there
|
||||||
if [ -f $2 ]; then
|
if [ -f $2 ]; then
|
||||||
# Check if we can find the main type (with or without brackets)
|
# Check if we can find the main type (with or without brackets)
|
||||||
|
@ -2224,16 +2225,19 @@
|
||||||
ITEM_FOUND=1
|
ITEM_FOUND=1
|
||||||
LogText "Result: found string"
|
LogText "Result: found string"
|
||||||
LogText "Full string: ${FIND}"
|
LogText "Full string: ${FIND}"
|
||||||
|
RETVAL=0
|
||||||
else
|
else
|
||||||
LogText "Result: search string NOT found"
|
LogText "Result: search string NOT found"
|
||||||
|
RETVAL=1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
LogText "Skipping search, file does not exist"
|
LogText "Skipping search, file does not exist"
|
||||||
ReportException ${TEST_NO} "Test is trying to search for a string in nonexistent file"
|
ReportException ${TEST_NO} "Test is trying to search for a string in nonexistent file"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
ReportException ${TEST_NO} "Error in function call to CheckItem"
|
ReportException ${TEST_NO} "Error in function call to CheckItem"
|
||||||
fi
|
fi
|
||||||
|
return ${RETVAL}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue