From: Paul Park Date: Fri, 12 May 1995 20:13:46 +0000 (+0000) Subject: Check for and use POSIX signal/setjmp/longjmp X-Git-Tag: krb5-1.0-beta6~1989 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b690fdffd77d179a0634b45bf11730cab075bd86;p=krb5.git Check for and use POSIX signal/setjmp/longjmp git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5808 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/v5server/configure.in b/src/kadmin/v5server/configure.in index e5a097e0d..727935e05 100644 --- a/src/kadmin/v5server/configure.in +++ b/src/kadmin/v5server/configure.in @@ -8,6 +8,8 @@ AC_CHECK_LIB(ndbm,main) AC_CHECK_LIB(dbm,main) AC_FUNC_CHECK(waitpid,AC_DEFINE(HAVE_WAITPID)) AC_FUNC_CHECK(vsprintf,AC_DEFINE(HAVE_VSPRINTF)) +CHECK_SIGNALS +CHECK_SETJMP CHECK_WAIT_TYPE ET_RULES KRB_INCLUDE diff --git a/src/kadmin/v5server/proto_serv.c b/src/kadmin/v5server/proto_serv.c index 8def48c6a..f88811ae3 100644 --- a/src/kadmin/v5server/proto_serv.c +++ b/src/kadmin/v5server/proto_serv.c @@ -57,7 +57,11 @@ static jmp_buf timeout_jmp; static krb5_sigtype proto_alarmclock() { +#if POSIX_SETJMP + siglongjmp(timeout_jmp, 1); +#else /* POSIX_SETJMP */ longjmp(timeout_jmp, 1); +#endif /* POSIX_SETJMP */ /* NOTREACHED */ } @@ -108,6 +112,10 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) krb5_address *local; krb5_address *remote; +#if POSIX_SIGNALS + struct sigaction s_action; +#endif /* POSIX_SIGNALS */ + char *curr_lang = (char *) NULL; krb5_boolean mime_setting = 0; @@ -130,6 +138,10 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) remote = (krb5_address *) NULL; ticket = (krb5_ticket *) NULL; rcache = (krb5_rcache) NULL; +#if POSIX_SIGNALS + (void) sigemptyset(&s_action.sa_mask); + s_action.sa_flags = 0; +#endif /* POSIX_SIGNALS */ /* Get memory for addresses */ local = (krb5_address *) malloc(sizeof(krb5_address)); @@ -240,9 +252,20 @@ proto_serv(kcontext, my_id, cl_sock, sv_p, cl_p) * * If enabled, the protocol times out after proto_proto_timeout seconds. */ - if (setjmp(timeout_jmp) == 0) { + if ( +#if POSIX_SETJMP + sigsetjmp(timeout_jmp, 1) == 0 +#else /* POSIX_SETJMP */ + setjmp(timeout_jmp) == 0 +#endif /* POSIX_SETJMP */ + ) { if (proto_proto_timeout > 0) { +#if POSIX_SIGNALS + s_action.sa_handler = proto_alarmclock; + (void) sigaction(SIGALRM, &s_action, (struct sigaction *) NULL); +#else /* POSIX_SIGNALS */ signal(SIGALRM, proto_alarmclock); +#endif /* POSIX_SIGNALS */ } /* * Loop forever - or until somebody puts us out of our misery. diff --git a/src/kadmin/v5server/srv_acl.c b/src/kadmin/v5server/srv_acl.c index 1e320daf1..583543459 100644 --- a/src/kadmin/v5server/srv_acl.c +++ b/src/kadmin/v5server/srv_acl.c @@ -373,6 +373,9 @@ acl_init(kcontext, debug_level, acl_file) char *acl_file; { krb5_error_code kret; +#if POSIX_SIGNALS + struct sigaction s_action; +#endif /* POSIX_SIGNALS */ kret = 0; acl_debug_level = debug_level; @@ -381,7 +384,14 @@ acl_init(kcontext, debug_level, acl_file) ((acl_file) ? acl_file : "(null)"))); acl_acl_file = (acl_file) ? acl_file : (char *) acl_default_file; acl_inited = acl_load_acl_file(); +#if POSIX_SIGNALS + (void) sigemptyset(&s_action.sa_mask); + s_action.sa_flags = 0; + s_action.sa_handler = acl_reload_acl_file; + (void) sigaction(SIGALRM, &s_action, (struct sigaction *) NULL); +#else /* POSIX_SIGNALS */ signal(SIGHUP, acl_reload_acl_file); +#endif /* POSIX_SIGNALS */ DPRINT(DEBUG_CALLS, acl_debug_level, ("X acl_init() = %d\n", kret)); return(kret); } diff --git a/src/kadmin/v5server/srv_main.c b/src/kadmin/v5server/srv_main.c index 6cd0af8ef..8ce9e6ce4 100644 --- a/src/kadmin/v5server/srv_main.c +++ b/src/kadmin/v5server/srv_main.c @@ -87,7 +87,11 @@ static krb5_sigtype unhandled_signal(signo) int signo; { +#if POSIX_SETJMP + siglongjmp(terminal_jmp, signo); +#else /* POSIX_SETJMP */ longjmp(terminal_jmp, signo); +#endif /* POSIX_SETJMP */ /* NOTREACHED */ } @@ -279,10 +283,32 @@ main(argc, argv) openlog(programname, LOG_AUTH|LOG_CONS|LOG_NDELAY|LOG_PID, LOG_LOCAL6); (void) set_com_err_hook(kadm_com_err_proc); - if ((signal_number = setjmp(terminal_jmp)) == 0) { + if ((signal_number = +#if POSIX_SETJMP + sigsetjmp(terminal_jmp, 1) +#else /* POSIX_SETJMP */ + setjmp(terminal_jmp) +#endif /* POSIX_SETJMP */ + ) == 0) { +#if POSIX_SIGNALS + struct sigaction s_action; +#endif /* POSIX_SIGNALS */ + /* * Initialize signal handling. */ +#if POSIX_SIGNALS + (void) sigemptyset(&s_action.sa_mask); + s_action.sa_flags = 0; + s_action.sa_handler = unhandled_signal; + (void) sigaction(SIGINT, &s_action, (struct sigaction *) NULL); + (void) sigaction(SIGTERM, &s_action, (struct sigaction *) NULL); + (void) sigaction(SIGHUP, &s_action, (struct sigaction *) NULL); + (void) sigaction(SIGQUIT, &s_action, (struct sigaction *) NULL); + (void) sigaction(SIGPIPE, &s_action, (struct sigaction *) NULL); + (void) sigaction(SIGALRM, &s_action, (struct sigaction *) NULL); + (void) sigaction(SIGCHLD, &s_action, (struct sigaction *) NULL); +#else /* POSIX_SIGNALS */ signal(SIGINT, unhandled_signal); signal(SIGTERM, unhandled_signal); signal(SIGHUP, unhandled_signal); @@ -290,6 +316,7 @@ main(argc, argv) signal(SIGPIPE, unhandled_signal); signal(SIGALRM, unhandled_signal); signal(SIGCHLD, unhandled_signal); +#endif /* POSIX_SIGNALS */ /* * Initialize our modules.