[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Wed Apr 8 22:24:03 UTC 2020


The branch, master has been updated
       via  03f79a3bd71 s3:rpc_server: Improve local dispatching
       via  bce570cfd75 spoolss: Add NCALRPC endpoint
       via  34240fd4e8e librpc:core: Make find_interface_by_uuid public
      from  37059e45182 smbtree: Align integer types

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 03f79a3bd71bc7a0a401d5f19560e831251d32b7
Author: Samuel Cabrero <scabrero at samba.org>
Date:   Mon Nov 18 14:01:52 2019 +0100

    s3:rpc_server: Improve local dispatching
    
    Craft core structures to dispatch local calls in the same way as remote
    ones, removing the special handling in the autogenerated code.
    
    This is also necessary to drop s3 rpc handles implementation.
    
    Signed-off-by: Samuel Cabrero <scabrero at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Wed Apr  8 22:23:05 UTC 2020 on sn-devel-184

commit bce570cfd751fe2348e62cd8e06d64760d769611
Author: Samuel Cabrero <scabrero at samba.org>
Date:   Mon Nov 18 16:55:39 2019 +0100

    spoolss: Add NCALRPC endpoint
    
    Signed-off-by: Samuel Cabrero <scabrero at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 34240fd4e8e1371207e27375392e11ba846b9f23
Author: Samuel Cabrero <scabrero at suse.de>
Date:   Thu Oct 31 14:31:37 2019 +0100

    librpc:core: Make find_interface_by_uuid public
    
    Signed-off-by: Samuel Cabrero <scabrero at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 librpc/idl/spoolss.idl                           |    2 +-
 librpc/rpc/dcesrv_core.c                         |    2 +-
 librpc/rpc/dcesrv_core.h                         |    5 +-
 pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm   |  193 +-
 source3/rpc_server/rpc_ncacn_np.c                |  364 +++-
 source3/rpc_server/spoolss/srv_iremotewinspool.c | 2051 +---------------------
 source3/winbindd/winbindd_dual_ndr.c             |  287 ++-
 7 files changed, 565 insertions(+), 2339 deletions(-)


Changeset truncated at 500 lines:

diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl
index afe60d2faf0..569fa02a829 100644
--- a/librpc/idl/spoolss.idl
+++ b/librpc/idl/spoolss.idl
@@ -10,7 +10,7 @@ cpp_quote("#define spoolss_security_descriptor security_descriptor")
 
 [ uuid("12345678-1234-abcd-ef00-0123456789ab"),
   version(1.0),
-  endpoint("ncacn_np:[\\pipe\\spoolss]"),
+  endpoint("ncacn_np:[\\pipe\\spoolss]", "ncalrpc:"),
   pointer_default(unique),
   helpstring("Spooler SubSystem"),
   helper("../librpc/ndr/ndr_spoolss_buf.h")
diff --git a/librpc/rpc/dcesrv_core.c b/librpc/rpc/dcesrv_core.c
index 4148c3f0f1a..88838121f2f 100644
--- a/librpc/rpc/dcesrv_core.c
+++ b/librpc/rpc/dcesrv_core.c
@@ -147,7 +147,7 @@ static bool interface_match_by_uuid(const struct dcesrv_interface *iface,
 /*
   find the interface operations on an endpoint by uuid
 */
-const struct dcesrv_interface *find_interface_by_uuid(const struct dcesrv_endpoint *endpoint,
+_PUBLIC_ const struct dcesrv_interface *find_interface_by_uuid(const struct dcesrv_endpoint *endpoint,
 						      const struct GUID *uuid, uint32_t if_version)
 {
 	struct dcesrv_if_list *ifl;
diff --git a/librpc/rpc/dcesrv_core.h b/librpc/rpc/dcesrv_core.h
index 161ed1a9691..c1234980b82 100644
--- a/librpc/rpc/dcesrv_core.h
+++ b/librpc/rpc/dcesrv_core.h
@@ -69,7 +69,7 @@ struct dcesrv_interface {
 
 	/* the local dispatch function for the chosen interface.
 	 */
-	NTSTATUS (*local)(void *p, int opnum, TALLOC_CTX *, const DATA_BLOB *in, DATA_BLOB *out);
+	NTSTATUS (*local)(struct dcesrv_call_state *, TALLOC_CTX *, void *);
 
 	/* for any private use by the interface code */
 	const void *private_data;
@@ -624,6 +624,9 @@ _PUBLIC_ void dcesrv_sock_report_output_data(struct dcesrv_connection *dce_conn)
 
 _PUBLIC_ NTSTATUS dcesrv_connection_loop_start(struct dcesrv_connection *conn);
 
+_PUBLIC_ const struct dcesrv_interface *find_interface_by_uuid(
+				const struct dcesrv_endpoint *endpoint,
+				const struct GUID *uuid, uint32_t if_version);
 
 void _dcesrv_save_ndr_fuzz_seed(DATA_BLOB call_blob,
 				struct dcesrv_call_state *call,
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm
index a1729d86d77..14f6ad9a1a0 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/ServerCompat.pm
@@ -212,67 +212,6 @@ sub gen_reply_switch($)
 	}
 }
 
-# generate the switch statement for local function dispatch
-sub gen_local_dispatch_switch($)
-{
-	my ($self, $interface) = @_;
-
-	my @alloc_error_block = ("p->fault_state = DCERPC_FAULT_CANT_PERFORM;",
-				 "return NT_STATUS_NO_MEMORY;");
-
-	foreach my $fn (@{$interface->{FUNCTIONS}}) {
-		next if not defined($fn->{OPNUM});
-
-		$self->pidl("case $fn->{OPNUM}: { /* $fn->{NAME} */");
-		$self->indent();
-		$self->pidl("struct $fn->{NAME} *r2 = (struct $fn->{NAME} *)r;");
-		$self->pidl("if (DEBUGLEVEL >= 10) {\n");
-		$self->indent();
-		$self->pidl("NDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_IN, r2);");
-		$self->deindent();
-		$self->pidl("}");
-
-		$self->gen_fn_out($fn, \@alloc_error_block);
-
-		if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
-			$self->pidl("r2->out.result = _$fn->{NAME}(p, r2);");
-		} else {
-			$self->pidl("_$fn->{NAME}(p, r2);");
-		}
-		$self->pidl("break;");
-		$self->deindent();
-		$self->pidl("}");
-	}
-}
-
-#####################################################
-# generate the switch statement for local function reply
-sub gen_local_reply_switch($)
-{
-	my ($self, $interface) = @_;
-
-	foreach my $fn (@{$interface->{FUNCTIONS}}) {
-		next if not defined($fn->{OPNUM});
-
-		$self->pidl("case $fn->{OPNUM}: { /* $fn->{NAME} */");
-		$self->indent();
-		$self->pidl("struct $fn->{NAME} *r2 = (struct $fn->{NAME} *)r;");
-		$self->pidl("if (DEBUGLEVEL >= 10 && p->fault_state == 0) {");
-		$self->indent();
-		$self->pidl("NDR_PRINT_FUNCTION_DEBUG($fn->{NAME}, NDR_OUT | NDR_SET_VALUES, r2);");
-		$self->deindent();
-		$self->pidl("}");
-		$self->pidl("if (p->fault_state != 0) {\n");
-		$self->indent();
-		$self->pidl("DBG_WARNING(\"dcerpc_fault %s in $fn->{NAME}\\n\", dcerpc_errstr(mem_ctx, p->fault_state));");
-		$self->deindent();
-		$self->pidl("}");
-		$self->pidl("break;");
-		$self->deindent();
-		$self->pidl("}");
-	}
-}
-
 #####################################################################
 # produce boilerplate code for a interface
 sub boilerplate_iface($)
@@ -392,15 +331,14 @@ sub boilerplate_iface($)
 	$self->pidl("}");
 	$self->pidl("");
 
-	$self->pidl_hdr("NTSTATUS $name\__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r);");
-	$self->pidl("NTSTATUS $name\__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)");
+	$self->pidl("static NTSTATUS $name\__op_dispatch_internal(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r, enum s3compat_rpc_dispatch dispatch)");
 	$self->pidl("{");
 	$self->indent();
 	$self->pidl("uint16_t opnum = dce_call->pkt.u.request.opnum;");
 	$self->pidl("struct pipes_struct *p = NULL;");
 	$self->pidl("struct auth_session_info *pipe_session_info = NULL;");
 	$self->pidl("NTSTATUS status = NT_STATUS_OK;");
-	$self->pidl("bool impersonated;");
+	$self->pidl("bool impersonated = false;");
 	$self->pidl("");
 	$self->pidl("/* Retrieve pipes struct */");
 	$self->pidl("p = dcesrv_get_pipes_struct(dce_call->conn);");
@@ -417,6 +355,8 @@ sub boilerplate_iface($)
 	$self->pidl("");
 
 	$self->pidl("/* Impersonate */");
+	$self->pidl("if (dispatch == S3COMPAT_RPC_DISPATCH_EXTERNAL) {");
+	$self->indent();
 	$self->pidl("impersonated = become_authenticated_pipe_user(p->session_info);");
 	$self->pidl("if (!impersonated) {");
 	$self->indent();
@@ -425,6 +365,8 @@ sub boilerplate_iface($)
 	$self->pidl("goto fail;");
 	$self->deindent();
 	$self->pidl("}");
+	$self->deindent();
+	$self->pidl("}");
 	$self->pidl("");
 
 	$self->pidl("switch (opnum) {");
@@ -469,6 +411,15 @@ sub boilerplate_iface($)
 	$self->pidl("}");
 	$self->pidl("");
 
+	$self->pidl_hdr("NTSTATUS $name\__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r);");
+	$self->pidl("NTSTATUS $name\__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)");
+	$self->pidl("{");
+	$self->indent();
+	$self->pidl("return $name\__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_EXTERNAL);");
+	$self->deindent();
+	$self->pidl("}");
+	$self->pidl("");
+
 	$self->pidl_hdr("NTSTATUS $name\__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r);");
 	$self->pidl("NTSTATUS $name\__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)");
 	$self->pidl("{");
@@ -519,112 +470,11 @@ sub boilerplate_iface($)
 	##############################
 	####    LOCAL DISPATCH    ####
 	##############################
-	$self->pidl_hdr("NTSTATUS $name\__op_local(void *q, int opnum, TALLOC_CTX *mem_ctx, const DATA_BLOB *in, DATA_BLOB *out);");
-	$self->pidl("NTSTATUS $name\__op_local(void *q, int opnum, TALLOC_CTX *mem_ctx, const DATA_BLOB *in, DATA_BLOB *out)");
+	$self->pidl_hdr("NTSTATUS $name\__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r);");
+	$self->pidl("NTSTATUS $name\__op_local(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)");
 	$self->pidl("{");
 	$self->indent();
-	$self->pidl("struct pipes_struct *p = talloc_get_type_abort(q, struct pipes_struct);");
-	$self->pidl("void *r;");
-	$self->pidl("struct ndr_pull *pull;");
-	$self->pidl("struct ndr_push *push;");
-	$self->pidl("enum ndr_err_code ndr_err;");
-	$self->pidl("");
-	$self->pidl("p->fault_state = 0;");
-	$self->pidl("if (opnum >= ndr_table_$name.num_calls) {");
-	$self->indent();
-	$self->pidl("p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;");
-	$self->pidl("return NT_STATUS_NET_WRITE_FAULT;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("r = talloc_named(mem_ctx, ndr_table_$name.calls[opnum].struct_size, \"struct %s\", ndr_table_$name.calls[opnum].name);");
-	$self->pidl("if (r == NULL) {");
-	$self->indent();
-	$self->pidl("p->fault_state = DCERPC_FAULT_CANT_PERFORM;");
-	$self->pidl("return NT_STATUS_NO_MEMORY;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("pull = ndr_pull_init_blob(in, r);");
-	$self->pidl("if (pull == NULL) {");
-	$self->indent();
-	$self->pidl("talloc_free(r);");
-	$self->pidl("p->fault_state = DCERPC_FAULT_CANT_PERFORM;");
-	$self->pidl("return NT_STATUS_NO_MEMORY;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("pull->flags |= LIBNDR_FLAG_REF_ALLOC;");
-	$self->pidl("if (p->endian) {");
-	$self->indent();
-	$self->pidl("pull->flags |= LIBNDR_FLAG_BIGENDIAN;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("ndr_err = ndr_table_$name.calls[opnum].ndr_pull(pull, NDR_IN, r);");
-	$self->pidl("if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {");
-	$self->indent();
-	$self->pidl("p->fault_state = DCERPC_FAULT_NDR;");
-	$self->pidl("talloc_free(r);");
-	$self->pidl("return NT_STATUS_NET_WRITE_FAULT;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("switch (opnum) {");
-	$self->gen_local_dispatch_switch($interface);
-	$self->pidl("default:");
-	$self->indent();
-	$self->pidl("p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;");
-	$self->pidl("break;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("if (p->fault_state != 0) {");
-	$self->indent();
-	$self->pidl("talloc_free(r);");
-	$self->pidl("return NT_STATUS_NET_WRITE_FAULT;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("switch (opnum) {");
-	$self->gen_local_reply_switch($interface);
-	$self->pidl("default:");
-	$self->indent();
-	$self->pidl("p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;");
-	$self->pidl("break;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("push = ndr_push_init_ctx(r);");
-	$self->pidl("if (push == NULL) {");
-	$self->indent();
-	$self->pidl("talloc_free(r);");
-	$self->pidl("p->fault_state = DCERPC_FAULT_CANT_PERFORM;");
-	$self->pidl("return NT_STATUS_NO_MEMORY;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("/*");
-	$self->pidl(" * carry over the pointer count to the reply in case we are");
-	$self->pidl(" * using full pointer. See NDR specification for full pointers");
-	$self->pidl(" */");
-	$self->pidl("push->ptr_count = pull->ptr_count;");
-	$self->pidl("");
-	$self->pidl("ndr_err = ndr_table_$name.calls[opnum].ndr_push(push, NDR_OUT, r);");
-	$self->pidl("if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {");
-	$self->indent();
-	$self->pidl("p->fault_state = DCERPC_FAULT_NDR;");
-	$self->pidl("talloc_free(r);");
-	$self->pidl("return NT_STATUS_NET_WRITE_FAULT;");
-	$self->deindent();
-	$self->pidl("}");
-	$self->pidl("");
-	$self->pidl("*out = ndr_push_blob(push);");
-	$self->pidl("talloc_steal(mem_ctx, out->data);");
-	$self->pidl("");
-	$self->pidl("talloc_free(r);");
-	$self->pidl("");
-	$self->pidl("return NT_STATUS_OK;");
+	$self->pidl("return $name\__op_dispatch_internal(dce_call, mem_ctx, r, S3COMPAT_RPC_DISPATCH_INTERNAL);");
 	$self->deindent();
 	$self->pidl("}");
 	$self->pidl("");
@@ -854,6 +704,13 @@ sub Parse($$)
 	$self->pidl("#include <rpc_server/rpc_server.h>");
 	$self->pidl("#include <util/debug.h>");
 	$self->pidl("");
+	$self->pidl("enum s3compat_rpc_dispatch {");
+	$self->indent();
+	$self->pidl("S3COMPAT_RPC_DISPATCH_EXTERNAL = 0x00000001,");
+	$self->pidl("S3COMPAT_RPC_DISPATCH_INTERNAL = 0x00000002,");
+	$self->deindent();
+	$self->pidl("};");
+	$self->pidl("");
 
 	foreach my $x (@{$ndr}) {
 		$self->parse_interface($x) if ($x->{TYPE} eq "INTERFACE" and not defined($x->{PROPERTIES}{object}));
diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c
index 850dd6b90a1..028b8a1a29a 100644
--- a/source3/rpc_server/rpc_ncacn_np.c
+++ b/source3/rpc_server/rpc_ncacn_np.c
@@ -42,14 +42,6 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
 
-static NTSTATUS make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
-				const struct ndr_syntax_id *syntax,
-				const struct tsocket_address *remote_address,
-				const struct tsocket_address *local_address,
-				const struct auth_session_info *session_info,
-				struct messaging_context *msg_ctx,
-				struct pipes_struct **p);
-
 struct np_proxy_state {
 	uint16_t file_type;
 	uint16_t device_state;
@@ -249,118 +241,274 @@ out:
 	return status;
 }
 
-/****************************************************************************
- Make an internal namedpipes structure
-****************************************************************************/
-
-static NTSTATUS make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
-				const struct ndr_syntax_id *syntax,
+static NTSTATUS make_internal_ncacn_conn(TALLOC_CTX *mem_ctx,
+				const struct ndr_interface_table *table,
 				const struct tsocket_address *remote_address,
 				const struct tsocket_address *local_address,
 				const struct auth_session_info *session_info,
 				struct messaging_context *msg_ctx,
-				struct pipes_struct **p)
+				struct dcerpc_ncacn_conn **_out)
 {
-	struct pipes_struct *out;
 	struct pipe_rpc_fns *context_fns;
-	const char *pipe_name;
+	struct dcerpc_ncacn_conn *ncacn_conn = NULL;
+	const char *pipe_name = NULL;
+	NTSTATUS status;
 	int ret;
-	const struct ndr_interface_table *table;
 
-	table = ndr_table_by_uuid(&syntax->uuid);
-	if (table == NULL) {
-		DBG_ERR("Unknown interface\n");
-		return NT_STATUS_RPC_INTERFACE_NOT_FOUND;
+	pipe_name = dcerpc_default_transport_endpoint(mem_ctx,
+						      NCACN_NP,
+						      table);
+
+	DBG_INFO("Create pipe requested %s\n", pipe_name);
+
+	ncacn_conn = talloc_zero(mem_ctx, struct dcerpc_ncacn_conn);
+	if (ncacn_conn == NULL) {
+		return NT_STATUS_NO_MEMORY;
 	}
 
-	pipe_name = dcerpc_default_transport_endpoint(mem_ctx, NCACN_NP, table);
+	ncacn_conn->msg_ctx = msg_ctx;
 
-	DBG_INFO("Create pipe requested %s\n", pipe_name);
+	if (remote_address != NULL) {
+		ncacn_conn->remote_client_addr =
+			tsocket_address_copy(remote_address, ncacn_conn);
+		if (ncacn_conn->remote_client_addr == NULL) {
+			status = NT_STATUS_NO_MEMORY;
+			goto fail;
+		}
+	}
 
-	ret = make_base_pipes_struct(mem_ctx, msg_ctx, pipe_name,
-				     NCALRPC, RPC_LITTLE_ENDIAN,
-				     remote_address, local_address, &out);
+	if (local_address != NULL) {
+		ncacn_conn->local_server_addr =
+			tsocket_address_copy(local_address, ncacn_conn);
+		if (ncacn_conn->local_server_addr == NULL) {
+			status = NT_STATUS_NO_MEMORY;
+			goto fail;
+		}
+	}
+
+	ncacn_conn->session_info = copy_session_info(ncacn_conn, session_info);
+	if (ncacn_conn->session_info == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
+	}
+
+	ret = make_base_pipes_struct(ncacn_conn,
+				     msg_ctx,
+				     pipe_name,
+				     NCALRPC,
+				     RPC_LITTLE_ENDIAN,
+				     ncacn_conn->remote_client_addr,
+				     ncacn_conn->local_server_addr,
+				     &ncacn_conn->p);
 	if (ret) {
 		DBG_ERR("No memory for pipes_struct!\n");
-		return NT_STATUS_NO_MEMORY;
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
 	}
 
-	if (!init_pipe_handles(out, syntax)) {
+	if (!init_pipe_handles(ncacn_conn->p, &table->syntax_id)) {
 		DBG_ERR("init_pipe_handles failed.\n");
-		TALLOC_FREE(out);
-		return NT_STATUS_UNSUCCESSFUL;
-	}
-
-	out->session_info = copy_session_info(out, session_info);
-	if (out->session_info == NULL) {
-		DBG_ERR("copy_serverinfo failed\n");
-		close_policy_by_pipe(out);
-		TALLOC_FREE(out);
-		return NT_STATUS_UNSUCCESSFUL;
+		status = NT_STATUS_UNSUCCESSFUL;
+		goto fail;
 	}
 
-	context_fns = talloc_zero(out, struct pipe_rpc_fns);
+	context_fns = talloc_zero(ncacn_conn->p, struct pipe_rpc_fns);
 	if (context_fns == NULL) {
 		DBG_ERR("No memory");
-		TALLOC_FREE(out);
-		return NT_STATUS_NO_MEMORY;
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
 	}
 
 	context_fns->next = context_fns->prev = NULL;
 	context_fns->context_id = 0;
-	context_fns->syntax = *syntax;
+	context_fns->syntax = table->syntax_id;
 
 	/* add to the list of open contexts */
-	DLIST_ADD(out->contexts, context_fns);
+	DLIST_ADD(ncacn_conn->p->contexts, context_fns);
 
 	DEBUG(4,("Created internal pipe %s\n", pipe_name));
 
-	*p = out;
+	*_out = ncacn_conn;
 
 	return NT_STATUS_OK;
+
+fail:
+	talloc_free(ncacn_conn);
+	return status;
+}
+
+static NTSTATUS find_ncalrpc_default_endpoint(struct dcesrv_context *dce_ctx,
+					      struct dcesrv_endpoint **ep)
+{
+	TALLOC_CTX *tmp_ctx = NULL;
+	struct dcerpc_binding *binding = NULL;
+	const char *ep_description = NULL;
+	NTSTATUS status;
+
+	tmp_ctx = talloc_new(dce_ctx);
+	if (tmp_ctx == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	/*
+	 * Some services use a rpcint binding handle in their initialization,
+	 * before the server is fully initialized. Search the NCALRPC endpoint
+	 * with and without endpoint
+	 */
+	status = dcerpc_parse_binding(tmp_ctx, "ncalrpc:", &binding);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto out;
+	}
+
+	status = dcesrv_find_endpoint(dce_ctx, binding, ep);
+	if (NT_STATUS_IS_OK(status)) {
+		goto out;
+	}
+
+	if (lp_server_role() == ROLE_ACTIVE_DIRECTORY_DC) {
+		ep_description = "ncalrpc:[SMBD]";
+	} else {
+		ep_description = "ncalrpc:[DEFAULT]";
+	}
+
+	status = dcerpc_parse_binding(tmp_ctx, ep_description, &binding);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto out;
+	}
+
+	status = dcesrv_find_endpoint(dce_ctx, binding, ep);
+	if (!NT_STATUS_IS_OK(status)) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list