/[radius]/radius/radiusd/checkrad.c
ViewVC logotype

Diff of /radius/radiusd/checkrad.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.22 by gray, Sat Dec 21 14:00:43 2002 UTC revision 1.23 by gray, Fri Apr 18 05:27:10 2003 UTC
# Line 37  static char rcsid[] = Line 37  static char rcsid[] =
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>
# Line 358  snmp_check(checkp, nas) Line 359  snmp_check(checkp, nas)
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)
# Line 466  finger_check(checkp, nas) Line 467  finger_check(checkp, nas)
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) {
# Line 494  finger_check(checkp, nas) Line 505  finger_check(checkp, nas)
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);
# Line 506  finger_check(checkp, nas) Line 517  finger_check(checkp, nas)
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                                    
# Line 516  finger_check(checkp, nas) Line 527  finger_check(checkp, nas)
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);
# Line 534  finger_check(checkp, nas) Line 545  finger_check(checkp, nas)
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;

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.23

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26