summaryrefslogtreecommitdiffstats
path: root/src/monitor
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 10:20:43 -0500
commit308f7bc63467b7a5baf9a73fe1dbbd1c756dbdf5 (patch)
tree8205f1c533b913c6ff4781380ec817387d217983 /src/monitor
parentd1571f8c173ca9172fa295e6aac48b8c0c367950 (diff)
downloadsssd_unused-308f7bc63467b7a5baf9a73fe1dbbd1c756dbdf5.tar.gz
sssd_unused-308f7bc63467b7a5baf9a73fe1dbbd1c756dbdf5.tar.xz
sssd_unused-308f7bc63467b7a5baf9a73fe1dbbd1c756dbdf5.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
Diffstat (limited to 'src/monitor')
-rw-r--r--src/monitor/monitor.c76
1 files changed, 38 insertions, 38 deletions
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;
}