From 308f7bc63467b7a5baf9a73fe1dbbd1c756dbdf5 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 30 Nov 2010 11:50:05 -0500 Subject: Set up signal handlers before initializing sysdb A temporary signal handler for SIGTERM is set up in server_setup() that calls exit() from within a pure signal handler. This causes a race condition where it's possible that if the SSSD is restarted immediately while it is still initializing the sysdb caches for the first time, it can leave the cache in a corrupt and unusable state. https://bugzilla.redhat.com/show_bug.cgi?id=658444 --- src/monitor/monitor.c | 76 +++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 6eab66fc..7727d09b 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -1833,6 +1833,44 @@ int monitor_process_init(struct mt_ctx *ctx, int num_providers; int ret; + /* Set up an event handler for a SIGHUP */ + tes = tevent_add_signal(ctx->ev, ctx, SIGHUP, 0, + monitor_hup, ctx); + if (tes == NULL) { + return EIO; + } + + /* Set up an event handler for a SIGINT */ + BlockSignals(false, SIGINT); + tes = tevent_add_signal(ctx->ev, ctx, SIGINT, 0, + monitor_quit, ctx); + if (tes == NULL) { + return EIO; + } + + /* Set up an event handler for a SIGTERM */ + tes = tevent_add_signal(ctx->ev, ctx, SIGTERM, 0, + monitor_quit, ctx); + if (tes == NULL) { + return EIO; + } + + /* Handle SIGUSR1 (tell all providers to go offline) */ + BlockSignals(false, SIGUSR1); + tes = tevent_add_signal(ctx->ev, ctx, SIGUSR1, 0, + signal_offline, ctx); + if (tes == NULL) { + return EIO; + } + + /* Handle SIGUSR2 (tell all providers to go reset offline) */ + BlockSignals(false, SIGUSR2); + tes = tevent_add_signal(ctx->ev, ctx, SIGUSR2, 0, + signal_offline_reset, ctx); + if (tes == NULL) { + return EIO; + } + #if 0 This feature is incomplete and can leave the SSSD in a bad state if the config file is changed while the SSSD is running. @@ -1917,44 +1955,6 @@ int monitor_process_init(struct mt_ctx *ctx, /* now start checking for global events */ set_global_checker(ctx); - /* Set up an event handler for a SIGHUP */ - tes = tevent_add_signal(ctx->ev, ctx, SIGHUP, 0, - monitor_hup, ctx); - if (tes == NULL) { - return EIO; - } - - /* Set up an event handler for a SIGINT */ - BlockSignals(false, SIGINT); - tes = tevent_add_signal(ctx->ev, ctx, SIGINT, 0, - monitor_quit, ctx); - if (tes == NULL) { - return EIO; - } - - /* Set up an event handler for a SIGTERM */ - tes = tevent_add_signal(ctx->ev, ctx, SIGTERM, 0, - monitor_quit, ctx); - if (tes == NULL) { - return EIO; - } - - /* Handle SIGUSR1 (tell all providers to go offline) */ - BlockSignals(false, SIGUSR1); - tes = tevent_add_signal(ctx->ev, ctx, SIGUSR1, 0, - signal_offline, ctx); - if (tes == NULL) { - return EIO; - } - - /* Handle SIGUSR2 (tell all providers to go reset offline) */ - BlockSignals(false, SIGUSR2); - tes = tevent_add_signal(ctx->ev, ctx, SIGUSR2, 0, - signal_offline_reset, ctx); - if (tes == NULL) { - return EIO; - } - return EOK; } -- cgit