summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-11-30 11:50:05 -0500
committerStephen Gallagher <sgallagh@redhat.com>2010-12-02 13:17:59 -0500
commit2fe27a3f1230209248787bb2da9d633101248f05 (patch)
treedefbe63061a9ed1e360a3258fe89d50de0dedb21
parent499db30832152fbd7050fd74036ed85deb669860 (diff)
downloadsssd2-2fe27a3f1230209248787bb2da9d633101248f05.tar.gz
sssd2-2fe27a3f1230209248787bb2da9d633101248f05.tar.xz
sssd2-2fe27a3f1230209248787bb2da9d633101248f05.zip
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
-rw-r--r--src/monitor/monitor.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index ac55d7c3..1a62f69a 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1769,6 +1769,36 @@ 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;
+ }
+
#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.
@@ -1846,35 +1876,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 */
- 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;
- }
-
return EOK;
}