Move error reporting of messaging context creation fail into
authorJeremy Allison <jra@samba.org>
Sun, 14 Nov 2010 04:28:41 +0000 (20:28 -0800)
committerJeremy Allison <jra@samba.org>
Sun, 14 Nov 2010 04:39:05 +0000 (04:39 +0000)
the daemons themselves. Allows client utilities to silently
fail to create a messaging context due to access denied on the
messaging tdb (which I need for the following patch).

Jeremy.

source3/lib/messages.c
source3/lib/messages_local.c
source3/lib/server_contexts.c
source3/nmbd/nmbd.c
source3/smbd/globals.c
source3/winbindd/winbindd.c
source3/winbindd/winbindd.h

index 11dc931f0f3330e13a4b3d2b4c93d9bf21442975..41f67d07dbd2ef63a19f077490a1d36091ed2a59 100644 (file)
@@ -194,7 +194,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
        status = messaging_tdb_init(ctx, ctx, &ctx->local);
 
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("messaging_tdb_init failed: %s\n",
+               DEBUG(2, ("messaging_tdb_init failed: %s\n",
                          nt_errstr(status)));
                TALLOC_FREE(ctx);
                return NULL;
@@ -205,7 +205,7 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
                status = messaging_ctdbd_init(ctx, ctx, &ctx->remote);
 
                if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(1, ("messaging_ctdb_init failed: %s\n",
+                       DEBUG(2, ("messaging_ctdb_init failed: %s\n",
                                  nt_errstr(status)));
                        TALLOC_FREE(ctx);
                        return NULL;
index bad577cc356331dc95e7a6860eeb1dcb73ec1537..8cc060b9e2bf26506ce19129d7789ad0c021d165 100644 (file)
@@ -108,7 +108,7 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
 
        if (!ctx->tdb) {
                NTSTATUS status = map_nt_error_from_unix(errno);
-               DEBUG(0, ("ERROR: Failed to initialise messages database: "
+               DEBUG(2, ("ERROR: Failed to initialise messages database: "
                          "%s\n", strerror(errno)));
                TALLOC_FREE(result);
                return status;
index 5e48b7986d246a943664e1217f0dc661a699dcfd..f8fe9dceacb34b6280458836a56158c861a04c76 100644 (file)
@@ -57,9 +57,6 @@ struct messaging_context *server_messaging_context(void)
                                                procid_self(),
                                                server_event_context());
        }
-       if (server_msg_ctx == NULL) {
-               DEBUG(0, ("Could not init server's messaging context.\n"));
-       }
        return server_msg_ctx;
 }
 
index 2bae5f7b2720c2d1e452b4967828a6089a7550a9..d6943b19e671e1797e21184af69de6bd1910fa31 100644 (file)
@@ -43,26 +43,17 @@ time_t StartupTime = 0;
 
 struct event_context *nmbd_event_context(void)
 {
-       static struct event_context *ctx;
-
-       if (!ctx && !(ctx = event_context_init(NULL))) {
-               smb_panic("Could not init nmbd event context");
-       }
-       return ctx;
+       return server_event_context();
 }
 
 struct messaging_context *nmbd_messaging_context(void)
 {
-       static struct messaging_context *ctx;
-
-       if (ctx == NULL) {
-               ctx = messaging_init(NULL, procid_self(),
-                                    nmbd_event_context());
-       }
-       if (ctx == NULL) {
-               DEBUG(0, ("Could not init nmbd messaging context.\n"));
+       struct messaging_context *msg_ctx = server_messaging_context();
+       if (likely(msg_ctx != NULL)) {
+               return msg_ctx;
        }
-       return ctx;
+       smb_panic("Could not init nmbd's messaging context.\n");
+       return NULL;
 }
 
 /**************************************************************************** **
index 4642328b4650698479866450f2f1c981ad7f772d..aac30ea9c1cf338c8cd115a7f1660daec2a1e79d 100644 (file)
@@ -117,7 +117,11 @@ struct smbd_server_connection *msg_ctx_to_sconn(struct messaging_context *msg_ct
 
 struct messaging_context *smbd_messaging_context(void)
 {
-       return server_messaging_context();
+       struct messaging_context *msg_ctx = server_messaging_context();
+       if (likely(msg_ctx != NULL)) {
+               return msg_ctx;
+       }
+       smb_panic("Could not init smbd's messaging context.\n");
 }
 
 struct memcache *smbd_memcache(void)
index c831c94221a3efc61801e00984347d9fa80b3c17..43cbd50d159afe6028d5191e4ae8b1ff58aeef98 100644 (file)
@@ -44,6 +44,16 @@ static bool interactive = False;
 
 extern bool override_logfile;
 
+struct messaging_context *winbind_messaging_context(void)
+{
+       struct messaging_context *msg_ctx = server_messaging_context();
+       if (likely(msg_ctx != NULL)) {
+               return msg_ctx;
+       }
+       smb_panic("Could not init winbindd's messaging context.\n");
+       return NULL;
+}
+
 /* Reload configuration */
 
 static bool reload_services_file(const char *lfile)
index 1ba24b5d0a6ed6ce0b113920486e3e677ba70277..d276b869479178827bc2166e8b9f4564389db895 100644 (file)
@@ -388,6 +388,5 @@ struct WINBINDD_CCACHE_ENTRY {
 #define DOM_SEQUENCE_NONE ((uint32)-1)
 
 #define winbind_event_context server_event_context
-#define winbind_messaging_context server_messaging_context
 
 #endif /* _WINBINDD_H */