summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2011-02-23 15:39:33 +0100
committerGünther Deschner <gd@samba.org>2011-03-08 11:41:29 +0100
commit148ed2c3f96810a19e8fc96196695028b6bec530 (patch)
tree9b0ff98e3d0219598291cc61fb46216bbb2fa9fb
parent0a2251da549b2cb1cff43116c9b3446c524345e2 (diff)
downloadsamba-148ed2c3f96810a19e8fc96196695028b6bec530.tar.gz
samba-148ed2c3f96810a19e8fc96196695028b6bec530.tar.bz2
samba-148ed2c3f96810a19e8fc96196695028b6bec530.zip
s3-librpc: Register endpoints using ncalrpc.
Signed-off-by: Günther Deschner <gd@samba.org>
-rw-r--r--source3/librpc/rpc/dcerpc_ep.c92
1 files changed, 56 insertions, 36 deletions
diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c
index 7e980e9bf4..f183efeb80 100644
--- a/source3/librpc/rpc/dcerpc_ep.c
+++ b/source3/librpc/rpc/dcerpc_ep.c
@@ -123,8 +123,11 @@ static NTSTATUS ep_register(const struct ndr_interface_table *iface,
uint32_t replace,
uint32_t unregister)
{
- struct dcerpc_binding_handle *h = NULL;
- static struct client_address client_id;
+ struct rpc_pipe_client *cli = NULL;
+ struct dcerpc_binding_handle *h;
+ struct pipe_auth_data *auth;
+ const char *ncalrpc_sock;
+ const char *rpcsrv_type;
struct epm_entry_t *entries;
uint32_t num_ents, i;
TALLOC_CTX *tmp_ctx;
@@ -144,43 +147,60 @@ static NTSTATUS ep_register(const struct ndr_interface_table *iface,
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;
- }
+ rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+ "rpc_server", "epmapper",
+ "none");
- status = rpc_pipe_open_ncalrpc(tmp_ctx,
- ncalrpc_sock,
- &ndr_table_epmapper.syntax_id,
- &cli);
- if (!NT_STATUS_IS_OK(status)) {
- goto done;
- }
-#endif
+ if (StrCaseCmp(rpcsrv_type, "embedded") == 0) {
+ static struct client_address client_id;
- strlcpy(client_id.addr, "localhost", sizeof(client_id.addr));
- client_id.name = "localhost";
+ 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_session_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)));
+ status = rpcint_binding_handle(tmp_ctx,
+ &ndr_table_epmapper,
+ &client_id,
+ get_session_info_system(),
+ server_messaging_context(),
+ &h);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("dcerpc_ep_register: Could not connect to "
+ "epmapper (%s)", nt_errstr(status)));
+ goto done;
+ }
+ } else if (StrCaseCmp(rpcsrv_type, "daemon") == 0) {
+ /* Connect to the endpoint mapper locally */
+ ncalrpc_sock = talloc_asprintf(tmp_ctx,
+ "%s/%s",
+ lp_ncalrpc_dir(),
+ "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;
+ }
+
+ status = rpccli_ncalrpc_bind_data(cli, &auth);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Failed to initialize anonymous bind.\n"));
+ goto done;
+ }
+
+ status = rpc_pipe_bind(cli, auth);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(2, ("Failed to bind ncalrpc socket.\n"));
+ goto done;
+ }
+
+ h = cli->binding_handle;
+ } else {
goto done;
}