diff -ur tcp_wrappers_7.6/rfc931.c tcp_wrappers_7.6.alarm/rfc931.c --- tcp_wrappers_7.6/rfc931.c Tue May 1 23:14:34 2001 +++ tcp_wrappers_7.6.alarm/rfc931.c Tue May 1 23:13:56 2001 @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -33,7 +32,8 @@ int rfc931_timeout = RFC931_TIMEOUT;/* Global so it can be changed */ -static sigjmp_buf timebuf; +struct sigaction oldact; +int restored = 0; /* fsocket - open stdio stream on top of socket */ @@ -59,10 +59,10 @@ /* timeout - handle timeouts */ -static void timeout(sig) -int sig; +static void timeout(int signum) { - siglongjmp(timebuf, sig); + sigaction(SIGALRM,&oldact,NULL); + restored = 1; } /* rfc931 - return remote user name, given socket structures */ @@ -92,6 +92,8 @@ char *cp; char *result = unknown; FILE *fp; + int old_alarm; + struct sigaction act; #ifdef INET6 /* address family must be the same */ @@ -133,9 +135,18 @@ * Set up a timer so we won't get stuck while waiting for the server. */ - if (sigsetjmp(timebuf,1) == 0) { - signal(SIGALRM, timeout); - alarm(rfc931_timeout); + act.sa_handler = timeout; + sigemptyset(&act.sa_mask); + act.sa_flags = 0; +#ifdef SA_INTERRUPT + act.sa_flags |= SA_INTERRUPT; +#endif + sigaction(SIGALRM,&act,&oldact); + restored = 0; +#ifdef HAVE_SIGINTERRUPT + siginterrupt(SIGALRM,1); +#endif + old_alarm = alarm(rfc931_timeout); /* * Bind the local and remote ends of the query socket to the same @@ -221,8 +232,11 @@ result = user; } } - alarm(0); + if (!restored) { + sigaction(SIGALRM,&oldact,NULL); + restored = 1; } + alarm(old_alarm); fclose(fp); } STRN_CPY(dest, result, STRING_LENGTH);