diff options
author | Stefan Metzmacher <metze@samba.org> | 2018-05-18 16:28:47 +0200 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2018-07-12 02:23:37 +0200 |
commit | e186d6a06b1b300256a2cb4138f0532d518d0597 (patch) | |
tree | 0235247033c46d3a98b1613190f832c32e574c3e /source4 | |
parent | a08ab2940051ae47ce71149087a24d060227ef19 (diff) | |
download | samba-e186d6a06b1b300256a2cb4138f0532d518d0597.tar.gz |
s4:messaging: make sure only imessaging_client_init() can be used with a wrapper tevent_context wrapper
imessaging_client_init() can be used with a wrapper tevent_context,
but only if a global messaging_dgm_ref() already exist.
All other uses of imessaging_init() and imessaging_client_init()
require a raw tevent_context.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Jul 12 02:23:37 CEST 2018 on sn-devel-144
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/messaging/messaging.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index 8903322bdc7..935951f3fba 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -319,7 +319,7 @@ NTSTATUS imessaging_reinit_all(void) /* create the listening socket and setup the dispatcher */ -struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx, +static struct imessaging_context *imessaging_init_internal(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, struct server_id server_id, struct tevent_context *ev) @@ -573,6 +573,30 @@ static void imessaging_dgm_recv(struct tevent_context *ev, } } +struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx, + struct loadparm_context *lp_ctx, + struct server_id server_id, + struct tevent_context *ev) +{ + if (ev == NULL) { + return NULL; + } + + if (tevent_context_is_wrapper(ev)) { + /* + * This is really a programmer error! + * + * The main/raw tevent context should + * have been registered first! + */ + DBG_ERR("Should not be used with a wrapper tevent context\n"); + errno = EINVAL; + return NULL; + } + + return imessaging_init_internal(mem_ctx, lp_ctx, server_id, ev); +} + /* A hack, for the short term until we get 'client only' messaging in place */ @@ -589,7 +613,7 @@ struct imessaging_context *imessaging_client_init(TALLOC_CTX *mem_ctx, /* This is because we are not in the s3 serverid database */ id.unique_id = SERVERID_UNIQUE_ID_NOT_TO_VERIFY; - return imessaging_init(mem_ctx, lp_ctx, id, ev); + return imessaging_init_internal(mem_ctx, lp_ctx, id, ev); } /* a list of registered irpc server functions |