diff options
author | Kim Hagen <kim.sidney@gmail.com> | 2016-09-01 09:56:42 +0200 |
---|---|---|
committer | Kim Hagen <kim.sidney@gmail.com> | 2016-09-01 09:56:42 +0200 |
commit | 235d5b22a8368aee4696b1b2c84d702bf326a084 (patch) | |
tree | 2eaa7bcd2577327807494233acdcda7c68f3ba06 /data/live-build-config/includes.chroot | |
parent | 1d115aa6e45112c976f70231a48d5fc76be7b7fa (diff) | |
download | vyos-build-235d5b22a8368aee4696b1b2c84d702bf326a084.tar.gz vyos-build-235d5b22a8368aee4696b1b2c84d702bf326a084.zip |
T18: Regression: jessie-based VyOS doesn't disconnect the SSH session before reboot
Diffstat (limited to 'data/live-build-config/includes.chroot')
3 files changed, 24 insertions, 16 deletions
diff --git a/data/live-build-config/includes.chroot/etc/systemd/system/sshd.service b/data/live-build-config/includes.chroot/etc/systemd/system/sshd.service deleted file mode 100644 index e84142bb..00000000 --- a/data/live-build-config/includes.chroot/etc/systemd/system/sshd.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=OpenBSD Secure Shell server -After=network.target auditd.service -ConditionPathExists=!/etc/ssh/sshd_not_to_be_run - -[Service] -EnvironmentFile=-/etc/default/ssh -ExecStart=/usr/sbin/sshd -D $SSHD_OPTS -ExecReload=/bin/kill -HUP $MAINPID -ExecStop=/usr/bin/killall sshd -KillMode=process -Restart=on-failure - -[Install] -WantedBy=multi-user.target -Alias=sshd.service diff --git a/data/live-build-config/includes.chroot/lib/systemd/system/ssh-session-cleanup.service b/data/live-build-config/includes.chroot/lib/systemd/system/ssh-session-cleanup.service new file mode 100755 index 00000000..b8672722 --- /dev/null +++ b/data/live-build-config/includes.chroot/lib/systemd/system/ssh-session-cleanup.service @@ -0,0 +1,13 @@ +[Unit] +Description=OpenBSD Secure Shell session cleanup +Wants=network.target +After=network.target + +[Service] +ExecStart=/bin/true +ExecStop=/usr/lib/openssh/ssh-session-cleanup +RemainAfterExit=yes +Type=oneshot + +[Install] +WantedBy=multi-user.target 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 |