lynis/include/tests_nameservices

665 lines
32 KiB
Plaintext
Raw Normal View History

2014-08-26 17:33:55 +02:00
#!/bin/sh
#################################################################################
#
# Lynis
# ------------------
#
# Copyright 2007-2016, Michael Boelen, CISOfy (michael.boelen@cisofy.com)
2015-07-22 16:28:11 +02:00
# Web site: https://cisofy.com
2014-08-26 17:33:55 +02:00
#
# Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
# See LICENSE file for usage of this software.
#
#################################################################################
#
# Name services
#
#################################################################################
#
InsertSection "Name services"
2014-08-26 17:33:55 +02:00
#
#################################################################################
#
BIND_RUNNING=0
BIND_CONFIG_LOCS="/etc /etc/bind /usr/local/etc /usr/local/etc/namedb"
2014-08-26 17:33:55 +02:00
BIND_CONFIG_LOCATIONS=""
POWERDNS_RUNNING=0
POWERDNS_CONFIG_LOCS="/etc/powerdns /usr/local/etc"
POWERDNS_AUTH_CONFIG_LOCATION=""
POWERDNS_AUTH_MASTER=0
POWERDNS_AUTH_SLAVE=0
UNBOUND_CONFIG_OK=0
2014-08-26 17:33:55 +02:00
YPBIND_RUNNING=0
#
#################################################################################
#
# Test : NAME-4016
# Description : Check main domain (domain <domain name> in /etc/resolv.conf)
Register --test-no NAME-4016 --weight L --network NO --description "Check /etc/resolv.conf default domain"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check /etc/resolv.conf for default domain"
2014-08-26 17:33:55 +02:00
if [ -f /etc/resolv.conf ]; then
LogText "Result: /etc/resolv.conf found"
FIND=`awk '/^domain/ { print $2 }' /etc/resolv.conf`
2014-08-26 17:33:55 +02:00
if [ "${FIND}" = "" ]; then
LogText "Result: no default domain found"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking default DNS search domain" --result NONE --color WHITE
2014-08-26 17:33:55 +02:00
else
LogText "Result: found default domain"
LogText "Output: ${FIND}"
Report "resolv_conf_domain=${FIND}"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking default DNS search domain" --result FOUND --color GREEN
2014-08-26 17:33:55 +02:00
RESOLV_DOMAINNAME="${FIND}"
fi
fi
fi
#
#################################################################################
#
# Test : NAME-4018
# Description : Check search domains in /etc/resolv.conf
# Notes : Maximum of one search keyword is allowed in /etc/resolv.conf
Register --test-no NAME-4018 --weight L --network NO --description "Check /etc/resolv.conf search domains"
if [ ${SKIPTEST} -eq 0 ]; then
N=0
LogText "Test: check /etc/resolv.conf for search domains"
2014-08-26 17:33:55 +02:00
if [ -f /etc/resolv.conf ]; then
LogText "Result: /etc/resolv.conf found"
FIND=`awk '/^search/ { print $2 }' /etc/resolv.conf`
2014-08-26 17:33:55 +02:00
if [ "${FIND}" = "" ]; then
LogText "Result: no search domains found, default domain is being used"
2014-08-26 17:33:55 +02:00
else
for I in ${FIND}; do
LogText "Found search domain: ${I}"
Report "resolv_conf_search_domain[]=${I}"
2014-08-26 17:33:55 +02:00
N=`expr ${N} + 1`
done
# Warn if we have more than 6 search domains, which is maximum in most resolvers
if [ ${N} -gt 6 ]; then
LogText "Result: Found ${N} search domains"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking search domains" --result WARNING --color YELLOW
2014-08-26 17:33:55 +02:00
ReportWarning ${TEST_NO} "L" "Found more than 6 search domains, which is usually more than the maximum allowed number in most resolvers"
else
LogText "Result: Found ${N} search domains"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking search domains" --result FOUND --color GREEN
2014-08-26 17:33:55 +02:00
fi
fi
else
LogText "Result: /etc/resolv.conf does not exist, skipping test"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking search domains" --result "NOT FOUND" --color YELLOW
2014-08-26 17:33:55 +02:00
fi
# Check amount of search domains (max 1)
FIND=`grep -c "^search" /etc/resolv.conf`
2014-08-26 17:33:55 +02:00
if [ ! "${FIND}" = "0" -a ! "${FIND}" = "1" ]; then
LogText "Result: found ${FIND} line(s) with a search statement (expecting less than 2 lines)"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking search domains lines" --result "CONFIG ERROR" --color YELLOW
2014-08-26 17:33:55 +02:00
ReportWarning ${TEST_NO} "L" "Found more than 1 search lines in /etc/resolv.conf, which is probably a misconfiguration"
else
LogText "Result: found ${FIND} line(s) with a search statement (expecting less than 2 lines)"
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4020
# Description : Check non default resolv.conf options
Register --test-no NAME-4020 --weight L --network NO --description "Check non default options"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check /etc/resolv.conf for non default options"
2014-08-26 17:33:55 +02:00
if [ -f /etc/resolv.conf ]; then
LogText "Result: /etc/resolv.conf found"
2014-08-26 17:33:55 +02:00
FIND=`grep "^options" /etc/resolv.conf | awk '{ print $2 }'`
if [ "${FIND}" = "" ]; then
LogText "Result: no specific other options configured in /etc/resolv.conf"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking /etc/resolv.conf options" --result "NONE" --color WHITE
2014-08-26 17:33:55 +02:00
else
for I in ${FIND}; do
LogText "Found option: ${I}"
Report "resolv_conf_option[]=${I}"
2014-08-26 17:33:55 +02:00
#rotate --> add performance tune point
#timeout <3 --> add performe tune point
done
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking /etc/resolv.conf options" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
fi
else
LogText "Result: /etc/resolv.conf not found, test skipped"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking /etc/resolv.conf options" --result "NOT FOUND" --color YELLOW
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4024
# Description : Check Solaris uname -n output
Register --test-no NAME-4024 --os Solaris --weight L --network NO --description "Solaris uname -n output"
if [ ${SKIPTEST} -eq 0 ]; then
FIND=`uname -n`
LogText "Result: 'uname -n' returned ${FIND}"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking uname -n output" --result DONE --color GREEN
2014-08-26 17:33:55 +02:00
fi
#
#################################################################################
#
# Test : NAME-4026
# Description : Check Solaris /etc/nodename
# Notes : If a system is standalone, /etc/nodename should contain a system name only, not FQDN
Register --test-no NAME-4026 --os Solaris --weight L --network NO --description "Check /etc/nodename"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: checking /etc/nodename"
2014-08-26 17:33:55 +02:00
if [ -f /etc/nodename ]; then
LogText "Result: file /etc/nodename exists"
2014-08-26 17:33:55 +02:00
FIND=`cat /etc/nodename`
LogText "Output: ${FIND}"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking /etc/nodename" --result "DONE" --color GREEN
2014-08-26 17:33:55 +02:00
else
LogText "Result: file /etc/nodename could not be found"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking /etc/nodename" --result "NONE FOUND" --color YELLOW
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4028
# Description : Check DNS domain name
# To Do : grep ^DOMAINNAME /etc/conf.d/domainname (remove "'s)
Register --test-no NAME-4028 --weight L --network NO --description "Check domain name"
if [ ${SKIPTEST} -eq 0 ]; then
DOMAINNAME=""
# NIS
#LogText "Test: Checking file /etc/domainname"
2014-08-26 17:33:55 +02:00
#if [ -f /etc/domainname ]; then
# LogText "Result: file /etc/domainname exists"
2014-08-26 17:33:55 +02:00
# FIND2=`cat /etc/domainname`
# if [ ! "${FIND}" = "" ]; then
# LogText "Found domain name: ${FIND}"
2014-08-26 17:33:55 +02:00
# DOMAINNAME="${FIND}"
# else
# LogText "Result: no domain name found in file"
2014-08-26 17:33:55 +02:00
# fi
# else
# LogText "Result: file /etc/domainname does not exist"
2014-08-26 17:33:55 +02:00
#fi
LogText "Test: Checking if dnsdomainname command is available"
2014-08-26 17:33:55 +02:00
if [ ! "${DNSDOMAINNAMEBINARY}" = "" ]; then
FIND2=`${DNSDOMAINNAMEBINARY} 2> /dev/null`
if [ ! "${FIND2}" = "" ]; then
LogText "Result: dnsdomainname command returned a value"
LogText "Found domain name: ${FIND2}"
2014-08-26 17:33:55 +02:00
DOMAINNAME="${FIND2}"
else
LogText "Result: dnsdomainname command returned no value"
2014-08-26 17:33:55 +02:00
fi
else
LogText "Result: dnsdomainname binary not found, skip specific test"
2014-08-26 17:33:55 +02:00
fi
# If files and commands can't be found, use defined value from resolv.conf
if [ "${DOMAINNAME}" = "" ]; then
if [ ! "${RESOLV_DOMAINNAME}" = "" ]; then
LogText "Result: using domain name from /etc/resolv.conf"
2014-08-26 17:33:55 +02:00
DOMAINNAME=${RESOLV_DOMAINNAME}
else
LogText "Result: using domain name from FQDN hostname"
#DOMAINNAME=${FQDN#${HOSTNAME}.}
DOMAINNAME=`echo ${FQDN} | cut -d . -f2-`
2014-08-26 17:33:55 +02:00
fi
fi
if [ ! "${DOMAINNAME}" = "" ]; then
LogText "Result: found domain name"
Report "domainname=${DOMAINNAME}"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Searching DNS domain name" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
Display --indent 6 --text "Domain name: ${DOMAINNAME}"
else
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Searching DNS domain name" --result "UNKNOWN" --color YELLOW
2014-08-26 17:33:55 +02:00
ReportSuggestion ${TEST_NO} "Check DNS configuration for the dns domain name"
fi
fi
#
#################################################################################
#
# Test : NAME-4032
# Description : Check name service caching daemon (NSCD) status
Register --test-no NAME-4032 --weight L --network NO --description "Check nscd status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: checking nscd status"
2014-09-19 00:56:51 +02:00
IsRunning nscd
if [ ${RUNNING} -eq 1 ]; then
NAME_CACHE_USED=1
LogText "Result: nscd is running"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking nscd status" --result RUNNING --color GREEN
2014-08-26 17:33:55 +02:00
else
LogText "Result: nscd is not running"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking nscd status" --result "NOT FOUND" --color WHITE
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4034
# Description : Check name service caching daemon (Unbound) status
Register --test-no NAME-4034 --weight L --network NO --description "Check Unbound status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: checking Unbound (unbound) status"
IsRunning unbound
if [ ${RUNNING} -eq 1 ]; then
UNBOUND_RUNNING=1
NAME_CACHE_USED=1
LogText "Result: Unbound daemon is running"
Display --indent 2 --text "- Checking Unbound status" --result RUNNING --color GREEN
else
LogText "Result: Unbound daemon is not running"
Display --indent 2 --text "- Checking Unbound status" --result "NOT FOUND" --color WHITE
fi
fi
#
#################################################################################
#
# Test : NAME-4036
# Description : Checking Unbound configuration file
if [ ${UNBOUND_RUNNING} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4036 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check Unbound configuration file"
if [ ${SKIPTEST} -eq 0 ]; then
FIND=`which unbound-checkconf`
if [ ! "${FIND}" = "" ]; then
LogText "Test: running unbound-checkconf"
# Don't capture any output, just gather exit code (0 is fine, otherwise bad)
FIND=`unbound-checkconf > /dev/null 2>&1`
if [ $? -eq 0 ]; then
UNBOUND_CONFIG_OK=1
LogText "Result: Configuration is fine"
Display --indent 2 --text "- Checking configuration file" --result OK --color GREEN
else
LogText "Result: Unbound daemon is not running"
Display --indent 2 --text "- Checking configuration file" --result "NOT OK" --color YELLOW
ReportWarning "${TEST_NO}" "L" "Found Unbound configuration file issues (run unbound-checkconf)"
fi
else
LogText "Result: skipped, can't find unbound-checkconf utility"
fi
fi
#
#################################################################################
2014-08-26 17:33:55 +02:00
#
# Test : NAME-4202
# Description : Check if BIND is running
Register --test-no NAME-4202 --weight L --network NO --description "Check BIND status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking for running BIND instance"
2014-09-19 00:56:51 +02:00
IsRunning named
if [ ${RUNNING} -eq 1 ]; then
LogText "Result: found BIND process"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking BIND status" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
BIND_RUNNING=1
else
LogText "Result: BIND not running"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking BIND status" --result "NOT FOUND" --color WHITE
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4204
# Description : Check configuration file of BIND
if [ ${BIND_RUNNING} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4204 --preqs-met ${PREQS_MET} --weight L --network NO --description "Search BIND configuration file"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Search BIND configuration file"
2014-08-26 17:33:55 +02:00
for I in ${BIND_CONFIG_LOCS}; do
if [ -f ${I}/named.conf ]; then
BIND_CONFIG_LOCATION="${I}/named.conf"
LogText "Result: found configuration file (${BIND_CONFIG_LOCATION})"
2014-08-26 17:33:55 +02:00
fi
done
if [ ! "${BIND_CONFIG_LOCATION}" = "" ]; then
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking BIND configuration file" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
else
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking BIND configuration file" --result "NOT FOUND" --color YELLOW
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4206
# Description : Check BIND configuration file consistency
if [ ${BIND_RUNNING} -eq 1 -a ! "${BIND_CONFIG_LOCATION}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4206 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check BIND configuration consistency"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: searching for named-checkconf binary"
2014-08-26 17:33:55 +02:00
if [ ! "${NAMEDCHECKCONFBINARY}" = "" ]; then
LogText "Result: named-checkconf is installed"
2014-08-26 17:33:55 +02:00
FIND=`${NAMEDCHECKCONFBINARY} ${BIND_CONFIG_LOCATION}; echo $?`
if [ "${FIND}" = "0" ]; then
LogText "Result: configuration file ${BIND_CONFIG_LOCATION} seems to be fine"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking BIND configuration consistency" --result "OK" --color GREEN
2014-08-26 17:33:55 +02:00
else
LogText "Result: possible errors found in ${BIND_CONFIG_LOCATION}"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking BIND configuration consistency" --result WARNING --color RED
2014-08-26 17:33:55 +02:00
ReportWarning ${TEST_NO} "Errors discovered in BIND configuration file"
fi
else
LogText "Result: named-checkconf not found, skipping test"
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4208
# Description : Check DNS server type (master, slave, caching, forwarding)
#Register --test-no NAME-4050 --weight L --network NO --description "Check nscd status"
#if [ ${SKIPTEST} -eq 0 ]; then
#
#################################################################################
#
# Test : NAME-4210
# Description : Check if we can determine useful information from banner
if [ ${BIND_RUNNING} -eq 1 -a ! "${BIND_CONFIG_LOCATION}" = "" -a ! "${DIGBINARY}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4210 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check DNS banner"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Trying to determine version from banner"
2014-08-26 17:33:55 +02:00
FIND=`${DIGBINARY} @localhost version.bind chaos txt | grep "^version.bind" | grep TXT | egrep "[0-9].[0-9].[0-9]*"`
if [ "${FIND}" = "" ]; then
LogText "Result: no useful information in banner found"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking BIND version in banner" --result "OK" --color GREEN
2014-08-26 17:33:55 +02:00
AddHP 2 2
else
LogText "Result: possible BIND version available in version banner"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking BIND version in banner" --result WARNING --color RED
2014-08-26 17:33:55 +02:00
ReportWarning ${TEST_NO} "M" "Found BIND version in banner"
ReportSuggestion ${TEST_NO} "The version in BIND can be masked by defining 'version none' in the configuration file"
AddHP 0 2
fi
fi
#
#################################################################################
#
# Test : NAME-4212
# Description : Check version option in BIND configuration
#if [ ${BIND_RUNNING} -eq 1 -a ! "${BIND_CONFIG_LOCATION}" = "" -a ! "${DIGBINARY}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
2015-09-24 20:27:17 +02:00
#Register --test-no NAME-4212 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check version setting in configuration"
2014-08-26 17:33:55 +02:00
#
#################################################################################
#
# Test : NAME-4220
# Description : Check if we can perform a zone transfer of primary domain
#Register --test-no NAME-4220 --weight L --network NO --description "Check zone transfer"
#if [ ${SKIPTEST} -eq 0 ]; then
#
#################################################################################
#
# Test : NAME-4222
# Description : Check if we can perform a zone transfer of PTR (of primary domain)
#Register --test-no NAME-4222 --weight L --network NO --description "Check zone transfer"
#if [ ${SKIPTEST} -eq 0 ]; then
#
#################################################################################
#
# Test : NAME-4230
# Description : Check if PowerDNS is running
Register --test-no NAME-4230 --weight L --network NO --description "Check PowerDNS status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking for running PowerDNS instance"
2014-09-19 00:56:51 +02:00
IsRunning pdns_server
if [ ${RUNNING} -eq 1 ]; then
LogText "Result: found PowerDNS process"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking PowerDNS status" --result "RUNNING" --color GREEN
2014-08-26 17:33:55 +02:00
POWERDNS_RUNNING=1
else
LogText "Result: PowerDNS not running"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking PowerDNS status" --result "NOT FOUND" --color WHITE
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4232
# Description : Check PowerDNS configuration file
if [ ${POWERDNS_RUNNING} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4232 --preqs-met ${PREQS_MET} --weight L --network NO --description "Search PowerDNS configuration file"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Search PowerDNS configuration file"
2014-08-26 17:33:55 +02:00
for I in ${POWERDNS_CONFIG_LOCS}; do
if [ -f ${I}/pdns.conf ]; then
POWERDNS_AUTH_CONFIG_LOCATION="${I}/pdns.conf"
LogText "Result: found configuration file (${POWERDNS_AUTH_CONFIG_LOCATION})"
2014-08-26 17:33:55 +02:00
fi
done
if [ ! "${POWERDNS_AUTH_CONFIG_LOCATION}" = "" ]; then
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking PowerDNS configuration file" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
else
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking PowerDNS configuration file" --result "NOT FOUND" --color YELLOW
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# # Test : NAME-4234
# # Description : Check PowerDNS configuration file consistency
# if [ ${POWERDNS_RUNNING} -eq 1 -a ! "${POWERDNS_AUTH_CONFIG_LOCATION}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
# Register --test-no NAME-4234 --weight L --network NO --description "Check PowerDNS configuration consistency"
# if [ ${SKIPTEST} -eq 0 ]; then
# fi
#
#################################################################################
#
# Test : NAME-4236
# Description : Check PowerDNS server backends
if [ ${POWERDNS_RUNNING} -eq 1 -a ! "${POWERDNS_AUTH_CONFIG_LOCATION}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4236 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check PowerDNS backends"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking for PowerDNS backends"
FIND=`awk -F= '/^launch/ { print $2 }' ${POWERDNS_AUTH_CONFIG_LOCATION}`
2014-08-26 17:33:55 +02:00
if [ ! "${FIND}" = "" ]; then
for I in ${FIND}; do
LogText "Found backend: ${I}"
2014-08-26 17:33:55 +02:00
done
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking PowerDNS backends" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
else
LogText "Result: no PowerDNS backends found"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking PowerDNS backends" --result "NOT FOUND" --color YELLOW
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4238
# Description : Check PowerDNS authoritive status
if [ ${POWERDNS_RUNNING} -eq 1 -a ! "${POWERDNS_AUTH_CONFIG_LOCATION}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4238 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check PowerDNS authoritive status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking for PowerDNS master status"
FIND=`grep "^master=yes" ${POWERDNS_AUTH_CONFIG_LOCATION}`
2014-08-26 17:33:55 +02:00
if [ ! "${FIND}" = "" ]; then
LogText "Found master=yes in configuration file"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- PowerDNS authoritive master: YES"
POWERDNS_AUTH_MASTER=1
else
LogText "Result: most likely not master (no master=yes)"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- PowerDNS authoritive master: NO"
fi
LogText "Test: Checking for PowerDNS slave status"
FIND=`grep "^slave=yes" ${POWERDNS_AUTH_CONFIG_LOCATION}`
2014-08-26 17:33:55 +02:00
if [ ! "${FIND}" = "" ]; then
LogText "Found slave=yes in configuration file"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- PowerDNS authoritive slave: YES"
POWERDNS_AUTH_SLAVE=1
else
LogText "Result: most likely not slave (no slave=yes)"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- PowerDNS authoritive slave: NO"
fi
fi
#
#################################################################################
#
# Test : NAME-4302
# Description : Check NIS ypbind daemon status
Register --test-no NAME-4304 --weight L --network NO --description "Check NIS ypbind status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking status of ypbind daemon"
2014-09-19 00:56:51 +02:00
IsRunning ypbind
if [ ${RUNNING} -eq 1 ]; then
LogText "Result: ypbind is running"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking ypbind status" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
YPBIND_RUNNING=1
2016-03-12 19:08:53 +01:00
IsRunning ypldap
if [ ${RUNNING} -eq 1 ]; then
LogText "Result: ypldap is running"
Display --indent 2 --text "- Checking ypldap status" --result "FOUND" --color GREEN
else
2015-10-16 11:52:25 +02:00
ReportSuggestion "Disable the usage of NIS/NIS+ and use an alternative like LDAP or Kerberos instead"
2016-03-12 19:08:53 +01:00
fi
2014-08-26 17:33:55 +02:00
else
LogText "Result: ypbind is not active"
2014-09-15 12:01:09 +02:00
Display --indent 2 --text "- Checking ypbind status" --result "NOT FOUND" --color WHITE
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4306
# Description : Check NIS domain
# Notes : FreeBSD: sysctl kern.domainname
if [ ${YPBIND_RUNNING} -eq 1 ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4306 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check NIS domain"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking `domainname` for NIS domain value"
2014-08-26 17:33:55 +02:00
FIND=`${DOMAINNAMEBINARY} | grep -v "(none)"`
if [ ! "${FIND}" = "" ]; then
LogText "Value: ${FIND}"
2014-08-26 17:33:55 +02:00
NISDOMAIN="${FIND}"
else
LogText "Result: no NIS domain found in command output"
2014-08-26 17:33:55 +02:00
fi
# Solaris / Linux style
LogText "Test: Checking file /etc/defaultdomain"
2014-08-26 17:33:55 +02:00
if [ -f /etc/defaultdomain ]; then
LogText "Result: file /etc/defaultdomain exists"
2014-08-26 17:33:55 +02:00
FIND2=`cat /etc/defaultdomain`
if [ ! "${FIND2}" = "" ]; then
LogText "Output: ${FIND2}"
2014-08-26 17:33:55 +02:00
NISDOMAIN="${FIND2}"
else
LogText "Result: no NIS domain found in file"
2014-08-26 17:33:55 +02:00
fi
fi
# Red Hat style
LogText "Test: checking /etc/sysconfig/network"
2014-08-26 17:33:55 +02:00
if [ -f /etc/sysconfig/network ]; then
LogText "Result: file /etc/sysconfig/network exists"
LogText "Test: checking NISDOMAIN value in file"
2014-08-26 17:33:55 +02:00
FIND3=`grep "^NISDOMAIN" /etc/sysconfig/network | awk -F= '{ print $2 }' | sed 's/"//g'`
if [ ! "${FIND3}" = "" ]; then
LogText "Found NIS domain: ${FIND3}"
2014-08-26 17:33:55 +02:00
NISDOMAIN="${FIND3}"
else
LogText "Result: No NIS domain found in file"
2014-08-26 17:33:55 +02:00
fi
else
LogText "Result: file /etc/sysconfig/network does not exist"
2014-08-26 17:33:55 +02:00
fi
if [ ! "${SYSCTLBINARY}" = "" ]; then
# Check sysctl (e.g. FreeBSD)
LogText "Test: checking sysctl for kern.domainname"
FIND=`${SYSCTLBINARY} -a 2>&1 | grep "^kern.domainname" | awk -F: '{ print $2 }' | sed 's/ //g' | grep -v "^$"`
if [ ! "${FIND}" = "" ]; then
LogText "Result: found NIS domain via sysctl"
NISDOMAIN="${FIND}"
fi
2014-08-26 17:33:55 +02:00
fi
# Check if we found any NIS domain
2015-09-07 17:35:07 +02:00
if [ ! "${NISDOMAIN}" = "" ]; then
LogText "Found NIS domain: ${NISDOMAIN}"
Report "nisdomain=${NISDOMAIN}"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking NIS domain" --result "FOUND" --color GREEN
2014-08-26 17:33:55 +02:00
else
LogText "Result: No NIS domain found"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "- Checking NIS domain" --result "UNKNOWN" --color YELLOW
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
if [ -f /etc/hosts ]; then
Display --indent 2 --text "- Checking /etc/hosts"
fi
# Test : NAME-4402
# Description : Check /etc/hosts configuration
Register --test-no NAME-4402 --weight L --network NO --description "Check duplicate line in /etc/hosts"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check duplicate line in /etc/hosts"
2014-08-26 17:33:55 +02:00
if [ -f /etc/hosts ]; then
sFIND=`egrep -v '^(#|$)' /etc/hosts | awk '{ print $1, $2 }' | sort | uniq -d`
2014-08-26 17:33:55 +02:00
if [ "${sFIND}" = "" ]; then
LogText "Result: OK, no duplicate lines found"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- Checking /etc/hosts (duplicates)" --result OK --color GREEN
else
LogText "Found duplicate line: ${sFIND}"
LogText "Result: found duplicate line"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- Checking /etc/hosts (duplicates)" --result SUGGESTION --color YELLOW
2015-04-21 16:03:14 +02:00
ReportSuggestion "${TEST_NO}" "Remove duplicate lines in /etc/hosts"
2014-08-26 17:33:55 +02:00
fi
else
LogText "Result: /etc/hosts not found, test skipped"
2014-09-15 12:01:09 +02:00
Display --indent 4 --text "Searching duplicate line" --result "SKIPPED" --color YELLOW
2014-08-26 17:33:55 +02:00
fi
fi
#
#################################################################################
#
# Test : NAME-4404
# Description : Check /etc/hosts contains an entry for this server name
if [ ! "${HOSTNAME}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4404 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check /etc/hosts contains an entry for this server name"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Check /etc/hosts contains an entry for this server name"
2014-08-26 17:33:55 +02:00
if [ -f /etc/hosts ]; then
2016-03-07 03:15:22 +01:00
sFIND=`egrep -v '^(#|$|^::1\s|localhost)' /etc/hosts | grep -i ${HOSTNAME}`
2014-08-26 17:33:55 +02:00
if [ "${sFIND}" != "" ]; then
LogText "Result: Found entry for ${HOSTNAME} in /etc/hosts"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- Checking /etc/hosts (hostname)" --result OK --color GREEN
else
LogText "Result: No entry found for ${HOSTNAME} in /etc/hosts"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- Checking /etc/hosts (hostname)" --result SUGGESTION --color YELLOW
ReportSuggestion ${TEST_NO} "Add the IP name and FQDN to /etc/hosts for proper name resolving"
LogText "Risk: No entry for the server name [hostname] in /etc/hosts may cause unexpected performance problems for local connections"
2014-08-26 17:33:55 +02:00
fi
fi
fi
#
#################################################################################
#
# Test : NAME-4406
# Description : Check server hostname mapping
if [ ! "${HOSTNAME}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no NAME-4406 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check server hostname mapping"
2014-08-26 17:33:55 +02:00
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Check server hostname not locally mapped in /etc/hosts"
sFIND=`egrep -v '^(#|$)' /etc/hosts | egrep '^(localhost|::1)\s' | grep -w ${HOSTNAME}`
2014-08-26 17:33:55 +02:00
if [ ! "${sFIND}" = "" ]; then
LogText "Result: Found this server hostname mapped to a local address"
LogText "Output: ${sFIND}"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- Checking /etc/hosts (localhost)" --result SUGGESTION --color YELLOW
LogText "Information: Linking the hostname to the localhost entry may break some resolving. Split resolving so that localhost resolves back to 127.0.0.1 (and ::1) and the hostname of the machine to the real IP address on the network interface."
2014-08-26 17:33:55 +02:00
ReportSuggestion ${TEST_NO} "Split resolving between localhost and the hostname of the system"
else
LogText "Result: this server hostname is not mapped to a local address"
2014-08-26 17:33:55 +02:00
Display --indent 4 --text "- Checking /etc/hosts (localhost)" --result OK --color GREEN
fi
fi
#
#################################################################################
#
report ="name_cache_used=${NAME_CACHE_USED}"
2014-08-26 17:33:55 +02:00
wait_for_keypress
#
#================================================================================
# Lynis - Copyright 2007-2016, Michael Boelen, CISOfy - https://cisofy.com