Skip to content

[OpenWrt] Fix BusyBox ps unsupported flags #1621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions include/tests_databases
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
# Description : Check if MySQL is being used
Register --test-no DBS-1804 --weight L --network NO --category security --description "Checking active MySQL process"
if [ ${SKIPTEST} -eq 0 ]; then
FIND=$(${PSBINARY} ax | ${GREPBINARY} -E "mariadb|mysqld|mysqld_safe" | ${GREPBINARY} -v "grep")
if [ -z "${FIND}" ]; then
if ! IsRunning 'mariadb' && ! IsRunning 'mysqld' && ! IsRunning 'mysqld_safe'; then
if [ ${DEBUG} -eq 1 ]; then Display --indent 2 --text "- MySQL process status" --result "${STATUS_NOT_FOUND}" --color WHITE --debug; fi
LogText "Result: MySQL process not active"
else
Expand Down Expand Up @@ -248,8 +247,7 @@
# reco: recovery (optional)
Register --test-no DBS-1840 --weight L --network NO --category security --description "Checking active Oracle processes"
if [ ${SKIPTEST} -eq 0 ]; then
FIND=$(${PSBINARY} ax | ${GREPBINARY} -E "ora_pmon|ora_smon|tnslsnr" | ${GREPBINARY} -v "grep")
if [ -z "${FIND}" ]; then
if ! IsRunning 'ora_pmon' && ! IsRunning 'ora_smon' && ! IsRunning 'tnslsnr'; then
if [ ${DEBUG} -eq 1 ]; then Display --indent 2 --text "- Oracle processes status" --result "${STATUS_NOT_FOUND}" --color WHITE --debug; fi
LogText "Result: Oracle process(es) not active"
else
Expand Down
3 changes: 1 addition & 2 deletions include/tests_logging
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
Register --test-no LOGG-2130 --weight L --network NO --category security --description "Check for running syslog daemon"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Searching for a logging daemon"
FIND=$(${PSBINARY} ax | ${GREPBINARY} -E "syslogd|syslog-ng|metalog|systemd-journal" | ${GREPBINARY} -v "grep")
if [ -z "${FIND}" ]; then
if ! IsRunning 'syslogd' && ! IsRunning 'syslog-ng' && ! IsRunning 'metalog' && ! IsRunning 'systemd-journal'; then
Display --indent 2 --text "- Checking for a running log daemon" --result "${STATUS_WARNING}" --color RED
LogText "Result: Could not find a syslog daemon like syslog, syslog-ng, rsyslog, metalog, systemd-journal"
ReportSuggestion "${TEST_NO}" "Check if any syslog daemon is running and correctly configured."
Expand Down
12 changes: 10 additions & 2 deletions include/tests_mail_messaging
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,12 @@
Register --test-no MAIL-8814 --weight L --network NO --category security --description "Check postfix process status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check Postfix status"
PSOPTIONS="ax"
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
PSOPTIONS="-w"
fi
# Some other processes also use master, therefore it should include both master and postfix
FIND1=$(${PSBINARY} ax | ${GREPBINARY} "master" | ${GREPBINARY} "postfix" | ${GREPBINARY} -v "grep")
FIND1=$(${PSBINARY} ${PSOPTIONS} | ${GREPBINARY} "master" | ${GREPBINARY} "postfix" | ${GREPBINARY} -v "grep")
if [ -n "${FIND1}" ]; then
LogText "Result: found running Postfix process"
Display --indent 2 --text "- Postfix status" --result "${STATUS_RUNNING}" --color GREEN
Expand Down Expand Up @@ -414,7 +418,11 @@
Register --test-no MAIL-8920 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check OpenSMTPD status"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: check smtpd status"
FIND=$(${PSBINARY} ax | ${GREPBINARY} -E "(/smtpd|smtpd: \[priv\]|smtpd: smtp)" | ${GREPBINARY} -v "grep")
PSOPTIONS="ax"
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
PSOPTIONS="-w"
fi
FIND=$(${PSBINARY} ${PSOPTIONS} | ${GREPBINARY} -E "(/smtpd|smtpd: \[priv\]|smtpd: smtp)" | ${GREPBINARY} -v "grep")
if [ ! "${FIND}" = "" ]; then
LogText "Result: found running smtpd process"
Display --indent 2 --text "- OpenSMTPD status" --result "${STATUS_RUNNING}" --color GREEN
Expand Down
8 changes: 6 additions & 2 deletions include/tests_memory_processes
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
if [ ! "${OS}" = "Solaris" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no PROC-3612 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check dead or zombie processes"
if [ ${SKIPTEST} -eq 0 ]; then
if [ "${OS}" = "AIX" ]; then
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
FIND=$(${PSBINARY} -w | ${AWKBINARY} '{ if ($4 ~ /Z|X/) print $1 }' | ${XARGSBINARY})
elif [ "${OS}" = "AIX" ]; then
FIND=$(${PSBINARY} -Ae -o pid,stat,comm | ${AWKBINARY} '{ if ($2 ~ /Z|X/) print $1 }' | ${XARGSBINARY})
else
FIND=$(${PSBINARY} x -o pid,stat,comm | ${AWKBINARY} '{ if ($2 ~ /Z|X/) print $1 }' | ${XARGSBINARY})
Expand All @@ -96,7 +98,9 @@
if [ ! "${OS}" = "Solaris" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
Register --test-no PROC-3614 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check heavy IO waiting based processes"
if [ ${SKIPTEST} -eq 0 ]; then
if [ "${OS}" = "AIX" ]; then
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
FIND=$(${PSBINARY} -w | ${AWKBINARY} '{ if ($4 ~ /D/) print $1 }' | ${XARGSBINARY})
elif [ "${OS}" = "AIX" ]; then
FIND=$(${PSBINARY} -Ae -o pid,stat,comm | ${AWKBINARY} '{ if ($2=="D") print $1 }' | ${XARGSBINARY})
else
FIND=$(${PSBINARY} x -o pid,stat,comm | ${AWKBINARY} '{ if ($2=="D") print $1 }' | ${XARGSBINARY})
Expand Down
12 changes: 10 additions & 2 deletions include/tests_scheduling
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
# Description : Check cron daemon
Register --test-no SCHD-7702 --weight L --network NO --category security --description "Check status of cron daemon"
if [ ${SKIPTEST} -eq 0 ]; then
FIND=$(${PSBINARY} aux | ${GREPBINARY} -E "( cron$|/cron(d)? )")
PSOPTIONS="aux"
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
PSOPTIONS="-w"
fi
FIND=$(${PSBINARY} ${PSOPTIONS} | ${GREPBINARY} -E "( cron$|/cron(d)? )")
if IsEmpty "${FIND}"; then
LogText "Result: no cron daemon found"
else
Expand Down Expand Up @@ -199,7 +203,11 @@
Register --test-no SCHD-7718 --weight L --network NO --category security --description "Check at users"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking atd status"
FIND=$(${PSBINARY} ax | ${GREPBINARY} "/atd" | ${GREPBINARY} -v "grep")
PSOPTIONS="ax"
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
PSOPTIONS="-w"
fi
FIND=$(${PSBINARY} ${PSOPTIONS} | ${GREPBINARY} "/atd" | ${GREPBINARY} -v "grep")
if [ -n "${FIND}" ]; then
LogText "Result: at daemon active"
Display --indent 2 --text "- Checking atd status" --result "${STATUS_RUNNING}" --color GREEN
Expand Down
3 changes: 1 addition & 2 deletions include/tests_squid
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
LogText "Test: Searching for a Squid daemon"
FOUND=0
# Check running processes
FIND=$(${PSBINARY} ax | ${GREPBINARY} -E "(squid|squid3) " | ${GREPBINARY} -v "grep")
if [ -n "${FIND}" ]; then
if IsRunning 'squid' || IsRunning 'squid3'; then
SQUID_DAEMON_RUNNING=1
LogText "Result: Squid daemon is running"
Display --indent 2 --text "- Checking running Squid daemon" --result "${STATUS_FOUND}" --color GREEN
Expand Down
3 changes: 1 addition & 2 deletions include/tests_storage_nfs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@
Register --test-no STRG-1920 --weight L --network NO --category security --description "Checking NFS daemon"
if [ ${SKIPTEST} -eq 0 ]; then
LogText "Test: Checking running NFS daemon"
FIND=$(${PSBINARY} ax | ${GREPBINARY} "nfsd" | ${GREPBINARY} -v "grep")
if [ -z "${FIND}" ]; then
if ! IsRunning 'nfsd'; then
LogText "Output: NFS daemon is not running"
Display --indent 2 --text "- Check running NFS daemon" --result "${STATUS_NOT_FOUND}" --color WHITE
else
Expand Down
18 changes: 15 additions & 3 deletions include/tests_time
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@

# Check for OpenNTPD, ntpctl comes with a "regular" install
if [ -n "${NTPCTLBINARY}" ]; then
PSOPTIONS="ax"
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
PSOPTIONS="-w"
fi
# In contrast to timectl, "synchronised: yes" is not grepped.
# Reason: openntpd syncs only if large time corrections are not required or -s is passed.
# This might be not intended by the administrator (-s is NOT the default!)
FIND=$(${PSBINARY} ax | ${GREPBINARY} "ntpd: ntp engine" | ${GREPBINARY} -v "grep")
FIND=$(${PSBINARY} ${PSOPTIONS} | ${GREPBINARY} "ntpd: ntp engine" | ${GREPBINARY} -v "grep")
# Status code 0 is when communication over the socket is successful
if ${NTPCTLBINARY} -s status > /dev/null 2> /dev/null; then
FOUND=1; NTP_DAEMON_RUNNING=1; NTP_CONFIG_TYPE_DAEMON=1; NTP_DAEMON="openntpd"
Expand All @@ -107,7 +111,11 @@
# Check running processes (ntpd from ntp.org)
# As checking by process name is ambiguous (openntpd has the same process name),
# this check will be skipped if openntpd has been found.
FIND=$(${PSBINARY} ax | ${GREPBINARY} "ntpd" | ${GREPBINARY} -v "dntpd" | ${GREPBINARY} -v "ntpd: " | ${GREPBINARY} -v "grep")
PSOPTIONS="ax"
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
PSOPTIONS="-w"
fi
FIND=$(${PSBINARY} ${PSOPTIONS} | ${GREPBINARY} "ntpd" | ${GREPBINARY} -v "dntpd" | ${GREPBINARY} -v "ntpd: " | ${GREPBINARY} -v "grep")
if [ "${NTP_DAEMON}" != "openntpd" ] && [ -n "${FIND}" ]; then
FOUND=1; NTPD_RUNNING=1; NTP_DAEMON_RUNNING=1; NTP_CONFIG_TYPE_DAEMON=1
NTP_DAEMON="ntpd"
Expand All @@ -122,7 +130,11 @@
fi

# Check timedate daemon (systemd)
FIND=$(${PSBINARY} ax | ${GREPBINARY} "systemd-timesyncd" | ${GREPBINARY} -v "grep")
PSOPTIONS="ax"
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
PSOPTIONS="-w"
fi
FIND=$(${PSBINARY} ${PSOPTIONS} | ${GREPBINARY} "systemd-timesyncd" | ${GREPBINARY} -v "grep")
if [ -n "${FIND}" ]; then
FOUND=1; NTP_DAEMON_RUNNING=1; NTP_CONFIG_TYPE_DAEMON=1; NTP_DAEMON="systemd-timesyncd"
Display --indent 2 --text "- NTP daemon found: systemd (timesyncd)" --result "${STATUS_FOUND}" --color GREEN
Expand Down