From 2c8c34fb270ee6c87aae21b94abd11d42eb9d22f Mon Sep 17 00:00:00 2001 From: John Ogness Date: Tue, 29 Jun 2021 21:15:38 +0200 Subject: system/openssh: ignore initscript process on shutdown On shutdown, the initscript will kill any processes that match sshd. However, since the initscript itself is called sshd, it ends up seeing/killing itself! Avoid this by only killing processes where /proc/$PID/exe is pointing to $SSHD_BINARY. Signed-off-by: John Ogness --- system/openssh/sshd.initd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'system/openssh/sshd.initd') diff --git a/system/openssh/sshd.initd b/system/openssh/sshd.initd index 065519174..e13924e2c 100755 --- a/system/openssh/sshd.initd +++ b/system/openssh/sshd.initd @@ -82,7 +82,12 @@ stop() { eend $? if [ "$RC_RUNLEVEL" = "shutdown" ]; then - _sshd_pids=$(pgrep "${SSHD_BINARY##*/}") + local _p _sshd_pids + for _p in $(pgrep "${SSHD_BINARY##*/}"); do + [ "$(realpath /proc/$_p/exe)" = "${SSHD_BINARY}" ] \ + || continue + _sshd_pids="$_sshd_pids $_p" + done if [ -n "$_sshd_pids" ]; then ebegin "Shutting down ssh connections" kill -TERM $_sshd_pids >/dev/null 2>&1 -- cgit v1.2.3-70-g09d2