From 6e132be81f50209da563fd6286064de97b1768b4 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 16 Feb 2005 20:44:18 +0000 Subject: [PATCH] *** empty log message *** --- citadel/citserver.c | 4 +++- citadel/ipc_c_tcp.c | 9 --------- citadel/sendcommand.c | 5 +++++ citadel/server_main.c | 3 ++- citadel/sysdep.c | 8 ++++++++ 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/citadel/citserver.c b/citadel/citserver.c index 88a7ad0ad..b3f369e2a 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -129,6 +129,7 @@ void master_startup(void) { void master_cleanup(int exitcode) { struct CleanupFunctionHook *fcn; static int already_cleaning_up = 0; + int i; if (already_cleaning_up) while(1) sleep(1); already_cleaning_up = 1; @@ -150,8 +151,9 @@ void master_cleanup(int exitcode) { #endif /* Now go away. */ - lprintf(CTDL_NOTICE, "citserver: Exiting with status %d.\n", exitcode); + lprintf(CTDL_NOTICE, "citserver: Exiting with status %d\n", exitcode); fflush(stdout); fflush(stderr); + exit(exitcode); } diff --git a/citadel/ipc_c_tcp.c b/citadel/ipc_c_tcp.c index 414acb71d..f4baa4f08 100644 --- a/citadel/ipc_c_tcp.c +++ b/citadel/ipc_c_tcp.c @@ -67,20 +67,11 @@ void connection_died(CtdlIPC* ipc, int using_ssl) { fflush(stdout); #ifdef HAVE_OPENSSL - /* ...don't try to shut down a connection on a dead socket? - SSL_shutdown(ipc->ssl); - */ - SSL_free(ipc->ssl); ipc->ssl = NULL; #endif shutdown(ipc->sock, 2); ipc->sock = -1; - - /* Hangup - let any children know as well */ - /* kill(0, SIGHUP); */ - /* This is disabled because it makes the setup program and other - * users of sendcommand do really unhappy things. */ } diff --git a/citadel/sendcommand.c b/citadel/sendcommand.c index 3fe918839..c4d6cbda0 100644 --- a/citadel/sendcommand.c +++ b/citadel/sendcommand.c @@ -129,6 +129,10 @@ void np_attach_to_server(void) } +void sendcommand_die(void) { + exit(0); +} + /* * main @@ -171,6 +175,7 @@ int main(int argc, char **argv) fflush(stderr); np_attach_to_server(); fflush(stderr); + setIPCDeathHook(sendcommand_die); fprintf(stderr, "%s\n", cmd); CtdlIPC_chat_send(ipc, cmd); diff --git a/citadel/server_main.c b/citadel/server_main.c index c4d6c5e24..1b94be7f6 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -74,7 +74,7 @@ int main(int argc, char **argv) struct passwd *pw; int drop_root_perms = 1; size_t size; - + /* initialize the master context */ InitializeMasterCC(); @@ -147,6 +147,7 @@ int main(int argc, char **argv) "This program is distributed under the terms of the GNU " "General Public License.\n"); lprintf(CTDL_NOTICE, "\n"); + lprintf(CTDL_DEBUG, "Called as: %s\n", argv[0]); /* Load site-specific parameters, and set the ipgm secret */ lprintf(CTDL_INFO, "Loading citadel.config\n"); diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 5b51e1286..888020f95 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -177,6 +177,7 @@ static RETSIGTYPE signal_cleanup(int signum) { */ void init_sysdep(void) { int i; + sigset_t set; /* Avoid vulnerabilities related to FD_SETSIZE if we can. */ #ifdef FD_SETSIZE @@ -213,6 +214,13 @@ void init_sysdep(void) { * The action for unexpected signals and exceptions should be to * call signal_cleanup() to gracefully shut down the server. */ + sigemptyset(&set); + sigaddset(&set, SIGINT); + sigaddset(&set, SIGQUIT); + sigaddset(&set, SIGHUP); + sigaddset(&set, SIGTERM); + sigaddset(&set, SIGSEGV); + sigprocmask(SIG_UNBLOCK, &set, NULL); signal(SIGINT, signal_cleanup); signal(SIGQUIT, signal_cleanup); signal(SIGHUP, signal_cleanup); -- 2.39.2