summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ogness <adelielinux@ogness.net>2021-06-29 21:15:38 +0200
committerJohn Ogness <adelielinux@ogness.net>2021-06-29 21:44:20 +0200
commit2c8c34fb270ee6c87aae21b94abd11d42eb9d22f (patch)
treeee728d1b463c9f664976ffecb52607629f41f4e7
parent607ac46b45782d21cd19ab42993800bfeba3620e (diff)
downloadpackages-2c8c34fb270ee6c87aae21b94abd11d42eb9d22f.tar.gz
packages-2c8c34fb270ee6c87aae21b94abd11d42eb9d22f.tar.bz2
packages-2c8c34fb270ee6c87aae21b94abd11d42eb9d22f.tar.xz
packages-2c8c34fb270ee6c87aae21b94abd11d42eb9d22f.zip
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 <adelielinux@ogness.net>
-rw-r--r--system/openssh/APKBUILD4
-rwxr-xr-xsystem/openssh/sshd.initd7
2 files changed, 8 insertions, 3 deletions
diff --git a/system/openssh/APKBUILD b/system/openssh/APKBUILD
index 7466d2844..a08c24f79 100644
--- a/system/openssh/APKBUILD
+++ b/system/openssh/APKBUILD
@@ -4,7 +4,7 @@
pkgname=openssh
pkgver=8.1_p1
_myver=${pkgver%_*}${pkgver#*_}
-pkgrel=0
+pkgrel=1
pkgdesc="Port of OpenBSD's free SSH release"
url="https://www.openssh.com/portable.html"
arch="all"
@@ -151,5 +151,5 @@ f3d5960572ddf49635d4edbdff45835df1b538a81840db169c36b39862e6fa8b0393ca90626000b7
9033520d18ccfea87628c78008591ae8a143999868254eabc926ca0665611c9f09c221265b1b6f552b82eca58558244a020d615b55249a02f96e298c1f7ff520 fix-utmpx.patch
34c0673f550e7afcd47eda4fe1da48fb42e5344c95ba8064c9c3c137fda9c43635b0f7b8145d0300f59c79f75a396ebd467afb54cdaa42aa251d624d0752dc84 sftp-interactive.patch
ad5b209f7f3fff69c10bae34da143e071e107a2141eee94f393532d6bb04a36bfe6d9b5d2c08b713f67118503c38d11b4aad689df1df7c8a918d52db8326821d time64-seccomp.patch
-394a420a36880bb0dd37dfd8727cea91fd9de6534050169e21212a46513ef3aaafe2752c338699b3d4ccd14871b26cf01a152df8060cd37f86ce0665fd53c63f sshd.initd
+964c0f8538ba25bdc9cdbd1467bbdfb2090e38492ff0ef7c64473785713fe26d752ea6a7b0ee7a0b34e08f4d3b4bccf6a69e6c456f0c57d0d0c581aa8a046936 sshd.initd
ce0abddbd2004891f88efd8522c4b37a4989290269fab339c0fa9aacc051f7fd3b20813e192e92e0e64315750041cb74012d4321260f4865ff69d7a935b259d4 sshd.confd"
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