[SCM] Samba Shared Repository - branch v3-6-test updated

Andreas Schneider asn at samba.org
Thu Feb 3 00:55:46 MST 2011


The branch, v3-6-test has been updated
       via  7b30c02 s3-epmap: use correct dcerpc client header in dcerpc_ep.c
       via  d24d0e2 s3-selftest: Enable RPC-EPMAPPER tests.
       via  13c5a5e s3-smbd: Disable the endpoint mapper by default. (cherry picked from commit d0d5d59943ac7958e95279cd8f8be3097e5e7db8)
       via  7d8b04f s3-smbd: Added a function to setup rpc services.
       via  1a5b875 s3-rpc_server: Only allow registering endpoints on priviledged pipes. (cherry picked from commit 612060d677ac64de1b9261beb2d98496cec2ab46)
       via  fe6044c s3-librpc: Added dcerpc_binding_vector_create function. (cherry picked from commit 31779662b728fa6cefd21df742273fd31d8d8dfb)
       via  b8ff339 s3-librpc: Added dcerpc register endpoint functions. (cherry picked from commit 20afe971777811c8e645a4d37b5159cd8300d3a8)
       via  4f9a3c2 s3-epmapper: Commented unimplemented functions. (cherry picked from commit bd5d14e6fa778b77217ca326828fd61cf516bd9b)
       via  402423c s3-epmapper: Improved the epm_Map function. (cherry picked from commit c451a454b3a87301ed17b3e7a06de37e6cfcb41e)
       via  370df0c s3-epmapper: Implemented epm_Lookup. (cherry picked from commit 1d33f5c6d641f2c4c18eae47f7d9ef464396f471)
       via  0d4b083 s3-epmapper: Implemented epm_LookupHandleFree. (cherry picked from commit 5b93e06e6c6a67640ee3cd4de1ffbbaa3018721f)
       via  9a8c3d5 s3-epmapper: Added arg to match uuid in build_ep_list(). (cherry picked from commit 3584dd18df1179ecb41791e2b14929699fc09660)
       via  3cccede s3-epmapper: Added epm_Map function from Samba4. (cherry picked from commit 658c05b939e0a96cb385bf2808b01595ae838f06)
       via  2a82d2e s3-epmapper: Added epm_Delete function. (cherry picked from commit 6747b89b3ce0e234c6129696825c59b68cada8cd)
       via  eb0cb3b s3-epmapper: Added epm_Insert function. (cherry picked from commit c31ee9a152d64c8236cc20af1a78ac0feb999f81)
       via  0311541 s3-epmapper: Added a endpoint mapper skeleton. (cherry picked from commit 84995397a7f24961065b17693afc1fda22b7bfd5)
      from  f8366d7 Fix value overflow (one too many 'f's ). (cherry picked from commit 9f83a1ba188975b24ebc3819037c9c10e09ec00d)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 7b30c02846ae037167f0d5f654e740ccce6112ff
Author: Günther Deschner <gd at samba.org>
Date:   Wed Feb 2 18:50:39 2011 +0100

    s3-epmap: use correct dcerpc client header in dcerpc_ep.c
    
    Guenther
    
    Autobuild-User: Günther Deschner <gd at samba.org>
    Autobuild-Date: Wed Feb  2 19:50:02 CET 2011 on sn-devel-104
    (cherry picked from commit 586b2ee82655d5849c8483eb787f5ba77c80f478)

commit d24d0e21e4d0036803cf04ac3ec8e13fe1bc3c7c
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Oct 4 18:32:35 2010 +0200

    s3-selftest: Enable RPC-EPMAPPER tests.
    
    Autobuild-User: Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date: Wed Feb  2 13:28:41 CET 2011 on sn-devel-104
    (cherry picked from commit 5aae1f462ed09decfc41d77a10dd4f135336986b)

commit 13c5a5e122aa46b24864a55ba085d7bf10ee2cea
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jan 20 15:37:46 2011 +0100

    s3-smbd: Disable the endpoint mapper by default.
    (cherry picked from commit d0d5d59943ac7958e95279cd8f8be3097e5e7db8)

commit 7d8b04f397cddb1399cc70849378eb835b3dd448
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jan 5 17:16:46 2011 +0100

    s3-smbd: Added a function to setup rpc services.
    
    Move the complete setup of the rpc service to its own file and use
    callbacks to register at the endpoint mapper.
    (cherry picked from commit e3bdfd2d46cb09a42eda1012287bb82af5b8ee9b)

commit 1a5b8754400467e093e86a1cc0aaf868970a330a
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jan 4 09:52:57 2011 +0100

    s3-rpc_server: Only allow registering endpoints on priviledged pipes.
    (cherry picked from commit 612060d677ac64de1b9261beb2d98496cec2ab46)

commit fe6044c0d748fa8200fffc11cee5ed264f64dc88
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Sep 16 10:48:33 2010 +0200

    s3-librpc: Added dcerpc_binding_vector_create function.
    (cherry picked from commit 31779662b728fa6cefd21df742273fd31d8d8dfb)

commit b8ff339532b42f97d3aeef52c5d569c959037e6f
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Sep 2 16:24:26 2010 +0200

    s3-librpc: Added dcerpc register endpoint functions.
    (cherry picked from commit 20afe971777811c8e645a4d37b5159cd8300d3a8)

commit 4f9a3c2fd950e7ac3f376f2106be917f9ab595d2
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jan 18 09:48:35 2011 +0100

    s3-epmapper: Commented unimplemented functions.
    (cherry picked from commit bd5d14e6fa778b77217ca326828fd61cf516bd9b)

commit 402423cae91785481dc0f7f6bd70219d17d12067
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Dec 21 19:38:40 2010 +0100

    s3-epmapper: Improved the epm_Map function.
    (cherry picked from commit c451a454b3a87301ed17b3e7a06de37e6cfcb41e)

commit 370df0cd61e65b2278f443845137e5b599a8ff1a
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Oct 5 11:56:47 2010 +0200

    s3-epmapper: Implemented epm_Lookup.
    (cherry picked from commit 1d33f5c6d641f2c4c18eae47f7d9ef464396f471)

commit 0d4b083ce84c6b380c802387fe8fc7ba1966a7e8
Author: Andreas Schneider <asn at cynapses.org>
Date:   Mon Oct 11 11:42:26 2010 +0200

    s3-epmapper: Implemented epm_LookupHandleFree.
    (cherry picked from commit 5b93e06e6c6a67640ee3cd4de1ffbbaa3018721f)

commit 9a8c3d580a61770745a39b6174c1e4abff8e6017
Author: Andreas Schneider <asn at cynapses.org>
Date:   Mon Oct 11 17:22:22 2010 +0200

    s3-epmapper: Added arg to match uuid in build_ep_list().
    (cherry picked from commit 3584dd18df1179ecb41791e2b14929699fc09660)

commit 3cccede18106a7c514ac35b2bd65fa6746856187
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Oct 4 17:58:33 2010 +0200

    s3-epmapper: Added epm_Map function from Samba4.
    (cherry picked from commit 658c05b939e0a96cb385bf2808b01595ae838f06)

commit 2a82d2ebefa336276055d1cb11699728d1555170
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Oct 5 11:45:41 2010 +0200

    s3-epmapper: Added epm_Delete function.
    (cherry picked from commit 6747b89b3ce0e234c6129696825c59b68cada8cd)

commit eb0cb3b075775529d3396dc43116228cf0731675
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Sep 16 10:50:25 2010 +0200

    s3-epmapper: Added epm_Insert function.
    (cherry picked from commit c31ee9a152d64c8236cc20af1a78ac0feb999f81)

commit 031154100d642a7ceb233595a50564fd4ba5880a
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Oct 4 15:56:49 2010 +0200

    s3-epmapper: Added a endpoint mapper skeleton.
    (cherry picked from commit 84995397a7f24961065b17693afc1fda22b7bfd5)

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

Summary of changes:
 selftest/target/Samba3.pm                          |    2 +
 source3/Makefile.in                                |    9 +-
 source3/librpc/rpc/dcerpc_ep.c                     |  250 +++++
 source3/librpc/rpc/dcerpc_ep.h                     |   72 ++
 source3/rpc_server/srv_epmapper.c                  | 1038 ++++++++++++++++++++
 source3/rpc_server/srv_rpc_register.c              |  403 ++++++++
 .../srv_rpc_register.h}                            |   15 +-
 source3/script/tests/selftest.sh                   |    2 +
 source3/script/tests/test_posix_s3.sh              |    2 +-
 source3/smbd/server.c                              |   91 +--
 10 files changed, 1787 insertions(+), 97 deletions(-)
 create mode 100644 source3/librpc/rpc/dcerpc_ep.c
 create mode 100644 source3/librpc/rpc/dcerpc_ep.h
 create mode 100644 source3/rpc_server/srv_epmapper.c
 create mode 100644 source3/rpc_server/srv_rpc_register.c
 copy source3/{printing/nt_printing_migrate.h => rpc_server/srv_rpc_register.h} (70%)


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 3104e49..a0a13f9 100644
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -556,6 +556,8 @@ sub provision($$$$$$)
 	queue resume command = $bindir_abs/vlp tdbfile=$lockdir/vlp.tdb queueresume %p
 	lpq cache time = 0
 
+	rpc_server:epmapper = embedded
+
 	# Begin extra options
 	$extra_options
 	# End extra options
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 6c2d8fb..09cd713 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -656,6 +656,8 @@ REG_FULL_OBJ = $(REG_SMBCONF_OBJ) \
 
 LIB_EVENTLOG_OBJ = lib/eventlog/eventlog.o
 
+DCE_RPC_EP_OBJ = librpc/rpc/dcerpc_ep.o
+
 RPC_LSARPC_OBJ = rpc_server/srv_lsa_nt.o \
 		 librpc/gen_ndr/srv_lsa.o
 
@@ -716,11 +718,15 @@ RPC_PIPE_OBJ = rpc_server/srv_pipe.o rpc_server/srv_pipe_hnd.o \
 
 RPC_RPCECHO_OBJ = rpc_server/srv_echo_nt.o librpc/gen_ndr/srv_echo.o
 
+RPC_EPMAPPER_OBJ = rpc_server/srv_epmapper.o librpc/gen_ndr/srv_epmapper.o
+
+RPC_SERVER_REGISTER_OBJ = rpc_server/srv_rpc_register.o $(DCE_RPC_EP_OBJ)
+
 RPC_SERVER_OBJ = $(RPC_LSARPC_OBJ) $(RPC_WINREG_OBJ) $(RPC_INITSHUTDOWN_OBJ) \
 		 $(RPC_DSSETUP_OBJ) $(RPC_WKSSVC_OBJ) $(RPC_SVCCTL_OBJ) \
 		 $(RPC_NTSVCS_OBJ) $(RPC_NETLOGON_OBJ) $(RPC_NETDFS_OBJ) \
 		 $(RPC_SRVSVC_OBJ) $(RPC_SPOOLSS_OBJ) $(RPC_EVENTLOG_OBJ) \
-		 $(RPC_SAMR_OBJ) $(RPC_RPCECHO_OBJ) \
+		 $(RPC_SAMR_OBJ) $(RPC_RPCECHO_OBJ) $(RPC_EPMAPPER_OBJ) \
 		 $(RPC_PIPE_OBJ) $(NPA_TSTREAM_OBJ) \
 		 $(LIBCLI_SPOOLSS_OBJ) \
 		 $(LIBCLI_WINREG_OBJ) \
@@ -728,6 +734,7 @@ RPC_SERVER_OBJ = $(RPC_LSARPC_OBJ) $(RPC_WINREG_OBJ) $(RPC_INITSHUTDOWN_OBJ) \
 		 $(LIBCLI_LSA_OBJ) \
 		 $(LIBCLI_SAMR_OBJ) \
 		 $(LIBCLI_NETLOGON_OBJ) \
+		 $(RPC_SERVER_REGISTER_OBJ) \
 		 $(RPC_CLIENT_SCHANNEL_OBJ) \
 		 rpc_client/init_netlogon.o \
 		 rpc_client/init_samr.o
diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c
new file mode 100644
index 0000000..b0c9104
--- /dev/null
+++ b/source3/librpc/rpc/dcerpc_ep.c
@@ -0,0 +1,250 @@
+/*
+ *  Endpoint Mapper Functions
+ *  DCERPC local endpoint mapper client routines
+ *  Copyright (c) 2010      Andreas Schneider.
+ *
+ *  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 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "librpc/rpc/dcerpc.h"
+#include "librpc/rpc/dcerpc_ep.h"
+#include "../librpc/gen_ndr/ndr_epmapper_c.h"
+
+#define EPM_MAX_ANNOTATION_SIZE 64
+
+NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx,
+				      const struct ndr_interface_table *iface,
+				      struct dcerpc_binding_vector **pbvec)
+{
+	struct dcerpc_binding_vector *bvec;
+	uint32_t ep_count, i;
+	NTSTATUS status;
+	TALLOC_CTX *tmp_ctx;
+
+	tmp_ctx = talloc_stackframe();
+	if (tmp_ctx == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	ep_count = iface->endpoints->count;
+
+	bvec = talloc_zero(tmp_ctx, struct dcerpc_binding_vector);
+	if (bvec == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto done;
+	}
+
+	bvec->bindings = talloc_array(bvec, struct dcerpc_binding, ep_count);
+	if (bvec->bindings == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto done;
+	}
+
+	for (i = 0; i < ep_count; i++) {
+		struct dcerpc_binding *b;
+
+		b = talloc_zero(bvec->bindings, struct dcerpc_binding);
+		if (b == NULL) {
+			status = NT_STATUS_NO_MEMORY;
+			goto done;
+		}
+
+		status = dcerpc_parse_binding(b, iface->endpoints->names[i], &b);
+		if (!NT_STATUS_IS_OK(status)) {
+			status = NT_STATUS_UNSUCCESSFUL;
+			goto done;
+		}
+
+		b->object = iface->syntax_id;
+		if (b->transport == NCACN_NP) {
+			b->host = talloc_asprintf(b, "\\\\%s", global_myname());
+		}
+
+		bvec->bindings[i] = *b;
+	}
+	bvec->count = ep_count;
+
+	*pbvec = talloc_move(mem_ctx, &bvec);
+
+	status = NT_STATUS_OK;
+done:
+	talloc_free(tmp_ctx);
+
+	return status;
+}
+
+static NTSTATUS ep_register(const struct ndr_interface_table *iface,
+			    const struct dcerpc_binding_vector *bind_vec,
+			    const struct GUID *object_guid,
+			    const char *annotation,
+			    uint32_t replace,
+			    uint32_t unregister)
+{
+	struct dcerpc_binding_handle *h = NULL;
+	static struct client_address client_id;
+	struct epm_entry_t *entries;
+	uint32_t num_ents, i;
+	TALLOC_CTX *tmp_ctx;
+	uint32_t result = EPMAPPER_STATUS_OK;
+	NTSTATUS status;
+
+	if (iface == NULL) {
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+
+	if (bind_vec == NULL || bind_vec->count == 0) {
+		return NT_STATUS_INVALID_PARAMETER;
+	}
+
+	tmp_ctx = talloc_stackframe();
+	if (tmp_ctx == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+#if 0
+	/* NOTE: Samba3 doesn't have a ncalrpc server component yet. As soon as
+	 * this is supported, we should talk to the endpoint mapper over the
+	 * local transport.
+	 */
+
+	/* Connect to the endpoint mapper locally */
+	ncalrpc_sock = talloc_asprintf(tmp_ctx,
+				      "%s/%s",
+				      get_dyn_NCALRPCDIR(),
+				      "epmapper");
+	if (ncalrpc_sock == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto done;
+	}
+
+	status = rpc_pipe_open_ncalrpc(tmp_ctx,
+				       ncalrpc_sock,
+				       &ndr_table_epmapper.syntax_id,
+				       &cli);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+#endif
+
+	strlcpy(client_id.addr, "localhost", sizeof(client_id.addr));
+	client_id.name = "localhost";
+
+	status = rpcint_binding_handle(tmp_ctx,
+				       &ndr_table_epmapper,
+				       &client_id,
+				       get_server_info_system(),
+				       server_messaging_context(),
+				       &h);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0, ("dcerpc_ep_register: Could not connect to epmapper (%s)",
+			  nt_errstr(status)));
+		goto done;
+	}
+
+	num_ents = bind_vec->count;
+	entries = talloc_array(tmp_ctx, struct epm_entry_t, num_ents);
+
+	for (i = 0; i < num_ents; i++) {
+		struct dcerpc_binding *map_binding = &bind_vec->bindings[i];
+		struct epm_twr_t *map_tower;
+
+		map_tower = talloc_zero(entries, struct epm_twr_t);
+		if (map_tower == NULL) {
+			goto done;
+		}
+
+		status = dcerpc_binding_build_tower(entries,
+						    map_binding,
+						    &map_tower->tower);
+		if (!NT_STATUS_IS_OK(status)) {
+			goto done;
+		}
+
+		entries[i].tower = map_tower;
+		if (annotation == NULL) {
+			entries[i].annotation = talloc_strdup(entries, "");
+		} else {
+			entries[i].annotation = talloc_strndup(entries,
+							       annotation,
+							       EPM_MAX_ANNOTATION_SIZE);
+		}
+		if (entries[i].annotation == NULL) {
+			status = NT_STATUS_NO_MEMORY;
+			goto done;
+		}
+
+		if (object_guid != NULL) {
+			entries[i].object = *object_guid;
+		} else {
+			entries[i].object = map_binding->object.uuid;
+		}
+	}
+
+	if (unregister) {
+		status = dcerpc_epm_Delete(h,
+					   tmp_ctx,
+					   num_ents,
+					   entries,
+					   &result);
+	} else {
+		status = dcerpc_epm_Insert(h,
+					   tmp_ctx,
+					   num_ents,
+					   entries,
+					   replace,
+					   &result);
+	}
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(0, ("dcerpc_ep_register: Could not insert tower (%s)\n",
+			  nt_errstr(status)));
+		goto done;
+	}
+	if (result != EPMAPPER_STATUS_OK) {
+		DEBUG(0, ("dcerpc_ep_register: Could not insert tower (0x%.8x)\n",
+			  result));
+		status = NT_STATUS_UNSUCCESSFUL;
+		goto done;
+	}
+
+done:
+	talloc_free(tmp_ctx);
+
+	return status;
+}
+
+NTSTATUS dcerpc_ep_register(const struct ndr_interface_table *iface,
+			    const struct dcerpc_binding_vector *bind_vec,
+			    const struct GUID *object_guid,
+			    const char *annotation)
+{
+	return ep_register(iface, bind_vec, object_guid, annotation, 1, 0);
+}
+
+NTSTATUS dcerpc_ep_register_noreplace(const struct ndr_interface_table *iface,
+				      const struct dcerpc_binding_vector *bind_vec,
+				      const struct GUID *object_guid,
+				      const char *annotation)
+{
+	return ep_register(iface, bind_vec, object_guid, annotation, 0, 0);
+}
+
+NTSTATUS dcerpc_ep_unregister(const struct ndr_interface_table *iface,
+			      const struct dcerpc_binding_vector *bind_vec,
+			      const struct GUID *object_guid)
+{
+	return ep_register(iface, bind_vec, object_guid, NULL, 0, 1);
+}
+
+/* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */
diff --git a/source3/librpc/rpc/dcerpc_ep.h b/source3/librpc/rpc/dcerpc_ep.h
new file mode 100644
index 0000000..6da7f9b
--- /dev/null
+++ b/source3/librpc/rpc/dcerpc_ep.h
@@ -0,0 +1,72 @@
+/*
+ *  Endpoint Mapper Functions
+ *  DCERPC local endpoint mapper client routines
+ *  Copyright (c) 2010      Andreas Schneider.
+ *
+ *  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 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _DCERPC_EP_H_
+#define _DCERPC_EP_H_
+
+struct dcerpc_binding_vector {
+    struct dcerpc_binding *bindings;
+    uint32_t count;
+};
+
+NTSTATUS dcerpc_binding_vector_create(TALLOC_CTX *mem_ctx,
+				      const struct ndr_interface_table *iface,
+				      struct dcerpc_binding_vector **pbvec);
+
+/**
+ * @brief Adds server address information in the local endpoint map.
+ *
+ * @param[in]  iface    The interface specification to register with the local
+ *                      endpoint map.
+ *
+ * @param[in]  binding  The server binding handles over which the server can
+ *                      receive remote procedure calls.
+ *
+ * @param[in]  object_guid The object GUID that the server offers. The server
+ *                         application constructs this vector.
+ *
+ * @param[in]  annotation  Defines a character string comment applied to the
+ *                         element added to the local endpoint map. The string
+ *                         can be up to 64 characters long, including the null
+ *                         terminating character. Strings longer than 64
+ *                         characters are truncated. The application supplies
+ *                         the value NULL or the string "" to indicate an empty
+ *                         annotation string.
+ *
+ *                         When replacing elements, the annotation string
+ *                         supplied, including an empty annotation string,
+ *                         replaces any existing annotation string.
+ *
+ * @return                 An NTSTATUS error code.
+ */
+NTSTATUS dcerpc_ep_register(const struct ndr_interface_table *iface,
+			    const struct dcerpc_binding_vector *bind_vec,
+			    const struct GUID *object_guid,
+			    const char *annotation);
+
+NTSTATUS dcerpc_ep_register_noreplace(const struct ndr_interface_table *iface,
+				      const struct dcerpc_binding_vector *bind_vec,
+				      const struct GUID *object_guid,
+				      const char *annotation);
+
+NTSTATUS dcerpc_ep_unregister(const struct ndr_interface_table *iface,
+			      const struct dcerpc_binding_vector *bind_vec,
+			      const struct GUID *object_guid);
+
+#endif /* _DCERPC_EP_H_ */
diff --git a/source3/rpc_server/srv_epmapper.c b/source3/rpc_server/srv_epmapper.c
new file mode 100644
index 0000000..0ec50a4
--- /dev/null
+++ b/source3/rpc_server/srv_epmapper.c
@@ -0,0 +1,1038 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Endpoint server for the epmapper pipe
+
+   Copyright (C) 2010-2011 Andreas Schneider <asn at samba.org>
+
+   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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "../libcli/security/security.h"
+#include "librpc/gen_ndr/ndr_epmapper.h"
+#include "librpc/gen_ndr/srv_epmapper.h"
+
+typedef uint32_t error_status_t;
+
+/* An endpoint combined with an interface description */
+struct dcesrv_ep_iface {
+	const char *name;
+	struct ndr_syntax_id syntax_id;
+	struct epm_tower ep;
+};
+
+/* A rpc service interface like samr, lsarpc or netlogon */
+struct dcesrv_iface {
+	const char *name;
+	struct ndr_syntax_id syntax_id;
+};
+
+struct dcesrv_iface_list {
+	struct dcesrv_iface_list *next, *prev;
+	struct dcesrv_iface *iface;
+};
+
+/*
+ * An endpoint can serve multiple rpc services interfaces.
+ * For example \\pipe\netlogon can be used by lsarpc and netlogon.
+ */
+struct dcesrv_endpoint {
+	struct dcesrv_endpoint *next, *prev;
+
+	/* The type and the location of the endpoint */
+	struct dcerpc_binding *ep_description;
+
+	/* A list of rpc services able to connect to the endpoint */
+	struct dcesrv_iface_list *iface_list;
+};
+
+struct rpc_eps {
+	struct dcesrv_ep_iface *e;
+	uint32_t count;
+};
+
+struct dcesrv_endpoint *endpoint_table;
+
+/*
+ * Check if the UUID and if_version match to an interface.
+ */
+static bool interface_match(const struct dcesrv_iface *if1,
+			    const struct dcesrv_iface *if2)
+{
+	return GUID_equal(&if1->syntax_id.uuid, &if2->syntax_id.uuid);
+}
+
+/*
+ * Find the interface operations on an endpoint.
+ */
+static const struct dcesrv_iface *find_interface(const struct dcesrv_endpoint *endpoint,
+						 const struct dcesrv_iface *iface)
+{
+	struct dcesrv_iface_list *iflist;
+
+	for (iflist = endpoint->iface_list; iflist; iflist = iflist->next) {
+		if (interface_match(iflist->iface, iface)) {
+			return iflist->iface;
+		}
+	}
+
+	return NULL;
+}
+
+/*
+ * See if a uuid and if_version match to an interface
+ */
+static bool interface_match_by_uuid(const struct dcesrv_iface *iface,
+				    const struct GUID *uuid)
+{
+	return GUID_equal(&iface->syntax_id.uuid, uuid);
+}
+
+static struct dcesrv_iface_list *find_interface_list(const struct dcesrv_endpoint *endpoint,
+						     const struct dcesrv_iface *iface)
+{
+	struct dcesrv_iface_list *iflist;
+
+	for (iflist = endpoint->iface_list; iflist; iflist = iflist->next) {
+		if (interface_match(iflist->iface, iface)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list