From e26da13dfa36b734a317072ced72a497d2b29a28 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 4 Dec 2010 20:34:05 +0100 Subject: [PATCH] s3: Fix bug 7842: WINBINDD_LOOKUPRIDS does not return the domain name --- source3/librpc/gen_ndr/cli_wbint.c | 5 +++ source3/librpc/gen_ndr/cli_wbint.h | 2 + source3/librpc/gen_ndr/ndr_wbint.c | 48 ++++++++++++++++++++++++++++++++ source3/librpc/gen_ndr/srv_wbint.c | 11 +++++++ source3/librpc/gen_ndr/wbint.h | 1 + source3/librpc/idl/wbint.idl | 1 + source3/winbindd/winbindd_dual_srv.c | 2 + source3/winbindd/winbindd_lookuprids.c | 3 +- 8 files changed, 72 insertions(+), 1 deletions(-) diff --git a/source3/librpc/gen_ndr/cli_wbint.c b/source3/librpc/gen_ndr/cli_wbint.c index 592b27b..7200d2a 100644 --- a/source3/librpc/gen_ndr/cli_wbint.c +++ b/source3/librpc/gen_ndr/cli_wbint.c @@ -2509,6 +2509,7 @@ struct tevent_req *rpccli_wbint_LookupRids_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct rpc_pipe_client *cli, struct wbint_RidArray *_rids /* [in] [ref] */, + const char **_domain_name /* [out] [ref,charset(UTF8)] */, struct wbint_Principals *_names /* [out] [ref] */) { struct tevent_req *req; @@ -2527,6 +2528,7 @@ struct tevent_req *rpccli_wbint_LookupRids_send(TALLOC_CTX *mem_ctx, state->orig.in.rids = _rids; /* Out parameters */ + state->orig.out.domain_name = _domain_name; state->orig.out.names = _names; /* Result */ @@ -2575,6 +2577,7 @@ static void rpccli_wbint_LookupRids_done(struct tevent_req *subreq) } /* Copy out parameters */ + *state->orig.out.domain_name = *state->tmp.out.domain_name; *state->orig.out.names = *state->tmp.out.names; /* Copy result */ @@ -2612,6 +2615,7 @@ NTSTATUS rpccli_wbint_LookupRids_recv(struct tevent_req *req, NTSTATUS rpccli_wbint_LookupRids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct wbint_RidArray *rids /* [in] [ref] */, + const char **domain_name /* [out] [ref,charset(UTF8)] */, struct wbint_Principals *names /* [out] [ref] */) { struct wbint_LookupRids r; @@ -2635,6 +2639,7 @@ NTSTATUS rpccli_wbint_LookupRids(struct rpc_pipe_client *cli, } /* Return variables */ + *domain_name = *r.out.domain_name; *names = *r.out.names; /* Return result */ diff --git a/source3/librpc/gen_ndr/cli_wbint.h b/source3/librpc/gen_ndr/cli_wbint.h index 4528d43..c4f9a81 100644 --- a/source3/librpc/gen_ndr/cli_wbint.h +++ b/source3/librpc/gen_ndr/cli_wbint.h @@ -224,6 +224,7 @@ struct tevent_req *rpccli_wbint_LookupRids_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct rpc_pipe_client *cli, struct wbint_RidArray *_rids /* [in] [ref] */, + const char **_domain_name /* [out] [ref,charset(UTF8)] */, struct wbint_Principals *_names /* [out] [ref] */); NTSTATUS rpccli_wbint_LookupRids_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, @@ -231,6 +232,7 @@ NTSTATUS rpccli_wbint_LookupRids_recv(struct tevent_req *req, NTSTATUS rpccli_wbint_LookupRids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, struct wbint_RidArray *rids /* [in] [ref] */, + const char **domain_name /* [out] [ref,charset(UTF8)] */, struct wbint_Principals *names /* [out] [ref] */); struct tevent_req *rpccli_wbint_CheckMachineAccount_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/source3/librpc/gen_ndr/ndr_wbint.c b/source3/librpc/gen_ndr/ndr_wbint.c index 50f781c..5bb6832 100644 --- a/source3/librpc/gen_ndr/ndr_wbint.c +++ b/source3/librpc/gen_ndr/ndr_wbint.c @@ -2082,6 +2082,16 @@ static enum ndr_err_code ndr_push_wbint_LookupRids(struct ndr_push *ndr, int fla NDR_CHECK(ndr_push_wbint_RidArray(ndr, NDR_SCALARS, r->in.rids)); } if (flags & NDR_OUT) { + if (r->out.domain_name == NULL) { + return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); + } + NDR_CHECK(ndr_push_unique_ptr(ndr, *r->out.domain_name)); + if (*r->out.domain_name) { + NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(*r->out.domain_name, CH_UTF8))); + NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(*r->out.domain_name, CH_UTF8))); + NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, *r->out.domain_name, ndr_charset_length(*r->out.domain_name, CH_UTF8), sizeof(uint8_t), CH_UTF8)); + } if (r->out.names == NULL) { return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer"); } @@ -2093,7 +2103,10 @@ static enum ndr_err_code ndr_push_wbint_LookupRids(struct ndr_push *ndr, int fla static enum ndr_err_code ndr_pull_wbint_LookupRids(struct ndr_pull *ndr, int flags, struct wbint_LookupRids *r) { + uint32_t _ptr_domain_name; TALLOC_CTX *_mem_save_rids_0; + TALLOC_CTX *_mem_save_domain_name_0; + TALLOC_CTX *_mem_save_domain_name_1; TALLOC_CTX *_mem_save_names_0; if (flags & NDR_IN) { ZERO_STRUCT(r->out); @@ -2105,11 +2118,37 @@ static enum ndr_err_code ndr_pull_wbint_LookupRids(struct ndr_pull *ndr, int fla NDR_PULL_SET_MEM_CTX(ndr, r->in.rids, LIBNDR_FLAG_REF_ALLOC); NDR_CHECK(ndr_pull_wbint_RidArray(ndr, NDR_SCALARS, r->in.rids)); NDR_PULL_SET_MEM_CTX(ndr, _mem_save_rids_0, LIBNDR_FLAG_REF_ALLOC); + NDR_PULL_ALLOC(ndr, r->out.domain_name); + ZERO_STRUCTP(r->out.domain_name); NDR_PULL_ALLOC(ndr, r->out.names); ZERO_STRUCTP(r->out.names); } if (flags & NDR_OUT) { if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { + NDR_PULL_ALLOC(ndr, r->out.domain_name); + } + _mem_save_domain_name_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->out.domain_name, LIBNDR_FLAG_REF_ALLOC); + NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_domain_name)); + if (_ptr_domain_name) { + NDR_PULL_ALLOC(ndr, *r->out.domain_name); + } else { + *r->out.domain_name = NULL; + } + if (*r->out.domain_name) { + _mem_save_domain_name_1 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, *r->out.domain_name, 0); + NDR_CHECK(ndr_pull_array_size(ndr, r->out.domain_name)); + NDR_CHECK(ndr_pull_array_length(ndr, r->out.domain_name)); + if (ndr_get_array_length(ndr, r->out.domain_name) > ndr_get_array_size(ndr, r->out.domain_name)) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, r->out.domain_name), ndr_get_array_length(ndr, r->out.domain_name)); + } + NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, r->out.domain_name), sizeof(uint8_t))); + NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, r->out.domain_name, ndr_get_array_length(ndr, r->out.domain_name), sizeof(uint8_t), CH_UTF8)); + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domain_name_1, 0); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_domain_name_0, LIBNDR_FLAG_REF_ALLOC); + if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) { NDR_PULL_ALLOC(ndr, r->out.names); } _mem_save_names_0 = NDR_PULL_GET_MEM_CTX(ndr); @@ -2140,6 +2179,15 @@ _PUBLIC_ void ndr_print_wbint_LookupRids(struct ndr_print *ndr, const char *name if (flags & NDR_OUT) { ndr_print_struct(ndr, "out", "wbint_LookupRids"); ndr->depth++; + ndr_print_ptr(ndr, "domain_name", r->out.domain_name); + ndr->depth++; + ndr_print_ptr(ndr, "domain_name", *r->out.domain_name); + ndr->depth++; + if (*r->out.domain_name) { + ndr_print_string(ndr, "domain_name", *r->out.domain_name); + } + ndr->depth--; + ndr->depth--; ndr_print_ptr(ndr, "names", r->out.names); ndr->depth++; ndr_print_wbint_Principals(ndr, "names", r->out.names); diff --git a/source3/librpc/gen_ndr/srv_wbint.c b/source3/librpc/gen_ndr/srv_wbint.c index efd9be6..afa50ca 100644 --- a/source3/librpc/gen_ndr/srv_wbint.c +++ b/source3/librpc/gen_ndr/srv_wbint.c @@ -1423,6 +1423,12 @@ static bool api_wbint_LookupRids(pipes_struct *p) } ZERO_STRUCT(r->out); + r->out.domain_name = talloc_zero(r, const char *); + if (r->out.domain_name == NULL) { + talloc_free(r); + return false; + } + r->out.names = talloc_zero(r, struct wbint_Principals); if (r->out.names == NULL) { talloc_free(r); @@ -2168,6 +2174,11 @@ NTSTATUS rpc_wbint_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, co case NDR_WBINT_LOOKUPRIDS: { struct wbint_LookupRids *r = (struct wbint_LookupRids *)_r; ZERO_STRUCT(r->out); + r->out.domain_name = talloc_zero(mem_ctx, const char *); + if (r->out.domain_name == NULL) { + return NT_STATUS_NO_MEMORY; + } + r->out.names = talloc_zero(mem_ctx, struct wbint_Principals); if (r->out.names == NULL) { return NT_STATUS_NO_MEMORY; diff --git a/source3/librpc/gen_ndr/wbint.h b/source3/librpc/gen_ndr/wbint.h index 96b7800..2add7fc 100644 --- a/source3/librpc/gen_ndr/wbint.h +++ b/source3/librpc/gen_ndr/wbint.h @@ -280,6 +280,7 @@ struct wbint_LookupRids { } in; struct { + const char **domain_name;/* [ref,charset(UTF8)] */ struct wbint_Principals *names;/* [ref] */ NTSTATUS result; } out; diff --git a/source3/librpc/idl/wbint.idl b/source3/librpc/idl/wbint.idl index 432d59e0..d12fae8 100644 --- a/source3/librpc/idl/wbint.idl +++ b/source3/librpc/idl/wbint.idl @@ -141,6 +141,7 @@ interface wbint NTSTATUS wbint_LookupRids( [in] wbint_RidArray *rids, + [out,string,charset(UTF8)] char **domain_name, [out] wbint_Principals *names ); diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c index b247d5a..26b9d84 100644 --- a/source3/winbindd/winbindd_dual_srv.c +++ b/source3/winbindd/winbindd_dual_srv.c @@ -379,6 +379,8 @@ NTSTATUS _wbint_LookupRids(pipes_struct *p, struct wbint_LookupRids *r) return status; } + *r->out.domain_name = talloc_move(r->out.domain_name, &domain_name); + result = talloc_array(p->mem_ctx, struct wbint_Principal, r->in.rids->num_rids); if (result == NULL) { diff --git a/source3/winbindd/winbindd_lookuprids.c b/source3/winbindd/winbindd_lookuprids.c index 51cd4d8..e1ac26c 100644 --- a/source3/winbindd/winbindd_lookuprids.c +++ b/source3/winbindd/winbindd_lookuprids.c @@ -83,7 +83,8 @@ struct tevent_req *winbindd_lookuprids_send(TALLOC_CTX *mem_ctx, } subreq = rpccli_wbint_LookupRids_send( - state, ev, domain->child.rpccli, &state->rids, &state->names); + state, ev, domain->child.rpccli, &state->rids, + &state->domain_name, &state->names); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } -- 1.7.3.2