summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/tcp-wrappers/tcp-wrappers-7.6/restore_sigalarm.patch
blob: a864e3812984ea4d9f72a7a0f1349b644e072a2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Upstream-Status: Inactive-Upstream [current release is from 1997; no vcs anywhere]

diff -ruN tcp_wrappers_7.6.orig/rfc931.c tcp_wrappers_7.6/rfc931.c
--- tcp_wrappers_7.6.orig/rfc931.c	2004-08-29 18:40:08.000000000 +0200
+++ tcp_wrappers_7.6/rfc931.c	2004-08-29 18:40:02.000000000 +0200
@@ -92,6 +92,8 @@
     char   *cp;
     char   *result = unknown;
     FILE   *fp;
+    unsigned saved_timeout;
+    struct sigaction nact, oact;
 
 #ifdef INET6
     /* address family must be the same */
@@ -134,7 +136,12 @@
 	 */
 
 	if (setjmp(timebuf) == 0) {
-	    signal(SIGALRM, timeout);
+	    /* Save SIGALRM timer and handler. Sudheer Abdul-Salam, SUN. */
+	    saved_timeout = alarm(0);
+	    nact.sa_handler = timeout;
+	    nact.sa_flags = 0;
+	    (void) sigemptyset(&nact.sa_mask);
+	    (void) sigaction(SIGALRM, &nact, &oact);
 	    alarm(rfc931_timeout);
 
 	    /*
@@ -223,6 +230,10 @@
 	    }
 	    alarm(0);
 	}
+	/* Restore SIGALRM timer and handler. Sudheer Abdul-Salam, SUN. */
+	(void) sigaction(SIGALRM, &oact, NULL);
+	if (saved_timeout > 0)
+	    alarm(saved_timeout);
 	fclose(fp);
     }
     STRN_CPY(dest, result, STRING_LENGTH);