From 3aa2efba4d04f8a1fe7673bd8d5218f64322c8a7 Mon Sep 17 00:00:00 2001 From: alobodzinski Date: Sat, 5 Nov 2016 11:55:11 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20for=20NAME-4408:=20getent=20hosts=20local?= =?UTF-8?q?host=20=20=20may=20show=20two=20lines=20on=20Ope=E2=80=A6=20(#3?= =?UTF-8?q?10)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix for NAME-4408: getent hosts localhost may show two lines on OpenBSD * This version does the comparisons in little less awkward way --- include/tests_nameservices | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/tests_nameservices b/include/tests_nameservices index 1881bd1b..01810688 100644 --- a/include/tests_nameservices +++ b/include/tests_nameservices @@ -662,7 +662,7 @@ Register --test-no NAME-4408 --preqs-met ${PREQS_MET} --skip-reason "${SKIPREASON}" --weight L --network NO --category security --description "Check localhost entry" if [ ${SKIPTEST} -eq 0 ]; then LogText "Test: Check server hostname not locally mapped in /etc/hosts" - FIND=$(${GETENT_BINARY} hosts localhost | ${AWKBINARY} '{print $1}') + FIND=$(${GETENT_BINARY} hosts localhost | ${AWKBINARY} '{print $1}' | ${SORTBINARY} | ${TRBINARY} -d '\n') if [ "${FIND}" = "127.0.0.1" ]; then LogText "Result: localhost mapped to 127.0.0.1" Display --indent 4 --text "- Checking /etc/hosts (localhost to IP)" --result "${STATUS_OK}" --color GREEN @@ -671,6 +671,10 @@ LogText "Result: localhost mapped to ::1" Display --indent 4 --text "- Checking /etc/hosts (localhost to IP)" --result "${STATUS_OK}" --color GREEN report "localhost-mapped-to=${FIND}" + elif [ "${FIND}" = "127.0.0.1::1" ]; then + LogText "Result: localhost mapped to 127.0.0.1 and ::1" + Display --indent 4 --text "- Checking /etc/hosts (localhost to IP)" --result "${STATUS_OK}" --color GREEN + report "localhost-mapped-to=${FIND}" else LogText "Output: ${FIND}" LogText "Result: this server hostname is not mapped to a local address"