summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-01-15 15:50:50 -0800
committerKarolin Seeger <kseeger@samba.org>2009-01-20 14:16:47 +0100
commit927372a559e153a5a14055463e2e5eaba0c460d5 (patch)
treeb8664ea1890e51de1ef5224878da161925e4f99f
parent662182b62e0fd08c8c256884428a405b2950fd03 (diff)
downloadsamba-927372a559e153a5a14055463e2e5eaba0c460d5.tar.gz
Allow reinit_after_fork to be called safely from within swat and other binaries that don't have
an event context or a msg context. Fixes crash bug in swat. Jeremy. (cherry picked from commit 45e6f9c5a4b5d9cdb89f398f1238872251ccbe54)
-rw-r--r--source/lib/dummysmbd.c7
-rw-r--r--source/lib/util.c24
2 files changed, 20 insertions, 11 deletions
diff --git a/source/lib/dummysmbd.c b/source/lib/dummysmbd.c
index 5c624bdebfb..f0fd18c87aa 100644
--- a/source/lib/dummysmbd.c
+++ b/source/lib/dummysmbd.c
@@ -59,7 +59,12 @@ bool change_to_root_user(void)
struct event_context *smbd_event_context(void)
{
- return NULL;
+ static struct event_context *ev;
+
+ if (!ev) {
+ ev = event_context_init(NULL);
+ }
+ return ev;
}
struct messaging_context *smbd_messaging_context(void)
diff --git a/source/lib/util.c b/source/lib/util.c
index 262d37f8c4f..5ec6f264103 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -1055,18 +1055,22 @@ bool reinit_after_fork(struct messaging_context *msg_ctx,
return false;
}
- /*
- * For clustering, we need to re-init our ctdbd connection after the
- * fork
- */
- status = messaging_reinit(msg_ctx);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0,("messaging_reinit() failed: %s\n",
- nt_errstr(status)));
- return false;
+ if (msg_ctx) {
+ /*
+ * For clustering, we need to re-init our ctdbd connection after the
+ * fork
+ */
+ status = messaging_reinit(msg_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("messaging_reinit() failed: %s\n",
+ nt_errstr(status)));
+ return false;
+ }
}
- event_context_reinit(ev_ctx);
+ if (ev_ctx) {
+ event_context_reinit(ev_ctx);
+ }
return true;
}