]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
OpenSSH: Fix initscript to actually kill the daemon
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Oct 2020 13:20:56 +0000 (14:20 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 27 Oct 2020 13:20:56 +0000 (14:20 +0100)
The SSH daemon was not terminated properly because killproc
tried to terminate all processes with that name. That caused
that the master daemon respawned some processed which were
therefore not killed because killproc determined a list of
PIDs only once before starting sending signals.

This patch only kills the master process which is being
determined by using sshd's pid file.

That results in all established connections not being
interrupted any more.

Furthermore, the loadproc function checks if any processes
with the given name are already running which could be true
if there are any connections still open.
That check is being disabled with the -f switch and sshd
will always be launched.

"/etc/init.d/sshd stop" might now print FAIL if only the
master process, but no connection processes were terminated.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/system/sshd

index 7b4092d38dd62bc6c3381fb6561b57410cdb00dd..c3c02adc1b45056674b3c307320b58b958cb245a 100644 (file)
@@ -25,7 +25,7 @@ case "$1" in
 
         [ -e "/var/ipfire/remote/enablessh" ] || exit 0 # SSH is not enabled
         boot_mesg "Starting SSH Server..."
-        loadproc /usr/sbin/sshd 
+        loadproc -f /usr/sbin/sshd
 
         # Also prevent ssh from being killed by out of memory conditions
        (
@@ -37,7 +37,7 @@ case "$1" in
 
     stop)
         boot_mesg "Stopping SSH Server..."
-        killproc /usr/sbin/sshd
+        killproc -p "/var/run/sshd.pid" /usr/sbin/sshd
         ;;
 
     reload)