summaryrefslogtreecommitdiff
path: root/data/live-build-config/includes.chroot/usr/lib/openssh/ssh-session-cleanup
diff options
context:
space:
mode:
Diffstat (limited to 'data/live-build-config/includes.chroot/usr/lib/openssh/ssh-session-cleanup')
-rwxr-xr-xdata/live-build-config/includes.chroot/usr/lib/openssh/ssh-session-cleanup11
1 files changed, 11 insertions, 0 deletions
diff --git a/data/live-build-config/includes.chroot/usr/lib/openssh/ssh-session-cleanup b/data/live-build-config/includes.chroot/usr/lib/openssh/ssh-session-cleanup
new file mode 100755
index 00000000..f283cc96
--- /dev/null
+++ b/data/live-build-config/includes.chroot/usr/lib/openssh/ssh-session-cleanup
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+ssh_session_pattern='sshd: \S.*@pts/[0-9]+'
+
+IFS="$IFS@"
+pgrep -a -f "$ssh_session_pattern" | while read pid daemon user pty; do
+ echo "Found ${daemon%:} session $pid on $pty; sending SIGTERM"
+ kill "$pid" || true
+done
+
+exit 0