[PATCH] dropbear-051: Kill child (shell) process when dropbear exits

Farrell Aultman fja0568 at gmail.com
Sat Sep 20 05:52:07 WST 2008


Dropbear child process (shells created by client connections) would hang
around after the server process
has exited.  This patch will kill these child processes when the dropbear
server exits.

Common subdirectories: ../../dropbear-vanilla/dropbear-0.51/debian and
../../dropbear-killchild/dropbear-0.51/debian
Common subdirectories: ../../dropbear-vanilla/dropbear-0.51/libtomcrypt and
../../dropbear-killchild/dropbear-0.51/libtomcrypt
Common subdirectories: ../../dropbear-vanilla/dropbear-0.51/libtommath and
../../dropbear-killchild/dropbear-0.51/libtommath
Common subdirectories: ../../dropbear-vanilla/dropbear-0.51/_MTN and
../../dropbear-killchild/dropbear-0.51/_MTN
Only in ../../dropbear-killchild/dropbear-0.51: patch051.killchild
diff -up ../../dropbear-vanilla/dropbear-0.51/svr-session.c
../../dropbear-killchild/dropbear-0.51/svr-session.c
--- ../../dropbear-vanilla/dropbear-0.51/svr-session.c    2008-03-27
09:17:16.000000000 -0400
+++ ../../dropbear-killchild/dropbear-0.51/svr-session.c    2008-09-19
11:06:51.000000000 -0400
@@ -117,10 +117,19 @@ void svr_session(int sock, int childpipe

 }

+static void killchild(int pid) {
+
+    if (pid > 1) {
+        kill(pid, SIGTERM);
+        waitpid(pid, NULL, 0);
+    }
+}
+
 /* failure exit - format must be <= 100 chars */
 void svr_dropbear_exit(int exitcode, const char* format, va_list param) {

     char fmtbuf[300];
+    int i;

     if (!sessinitdone) {
         /* before session init */
@@ -147,6 +156,11 @@ void svr_dropbear_exit(int exitcode, con
     /* must be after we've done with username etc */
     common_session_cleanup();

+    /* kill child processes */
+    for (i = 0; i < svr_ses.childpidsize; i++) {
+        killchild(svr_ses.childpids[i].pid);
+    }
+
     exit(exitcode);

 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ucc.gu.uwa.edu.au/pipermail/dropbear/attachments/20080919/1b27e1cf/attachment-0001.htm 


More information about the Dropbear mailing list