From 16b5eac38df91b2377cbffe3009cc956fcb8a78a Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 15 May 2006 21:49:27 +0000 Subject: r15625: Partial commit of my current work. It makes libnet api functions a bit more smart and more aware of what libnet_context can offer. The context is a help when some of the arguments are not passed (programmer counts on using sensible defaults) and stores some of results so that similar subsequent calls don't need to reopen some of policy handles, pipes, etc. again. It also helps to hide some of details the library user don't really want to know much about. Also, change domain open function to be part of public api, as it is going to be used in ejsnet interface. Note, this is work in progress. Comments are welcome. rafal (This used to be commit 1ed80c594c2f466e364a11194d6fdc30ac4a8f27) --- source4/libnet/libnet_rpc.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'source4/libnet/libnet_rpc.c') diff --git a/source4/libnet/libnet_rpc.c b/source4/libnet/libnet_rpc.c index 3e66a5c27c..b185380295 100644 --- a/source4/libnet/libnet_rpc.c +++ b/source4/libnet/libnet_rpc.c @@ -24,6 +24,7 @@ #include "libcli/libcli.h" #include "libcli/composite/composite.h" #include "librpc/gen_ndr/ndr_lsa_c.h" +#include "librpc/gen_ndr/ndr_samr.h" struct rpc_connect_srv_state { @@ -137,7 +138,15 @@ static NTSTATUS libnet_RpcConnectSrv_recv(struct composite_context *c, /* move the returned rpc pipe between memory contexts */ s = talloc_get_type(c->private_data, struct rpc_connect_srv_state); r->out.dcerpc_pipe = talloc_steal(mem_ctx, s->r.out.dcerpc_pipe); - ctx->pipe = r->out.dcerpc_pipe; + + /* reference created pipe structure to long-term libnet_context + so that it can be used by other api functions even after short-term + mem_ctx is freed */ + if (r->in.dcerpc_iface == &dcerpc_table_samr) { + ctx->samr_pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + } else { + ctx->pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + } } talloc_free(c); @@ -301,7 +310,15 @@ static NTSTATUS libnet_RpcConnectDC_recv(struct composite_context *c, /* move connected rpc pipe between memory contexts */ s = talloc_get_type(c->private_data, struct rpc_connect_dc_state); r->out.dcerpc_pipe = talloc_steal(mem_ctx, s->r.out.dcerpc_pipe); - ctx->pipe = r->out.dcerpc_pipe; + + /* reference created pipe structure to long-term libnet_context + so that it can be used by other api functions even after short-term + mem_ctx is freed */ + if (r->in.dcerpc_iface == &dcerpc_table_samr) { + ctx->samr_pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + } else { + ctx->pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + } } talloc_free(c); @@ -639,9 +656,17 @@ static NTSTATUS libnet_RpcConnectDCInfo_recv(struct composite_context *c, struct r->out.guid = talloc_steal(mem_ctx, s->r.out.guid); r->out.domain_name = talloc_steal(mem_ctx, s->r.out.domain_name); r->out.domain_sid = talloc_steal(mem_ctx, s->r.out.domain_sid); + r->out.dcerpc_pipe = talloc_steal(mem_ctx, s->r.out.dcerpc_pipe); - r->out.error_string = NULL; + /* reference created pipe structure to long-term libnet_context + so that it can be used by other api functions even after short-term + mem_ctx is freed */ + if (r->in.dcerpc_iface == &dcerpc_table_samr) { + ctx->samr_pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + } else { + ctx->pipe = talloc_reference(ctx, r->out.dcerpc_pipe); + } } talloc_free(c); -- cgit