From: Stefan Metzmacher Date: Tue, 11 Dec 2007 10:39:39 +0000 (+0100) Subject: wb-ndr: change winbindd_sid2gid_async() to use winbind_get_idmap() X-Git-Url: http://git.samba.org/?p=metze%2Fsamba%2Fwb-ndr.git;a=commitdiff_plain;h=e50fbcaa302dd778f10f7e7d4d1e587886c17219 wb-ndr: change winbindd_sid2gid_async() to use winbind_get_idmap() metze --- diff --git a/source/winbindd/winbindd_idmap.c b/source/winbindd/winbindd_idmap.c index 1186764d51b..3fb95702a8f 100644 --- a/source/winbindd/winbindd_idmap.c +++ b/source/winbindd/winbindd_idmap.c @@ -408,41 +408,71 @@ nomem: } static void winbindd_sid2gid_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, gid_t gid) = - (void (*)(void *, bool, gid_t))c; + void (*cont)(void *priv, bool succ, gid_t) = + (void (*)(void *, bool, gid_t))_cont; + struct winbind_get_idmap *r = + talloc_get_type_abort(_r, struct winbind_get_idmap); + gid_t gid; if (!success) { - DEBUG(5, ("Could not trigger sid2gid\n")); - cont(private_data, False, 0); + DEBUG(5, ("Could not get_idmap(sid2gid)\n")); + TALLOC_FREE(r); + cont(private_data, false, (gid_t)-1); return; } - if (response->result != WINBINDD_OK) { - DEBUG(5, ("sid2gid returned an error\n")); - cont(private_data, False, 0); + if (r->out.result != WINBIND_STATUS_OK) { + DEBUG(5, ("get_idmap(sid2gid) returned an error:0x%08X\n", + r->out.result)); + TALLOC_FREE(r); + cont(private_data, false, (gid_t)-1); return; } - cont(private_data, True, response->data.gid); + if (r->out.rep->gid > UINT32_MAX) { + DEBUG(1, ("get_idmap(sid2gid) returned a 64bit gid %llu\n", + (unsigned long long)r->out.rep->gid)); + TALLOC_FREE(r); + cont(private_data, false, (gid_t)-1); + return; + } + + gid = r->out.rep->gid; + TALLOC_FREE(r); + cont(private_data, true, gid); } void winbindd_sid2gid_async(TALLOC_CTX *mem_ctx, const DOM_SID *sid, void (*cont)(void *private_data, bool success, gid_t gid), void *private_data) { - struct winbindd_request request; - ZERO_STRUCT(request); - request.cmd = WINBINDD_DUAL_SID2GID; - sid_to_fstring(request.data.dual_sid2id.sid, sid); + struct winbind_get_idmap *r = NULL; DEBUG(7,("winbindd_sid2gid_async: Resolving %s to a gid\n", - request.data.dual_sid2id.sid)); + sid_string_tos(sid))); - do_async(mem_ctx, idmap_child(), &request, winbindd_sid2gid_recv, - (void *)cont, private_data); + 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_SID_TO_GID; + r->in.req.sid = discard_const(sid); + + do_async_ndr(mem_ctx, idmap_child(), + NDR_WINBIND_GET_IDMAP, r, + winbindd_sid2gid_recv, r, + (void *)cont, private_data); + return; +nomem: + TALLOC_FREE(r); + cont(private_data, false, (gid_t)-1); + return; } enum winbindd_result winbindd_dual_sid2gid(struct winbindd_domain *domain,