Use IsRunning exit code instead of variable

This commit is contained in:
Michael Boelen 2019-07-26 11:32:48 +02:00
parent 8321b98689
commit 17137408d2
No known key found for this signature in database
GPG Key ID: 26141F77A09D7F04
13 changed files with 51 additions and 104 deletions

View File

@ -139,8 +139,7 @@
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Check auditd status"
# Should not get kauditd
IsRunning auditd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "auditd"; then
LogText "Result: auditd running"
Display --indent 2 --text "- Checking auditd" --result "${STATUS_ENABLED}" --color GREEN
LINUX_AUDITD_RUNNING=1
@ -277,8 +276,7 @@
Register --test-no ACCT-9650 --os Solaris --weight L --network NO --category security --description "Check Solaris audit daemon"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check if audit daemon is running"
IsRunning auditd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "auditd"; then
LogText "Result: Solaris audit daemon is running"
SOLARIS_AUDITD_RUNNING=1
AUDIT_DAEMON_RUNNING=1

View File

@ -81,8 +81,7 @@
# Description : Checking Docker daemon status and basic information for later tests
Register --test-no CONT-8102 --weight L --network NO --category security --description "Checking Docker status and information"
if [ ${SKIPTEST} -eq 0 ]; then
IsRunning "dockerd"
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "dockerd"; then
LogText "Result: found Docker daemon running"
Report "docker_daemon_running=1"
DOCKER_DAEMON_RUNNING=1

View File

@ -245,8 +245,7 @@
LogText "Result: no kldstat binary, skipping this part"
fi
IsRunning pflogd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "pflogd"; then
LogText "Result: found pflog daemon in process list"
Display --indent 4 --text "- Checking pflogd status" --result "ACTIVE" --color GREEN
PFFOUND=1
@ -410,8 +409,7 @@
# Little Snitch Daemon (macOS)
LogText "Test: checking process Little Snitch Daemon"
IsRunning --full "Little Snitch Daemon"
if [ ${RUNNING} -eq 1 ]; then
if IsRunning --full "Little Snitch Daemon"; then
Display --indent 2 --text "- Checking Little Snitch Daemon" --result "${STATUS_ENABLED}" --color GREEN
LogText "Result: Little Snitch found"
FOUND=1
@ -423,8 +421,7 @@
# HandsOff! Daemon (macOS)
LogText "Test: checking process HandsOffDaemon"
IsRunning HandsOffDaemon
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "HandsOffDaemon"; then
Display --indent 2 --text "- Checking Hands Off! Daemon" --result "${STATUS_ENABLED}" --color GREEN
LogText "Result: Hands Off! found"
FOUND=1
@ -436,8 +433,7 @@
# LuLu Daemon (macOS)
LogText "Test: checking process LuLu"
IsRunning LuLu
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "LuLu"; then
Display --indent 2 --text "- Checking LuLu Daemon" --result "${STATUS_ENABLED}" --color GREEN
LogText "Result: LuLu found"
FOUND=1
@ -449,8 +445,7 @@
# Radio Silence (macOS)
LogText "Test: checking process Radio Silence"
IsRunning --full "Radio Silence"
if [ ${RUNNING} -eq 1 ]; then
if IsRunning --full "Radio Silence"; then
Display --indent 2 --text "- Checking Radio Silence" --result "${STATUS_ENABLED}" --color GREEN
LogText "Result: Radio Silence found"
FOUND=1

View File

@ -36,9 +36,7 @@
# Description : Check running OpenLDAP instance
Register --test-no LDAP-2219 --weight L --network NO --category security --description "Check running OpenLDAP instance"
if [ ${SKIPTEST} -eq 0 ]; then
# TODO adding additional slash needed?
IsRunning slapd
if [ ${RUNNING} -eq 0 ]; then
if IsRunning "slapd"; then
Display --indent 2 --text "- Checking OpenLDAP instance" --result "${STATUS_NOT_FOUND}" --color WHITE
LogText "Result: No running slapd process found."
else

View File

@ -65,8 +65,7 @@
Register --test-no LOGG-2132 --weight L --network NO --category security --description "Check for running syslog-ng daemon"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Searching for syslog-ng daemon in process list"
IsRunning syslog-ng
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "syslog-ng"; then
LogText "Result: Found syslog-ng in process list"
Display --indent 4 --text "- Checking Syslog-NG status" --result "${STATUS_FOUND}" --color GREEN
SYSLOG_DAEMON_PRESENT=1
@ -104,8 +103,7 @@
Register --test-no LOGG-2136 --weight L --network NO --category security --description "Check for running systemd journal daemon"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Searching for systemd journal daemon in process list"
IsRunning systemd-journal
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "systemd-journal"; then
Display --indent 4 --text "- Checking systemd journal status" --result "${STATUS_FOUND}" --color GREEN
SYSTEMD_JOURNAL_RUNNING=1
Report "syslog_daemon_present=1"
@ -122,8 +120,7 @@
Register --test-no LOGG-2210 --weight L --network NO --category security --description "Check for running metalog daemon"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Searching for metalog daemon in process list"
IsRunning metalog
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "metalog"; then
LogText "Result: Found metalog in process list"
Display --indent 4 --text "- Checking Metalog status" --result "${STATUS_FOUND}" --color GREEN
SYSLOG_DAEMON_PRESENT=1
@ -143,8 +140,7 @@
Register --test-no LOGG-2230 --weight L --network NO --category security --description "Check for running RSyslog daemon"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Searching for RSyslog daemon in process list"
IsRunning rsyslogd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "rsyslogd"; then
LogText "Result: Found rsyslogd in process list"
Display --indent 4 --text "- Checking RSyslog status" --result "${STATUS_FOUND}" --color GREEN
SYSLOG_DAEMON_PRESENT=1
@ -164,8 +160,7 @@
Register --test-no LOGG-2240 --weight L --network NO --category security --description "Check for running RFC 3195 compliant daemon"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Searching for RFC 3195 daemon (alias syslog reliable) in process list"
IsRunning rfc3195d
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "rfc3195d"; then
LogText "Result: Found rfc3195d in process list"
Display --indent 4 --text "- Checking RFC 3195 daemon status" --result "${STATUS_FOUND}" --color GREEN
SYSLOG_DAEMON_PRESENT=1
@ -190,8 +185,7 @@
if [ ${RSYSLOG_RUNNING} -eq 0 -a ${SYSTEMD_JOURNAL_RUNNING} -eq 0 ]; then
# Search for klogd, but ignore other lines related to klogd (like dd with input/output file)
#FIND=$(${PSBINARY} ax | ${GREPBINARY} "klogd" | ${GREPBINARY} -v "dd" | ${GREPBINARY} -v "grep")
IsRunning klogd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "klogd"; then
LogText "Result: klogd running"
Display --indent 4 --text "- Checking klogd" --result "${STATUS_FOUND}" --color GREEN
else
@ -212,8 +206,7 @@
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Result: Checking for unkilled minilogd instances"
# Search for minilogd. It shouldn't be running normally, if another syslog daemon is started
IsRunning minilogd
if [ ${RUNNING} -eq 0 ]; then
if IsRunning "minilogd"; then
Display --indent 4 --text "- Checking minilogd instances" --result "${STATUS_NOT_FOUND}" --color WHITE
LogText "Result: No minilogd is running"
else

View File

@ -44,8 +44,7 @@
Register --test-no MAIL-8802 --weight L --network NO --category security --description "Check Exim status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check Exim status"
IsRunning exim4 || IsRunning exim
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "exim4" || IsRunning "exim"; then
LogText "Result: found running Exim process"
Display --indent 2 --text "- Exim status" --result "${STATUS_RUNNING}" --color GREEN
EXIM_RUNNING=1
@ -283,8 +282,7 @@
Register --test-no MAIL-8838 --weight L --network NO --category security --description "Check dovecot process"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check dovecot status"
IsRunning dovecot
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "dovecot"; then
LogText "Result: found running dovecot process"
Display --indent 2 --text "- Dovecot status" --result "${STATUS_RUNNING}" --color GREEN
DOVECOT_RUNNING=1
@ -305,8 +303,7 @@
Register --test-no MAIL-8860 --weight L --network NO --category security --description "Check Qmail status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check Qmail status"
IsRunning qmail-smtpd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "qmail-smtpd"; then
LogText "Result: found running Qmail process"
Display --indent 2 --text "- Qmail status" --result "${STATUS_RUNNING}" --color GREEN
QMAIL_RUNNING=1
@ -325,8 +322,7 @@
Register --test-no MAIL-8880 --weight L --network NO --category security --description "Check Sendmail status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check sendmail status"
IsRunning sendmail
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "sendmail"; then
LogText "Result: found running Sendmail process"
Display --indent 2 --text "- Sendmail status" --result "${STATUS_RUNNING}" --color GREEN
SENDMAIL_RUNNING=1

View File

@ -102,8 +102,7 @@
# ESET security products
LogText "Test: checking process esets_daemon"
IsRunning esets_daemon
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "esets_daemon"; then
FOUND=1
ESET_DAEMON_RUNNING=1
MALWARE_SCANNER_INSTALLED=1
@ -114,8 +113,7 @@
# Bitdefender (macOS)
LogText "Test: checking process epagd"
IsRunning epagd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "epagd"; then
FOUND=1
BITDEFENDER_DAEMON_RUNNING=1
MALWARE_SCANNER_INSTALLED=1
@ -126,8 +124,7 @@
# Avast (macOS)
LogText "Test: checking process com.avast.daemon"
IsRunning com.avast.daemon
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "com.avast.daemon"; then
FOUND=1
AVAST_DAEMON_RUNNING=1
MALWARE_SCANNER_INSTALLED=1
@ -138,8 +135,7 @@
# Avira
LogText "Test: checking process Avira daemon"
IsRunning avqmd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "avqmd"; then
FOUND=1
AVIRA_DAEMON_RUNNING=1
MALWARE_SCANNER_INSTALLED=1
@ -150,8 +146,7 @@
# Cylance (macOS)
LogText "Test: checking process CylanceSvc"
IsRunning CylanceSvc
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "CylanceSvc"; then
FOUND=1
if IsVerbose; then Display --indent 2 --text "- ${GEN_CHECKING} CylancePROTECT" --result "${STATUS_FOUND}" --color GREEN; fi
LogText "Result: found CylancePROTECT service"
@ -164,11 +159,9 @@
LogText "Test: checking process cma or cmdagent (McAfee)"
# cma is too generic to match on, so we want to ensure that it is related to McAfee first
if [ -x /opt/McAfee/cma/bin/cma ]; then
IsRunning cma
if [ ${RUNNING} -eq 1 ]; then MCAFEE_SCANNER_RUNNING=1; fi
if IsRunning "cma"; then MCAFEE_SCANNER_RUNNING=1; fi
else
IsRunning cmdagent
if [ ${RUNNING} -eq 1 ]; then MCAFEE_SCANNER_RUNNING=1; fi
if IsRunning "cmdagent"; then MCAFEE_SCANNER_RUNNING=1; fi
fi
if [ ${MCAFEE_SCANNER_RUNNING} -eq 1 ]; then
FOUND=1
@ -180,14 +173,12 @@
# Sophos savscand/SophosScanD
LogText "Test: checking process savscand"
IsRunning savscand
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "savscand"; then
FOUND=1
SOPHOS_SCANNER_RUNNING=1
fi
LogText "Test: checking process SophosScanD"
IsRunning SophosScanD
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "SophosScanD"; then
FOUND=1
SOPHOS_SCANNER_RUNNING=1
fi
@ -200,18 +191,15 @@
# Symantec rtvscand/smcd/symcfgd
LogText "Test: checking process rtvscand"
IsRunning rtvscand
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "rtvscand"; then
SYMANTEC_SCANNER_RUNNING=1
fi
LogText "Test: checking process Symantec management client service"
IsRunning smcd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "smcd"; then
SYMANTEC_SCANNER_RUNNING=1
fi
LogText "Test: checking process Symantec Endpoint Protection configuration service"
IsRunning symcfgd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "symcfgd"; then
SYMANTEC_SCANNER_RUNNING=1
fi
if [ ${SYMANTEC_SCANNER_RUNNING} -eq 1 ]; then
@ -224,8 +212,7 @@
# TrendMicro (macOS)
LogText "Test: checking process TmccMac to test for Trend Micro anti-virus (macOS)"
IsRunning TmccMac
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "TmccMac"; then
if IsVerbose; then Display --indent 2 --text "- ${GEN_CHECKING} Trend Micro anti-virus" --result "${STATUS_FOUND}" --color GREEN; fi
LogText "Result: found Trend Micro component"
FOUND=1
@ -267,8 +254,7 @@
Register --test-no MALW-3284 --weight L --network NO --category security --description "Check for clamd"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: checking running ClamAV daemon (clamd)"
IsRunning clamd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "clamd"; then
Display --indent 2 --text "- ${GEN_CHECKING} ClamAV daemon" --result "${STATUS_FOUND}" --color GREEN
LogText "Result: found running clamd process"
MALWARE_SCANNER_INSTALLED=1
@ -286,8 +272,7 @@
Register --test-no MALW-3286 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check for freshclam"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: checking running freshclam daemon"
IsRunning freshclam
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "freshclam"; then
FRESHCLAM_DAEMON_RUNNING=1
Display --indent 4 --text "- ${GEN_CHECKING} freshclam" --result "${STATUS_FOUND}" --color GREEN
LogText "Result: found running freshclam process"

View File

@ -215,8 +215,7 @@
Register --test-no NAME-4032 --weight L --network NO --category security --description "Check nscd status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: checking nscd status"
IsRunning nscd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "nscd"; then
NAME_CACHE_USED=1
LogText "Result: nscd is running"
Display --indent 2 --text "- Checking nscd status" --result "${STATUS_RUNNING}" --color GREEN
@ -233,8 +232,7 @@
Register --test-no NAME-4034 --weight L --network NO --category security --description "Check Unbound status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: checking Unbound (unbound) status"
IsRunning unbound
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "unbound"; then
UNBOUND_RUNNING=1
NAME_CACHE_USED=1
LogText "Result: Unbound daemon is running"
@ -278,8 +276,7 @@
Register --test-no NAME-4202 --weight L --network NO --category security --description "Check BIND status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking for running BIND instance"
IsRunning named
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "named"; then
LogText "Result: found BIND process"
Display --indent 2 --text "- Checking BIND status" --result "${STATUS_FOUND}" --color GREEN
BIND_RUNNING=1
@ -384,8 +381,7 @@
Register --test-no NAME-4230 --weight L --network NO --category security --description "Check PowerDNS status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking for running PowerDNS instance"
IsRunning pdns_server
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "pdns_server"; then
LogText "Result: found PowerDNS process"
Display --indent 2 --text "- Checking PowerDNS status" --result "${STATUS_RUNNING}" --color GREEN
POWERDNS_RUNNING=1
@ -481,13 +477,11 @@
Register --test-no NAME-4304 --weight L --network NO --category security --description "Check NIS ypbind status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking status of ypbind daemon"
IsRunning ypbind
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "ypbind"; then
LogText "Result: ypbind is running"
Display --indent 2 --text "- Checking ypbind status" --result "${STATUS_FOUND}" --color GREEN
YPBIND_RUNNING=1
IsRunning ypldap
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "ypldap"; then
LogText "Result: ypldap is running"
Display --indent 2 --text "- Checking ypldap status" --result "${STATUS_FOUND}" --color GREEN
else

View File

@ -596,8 +596,7 @@
# Description : Checking for DHCP client
Register --test-no NETW-3030 --weight L --network NO --category security --description "Checking DHCP client status"
if [ ${SKIPTEST} -eq 0 ]; then
IsRunning dhclient || IsRunning dhcpcd || IsRunning udhcpc
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "dhclient" || IsRunning "dhcpcd" || IsRunning "udhcpc"; then
Display --indent 2 --text "- Checking status DHCP client" --result "${STATUS_RUNNING}" --color WHITE
DHCP_CLIENT_RUNNING=1
else

View File

@ -69,8 +69,7 @@
Register --test-no PRNT-2304 --weight L --network NO --category security --description "Check cupsd status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking cupsd status"
IsRunning cupsd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "cupsd"; then
Display --indent 2 --text "- Checking cups daemon" --result "${STATUS_RUNNING}" --color GREEN
LogText "Result: cups daemon running"
CUPSD_RUNNING=1; PRINTING_DAEMON="cups"
@ -188,8 +187,7 @@
Register --test-no PRNT-2314 --weight L --network NO --category security --description "Check lpd status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking lpd status"
IsRunning lpd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "lpd"; then
Display --indent 2 --text "- Checking lp daemon" --result "${STATUS_RUNNING}" --color GREEN
LogText "Result: lp daemon running"
LPD_RUNNING=1; PRINTING_DAEMON="lp"
@ -231,8 +229,7 @@
Register --test-no PRNT-2418 --os AIX --weight L --network NO --category security --description "Checking qdaemon printer spooler status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking qdaemon status"
IsRunning qdaemon
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "qdaemon"; then
LogText "Result: qdaemon daemon running"
Display --indent 2 --text "- Checking qdaemon daemon" --result "${STATUS_RUNNING}" --color GREEN
QDAEMON_RUNNING=1; PRINTING_DAEMON="qdaemon"

View File

@ -107,14 +107,12 @@
IDLE_TIMEOUT_READONLY=""
LogText "Test: Search for session timeout tools or settings in shell"
IsRunning timeoutd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "timeoutd"; then
IDLE_TIMEOUT=1
LogText "Result: found timeoutd process to kill idle sesions"
IDLE_TIMEOUT_METHOD="timeout-daemon"
fi
IsRunning autolog
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "autolog"; then
IDLE_TIMEOUT=1
LogText "Result: found autolog process to kill idle sesions"
Report="session_timeout_method[]=autolog"

View File

@ -35,9 +35,7 @@
Register --test-no SNMP-3302 --weight L --network NO --category security --description "Check for running SNMP daemon"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Searching for a SNMP daemon"
# Check running processes
IsRunning snmpd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "snmpd"; then
SNMP_DAEMON_RUNNING=1
LogText "Result: SNMP daemon is running"
Display --indent 2 --text "- Checking running SNMP daemon" --result "${STATUS_FOUND}" --color GREEN

View File

@ -63,8 +63,7 @@
if [ -f ${FILE} ]; then LogText "result: found chrony configuration: ${FILE}"; CHRONY_CONF_FILE="${FILE}"; fi
done
if [ -n "${CHRONY_CONF_FILE}" ]; then
IsRunning chronyd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "chronyd"; then
FOUND=1; NTP_DAEMON_RUNNING=1; NTP_CONFIG_TYPE_DAEMON=1; NTP_DAEMON="chronyd"
Display --indent 2 --text "- NTP daemon found: chronyd" --result "${STATUS_FOUND}" --color GREEN
else
@ -75,8 +74,7 @@
fi
# Check time daemon (eg DragonFly BSD)
IsRunning dntpd
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "dntpd"; then
FOUND=1; NTP_DAEMON_RUNNING=1; NTP_CONFIG_TYPE_DAEMON=1; NTP_DAEMON="dntpd"
Display --indent 2 --text "- NTP daemon found: dntpd" --result "${STATUS_FOUND}" --color GREEN
fi
@ -91,8 +89,7 @@
fi
# Check time daemon (eg NetBSD)
IsRunning timed
if [ ${RUNNING} -eq 1 ]; then
if IsRunning "timed"; then
FOUND=1; NTP_DAEMON_RUNNING=1; NTP_CONFIG_TYPE_DAEMON=1; NTP_DAEMON="timed"
Display --indent 2 --text "- NTP daemon found: timed" --result "${STATUS_FOUND}" --color GREEN
fi