From: Geoffrey King Date: Tue, 21 Jul 1998 21:03:41 +0000 (+0000) Subject: Call krb5_klog_reopen in kadm_svc_run upon receiving a SIGHUP. Use X-Git-Tag: krb5-1.1-beta1~638 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1efad3b012e9751a0af13b085e3294864f31f5aa;p=krb5.git Call krb5_klog_reopen in kadm_svc_run upon receiving a SIGHUP. Use sigaction instead of signal if POSIX_SIGNALS is defined. All of the calls to signal and sigaction are now in a separate function setup_signal_handlers, as the kdc code does. Also, since reset_db no longer does anything, change the name of signal_request_reset to the more descriptive signal_request_hup, and request_reset_db to request_hup (paralleling the nomenclature in the kdc code). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10712 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/server/ChangeLog b/src/kadmin/server/ChangeLog index e0e1a36ae..d27ceb1d8 100644 --- a/src/kadmin/server/ChangeLog +++ b/src/kadmin/server/ChangeLog @@ -1,3 +1,16 @@ +Tue Jul 21 16:36:51 1998 Geoffrey King + + * ovsec_kadmd.c: Call krb5_klog_reopen in kadm_svc_run + upon receiving a SIGHUP. Use sigaction instead of + signal if POSIX_SIGNALS is defined. All of the calls + to signal and sigaction are now in a separate function + setup_signal_handlers, as the kdc code does. Also, + since reset_db no longer does anything, change the name + of signal_request_reset to the more descriptive + signal_request_hup, and request_reset_db to + request_hup (paralleling the nomenclature in the kdc + code). + Mon Jul 20 11:28:39 1998 Ezra Peisach * schpw.c (process_chpw_request): Cast to krb5_octet * instead of diff --git a/src/kadmin/server/ovsec_kadmd.c b/src/kadmin/server/ovsec_kadmd.c index 5a1c6b44c..3012b0459 100644 --- a/src/kadmin/server/ovsec_kadmd.c +++ b/src/kadmin/server/ovsec_kadmd.c @@ -32,14 +32,20 @@ void request_pure_report(int); void request_pure_clear(int); #endif /* PURIFY */ -int signal_request_exit = 0; -int signal_request_reset = 0; +volatile int signal_request_exit = 0; +volatile int signal_request_hup = 0; +void setup_signal_handlers(void); void request_exit(int); -void request_reset_db(int); +void request_hup(int); void reset_db(void); void sig_pipe(int); void kadm_svc_run(void); +#ifdef POSIX_SIGNALS +static struct sigaction s_action; +#endif /* POSIX_SIGNALS */ + + #define TIMEOUT 15 gss_name_t gss_changepw_name = NULL, gss_oldchangepw_name = NULL; @@ -297,7 +303,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "This probably means that another %s process is already\n" "running, or that another program is using the server port (number %d)\n" -"after being assigned it by the RPC portmap deamon. If another\n" +"after being assigned it by the RPC portmap daemon. If another\n" "%s is already running, you should kill it before\n" "restarting the server. If, on the other hand, another program is\n" "using the server port, you should kill it before running\n" @@ -437,17 +443,8 @@ int main(int argc, char *argv[]) exit(1); } - signal(SIGINT, request_exit); - signal(SIGTERM, request_exit); - signal(SIGQUIT, request_exit); - signal(SIGHUP, request_reset_db); - signal(SIGPIPE, sig_pipe); -#ifdef PURIFY - signal(SIGUSR1, request_pure_report); - signal(SIGUSR2, request_pure_clear); -#endif /* PURIFY */ + setup_signal_handlers(); krb5_klog_syslog(LOG_INFO, "starting"); - kadm_svc_run(); krb5_klog_syslog(LOG_INFO, "finished, exiting"); @@ -472,6 +469,43 @@ int main(int argc, char *argv[]) exit(2); } +/* + * Function: setup_signal_handlers + * + * Purpose: Setup signal handling functions using POSIX's sigaction() + * if possible, otherwise with System V's signal(). + */ + +void setup_signal_handlers(void) { +#ifdef POSIX_SIGNALS + (void) sigemptyset(&s_action.sa_mask); + s_action.sa_handler = request_exit; + (void) sigaction(SIGINT, &s_action, (struct sigaction *) NULL); + (void) sigaction(SIGTERM, &s_action, (struct sigaction *) NULL); + (void) sigaction(SIGQUIT, &s_action, (struct sigaction *) NULL); + s_action.sa_handler = request_hup; + (void) sigaction(SIGHUP, &s_action, (struct sigaction *) NULL); + s_action.sa_handler = sig_pipe; + (void) sigaction(SIGPIPE, &s_action, (struct sigaction *) NULL); +#ifdef PURIFY + s_action.sa_handler = request_pure_report; + (void) sigaction(SIGUSR1, &s_action, (struct sigaction *) NULL); + s_action.sa_handler = request_pure_clear; + (void) sigaction(SIGUSR2, &s_action, (struct sigaction *) NULL); +#endif /* PURIFY */ +#else /* POSIX_SIGNALS */ + signal(SIGINT, request_exit); + signal(SIGTERM, request_exit); + signal(SIGQUIT, request_exit); + signal(SIGHUP, request_hup); + signal(SIGPIPE, sig_pipe); +#ifdef PURIFY + signal(SIGUSR1, request_pure_report); + signal(SIGUSR2, request_pure_clear); +#endif /* PURIFY */ +#endif /* POSIX_SIGNALS */ +} + /* * Function: kadm_svc_run * @@ -491,8 +525,11 @@ void kadm_svc_run(void) struct timeval timeout; while(signal_request_exit == 0) { - if (signal_request_reset) - reset_db(); + if (signal_request_hup) { + reset_db(); + krb5_klog_reopen(); + signal_request_hup = 0; + } #ifdef PURIFY if (signal_pure_report) /* check to see if a report */ /* should be dumped... */ @@ -575,7 +612,7 @@ void request_pure_clear(int signum) #endif /* PURIFY */ /* - * Function: request_reset_db + * Function: request_hup * * Purpose: sets flag saying the server got a signal and that it should * reset the database files when convenient. @@ -584,18 +621,17 @@ void request_pure_clear(int signum) * Requires: * Effects: * Modifies: - * sets signal_request_reset to one + * sets signal_request_hup to one */ -void request_reset_db(int signum) +void request_hup(int signum) { - krb5_klog_syslog(LOG_DEBUG, "Got signal to request resetting the databases"); - signal_request_reset = 1; + signal_request_hup = 1; return; } /* - * Function: reset-db + * Function: reset_db * * Purpose: flushes the currently opened database files to disk. * @@ -622,12 +658,11 @@ void reset_db(void) } #endif - signal_request_reset = 0; return; } /* - * Function: request-exit + * Function: request_exit * * Purpose: sets flags saying the server got a signal and that it * should exit when convient. @@ -920,7 +955,7 @@ void do_schpw(int s1, kadm5_config_params *params) close(s2); if (repdata.length == 0) { - /* just qreturn. This means something really bad happened */ + /* just return. This means something really bad happened */ goto cleanup; } @@ -942,3 +977,11 @@ cleanup: return; } + + + + + + + +