summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2010-10-26 13:00:05 +0100
committerColin Watson <cjwatson@debian.org>2010-10-26 13:00:05 +0100
commit2ff7e453722250e15e681574314a635ac9003f3c (patch)
tree02628fef3072bb8719a4b9e26d7fb44e23c74ff9
parentd03a9f67f01b5c828ecb9aac1f8b9439e252fc4a (diff)
Backport upstream patch to install a SIGCHLD handler to reap expired ssh
child processes, preventing lots of zombies when using ControlPersist (closes: #594687).
-rw-r--r--debian/changelog8
-rw-r--r--debian/patches/series1
-rw-r--r--debian/patches/ssh-sigchld.patch55
-rw-r--r--ssh.c19
4 files changed, 83 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index e41eee767..0cdc326ae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
1openssh (1:5.6p1-2) UNRELEASED; urgency=low
2
3 * Backport upstream patch to install a SIGCHLD handler to reap expired ssh
4 child processes, preventing lots of zombies when using ControlPersist
5 (closes: #594687).
6
7 -- Colin Watson <cjwatson@debian.org> Tue, 26 Oct 2010 12:58:39 +0100
8
1openssh (1:5.6p1-1) experimental; urgency=low 9openssh (1:5.6p1-1) experimental; urgency=low
2 10
3 * New upstream release (http://www.openssh.com/txt/release-5.6): 11 * New upstream release (http://www.openssh.com/txt/release-5.6):
diff --git a/debian/patches/series b/debian/patches/series
index fe14d7a8d..f3c6a87e0 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -41,3 +41,4 @@ doc-hash-tab-completion.patch
41# Debian-specific configuration 41# Debian-specific configuration
42gnome-ssh-askpass2-icon.patch 42gnome-ssh-askpass2-icon.patch
43debian-config.patch 43debian-config.patch
44ssh-sigchld.patch
diff --git a/debian/patches/ssh-sigchld.patch b/debian/patches/ssh-sigchld.patch
new file mode 100644
index 000000000..21d286b21
--- /dev/null
+++ b/debian/patches/ssh-sigchld.patch
@@ -0,0 +1,55 @@
1Description: Install a SIGCHLD handler to reap expired child processes
2Origin: upstream, http://bazaar.launchpad.net/~vcs-imports/openssh/main/revision/6166
3Bug-Debian: http://bugs.debian.org/594687
4Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1812
5Forwarded: not-needed
6Last-Update: 2010-10-26
7
8Index: b/ssh.c
9===================================================================
10--- a/ssh.c
11+++ b/ssh.c
12@@ -50,6 +50,7 @@
13 #include <sys/ioctl.h>
14 #include <sys/param.h>
15 #include <sys/socket.h>
16+#include <sys/wait.h>
17
18 #include <ctype.h>
19 #include <errno.h>
20@@ -210,6 +211,7 @@
21 static int ssh_session(void);
22 static int ssh_session2(void);
23 static void load_public_identity_files(void);
24+static void main_sigchld_handler(int);
25
26 /* from muxclient.c */
27 void muxclient(const char *);
28@@ -849,6 +851,7 @@
29 tilde_expand_filename(options.user_hostfile2, original_real_uid);
30
31 signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */
32+ signal(SIGCHLD, main_sigchld_handler);
33
34 /* Log into the remote system. Never returns if the login fails. */
35 ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr,
36@@ -1532,3 +1535,19 @@
37 bzero(pwdir, strlen(pwdir));
38 xfree(pwdir);
39 }
40+
41+static void
42+main_sigchld_handler(int sig)
43+{
44+ int save_errno = errno;
45+ pid_t pid;
46+ int status;
47+
48+ while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
49+ (pid < 0 && errno == EINTR))
50+ ;
51+
52+ signal(sig, main_sigchld_handler);
53+ errno = save_errno;
54+}
55+
diff --git a/ssh.c b/ssh.c
index ab3c33d87..22d4f53c4 100644
--- a/ssh.c
+++ b/ssh.c
@@ -50,6 +50,7 @@
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/param.h> 51#include <sys/param.h>
52#include <sys/socket.h> 52#include <sys/socket.h>
53#include <sys/wait.h>
53 54
54#include <ctype.h> 55#include <ctype.h>
55#include <errno.h> 56#include <errno.h>
@@ -210,6 +211,7 @@ usage(void)
210static int ssh_session(void); 211static int ssh_session(void);
211static int ssh_session2(void); 212static int ssh_session2(void);
212static void load_public_identity_files(void); 213static void load_public_identity_files(void);
214static void main_sigchld_handler(int);
213 215
214/* from muxclient.c */ 216/* from muxclient.c */
215void muxclient(const char *); 217void muxclient(const char *);
@@ -849,6 +851,7 @@ main(int ac, char **av)
849 tilde_expand_filename(options.user_hostfile2, original_real_uid); 851 tilde_expand_filename(options.user_hostfile2, original_real_uid);
850 852
851 signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */ 853 signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE early */
854 signal(SIGCHLD, main_sigchld_handler);
852 855
853 /* Log into the remote system. Never returns if the login fails. */ 856 /* Log into the remote system. Never returns if the login fails. */
854 ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr, 857 ssh_login(&sensitive_data, host, (struct sockaddr *)&hostaddr,
@@ -1532,3 +1535,19 @@ load_public_identity_files(void)
1532 bzero(pwdir, strlen(pwdir)); 1535 bzero(pwdir, strlen(pwdir));
1533 xfree(pwdir); 1536 xfree(pwdir);
1534} 1537}
1538
1539static void
1540main_sigchld_handler(int sig)
1541{
1542 int save_errno = errno;
1543 pid_t pid;
1544 int status;
1545
1546 while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
1547 (pid < 0 && errno == EINTR))
1548 ;
1549
1550 signal(sig, main_sigchld_handler);
1551 errno = save_errno;
1552}
1553