Skip to contentSkip to conversation

package/openssh: fix initscript killing subprocesses

PATCH New John Doe 2 participants 2 messages Jan 1, 2021 – Jan 2, 2021

lore
Share & tools
lore

John Doe

author
#0 lore raw

PATCH 1/1 package/openssh: fix initscript killing subprocesses

The initscript currently calls killall sshd when stopping the service, which kills all active SSH sessions. Rewritten to use start-stop-daemon with PIDfile.

---
 package/openssh/S50sshd | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
package/openssh/S50sshd +21 -6
index 22da41d1ca..77a82308ca 100644
@@ -3,6 +3,9 @@
 # sshd        Starts sshd.
 #
 
+DAEMON="sshd"
+PIDFILE="/var/run/$DAEMON.pid"
+
 # Make sure the ssh-keygen progam exists
 [ -f /usr/bin/ssh-keygen ] || exit 0
 
@@ -13,15 +16,27 @@ start() {
 	/usr/bin/ssh-keygen -A
 
 	printf "Starting sshd: "
-	/usr/sbin/sshd
-	touch /var/lock/sshd
-	echo "OK"
+	start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/sshd"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		touch /var/lock/sshd
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
 }
 stop() {
 	printf "Stopping sshd: "
-	killall sshd
-	rm -f /var/lock/sshd
-	echo "OK"
+	start-stop-daemon -K -q -p "$PIDFILE"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		rm -f /var/lock/sshd
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
 }
 restart() {
 	stop
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/1 package/openssh: fix initscript killing subprocesses

John, All,

On 2021-01-01 20:31 +0000, John Doe spake thusly:

Quoted 4 lines

The initscript currently calls killall sshd when stopping the service, which kills all active SSH sessions. Rewritten to use start-stop-daemon with PIDfile.

Thanks for your contribution.

However, we can't accept anonymous contributions; we require that people use their real names. Furthermore, the authorship (the email address used to send the patch) shall match the sign-off tag.

I'm sorry, but I've marked this patch as rejected in our patchwork [0]. Please respin using your real name.

[0] https://patchwork.ozlabs.org/project/buildroot/list/

Regards,
Yann E. MORIN.

Quoted 58 lines
---
 package/openssh/S50sshd | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
package/openssh/S50sshd +21 -6
index 22da41d1ca..77a82308ca 100644
@@ -3,6 +3,9 @@
 # sshd        Starts sshd.
 #
 
+DAEMON="sshd"
+PIDFILE="/var/run/$DAEMON.pid"
+
 # Make sure the ssh-keygen progam exists
 [ -f /usr/bin/ssh-keygen ] || exit 0
 
@@ -13,15 +16,27 @@ start() {
 	/usr/bin/ssh-keygen -A
 
 	printf "Starting sshd: "
-	/usr/sbin/sshd
-	touch /var/lock/sshd
-	echo "OK"
+	start-stop-daemon -S -q -p "$PIDFILE" -x "/usr/sbin/sshd"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		touch /var/lock/sshd
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
 }
 stop() {
 	printf "Stopping sshd: "
-	killall sshd
-	rm -f /var/lock/sshd
-	echo "OK"
+	start-stop-daemon -K -q -p "$PIDFILE"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		rm -f /var/lock/sshd
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
 }
 restart() {
 	stop
Signature · 5 lines
2.29.2
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'