Package: authbind
Severity: normal
Tags: upstream patch

I have been using this patch for a few months and it fixes for me
the SIGCHLD problem documented in the man page:

       Some programs may have trouble because authbind spawns a child
       process `under their feet', causing (for example) a fork(2) to
       happen and SIGCHLD signal to be delivered.  Unfortunately the
       Unix API does not make it possible to deal with this problem in
       a sane way.

-- 
ciao,
Marco
--- libauthbind.c.orig	2014-08-04 02:41:39.104594468 +0200
+++ libauthbind.c	2014-08-04 03:00:18.784625815 +0200
@@ -146,9 +146,10 @@
   pid_t child, rchild;
   char portarg[5], addrarg[33];
   const char *afarg;
-  int i, r, status;
+  int i, r, status, restore_sigchild;
   const int *evilsignal;
   sigset_t block, saved;
+  struct sigaction old_sigchild;
   unsigned int portval;
 
   switch (addr->sa_family) {
@@ -195,6 +196,18 @@
   sprintf(portarg,"%04x",
 	  portval&0x0ffff);
 
+  restore_sigchild= 0;
+  if (sigaction(SIGCHLD,NULL,&old_sigchild)) return -1;
+  if (old_sigchild.sa_handler == SIG_IGN) {
+    struct sigaction new_sigchild;
+
+    new_sigchild.sa_handler= SIG_DFL;
+    sigemptyset(&new_sigchild.sa_mask);
+    new_sigchild.sa_flags= 0;
+    if (sigaction(SIGCHLD,&new_sigchild,&old_sigchild)) return -1;
+    restore_sigchild= 1;
+  }
+
   child= fork(); if (child==-1) goto x_err;
 
   if (!child) {
@@ -228,5 +241,8 @@
   r= -1;
 x:
   if (sigprocmask(SIG_SETMASK,&saved,0)) abort();
+  if (restore_sigchild) {
+    if (sigaction(SIGCHLD,&old_sigchild,NULL)) return -1;
+  }
   return r;
 }

Attachment: signature.asc
Description: Digital signature

Reply via email to