mirror of
https://github.com/CISOfy/lynis.git
synced 2025-07-27 07:44:14 +02:00
Apply additional checks on first cURL command execution
This commit is contained in:
parent
e4e26930b0
commit
2e87b8fde9
@ -90,7 +90,18 @@ output "Settings file: ${SETTINGS_FILE}"
|
|||||||
if [ -f ${REPORTFILE} ]; then
|
if [ -f ${REPORTFILE} ]; then
|
||||||
output "${WHITE}Report file found.${NORMAL} Starting with connectivity check.."
|
output "${WHITE}Report file found.${NORMAL} Starting with connectivity check.."
|
||||||
# Quit if license is not valid, to reduce load on both client and server.
|
# Quit if license is not valid, to reduce load on both client and server.
|
||||||
UPLOAD=`${CURLBINARY} ${CURL_OPTIONS} -s -S --data-urlencode "licensekey=${LICENSE_KEY}" --data-urlencode "collector_version=${PROGRAM_VERSION}" ${LICENSE_SERVER_URL}`
|
UPLOAD=`${CURLBINARY} ${CURL_OPTIONS} -s -S --data-urlencode "licensekey=${LICENSE_KEY}" --data-urlencode "collector_version=${PROGRAM_VERSION}" ${LICENSE_SERVER_URL} 2> /dev/null`
|
||||||
|
EXITCODE=$?
|
||||||
|
if [ ${EXITCODE} -gt 0 ]; then
|
||||||
|
if [ ${EXITCODE} -eq 60 ]; then
|
||||||
|
output "${RED}Self-signed certificate used on Lynis Enterprise node${NORMAL}"
|
||||||
|
output "If you want to accept a self-signed certificate, use the -k option in the profile."
|
||||||
|
output "Example: ${WHITE}config:upload_options:-k:${NORMAL}"
|
||||||
|
else
|
||||||
|
output "${RED}Error: ${NORMAL}cURL exited with code ${EXITCODE}"
|
||||||
|
fi
|
||||||
|
ExitFatal
|
||||||
|
fi
|
||||||
UPLOAD_CODE=`echo ${UPLOAD} | head -n 1 | awk '{ if ($1=="Response") { print $2 }}'`
|
UPLOAD_CODE=`echo ${UPLOAD} | head -n 1 | awk '{ if ($1=="Response") { print $2 }}'`
|
||||||
if [ "${UPLOAD_CODE}" = "100" ]; then
|
if [ "${UPLOAD_CODE}" = "100" ]; then
|
||||||
output "${WHITE}License is valid${NORMAL}"
|
output "${WHITE}License is valid${NORMAL}"
|
||||||
@ -110,7 +121,7 @@ output "Settings file: ${SETTINGS_FILE}"
|
|||||||
echo "Key: ${LICENSE_KEY}"
|
echo "Key: ${LICENSE_KEY}"
|
||||||
output "Debug information: ${UPLOAD}"
|
output "Debug information: ${UPLOAD}"
|
||||||
# Quit
|
# Quit
|
||||||
ExitClean
|
ExitFatal
|
||||||
fi
|
fi
|
||||||
# Extract the hostid from the parse file
|
# Extract the hostid from the parse file
|
||||||
HOSTID=`cat ${REPORTFILE} | grep "^hostid=" | awk -F= '{ print $2 }'`
|
HOSTID=`cat ${REPORTFILE} | grep "^hostid=" | awk -F= '{ print $2 }'`
|
||||||
@ -122,27 +133,24 @@ output "Settings file: ${SETTINGS_FILE}"
|
|||||||
UPLOAD=`${CURLBINARY} ${CURL_OPTIONS} -s -S --data-urlencode "data@${REPORTFILE}" --data-urlencode "licensekey=${LICENSE_KEY}" --data-urlencode "hostid=${HOSTID}" ${UPLOAD_URL} 2> /dev/null`
|
UPLOAD=`${CURLBINARY} ${CURL_OPTIONS} -s -S --data-urlencode "data@${REPORTFILE}" --data-urlencode "licensekey=${LICENSE_KEY}" --data-urlencode "hostid=${HOSTID}" ${UPLOAD_URL} 2> /dev/null`
|
||||||
EXITCODE=$?
|
EXITCODE=$?
|
||||||
if [ ${EXITCODE} -gt 0 ]; then
|
if [ ${EXITCODE} -gt 0 ]; then
|
||||||
if [ ${EXITCODE} -eq 60 ]; then
|
#UPLOAD_CODE=`echo ${UPLOAD} | head -n 1 | awk '{ print $2 }'`
|
||||||
output "${RED}Self-signed certificate used on Lynis Enterprise node${NORMAL}"
|
#output "Output code from upload: ${UPLOAD_CODE}"
|
||||||
output "If you want to accept a self-signed certificate, use the -k option in the profile."
|
output "${RED}Error: ${NORMAL}Error occurred, cURL ended during the upload of the report data."
|
||||||
output "Example: ${WHITE}config:upload_options:-k:${NORMAL}"
|
output "Related exit code: ${EXITCODE}"
|
||||||
else
|
output "Check the last section of the log file for the exact command used, for further troubleshooting"
|
||||||
#UPLOAD_CODE=`echo ${UPLOAD} | head -n 1 | awk '{ print $2 }'`
|
output "Debug:"
|
||||||
#output "Output code from upload: ${UPLOAD_CODE}"
|
output ${UPLOAD}
|
||||||
output "${RED}Error occurred, please check documentation for code ${UPLOAD_CODE}.${NORMAL}"
|
|
||||||
output "Debug:"
|
|
||||||
output ${UPLOAD}
|
|
||||||
fi
|
|
||||||
# Quit
|
# Quit
|
||||||
ExitClean
|
ExitClean
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "${RED}Fatal error${NORMAL}: No hostid found in report file. Can not upload report file."
|
echo "${RED}Error${NORMAL}: No hostid found in report file. Can not upload report file."
|
||||||
# Quit
|
# Quit
|
||||||
ExitClean
|
ExitFatal
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
output "${YELLOW}No report file found to upload.${NORMAL}"
|
output "${YELLOW}No report file found to upload.${NORMAL}"
|
||||||
|
ExitFatal
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user