From: Stefan Metzmacher Date: Tue, 11 Dec 2007 13:26:53 +0000 (+0100) Subject: wb-ndr: change winbindd_gid2sid_async() to use winbind_get_idmap() X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwb-ndr.git;a=commitdiff_plain;h=988aef6758cdf3bbb35d1a1068c63401bcfd3533 wb-ndr: change winbindd_gid2sid_async() to use winbind_get_idmap() metze --- diff --git a/source/winbindd/winbindd_idmap.c b/source/winbindd/winbindd_idmap.c index c2582170695..d7338f2a5f5 100644 --- a/source/winbindd/winbindd_idmap.c +++ b/source/winbindd/winbindd_idmap.c @@ -542,38 +542,69 @@ nomem: } static void winbindd_gid2sid_recv(TALLOC_CTX *mem_ctx, bool success, - struct winbindd_response *response, - void *c, void *private_data) + struct winbindd_ndr_call *c, + void *_r, + void *_cont, + void *private_data) { void (*cont)(void *priv, bool succ, const char *sid) = - (void (*)(void *, bool, const char *))c; + (void (*)(void *, bool, const char *))_cont; + struct winbind_get_idmap *r = + talloc_get_type_abort(_r, struct winbind_get_idmap); + const char *sid; if (!success) { - DEBUG(5, ("Could not trigger gid2sid\n")); - cont(private_data, False, NULL); + DEBUG(5, ("Could not get_idmap(gid2sid)\n")); + TALLOC_FREE(r); + cont(private_data, false, NULL); return; } - if (response->result != WINBINDD_OK) { - DEBUG(5, ("gid2sid returned an error\n")); - cont(private_data, False, NULL); + if (r->out.result != WINBIND_STATUS_OK) { + DEBUG(5, ("get_idmap(gid2sid) returned an error:0x%08X\n", + r->out.result)); + TALLOC_FREE(r); + cont(private_data, false, NULL); + return; + } + + sid = dom_sid_string(mem_ctx, r->out.rep->sid); + if (!sid) { + TALLOC_FREE(r); + cont(private_data, false, NULL); return; } - cont(private_data, True, response->data.sid.sid); + TALLOC_FREE(r); + cont(private_data, true, sid); } void winbindd_gid2sid_async(TALLOC_CTX *mem_ctx, gid_t gid, void (*cont)(void *private_data, bool success, const char *sid), void *private_data) { - struct winbindd_request request; + struct winbind_get_idmap *r = NULL; - ZERO_STRUCT(request); - request.cmd = WINBINDD_DUAL_GID2SID; - request.data.gid = gid; - do_async(mem_ctx, idmap_child(), &request, winbindd_gid2sid_recv, - (void *)cont, private_data); + DEBUG(7,("winbindd_gid2sid_async: Resolving %u to a sid\n", + gid)); + + r = TALLOC_P(mem_ctx, struct winbind_get_idmap); + if (!r) goto nomem; + r->in.level = TALLOC_P(r, enum winbind_get_idmap_level); + if (!r->in.level) goto nomem; + + *r->in.level = WINBIND_IDMAP_LEVEL_GID_TO_SID; + r->in.req.gid = gid; + + do_async_ndr(mem_ctx, idmap_child(), + NDR_WINBIND_GET_IDMAP, r, + winbindd_gid2sid_recv, r, + (void *)cont, private_data); + return; +nomem: + TALLOC_FREE(r); + cont(private_data, false, NULL); + return; } enum winbindd_result winbindd_dual_gid2sid(struct winbindd_domain *domain,