From fd8b1e790d3eb7e3d98b89fc66edd392862f8430 Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Mon, 8 Apr 2019 15:09:18 +0200 Subject: [PATCH] Improved PackageIsInstalled function and its usage --- include/functions | 2 +- include/tests_insecure_services | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/functions b/include/functions index 26d8c378..b15bda88 100644 --- a/include/functions +++ b/include/functions @@ -1719,7 +1719,7 @@ output=$(${DNFBINARY} --quiet --cacheonly --noplugins --assumeno info --installed ${package} > /dev/null 2>&1) exit_code=$? elif [ ! -z "${DPKGBINARY}" ]; then - output=$(${DPKGBINARY} -l ${package} > /dev/null 2>&1) + output=$(${DPKGBINARY} -l ${package} 2> /dev/null | ${GREPBINARY} "^ii") exit_code=$? elif [ ! -z "${EQUERYBINARY}" ]; then output=$(${EQUERYBINARY} --quiet ${package} > /dev/null 2>&1) diff --git a/include/tests_insecure_services b/include/tests_insecure_services index 2b673072..841189d8 100644 --- a/include/tests_insecure_services +++ b/include/tests_insecure_services @@ -138,8 +138,7 @@ if [ ${SKIPTEST} -eq 0 ]; then # Check for installed xinetd daemon LogText "Test: Checking for installed xinetd daemon" - PackageIsInstalled xinetd - if [ $? -eq 0 ]; then + if PackageIsInstalled "xinetd"; then LogText "Result: xinetd is installed" Display --indent 2 --text "- Installed xinetd package" --result "${STATUS_FOUND}" --color YELLOW ReportSuggestion ${TEST_NO} "If there are no xinetd services required, it is recommended that the daemon be removed" @@ -277,7 +276,7 @@ FOUND=0 PACKAGES="tcp_wrappers tcpd" for PACKAGE in ${PACKAGES}; do - if PackageIsInstalled ${PACKAGE}; then FOUND=1; fi + if PackageIsInstalled "${PACKAGE}"; then LogText "Package '${PACKAGE}' is installed"; FOUND=1; fi done if [ ${FOUND} -eq 1 ]; then LogText "Result: tcp_wrappers is installed" @@ -299,7 +298,7 @@ FOUND=0 PACKAGES="rsh rsh-client rsh-redone-client" for PACKAGE in ${PACKAGES}; do - if PackageIsInstalled "${PACKAGE}"; then FOUND=1; fi + if PackageIsInstalled "${PACKAGE}"; then LogText "Package '${PACKAGE}' is installed"; FOUND=1; fi done if [ ${FOUND} -eq 1 ]; then LogText "Result: rsh client is installed" @@ -356,7 +355,7 @@ FOUND=0 PACKAGES="rsh-server rsh-redone-server" for PACKAGE in ${PACKAGES}; do - if PackageIsInstalled "${PACKAGE}"; then FOUND=1; fi + if PackageIsInstalled "${PACKAGE}"; then LogText "Package '${PACKAGE}' is installed"; FOUND=1; fi done if [ ${FOUND} -eq 1 ]; then LogText "Result: rsh server is installed" @@ -377,7 +376,8 @@ if [ ${SKIPTEST} -eq 0 ]; then # Check if telnet client is installed LogText "Test: Checking if telnet client is installed" - if PackageIsInstalled "${PACKAGE}"; then FOUND=1; fi + if PackageIsInstalled "${PACKAGE}"; then LogText "Package '${PACKAGE}' is installed"; FOUND=1; fi + if [ ${FOUND} -eq 1 ]; then LogText "Result: telnet client is installed" Display --indent 2 --text "- Installed telnet client package" --result "${STATUS_FOUND}" --color YELLOW @@ -400,7 +400,7 @@ FOUND=0 PACKAGES="telnetd telnet-server" for PACKAGE in ${PACKAGES}; do - if PackageIsInstalled "${PACKAGE}"; then FOUND=1; fi + if PackageIsInstalled "${PACKAGE}"; then LogText "Package '${PACKAGE}' is installed"; FOUND=1; fi done if [ ${FOUND} -eq 1 ]; then LogText "Result: telnet server is installed"