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;
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"
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");
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
*
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... */
#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.
* 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.
*
}
#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.
close(s2);
if (repdata.length == 0) {
- /* just qreturn. This means something really bad happened */
+ /* just return. This means something really bad happened */
goto cleanup;
}
return;
}
+
+
+
+
+
+
+
+