summaryrefslogtreecommitdiff
path: root/debian/systemd
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2016-07-22 16:51:08 +0100
committerColin Watson <cjwatson@debian.org>2016-07-22 16:51:08 +0100
commitb66f1de1c94fcf912b3a1bc0cd73c3b73cdae8a1 (patch)
tree76bc05af9b826471b6c1af83ccf9ba572e9e05d3 /debian/systemd
parent4e620d6d9ebe0eda9ceddb28134d1fc465dd925c (diff)
Add a session cleanup script and a systemd unit file to trigger it, which serves to terminate SSH sessions cleanly if systemd doesn't do that itself, often because libpam-systemd is not installed (thanks, Vivek Das Mohapatra, Tom Hutter, and others; closes: #751636).
Diffstat (limited to 'debian/systemd')
-rwxr-xr-xdebian/systemd/ssh-session-cleanup11
-rw-r--r--debian/systemd/ssh-session-cleanup.service13
2 files changed, 24 insertions, 0 deletions
diff --git a/debian/systemd/ssh-session-cleanup b/debian/systemd/ssh-session-cleanup
new file mode 100755
index 000000000..f283cc967
--- /dev/null
+++ b/debian/systemd/ssh-session-cleanup
@@ -0,0 +1,11 @@
1#! /bin/sh
2
3ssh_session_pattern='sshd: \S.*@pts/[0-9]+'
4
5IFS="$IFS@"
6pgrep -a -f "$ssh_session_pattern" | while read pid daemon user pty; do
7 echo "Found ${daemon%:} session $pid on $pty; sending SIGTERM"
8 kill "$pid" || true
9done
10
11exit 0
diff --git a/debian/systemd/ssh-session-cleanup.service b/debian/systemd/ssh-session-cleanup.service
new file mode 100644
index 000000000..b86727227
--- /dev/null
+++ b/debian/systemd/ssh-session-cleanup.service
@@ -0,0 +1,13 @@
1[Unit]
2Description=OpenBSD Secure Shell session cleanup
3Wants=network.target
4After=network.target
5
6[Service]
7ExecStart=/bin/true
8ExecStop=/usr/lib/openssh/ssh-session-cleanup
9RemainAfterExit=yes
10Type=oneshot
11
12[Install]
13WantedBy=multi-user.target