[oe-commits] Richard Tollerton : openssh: use pidfile in initscript

git at git.openembedded.org git at git.openembedded.org
Fri Jul 18 23:09:29 UTC 2014


Module: openembedded-core.git
Branch: master
Commit: 993405285e547403d5c753adfa91c26c43be13f6
URL:    http://git.openembedded.org/?p=openembedded-core.git&a=commit;h=993405285e547403d5c753adfa91c26c43be13f6

Author: Richard Tollerton <rich.tollerton at ni.com>
Date:   Wed Jul 16 16:28:32 2014 -0500

openssh: use pidfile in initscript

Stopping sshd must only kill the listening (top-level) daemon; it must
not stop any other sshd process, because those are forked ssh
connections which may include e.g. the connection that called
/etc/init.d/sshd stop.

This initscript uses "start-stop-daemon -x <exe>" for starting/stopping.
When that is provided by busybox, this behavior is broken:
`/etc/init.d/sshd stop` stops *all* sshd processes. This was caused by a
fix to busybox 1.20: 17eedcad9406c43beddab3906c8c693626c351fb
"ssd: compat: match -x EXECUTABLE by /proc/pid/exe too".

The fix is to use a pidfile. All initscripts in upstream openssh do this,
as does dropbear.

Acked-by: Gratian Crisan <gratian.crisan at ni.com>
Acked-by: Ken Sharp <ken.sharp at ni.com>
Signed-off-by: Richard Tollerton <rich.tollerton at ni.com>
Signed-off-by: Ben Shelton <ben.shelton at ni.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>

---

 meta/recipes-connectivity/openssh/openssh/init | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh/init b/meta/recipes-connectivity/openssh/openssh/init
index 37c8e7b..70d4a34 100644
--- a/meta/recipes-connectivity/openssh/openssh/init
+++ b/meta/recipes-connectivity/openssh/openssh/init
@@ -1,6 +1,8 @@
 #! /bin/sh
 set -e
 
+PIDFILE=/var/run/sshd.pid
+
 # source function library
 . /etc/init.d/functions
 
@@ -70,12 +72,12 @@ case "$1" in
 	echo "Starting OpenBSD Secure Shell server: sshd"
 	check_keys
 	check_privsep_dir
-	start-stop-daemon -S -x /usr/sbin/sshd -- $SSHD_OPTS
+	start-stop-daemon -S -p $PIDFILE -x /usr/sbin/sshd -- $SSHD_OPTS
         echo "done."
 	;;
   stop)
         echo -n "Stopping OpenBSD Secure Shell server: sshd"
-	start-stop-daemon -K -x /usr/sbin/sshd
+	start-stop-daemon -K -p $PIDFILE -x /usr/sbin/sshd
         echo "."
 	;;
 
@@ -84,7 +86,7 @@ case "$1" in
 	check_keys
 	check_config
         echo -n "Reloading OpenBSD Secure Shell server's configuration"
-	start-stop-daemon -K -s 1 -x /usr/sbin/sshd
+	start-stop-daemon -K -p $PIDFILE -s 1 -x /usr/sbin/sshd
 	echo "."
 	;;
 
@@ -92,11 +94,11 @@ case "$1" in
   	check_keys
 	check_config
         echo -n "Restarting OpenBSD Secure Shell server: sshd"
-	start-stop-daemon -K --oknodo -x /usr/sbin/sshd
+	start-stop-daemon -K -p $PIDFILE --oknodo -x /usr/sbin/sshd
 	check_for_no_start
 	check_privsep_dir
 	sleep 2
-	start-stop-daemon -S -x /usr/sbin/sshd -- $SSHD_OPTS
+	start-stop-daemon -S -p $PIDFILE -x /usr/sbin/sshd -- $SSHD_OPTS
 	echo "."
 	;;
 



More information about the Openembedded-commits mailing list