X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=source4%2Flibnet%2Flibnet_lookup.c;h=21851d5ae89ef7616160ad2ea7714a1e3d16199d;hb=f9ca9e46ad24036bf00cb361a6cef4b2e7e98d7d;hp=c8dc7267643a896df7d8e34df984a0659080868c;hpb=7e14a25dc66082f48143368fef305067d4c0dfab;p=amitay%2Fsamba.git diff --git a/source4/libnet/libnet_lookup.c b/source4/libnet/libnet_lookup.c index c8dc7267643..21851d5ae89 100644 --- a/source4/libnet/libnet_lookup.c +++ b/source4/libnet/libnet_lookup.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ /* @@ -35,6 +34,8 @@ #include "librpc/gen_ndr/lsa.h" #include "librpc/gen_ndr/ndr_lsa_c.h" +#include "param/param.h" + struct lookup_state { struct nbt_name hostname; const char *address; @@ -56,7 +57,7 @@ struct composite_context *libnet_Lookup_send(struct libnet_context *ctx, struct composite_context *c; struct lookup_state *s; struct composite_context *cresolve_req; - const char** methods; + struct resolve_context *resolve_ctx; /* allocate context and state structures */ c = composite_create(ctx, ctx->event_ctx); @@ -80,14 +81,14 @@ struct composite_context *libnet_Lookup_send(struct libnet_context *ctx, s->hostname.scope = NULL; /* name resolution methods */ - if (io->in.methods) { - methods = io->in.methods; + if (io->in.resolve_ctx) { + resolve_ctx = io->in.resolve_ctx; } else { - methods = ctx->name_res_methods; + resolve_ctx = ctx->resolve_ctx; } /* send resolve request */ - cresolve_req = resolve_name_send(&s->hostname, c->event_ctx, methods); + cresolve_req = resolve_name_send(resolve_ctx, s, &s->hostname, c->event_ctx); if (composite_nomem(cresolve_req, c)) return c; composite_continue(c, cresolve_req, continue_name_resolved, c); @@ -128,7 +129,7 @@ NTSTATUS libnet_Lookup_recv(struct composite_context *c, TALLOC_CTX *mem_ctx, if (NT_STATUS_IS_OK(status)) { s = talloc_get_type(c->private_data, struct lookup_state); - io->out.address = str_list_make(mem_ctx, s->address, NULL); + io->out.address = (const char **)str_list_make_single(mem_ctx, s->address); NT_STATUS_HAVE_NO_MEMORY(io->out.address); } @@ -190,10 +191,15 @@ struct composite_context* libnet_LookupDCs_send(struct libnet_context *ctx, struct libnet_LookupDCs *io) { struct composite_context *c; - struct messaging_context *msg_ctx = messaging_client_init(mem_ctx, ctx->event_ctx); - - c = finddcs_send(mem_ctx, io->in.domain_name, io->in.name_type, - NULL, ctx->name_res_methods, ctx->event_ctx, msg_ctx); + struct messaging_context *msg_ctx = + messaging_client_init(mem_ctx, + lp_messaging_path(mem_ctx, ctx->lp_ctx), + ctx->event_ctx); + + c = finddcs_send(mem_ctx, lp_netbios_name(ctx->lp_ctx), + lp_nbt_port(ctx->lp_ctx), io->in.domain_name, + io->in.name_type, NULL, ctx->resolve_ctx, + ctx->event_ctx, msg_ctx); return c; } @@ -247,7 +253,7 @@ static bool prepare_lookup_params(struct libnet_context *ctx, struct composite_context *c, struct lookup_name_state *s); static void continue_lookup_name(struct composite_context *ctx); -static void continue_name_found(struct rpc_request *req); +static void continue_name_found(struct tevent_req *subreq); struct composite_context* libnet_LookupName_send(struct libnet_context *ctx, @@ -257,8 +263,8 @@ struct composite_context* libnet_LookupName_send(struct libnet_context *ctx, { struct composite_context *c; struct lookup_name_state *s; - struct rpc_request *lookup_req; - BOOL prereq_met = False; + struct tevent_req *subreq; + bool prereq_met = false; c = composite_create(mem_ctx, ctx->event_ctx); if (c == NULL) return NULL; @@ -278,10 +284,12 @@ struct composite_context* libnet_LookupName_send(struct libnet_context *ctx, if (!prepare_lookup_params(ctx, c, s)) return c; - lookup_req = dcerpc_lsa_LookupNames_send(ctx->lsa.pipe, c, &s->lookup); - if (composite_nomem(lookup_req, c)) return c; + subreq = dcerpc_lsa_LookupNames_r_send(s, c->event_ctx, + ctx->lsa.pipe->binding_handle, + &s->lookup); + if (composite_nomem(subreq, c)) return c; - composite_continue_rpc(c, lookup_req, continue_name_found, c); + tevent_req_set_callback(subreq, continue_name_found, c); return c; } @@ -307,6 +315,8 @@ static bool prepare_lookup_params(struct libnet_context *ctx, s->lookup.in.count = &s->count; s->lookup.out.count = &s->count; s->lookup.out.sids = &s->sids; + s->lookup.out.domains = talloc_zero(ctx, struct lsa_RefDomainList *); + if (composite_nomem(s->lookup.out.domains, c)) return false; return true; } @@ -316,7 +326,7 @@ static void continue_lookup_name(struct composite_context *ctx) { struct composite_context *c; struct lookup_name_state *s; - struct rpc_request *lookup_req; + struct tevent_req *subreq; c = talloc_get_type(ctx->async.private_data, struct composite_context); s = talloc_get_type(c->private_data, struct lookup_name_state); @@ -326,22 +336,25 @@ static void continue_lookup_name(struct composite_context *ctx) if (!prepare_lookup_params(s->ctx, c, s)) return; - lookup_req = dcerpc_lsa_LookupNames_send(s->ctx->lsa.pipe, c, &s->lookup); - if (composite_nomem(lookup_req, c)) return; + subreq = dcerpc_lsa_LookupNames_r_send(s, c->event_ctx, + s->ctx->lsa.pipe->binding_handle, + &s->lookup); + if (composite_nomem(subreq, c)) return; - composite_continue_rpc(c, lookup_req, continue_name_found, c); + tevent_req_set_callback(subreq, continue_name_found, c); } -static void continue_name_found(struct rpc_request *req) +static void continue_name_found(struct tevent_req *subreq) { struct composite_context *c; struct lookup_name_state *s; - c = talloc_get_type(req->async.private, struct composite_context); + c = tevent_req_callback_data(subreq, struct composite_context); s = talloc_get_type(c->private_data, struct lookup_name_state); - c->status = dcerpc_ndr_request_recv(req); + c->status = dcerpc_lsa_LookupNames_r_recv(subreq, s); + TALLOC_FREE(subreq); if (!composite_is_ok(c)) return; c->status = s->lookup.out.result; @@ -367,7 +380,7 @@ NTSTATUS libnet_LookupName_recv(struct composite_context *c, TALLOC_CTX *mem_ctx io->out.sidstr = NULL; if (*s->lookup.out.count > 0) { - struct lsa_RefDomainList *domains = s->lookup.out.domains; + struct lsa_RefDomainList *domains = *s->lookup.out.domains; struct lsa_TransSidArray *sids = s->lookup.out.sids; if (domains == NULL || sids == NULL) {