37 |
#include <netdb.h> |
#include <netdb.h> |
38 |
#include <unistd.h> |
#include <unistd.h> |
39 |
#include <ctype.h> |
#include <ctype.h> |
40 |
|
#include <setjmp.h> |
41 |
#include <errno.h> |
#include <errno.h> |
42 |
#ifdef HAVE_SYS_UIO_H |
#ifdef HAVE_SYS_UIO_H |
43 |
# include <sys/uio.h> |
# include <sys/uio.h> |
359 |
} |
} |
360 |
|
|
361 |
|
|
362 |
static int ring; |
static jmp_buf to_env; |
363 |
|
|
364 |
static RETSIGTYPE |
static RETSIGTYPE |
365 |
alrm_handler() |
alrm_handler() |
366 |
{ |
{ |
367 |
ring = 1; |
longjmp(to_env, 1); |
368 |
} |
} |
369 |
|
|
370 |
#define MIN(a,b) ((a)<(b))?(a):(b) |
#define MIN(a,b) ((a)<(b))?(a):(b) |
467 |
*/ |
*/ |
468 |
lastc = 0; |
lastc = 0; |
469 |
if ((fp = fdopen(s, "r")) != NULL) { |
if ((fp = fdopen(s, "r")) != NULL) { |
470 |
|
if (setjmp(to_env)) { |
471 |
|
radlog(L_NOTICE, |
472 |
|
_("timed out in waiting for finger response from NAS %s"), |
473 |
|
checkp->hostname); |
474 |
|
fclose(fp); |
475 |
|
obstack_free(&stk, NULL); |
476 |
|
alarm(0); |
477 |
|
signal(SIGALRM, handler); |
478 |
|
return checkp->result = -1; |
479 |
|
} |
480 |
|
|
481 |
to = ilookup(checkp, "timeout", 10); |
to = ilookup(checkp, "timeout", 10); |
482 |
|
handler = signal(SIGALRM, alrm_handler); |
483 |
install_signal_flags(SIGALRM, alrm_handler, 0); |
alarm(to); |
|
alarm(to); |
|
484 |
|
|
485 |
while ((c = getc(fp)) != EOF) { |
while ((c = getc(fp)) != EOF) { |
486 |
if (c == 0x0d) { |
if (c == 0x0d) { |
505 |
/* Make sure no alarm arrives while |
/* Make sure no alarm arrives while |
506 |
* processing data |
* processing data |
507 |
*/ |
*/ |
508 |
to = alarm(0); |
to = alarm(0); |
509 |
install_signal(SIGALRM, handler); |
signal(SIGALRM, handler); |
510 |
|
|
511 |
obstack_1grow(&stk, 0); |
obstack_1grow(&stk, 0); |
512 |
ptr = obstack_finish(&stk); |
ptr = obstack_finish(&stk); |
517 |
break; |
break; |
518 |
|
|
519 |
/* restore alarm settings */ |
/* restore alarm settings */ |
520 |
install_signal_flags(SIGALRM, alrm_handler, 0); |
signal(SIGALRM, alrm_handler); |
521 |
alarm(to); |
alarm(to); |
522 |
} |
} |
523 |
} |
} |
524 |
|
|
527 |
* processing data |
* processing data |
528 |
*/ |
*/ |
529 |
alarm(0); |
alarm(0); |
530 |
install_signal(SIGALRM, handler); |
signal(SIGALRM, handler); |
531 |
|
|
532 |
obstack_1grow(&stk, '\n'); |
obstack_1grow(&stk, '\n'); |
533 |
obstack_1grow(&stk, 0); |
obstack_1grow(&stk, 0); |
545 |
|
|
546 |
/* restore alarm settings */ |
/* restore alarm settings */ |
547 |
alarm(0); |
alarm(0); |
548 |
install_signal(SIGALRM, handler); |
signal(SIGALRM, handler); |
549 |
|
|
550 |
debug(1, ("result: %d", found)); |
debug(1, ("result: %d", found)); |
551 |
checkp->result = found; |
checkp->result = found; |