mirror of
https://github.com/CISOfy/lynis.git
synced 2025-07-16 18:34:35 +02:00
Allow ExitFatal with text and test for input file on other tests
This commit is contained in:
parent
bba7cfe200
commit
e78e7801ab
@ -634,7 +634,7 @@
|
|||||||
# Name : ExitFatal()
|
# Name : ExitFatal()
|
||||||
# Description : Perform exit of the program (with code 1), clean up resources
|
# Description : Perform exit of the program (with code 1), clean up resources
|
||||||
#
|
#
|
||||||
# Input : <nothing>
|
# Input : $1 = text string (optional)
|
||||||
# Returns : <nothing>
|
# Returns : <nothing>
|
||||||
# Usage : ExitFatal
|
# Usage : ExitFatal
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -643,6 +643,11 @@
|
|||||||
RemovePIDFile
|
RemovePIDFile
|
||||||
RemoveTempFiles
|
RemoveTempFiles
|
||||||
LogText "${PROGRAM_NAME} ended with exit code 1."
|
LogText "${PROGRAM_NAME} ended with exit code 1."
|
||||||
|
if [ $# -eq 1 ]; then
|
||||||
|
${ECHOCMD} ""
|
||||||
|
${ECHOCMD} "${RED}Fatal error${NORMAL}: ${WHITE}$1${NORMAL}"
|
||||||
|
${ECHOCMD} ""
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,6 +705,7 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
FileIsReadable() {
|
FileIsReadable() {
|
||||||
|
if [ $# -eq 0 ]; then ExitFatal "Function FileIsReadable() called without a file name"; fi
|
||||||
sFILE=$1
|
sFILE=$1
|
||||||
CANREAD=0
|
CANREAD=0
|
||||||
LogText "Test: check if we can access ${sFILE}"
|
LogText "Test: check if we can access ${sFILE}"
|
||||||
@ -2353,10 +2359,12 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ShowSymlinkPath() {
|
ShowSymlinkPath() {
|
||||||
|
if [ $# -eq 0 ]; then ExitFatal "Function ShowSymlinkPath() called without a file name"; fi
|
||||||
sFILE=$1
|
sFILE=$1
|
||||||
FOUNDPATH=0
|
FOUNDPATH=0
|
||||||
SYMLINK_USE_PYTHON=0
|
SYMLINK_USE_PYTHON=0
|
||||||
SYMLINK_USE_READLINK=0
|
SYMLINK_USE_READLINK=0
|
||||||
|
LogText "Action: checking symlink for file ${sFILE}"
|
||||||
# Check for symlink
|
# Check for symlink
|
||||||
if [ -L ${sFILE} ]; then
|
if [ -L ${sFILE} ]; then
|
||||||
|
|
||||||
@ -2367,6 +2375,7 @@
|
|||||||
FIND=`which python 2> /dev/null`
|
FIND=`which python 2> /dev/null`
|
||||||
if [ ! "${FIND}" = "" ]; then LogText "Setting temporary pythonbinary variable"; PYTHONBINARY="${FIND}"; fi
|
if [ ! "${FIND}" = "" ]; then LogText "Setting temporary pythonbinary variable"; PYTHONBINARY="${FIND}"; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! "${PYTHONBINARY}" = "" ]; then
|
if [ ! "${PYTHONBINARY}" = "" ]; then
|
||||||
SYMLINK_USE_PYTHON=1
|
SYMLINK_USE_PYTHON=1
|
||||||
LogText "Note: using Python to determine symlinks"
|
LogText "Note: using Python to determine symlinks"
|
||||||
@ -2380,7 +2389,7 @@
|
|||||||
|
|
||||||
if [ ! "${READLINKBINARY}" = "" ]; then
|
if [ ! "${READLINKBINARY}" = "" ]; then
|
||||||
SYMLINK_USE_READLINK=1
|
SYMLINK_USE_READLINK=1
|
||||||
LogText "Note: Using real readlink binary to determine symlinks"
|
LogText "Note: Using real readlink binary to determine symlink on ${sFILE}"
|
||||||
tFILE=`${READLINKBINARY} -f ${sFILE}`
|
tFILE=`${READLINKBINARY} -f ${sFILE}`
|
||||||
LogText "Result: readlink shows ${tFILE} as output"
|
LogText "Result: readlink shows ${tFILE} as output"
|
||||||
fi
|
fi
|
||||||
@ -2441,7 +2450,7 @@
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
LogText "Result: file not a symlink"
|
LogText "Result: file ${sFILE} is not a symlink"
|
||||||
fi
|
fi
|
||||||
# Now check if our new location is actually a file or directory destination
|
# Now check if our new location is actually a file or directory destination
|
||||||
if [ -L ${sFILE} ]; then
|
if [ -L ${sFILE} ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user