From e0e56f2cdcfc94b847142bf8d3b68f39ef6d9b50 Mon Sep 17 00:00:00 2001 From: mboelen Date: Mon, 11 Jan 2016 01:04:38 +0100 Subject: [PATCH] Use CreateTempFile for creation of temporary files --- include/helper_update | 11 ++++++----- include/tests_shells | 3 ++- include/tests_webservers | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/helper_update b/include/helper_update index 60529c4b..5bee2b07 100644 --- a/include/helper_update +++ b/include/helper_update @@ -84,11 +84,12 @@ if [ "$1" = "release" ]; then # Normal update FULLPATH="${UPDATE_SERVER_PROTOCOL}://${UPDATE_SERVER_ADDRESS}${UPDATE_LATEST_VERSION_INFO}" - TMP_FILE=`mktemp /tmp/audit.XXXXXXXXXX` - if [ "${TMP_FILE}" = "" ]; then - Display --indent 2 --text "Could not create a temporary file in /tmp with mktemp. Aborting.." - ExitFatal - fi + + # Create temporary file + CreateTempFile + TMP_FILE="${TEMP_FILE}" + if [ "${TMP_FILE}" = "" ]; then Display --indent 2 --text "Could not create a temporary file. Exiting..."; ExitFatal; fi + Display --indent 2 --text "${CYAN}[Phase 1] Downloading details${NORMAL}" if [ ! "${WGET_EXISTS}" = "" ]; then logtext "Using wget to download release information" diff --git a/include/tests_shells b/include/tests_shells index 024eb972..05c5f25f 100644 --- a/include/tests_shells +++ b/include/tests_shells @@ -285,7 +285,8 @@ if [ ! "${FIND}" = "" ]; then if [ -x "${FIND}" -a ! -L "${FIND}" ]; then LogText "Result: found ${FIND} as a valid shell" - SHELLSHOCK_TMP=`mktemp /tmp/lynis-shellshock-test.XXXXXXXXXX` || exit 1 + CreateTempFile || ExitFatal + SHELLSHOCK_TMP="${TEMP_FILE}" # CVE-2014-6271 LogText "Test: Check for first exploit (CVE-2014-6271)" diff --git a/include/tests_webservers b/include/tests_webservers index 167fcf95..267619b4 100644 --- a/include/tests_webservers +++ b/include/tests_webservers @@ -36,9 +36,9 @@ /usr/local/etc/apache /usr/local/etc/apache2 /usr/local/etc/apache22 \ /usr/pkg/etc/httpd /etc/sysconfig/apache2" - CreateTempFile + CreateTempFile || ExitFatal TMPFILE="${TEMP_FILE}" - CreateTempFile + CreateTempFile || ExitFatal TMPFILE2="${TEMP_FILE}" # #################################################################################