From 82020a3f62de17db41b839d53e63f89b80605e88 Mon Sep 17 00:00:00 2001 From: Samuel Cabrero Date: Wed, 27 Feb 2019 19:32:26 +0100 Subject: [PATCH] s3:rpc_server: Drop dcerpc_binding_vector usage in the server side The endpoint mapper entry is built using the dcesrv_endpoint and the interfaces registered into it instead of using the dcerpc_binding_vector. Signed-off-by: Samuel Cabrero Reviewed-by: Andrew Bartlett --- source3/librpc/rpc/dcerpc_ep.c | 381 +++++------------------------- source3/librpc/rpc/dcerpc_ep.h | 102 +------- source3/printing/spoolssd.c | 42 ++-- source3/rpc_server/epmd.c | 1 - source3/rpc_server/fssd.c | 1 - source3/rpc_server/lsasd.c | 104 ++------ source3/rpc_server/mdssd.c | 47 ++-- source3/rpc_server/mdssvc/srv_mdssvc_nt.c | 10 - source3/rpc_server/rpc_ep_register.c | 31 ++- source3/rpc_server/rpc_ep_register.h | 7 +- source3/rpc_server/rpc_service_setup.c | 155 ++---------- source3/rpc_server/rpc_service_setup.h | 7 +- source3/rpc_server/rpc_sock_helper.c | 132 ----------- source3/rpc_server/rpc_sock_helper.h | 2 - 14 files changed, 152 insertions(+), 870 deletions(-) diff --git a/source3/librpc/rpc/dcerpc_ep.c b/source3/librpc/rpc/dcerpc_ep.c index da26fab76ae..6ac098c1b03 100644 --- a/source3/librpc/rpc/dcerpc_ep.c +++ b/source3/librpc/rpc/dcerpc_ep.c @@ -25,315 +25,16 @@ #include "auth.h" #include "rpc_server/rpc_ncacn_np.h" #include "../lib/tsocket/tsocket.h" + +#include "librpc/rpc/dcesrv_core.h" #include "rpc_server/rpc_config.h" #define EPM_MAX_ANNOTATION_SIZE 64 -struct dcerpc_binding_vector { - struct dcerpc_binding **bindings; - uint32_t count; - uint32_t allocated; -}; - -static bool binding_vector_realloc(struct dcerpc_binding_vector *bvec) -{ - if (bvec->count >= bvec->allocated) { - struct dcerpc_binding **tmp; - - tmp = talloc_realloc(bvec, - bvec->bindings, - struct dcerpc_binding *, - bvec->allocated * 2); - if (tmp == NULL) { - return false; - } - bvec->bindings = tmp; - bvec->allocated = bvec->allocated * 2; - } - - return true; -} - -NTSTATUS dcerpc_binding_vector_new(TALLOC_CTX *mem_ctx, - struct dcerpc_binding_vector **pbvec) -{ - struct dcerpc_binding_vector *bvec; - NTSTATUS status; - TALLOC_CTX *tmp_ctx; - - tmp_ctx = talloc_stackframe(); - if (tmp_ctx == NULL) { - return NT_STATUS_NO_MEMORY; - } - - bvec = talloc_zero(tmp_ctx, struct dcerpc_binding_vector); - if (bvec == NULL) { - status = NT_STATUS_NO_MEMORY; - goto done; - } - - bvec->bindings = talloc_zero_array(bvec, - struct dcerpc_binding *, - 4); - if (bvec->bindings == NULL) { - status = NT_STATUS_NO_MEMORY; - goto done; - } - - bvec->allocated = 4; - bvec->count = 0; - - *pbvec = talloc_move(mem_ctx, &bvec); - - status = NT_STATUS_OK; -done: - talloc_free(tmp_ctx); - - return status; -} - -NTSTATUS dcerpc_binding_vector_add_np_default(const struct ndr_interface_table *iface, - struct dcerpc_binding_vector *bvec) -{ - uint32_t ep_count = iface->endpoints->count; - uint32_t i; - NTSTATUS status; - bool ok; - - for (i = 0; i < ep_count; i++) { - struct dcerpc_binding *b; - enum dcerpc_transport_t transport; - char *unc = NULL; - - status = dcerpc_parse_binding(bvec->bindings, - iface->endpoints->names[i], - &b); - if (!NT_STATUS_IS_OK(status)) { - return NT_STATUS_UNSUCCESSFUL; - } - - /* Only add the named pipes defined in the iface endpoints */ - transport = dcerpc_binding_get_transport(b); - if (transport != NCACN_NP) { - talloc_free(b); - continue; - } - - status = dcerpc_binding_set_abstract_syntax(b, &iface->syntax_id); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(b); - return NT_STATUS_UNSUCCESSFUL; - } - - unc = talloc_asprintf(b, "\\\\%s", lp_netbios_name()); - if (unc == NULL) { - talloc_free(b); - return NT_STATUS_NO_MEMORY; - } - - status = dcerpc_binding_set_string_option(b, "host", unc); - TALLOC_FREE(unc); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(b); - return NT_STATUS_NO_MEMORY; - } - - ok = binding_vector_realloc(bvec); - if (!ok) { - talloc_free(b); - return NT_STATUS_NO_MEMORY; - } - - bvec->bindings[bvec->count] = b; - bvec->count++; - } - - return NT_STATUS_OK; -} - -NTSTATUS dcerpc_binding_vector_add_port(const struct ndr_interface_table *iface, - struct dcerpc_binding_vector *bvec, - const char *host, - uint16_t _port) -{ - uint32_t ep_count = iface->endpoints->count; - uint32_t i; - NTSTATUS status; - bool ok; - char port[6]; - - snprintf(port, sizeof(port), "%u", _port); - - for (i = 0; i < ep_count; i++) { - struct dcerpc_binding *b; - enum dcerpc_transport_t transport; - - status = dcerpc_parse_binding(bvec->bindings, - iface->endpoints->names[i], - &b); - if (!NT_STATUS_IS_OK(status)) { - return NT_STATUS_UNSUCCESSFUL; - } - - transport = dcerpc_binding_get_transport(b); - if (transport != NCACN_IP_TCP) { - talloc_free(b); - continue; - } - - status = dcerpc_binding_set_abstract_syntax(b, &iface->syntax_id); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(b); - return NT_STATUS_UNSUCCESSFUL; - } - - status = dcerpc_binding_set_string_option(b, "host", host); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(b); - return NT_STATUS_UNSUCCESSFUL; - } - - status = dcerpc_binding_set_string_option(b, "endpoint", port); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(b); - return NT_STATUS_UNSUCCESSFUL; - } - - ok = binding_vector_realloc(bvec); - if (!ok) { - talloc_free(b); - return NT_STATUS_NO_MEMORY; - } - - bvec->bindings[bvec->count] = b; - bvec->count++; - - break; - } - - return NT_STATUS_OK; -} - -NTSTATUS dcerpc_binding_vector_add_unix(const struct ndr_interface_table *iface, - struct dcerpc_binding_vector *bvec, - const char *name) -{ - uint32_t ep_count = iface->endpoints->count; - uint32_t i; - NTSTATUS status; - bool ok; - - for (i = 0; i < ep_count; i++) { - struct dcerpc_binding *b; - enum dcerpc_transport_t transport; - char *endpoint = NULL; - - status = dcerpc_parse_binding(bvec->bindings, - iface->endpoints->names[i], - &b); - if (!NT_STATUS_IS_OK(status)) { - return NT_STATUS_UNSUCCESSFUL; - } - - transport = dcerpc_binding_get_transport(b); - if (transport != NCALRPC) { - talloc_free(b); - continue; - } - - status = dcerpc_binding_set_abstract_syntax(b, &iface->syntax_id); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(b); - return NT_STATUS_UNSUCCESSFUL; - } - - endpoint = talloc_asprintf(b, - "%s/%s", - lp_ncalrpc_dir(), - name); - if (endpoint == NULL) { - talloc_free(b); - return NT_STATUS_NO_MEMORY; - } - - status = dcerpc_binding_set_string_option(b, "endpoint", endpoint); - TALLOC_FREE(endpoint); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(b); - return NT_STATUS_UNSUCCESSFUL; - } - - ok = binding_vector_realloc(bvec); - if (!ok) { - talloc_free(b); - return NT_STATUS_NO_MEMORY; - } - - bvec->bindings[bvec->count] = b; - bvec->count++; - - break; - } - - return NT_STATUS_OK; -} - -NTSTATUS dcerpc_binding_vector_replace_iface(const struct ndr_interface_table *iface, - struct dcerpc_binding_vector *v) -{ - uint32_t i; - - for (i = 0; i < v->count; i++) { - struct dcerpc_binding *b = v->bindings[i]; - NTSTATUS status; - - status = dcerpc_binding_set_abstract_syntax(b, - &iface->syntax_id); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - } - - return NT_STATUS_OK; -} - -struct dcerpc_binding_vector *dcerpc_binding_vector_dup(TALLOC_CTX *mem_ctx, - const struct dcerpc_binding_vector *bvec) -{ - struct dcerpc_binding_vector *v; - uint32_t i; - - v = talloc(mem_ctx, struct dcerpc_binding_vector); - if (v == NULL) { - return NULL; - } - - v->bindings = talloc_array(v, struct dcerpc_binding *, bvec->allocated); - if (v->bindings == NULL) { - talloc_free(v); - return NULL; - } - v->allocated = bvec->allocated; - - for (i = 0; i < bvec->count; i++) { - struct dcerpc_binding *b; - - b = dcerpc_binding_dup(v->bindings, bvec->bindings[i]); - if (b == NULL) { - talloc_free(v); - return NULL; - } - v->bindings[i] = b; - } - v->count = bvec->count; - - return v; -} - static NTSTATUS ep_register(TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *bind_vec, + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface, const struct GUID *object_guid, const char *annotation, uint32_t replace, @@ -345,17 +46,40 @@ static NTSTATUS ep_register(TALLOC_CTX *mem_ctx, struct pipe_auth_data *auth; const char *ncalrpc_sock; enum rpc_service_mode_e epmd_mode; - struct epm_entry_t *entries; - uint32_t num_ents, i; + struct epm_entry_t *entries = NULL; + uint32_t i = 0; TALLOC_CTX *tmp_ctx; uint32_t result = EPMAPPER_STATUS_OK; NTSTATUS status; + struct dcesrv_endpoint *ep; + bool found = false; if (iface == NULL) { return NT_STATUS_INVALID_PARAMETER; } - if (bind_vec == NULL || bind_vec->count == 0) { + if (dce_ctx == NULL || iface == NULL) { + return NT_STATUS_INVALID_PARAMETER; + } + + /* Check if interface is registered */ + for (ep = dce_ctx->endpoint_list; ep; ep = ep->next) { + struct dcesrv_if_list *ifl; + for (ifl = ep->interface_list; ifl; ifl = ifl->next) { + if (ndr_syntax_id_equal(&ifl->iface->syntax_id, + &iface->syntax_id)) { + found = true; + break; + } + } + if (found) { + break; + } + } + if (!found) { + DBG_ERR("Failed to register interface '%s' in the endpoint " + "mapper as it is not registered in any endpoint\n", + iface->name); return NT_STATUS_INVALID_PARAMETER; } @@ -428,14 +152,27 @@ static NTSTATUS ep_register(TALLOC_CTX *mem_ctx, 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++) { + for (i = 0, ep = dce_ctx->endpoint_list; ep; i++, ep = ep->next) { struct dcerpc_binding *map_binding; struct epm_twr_t *map_tower; + struct dcesrv_if_list *ifl; + + for (ifl = ep->interface_list; ifl; ifl = ifl->next) { + if (!ndr_syntax_id_equal(&ifl->iface->syntax_id, + &iface->syntax_id)) { + continue; + } + } + + /* The interface is registered in this endpoint, add it */ + entries = talloc_realloc(tmp_ctx, entries, struct epm_entry_t, + i + 1); + if (entries == NULL) { + status = NT_STATUS_NO_MEMORY; + goto done; + } - map_binding = dcerpc_binding_dup(entries, bind_vec->bindings[i]); + map_binding = dcerpc_binding_dup(entries, ep->ep_description); if (map_binding == NULL) { status = NT_STATUS_NO_MEMORY; goto done; @@ -485,13 +222,13 @@ static NTSTATUS ep_register(TALLOC_CTX *mem_ctx, if (unregister) { status = dcerpc_epm_Delete(h, tmp_ctx, - num_ents, + i, entries, &result); } else { status = dcerpc_epm_Insert(h, tmp_ctx, - num_ents, + i, entries, replace, &result); @@ -521,16 +258,16 @@ done: NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *bind_vec, + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface, const struct GUID *object_guid, const char *annotation, struct dcerpc_binding_handle **ph) { return ep_register(mem_ctx, msg_ctx, + dce_ctx, iface, - bind_vec, object_guid, annotation, 1, @@ -540,16 +277,16 @@ NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *bind_vec, + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface, const struct GUID *object_guid, const char *annotation, struct dcerpc_binding_handle **ph) { return ep_register(mem_ctx, msg_ctx, + dce_ctx, iface, - bind_vec, object_guid, annotation, 0, @@ -558,14 +295,14 @@ NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx, } NTSTATUS dcerpc_ep_unregister(struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *bind_vec, + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface, const struct GUID *object_guid) { return ep_register(NULL, msg_ctx, + dce_ctx, iface, - bind_vec, object_guid, NULL, 0, diff --git a/source3/librpc/rpc/dcerpc_ep.h b/source3/librpc/rpc/dcerpc_ep.h index 6cd46830a58..f8437953225 100644 --- a/source3/librpc/rpc/dcerpc_ep.h +++ b/source3/librpc/rpc/dcerpc_ep.h @@ -20,99 +20,17 @@ #ifndef _DCERPC_EP_H_ #define _DCERPC_EP_H_ -struct dcerpc_binding_vector; - -/** - * @brief Allocate a new binding vector. - * - * @param[in] mem_ctx The memory context to allocate the vector. - * - * @param[out] pbvec A pointer to store the binding vector. - * - * @return An NTSTATUS error code. - */ -NTSTATUS dcerpc_binding_vector_new(TALLOC_CTX *mem_ctx, - struct dcerpc_binding_vector **pbvec); - -/** - * @brief Add default named pipes to the binding vector. - * - * @param[in] iface The rpc interface to add. - * - * @param[in] bvec The binding vector to add the interface. - * - * @return An NTSTATUS error code. - */ -NTSTATUS dcerpc_binding_vector_add_np_default(const struct ndr_interface_table *iface, - struct dcerpc_binding_vector *bvec); - -/** - * @brief Add a tcpip port to a binding vector. - * - * @param[in] iface The rpc interface to add. - * - * @param[in] bvec The binding vector to add the interface, host and port. - * - * @param[in] host The ip address of the network interface bound. - * - * @param[in] port The port bound. - * - * @return An NTSTATUS error code. - */ -NTSTATUS dcerpc_binding_vector_add_port(const struct ndr_interface_table *iface, - struct dcerpc_binding_vector *bvec, - const char *host, - uint16_t port); - -/** - * @brief Add a unix socket (ncalrpc) to a binding vector. - * - * @param[in] iface The rpc interface to add. - * - * @param[in] bvec The binding vector to add the interface, host and port. - * - * @param[in] name The name of the unix socket. - * - * @return An NTSTATUS error code. - */ -NTSTATUS dcerpc_binding_vector_add_unix(const struct ndr_interface_table *iface, - struct dcerpc_binding_vector *bvec, - const char *name); - -/** - * @brief Duplicate a dcerpc_binding_vector. - * - * @param[in] mem_ctx The memory context to create the duplicate on. - * - * @param[in] bvec The binding vector to duplicate. - * - * @return The duplicated binding vector or NULL on error. - */ -struct dcerpc_binding_vector *dcerpc_binding_vector_dup(TALLOC_CTX *mem_ctx, - const struct dcerpc_binding_vector *bvec); - -/** - * @brief Replace the interface of the bindings in the vector. - * - * @param[in] iface The new interface identifier to use. - * - * @param[in] v The binding vector to change. - * - * @return An NTSTATUS error code. - */ -NTSTATUS dcerpc_binding_vector_replace_iface(const struct ndr_interface_table *iface, - struct dcerpc_binding_vector *v); +struct dcesrv_context; +struct dcesrv_interface; /** * @brief Adds server address information in the local endpoint map. * * @param[in] mem_ctx The memory context to use for the binding handle. * - * @param[in] iface The interface specification to register with the local - * endpoint map. + * @param[in] dce_ctx The dcerpc server context * - * @param[in] binding The server binding handles over which the server can - * receive remote procedure calls. + * @param[in] iface The interface to register in the endpoint mapper * * @param[in] object_guid The object GUID that the server offers. The server * application constructs this vector. @@ -137,23 +55,23 @@ NTSTATUS dcerpc_binding_vector_replace_iface(const struct ndr_interface_table *i */ NTSTATUS dcerpc_ep_register(TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *bind_vec, + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface, const struct GUID *object_guid, const char *annotation, struct dcerpc_binding_handle **ph); NTSTATUS dcerpc_ep_register_noreplace(TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *bind_vec, + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface, const struct GUID *object_guid, const char *annotation, struct dcerpc_binding_handle **ph); NTSTATUS dcerpc_ep_unregister(struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *bind_vec, + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface, const struct GUID *object_guid); #endif /* _DCERPC_EP_H_ */ diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c index cad2ad2317e..6ddbf4a220f 100644 --- a/source3/printing/spoolssd.c +++ b/source3/printing/spoolssd.c @@ -574,8 +574,6 @@ static NTSTATUS spoolssd_create_sockets(struct tevent_context *ev_ctx, struct pf_listen_fd *listen_fd, int *listen_fd_size) { - struct dcerpc_binding_vector *v = NULL; - TALLOC_CTX *tmp_ctx; NTSTATUS status; int fd = -1; int rc; @@ -583,18 +581,6 @@ static NTSTATUS spoolssd_create_sockets(struct tevent_context *ev_ctx, uint32_t i; struct dcesrv_endpoint *e = NULL; - tmp_ctx = talloc_stackframe(); - if (tmp_ctx == NULL) { - return NT_STATUS_NO_MEMORY; - } - - status = dcerpc_binding_vector_new(tmp_ctx, &v); - if (!NT_STATUS_IS_OK(status)) { - DBG_ERR("Failed to create binding vector (%s)\n", - nt_errstr(status)); - goto done; - } - DBG_INFO("Initializing DCE/RPC connection endpoints\n"); for (e = dce_ctx->endpoint_list; e; e = e->next) { @@ -602,7 +588,6 @@ static NTSTATUS spoolssd_create_sockets(struct tevent_context *ev_ctx, msg_ctx, dce_ctx, e, - v, listen_fd, listen_fd_size); if (!NT_STATUS_IS_OK(status)) { @@ -630,18 +615,20 @@ static NTSTATUS spoolssd_create_sockets(struct tevent_context *ev_ctx, if (epm_mode != RPC_SERVICE_MODE_DISABLED && (lp_parm_bool(-1, "rpc_server", "register_embedded_np", false))) { - status = dcerpc_binding_vector_add_np_default(&ndr_table_spoolss, v); - if (!NT_STATUS_IS_OK(status)) { - DBG_ERR("Failed to add np to binding vector (%s)\n", - nt_errstr(status)); - goto done; - } - - status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_spoolss, v); - if (!NT_STATUS_IS_OK(status)) { - DBG_ERR("Failed to register spoolss endpoint! (%s)\n", - nt_errstr(status)); - goto done; + for (e = dce_ctx->endpoint_list; e; e = e->next) { + struct dcesrv_if_list *ifl = NULL; + for (ifl = e->interface_list; ifl; ifl = ifl->next) { + status = rpc_ep_register(ev_ctx, + msg_ctx, + dce_ctx, + ifl->iface); + if (!NT_STATUS_IS_OK(status)) { + DBG_ERR("Failed to register interface" + " in endpoint mapper: %s\n", + nt_errstr(status)); + goto done; + } + } } } @@ -651,7 +638,6 @@ done: close(fd); } - talloc_free(tmp_ctx); return status; } diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c index 2692276394d..15049c317e7 100644 --- a/source3/rpc_server/epmd.c +++ b/source3/rpc_server/epmd.c @@ -225,7 +225,6 @@ void start_epmd(struct tevent_context *ev_ctx, msg_ctx, dce_ctx, e, - NULL, /* binding vector */ term_fn, NULL); /* termination_data */ if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/rpc_server/fssd.c b/source3/rpc_server/fssd.c index c625b45e10c..60d2b74ffd3 100644 --- a/source3/rpc_server/fssd.c +++ b/source3/rpc_server/fssd.c @@ -214,7 +214,6 @@ void start_fssd(struct tevent_context *ev_ctx, msg_ctx, dce_ctx, e, - NULL, /* binding vector */ NULL, /* termination function */ NULL); /* termination data */ if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/rpc_server/lsasd.c b/source3/rpc_server/lsasd.c index 031679f31f0..9d7be4a7a0c 100644 --- a/source3/rpc_server/lsasd.c +++ b/source3/rpc_server/lsasd.c @@ -580,24 +580,12 @@ static NTSTATUS lsasd_create_sockets(struct tevent_context *ev_ctx, struct pf_listen_fd *listen_fd, int *listen_fd_size) { - struct dcerpc_binding_vector *v, *v_orig; - TALLOC_CTX *tmp_ctx; NTSTATUS status; int i; int fd = -1; int rc; struct dcesrv_endpoint *e = NULL; - tmp_ctx = talloc_stackframe(); - if (tmp_ctx == NULL) { - return NT_STATUS_NO_MEMORY; - } - - status = dcerpc_binding_vector_new(tmp_ctx, &v_orig); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - DBG_INFO("Initializing DCE/RPC connection endpoints\n"); for (e = dce_ctx->endpoint_list; e; e = e->next) { @@ -605,7 +593,6 @@ static NTSTATUS lsasd_create_sockets(struct tevent_context *ev_ctx, msg_ctx, dce_ctx, e, - v_orig, listen_fd, listen_fd_size); if (!NT_STATUS_IS_OK(status)) { @@ -631,82 +618,20 @@ static NTSTATUS lsasd_create_sockets(struct tevent_context *ev_ctx, } } - /* LSARPC */ - v = dcerpc_binding_vector_dup(tmp_ctx, v_orig); - if (v == NULL) { - goto done; - } - - status = dcerpc_binding_vector_replace_iface(&ndr_table_lsarpc, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = dcerpc_binding_vector_add_np_default(&ndr_table_lsarpc, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = dcerpc_binding_vector_add_unix(&ndr_table_lsarpc, v, "lsarpc"); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_lsarpc, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - /* SAMR */ - v = dcerpc_binding_vector_dup(tmp_ctx, v_orig); - if (v == NULL) { - goto done; - } - - status = dcerpc_binding_vector_replace_iface(&ndr_table_samr, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = dcerpc_binding_vector_add_np_default(&ndr_table_samr, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = dcerpc_binding_vector_add_unix(&ndr_table_lsarpc, v, "samr"); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_samr, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - /* NETLOGON */ - v = dcerpc_binding_vector_dup(tmp_ctx, v_orig); - if (v == NULL) { - goto done; - } - - status = dcerpc_binding_vector_replace_iface(&ndr_table_netlogon, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = dcerpc_binding_vector_add_np_default(&ndr_table_netlogon, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = dcerpc_binding_vector_add_unix(&ndr_table_lsarpc, v, "netlogon"); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_netlogon, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; + for (e = dce_ctx->endpoint_list; e; e = e->next) { + struct dcesrv_if_list *ifl = NULL; + for (ifl = e->interface_list; ifl; ifl = ifl->next) { + status = rpc_ep_register(ev_ctx, + msg_ctx, + dce_ctx, + ifl->iface); + if (!NT_STATUS_IS_OK(status)) { + DBG_ERR("Failed to register interface in " + "endpoint mapper: %s", + nt_errstr(status)); + goto done; + } + } } status = NT_STATUS_OK; @@ -714,7 +639,6 @@ done: if (fd != -1) { close(fd); } - talloc_free(tmp_ctx); return status; } diff --git a/source3/rpc_server/mdssd.c b/source3/rpc_server/mdssd.c index f183c14bd53..eafe7b99fea 100644 --- a/source3/rpc_server/mdssd.c +++ b/source3/rpc_server/mdssd.c @@ -527,24 +527,12 @@ static NTSTATUS mdssd_create_sockets(struct tevent_context *ev_ctx, struct pf_listen_fd *listen_fd, int *listen_fd_size) { - struct dcerpc_binding_vector *v, *v_orig; - TALLOC_CTX *tmp_ctx; NTSTATUS status; int fd = -1; int rc; uint32_t i; struct dcesrv_endpoint *e = NULL; - tmp_ctx = talloc_stackframe(); - if (tmp_ctx == NULL) { - return NT_STATUS_NO_MEMORY; - } - - status = dcerpc_binding_vector_new(tmp_ctx, &v_orig); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - DBG_INFO("Initializing DCE/RPC connection endpoints\n"); for (e = dce_ctx->endpoint_list; e; e = e->next) { @@ -552,7 +540,6 @@ static NTSTATUS mdssd_create_sockets(struct tevent_context *ev_ctx, msg_ctx, dce_ctx, e, - v_orig, listen_fd, listen_fd_size); if (!NT_STATUS_IS_OK(status)) { @@ -578,25 +565,20 @@ static NTSTATUS mdssd_create_sockets(struct tevent_context *ev_ctx, } } - /* mdssvc */ - v = dcerpc_binding_vector_dup(tmp_ctx, v_orig); - if (v == NULL) { - goto done; - } - - status = dcerpc_binding_vector_replace_iface(&ndr_table_mdssvc, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = dcerpc_binding_vector_add_np_default(&ndr_table_mdssvc, v); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - - status = dcerpc_binding_vector_add_unix(&ndr_table_mdssvc, v, "mdssvc"); - if (!NT_STATUS_IS_OK(status)) { - goto done; + for (e = dce_ctx->endpoint_list; e; e = e->next) { + struct dcesrv_if_list *ifl = NULL; + for (ifl = e->interface_list; ifl; ifl = ifl->next) { + status = rpc_ep_register(ev_ctx, + msg_ctx, + dce_ctx, + ifl->iface); + if (!NT_STATUS_IS_OK(status)) { + DBG_ERR("Failed to register interface in " + "endpoint mapper: %s", + nt_errstr(status)); + goto done; + } + } } status = NT_STATUS_OK; @@ -604,7 +586,6 @@ done: if (fd != -1) { close(fd); } - talloc_free(tmp_ctx); return status; } diff --git a/source3/rpc_server/mdssvc/srv_mdssvc_nt.c b/source3/rpc_server/mdssvc/srv_mdssvc_nt.c index 12cb37b9d68..491f3252265 100644 --- a/source3/rpc_server/mdssvc/srv_mdssvc_nt.c +++ b/source3/rpc_server/mdssvc/srv_mdssvc_nt.c @@ -42,7 +42,6 @@ static bool rpc_setup_mdssvc(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { const struct ndr_interface_table *t = &ndr_table_mdssvc; - const char *pipe_name = "mdssvc"; NTSTATUS status; enum rpc_service_mode_e service_mode = rpc_service_mode(t->name); enum rpc_daemon_type_e mdssvc_type = rpc_mdssd_daemon(); @@ -68,15 +67,6 @@ static bool rpc_setup_mdssvc(struct tevent_context *ev_ctx, return false; } - if (external) { - return true; - } - - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return false; - } - return true; } diff --git a/source3/rpc_server/rpc_ep_register.c b/source3/rpc_server/rpc_ep_register.c index 30184f52724..cf28f04d207 100644 --- a/source3/rpc_server/rpc_ep_register.c +++ b/source3/rpc_server/rpc_ep_register.c @@ -25,6 +25,7 @@ #include "../librpc/gen_ndr/ndr_epmapper_c.h" #include "librpc/rpc/dcerpc_ep.h" +#include "librpc/rpc/dcesrv_core.h" #include "rpc_server/rpc_ep_register.h" #undef DBGC_CLASS @@ -34,8 +35,8 @@ static void rpc_ep_register_loop(struct tevent_req *subreq); static NTSTATUS rpc_ep_try_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *v, + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface, struct dcerpc_binding_handle **pbh); struct rpc_ep_register_state { @@ -43,22 +44,24 @@ struct rpc_ep_register_state { struct tevent_context *ev_ctx; struct messaging_context *msg_ctx; + struct dcesrv_context *dce_ctx; - const struct ndr_interface_table *iface; - const struct dcerpc_binding_vector *vector; + const struct dcesrv_interface *iface; uint32_t wait_time; }; NTSTATUS rpc_ep_register(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *v) + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface) { struct rpc_ep_register_state *state; struct tevent_req *req; - state = talloc(ev_ctx, struct rpc_ep_register_state); + /* Allocate under iface to stop the loop if the interface is + * removed from server */ + state = talloc_zero(iface, struct rpc_ep_register_state); if (state == NULL) { return NT_STATUS_NO_MEMORY; } @@ -66,12 +69,8 @@ NTSTATUS rpc_ep_register(struct tevent_context *ev_ctx, state->wait_time = 1; state->ev_ctx = ev_ctx; state->msg_ctx = msg_ctx; + state->dce_ctx = dce_ctx; state->iface = iface; - state->vector = dcerpc_binding_vector_dup(state, v); - if (state->vector == NULL) { - talloc_free(state); - return NT_STATUS_NO_MEMORY; - } req = tevent_wakeup_send(state, state->ev_ctx, @@ -106,8 +105,8 @@ static void rpc_ep_register_loop(struct tevent_req *subreq) status = rpc_ep_try_register(state, state->ev_ctx, state->msg_ctx, + state->dce_ctx, state->iface, - state->vector, &state->h); if (NT_STATUS_IS_OK(status)) { /* endpoint registered, monitor the connnection. */ @@ -145,16 +144,16 @@ static void rpc_ep_register_loop(struct tevent_req *subreq) static NTSTATUS rpc_ep_try_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *v, + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface, struct dcerpc_binding_handle **pbh) { NTSTATUS status; status = dcerpc_ep_register(mem_ctx, msg_ctx, + dce_ctx, iface, - v, &iface->syntax_id.uuid, iface->name, pbh); diff --git a/source3/rpc_server/rpc_ep_register.h b/source3/rpc_server/rpc_ep_register.h index 54ef58f76b7..cd61778edda 100644 --- a/source3/rpc_server/rpc_ep_register.h +++ b/source3/rpc_server/rpc_ep_register.h @@ -22,7 +22,8 @@ #ifndef _RPC_EP_REGISTER_H #define _RPC_EP_REGISTER_H -struct dcerpc_binding_vector; +struct dcesrv_context; +struct dcesrv_interface; /** * @brief Register an endpoint at the endpoint mapper. @@ -42,8 +43,8 @@ struct dcerpc_binding_vector; */ NTSTATUS rpc_ep_register(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *iface, - const struct dcerpc_binding_vector *v); + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface); #endif /* _RPC_EP_REGISTER_H */ diff --git a/source3/rpc_server/rpc_service_setup.c b/source3/rpc_server/rpc_service_setup.c index cb8d5b905d9..f0d819c088d 100644 --- a/source3/rpc_server/rpc_service_setup.c +++ b/source3/rpc_server/rpc_service_setup.c @@ -22,23 +22,6 @@ #include "includes.h" #include "ntdomain.h" -#include "../librpc/gen_ndr/ndr_epmapper_c.h" -#include "../librpc/gen_ndr/srv_epmapper.h" -#include "../librpc/gen_ndr/srv_srvsvc.h" -#include "../librpc/gen_ndr/srv_winreg.h" -#include "../librpc/gen_ndr/srv_dfs.h" -#include "../librpc/gen_ndr/srv_dssetup.h" -#include "../librpc/gen_ndr/srv_echo.h" -#include "../librpc/gen_ndr/srv_eventlog.h" -#include "../librpc/gen_ndr/srv_initshutdown.h" -#include "../librpc/gen_ndr/srv_lsa.h" -#include "../librpc/gen_ndr/srv_netlogon.h" -#include "../librpc/gen_ndr/srv_ntsvcs.h" -#include "../librpc/gen_ndr/srv_samr.h" -#include "../librpc/gen_ndr/srv_spoolss.h" -#include "../librpc/gen_ndr/srv_svcctl.h" -#include "../librpc/gen_ndr/srv_wkssvc.h" - #include "librpc/gen_ndr/ndr_winreg_scompat.h" #include "librpc/gen_ndr/ndr_srvsvc_scompat.h" #include "librpc/gen_ndr/ndr_lsa_scompat.h" @@ -79,10 +62,9 @@ static_decl_rpc; /* Common routine for embedded RPC servers */ NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *t, - const char *pipe_name) + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface) { - struct dcerpc_binding_vector *v; enum rpc_service_mode_e epm_mode = rpc_epmapper_mode(); NTSTATUS status; @@ -92,22 +74,9 @@ NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx, * they will all attempt to re-register. But we want to test * the code for now, so it is enabled in on environment in * make test */ - if (epm_mode != RPC_SERVICE_MODE_DISABLED && + if (epm_mode != RPC_SERVICE_MODE_DISABLED && (lp_parm_bool(-1, "rpc_server", "register_embedded_np", false))) { - status = dcerpc_binding_vector_new(talloc_tos(), &v); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - status = dcerpc_binding_vector_add_np_default(t, v); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - status = rpc_ep_register(ev_ctx, - msg_ctx, - t, - v); + status = rpc_ep_register(ev_ctx, msg_ctx, dce_ctx, iface); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -120,7 +89,6 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, - struct dcerpc_binding_vector *bvec, struct pf_listen_fd *listen_fds, int *listen_fds_size) { @@ -149,7 +117,6 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx, case NCACN_IP_TCP: status = dcesrv_create_ncacn_ip_tcp_sockets(e, - bvec, listen_fds, listen_fds_size); break; @@ -202,7 +169,6 @@ NTSTATUS dcesrv_setup_endpoint_sockets(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, - struct dcerpc_binding_vector *bvec, dcerpc_ncacn_termination_fn term_fn, void *term_data) { @@ -233,7 +199,6 @@ NTSTATUS dcesrv_setup_endpoint_sockets(struct tevent_context *ev_ctx, msg_ctx, dce_ctx, e, - bvec, term_fn, term_data); break; @@ -305,13 +270,27 @@ static NTSTATUS dcesrv_init_endpoints(struct tevent_context *ev_ctx, dce_ctx, e, NULL, - NULL, NULL); if (!NT_STATUS_IS_OK(status)) { return status; } - /* TODO If NCACN_NP register in endpoint mapper */ + /* Register only NCACN_NP for embedded services */ + if (transport == NCACN_NP) { + struct dcesrv_if_list *ifl = NULL; + for (ifl = e->interface_list; ifl; ifl = ifl->next) { + status = rpc_setup_embedded(ev_ctx, + msg_ctx, + dce_ctx, + ifl->iface); + if (!NT_STATUS_IS_OK(status)) { + DBG_ERR("Failed to register embedded " + "interface in endpoint mapper " + ": %s", nt_errstr(status)); + return status; + } + } + } } return NT_STATUS_OK; @@ -320,8 +299,6 @@ static NTSTATUS dcesrv_init_endpoints(struct tevent_context *ev_ctx, static NTSTATUS rpc_setup_winreg(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_winreg; - const char *pipe_name = "winreg"; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -345,19 +322,12 @@ static NTSTATUS rpc_setup_winreg(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_srvsvc(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_srvsvc; - const char *pipe_name = "srvsvc"; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -381,19 +351,12 @@ static NTSTATUS rpc_setup_srvsvc(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_lsarpc(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_lsarpc; - const char *pipe_name = "lsarpc"; enum rpc_daemon_type_e lsasd_type = rpc_lsasd_daemon(); NTSTATUS status; enum rpc_service_mode_e service_mode; @@ -419,19 +382,12 @@ static NTSTATUS rpc_setup_lsarpc(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_samr(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_samr; - const char *pipe_name = "samr"; enum rpc_daemon_type_e lsasd_type = rpc_lsasd_daemon(); NTSTATUS status; enum rpc_service_mode_e service_mode; @@ -457,19 +413,12 @@ static NTSTATUS rpc_setup_samr(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_netlogon(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_netlogon; - const char *pipe_name = "netlogon"; enum rpc_daemon_type_e lsasd_type = rpc_lsasd_daemon(); NTSTATUS status; enum rpc_service_mode_e service_mode; @@ -495,19 +444,12 @@ static NTSTATUS rpc_setup_netlogon(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_netdfs(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_netdfs; - const char *pipe_name = "netdfs"; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -531,11 +473,6 @@ static NTSTATUS rpc_setup_netdfs(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } @@ -543,8 +480,6 @@ static NTSTATUS rpc_setup_netdfs(struct tevent_context *ev_ctx, static NTSTATUS rpc_setup_rpcecho(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_rpcecho; - const char *pipe_name = "rpcecho"; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -568,11 +503,6 @@ static NTSTATUS rpc_setup_rpcecho(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } #endif @@ -580,8 +510,6 @@ static NTSTATUS rpc_setup_rpcecho(struct tevent_context *ev_ctx, static NTSTATUS rpc_setup_dssetup(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_dssetup; - const char *pipe_name = "dssetup"; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -605,19 +533,12 @@ static NTSTATUS rpc_setup_dssetup(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_wkssvc(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_wkssvc; - const char *pipe_name = "wkssvc"; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -641,18 +562,12 @@ static NTSTATUS rpc_setup_wkssvc(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_spoolss(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_spoolss; enum rpc_daemon_type_e spoolss_type = rpc_spoolss_daemon(); NTSTATUS status = NT_STATUS_UNSUCCESSFUL; enum rpc_service_mode_e service_mode; @@ -682,19 +597,12 @@ static NTSTATUS rpc_setup_spoolss(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, NULL); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_svcctl(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_svcctl; - const char *pipe_name = "svcctl"; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -718,18 +626,12 @@ static NTSTATUS rpc_setup_svcctl(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, pipe_name); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_ntsvcs(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_ntsvcs; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -753,18 +655,12 @@ static NTSTATUS rpc_setup_ntsvcs(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, NULL); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_eventlog(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_eventlog; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -788,18 +684,12 @@ static NTSTATUS rpc_setup_eventlog(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, NULL); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } static NTSTATUS rpc_setup_initshutdown(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx) { - const struct ndr_interface_table *t = &ndr_table_initshutdown; NTSTATUS status; enum rpc_service_mode_e service_mode; const struct dcesrv_endpoint_server *ep_server = NULL; @@ -823,11 +713,6 @@ static NTSTATUS rpc_setup_initshutdown(struct tevent_context *ev_ctx, return status; } - status = rpc_setup_embedded(ev_ctx, msg_ctx, t, NULL); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - return NT_STATUS_OK; } diff --git a/source3/rpc_server/rpc_service_setup.h b/source3/rpc_server/rpc_service_setup.h index b9bf52564c9..b444c0fa583 100644 --- a/source3/rpc_server/rpc_service_setup.h +++ b/source3/rpc_server/rpc_service_setup.h @@ -25,7 +25,6 @@ #include "rpc_server/rpc_server.h" struct pf_listen_fd; -struct dcerpc_binding_vector; NTSTATUS dcesrv_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx, @@ -36,7 +35,6 @@ NTSTATUS dcesrv_setup_endpoint_sockets(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, - struct dcerpc_binding_vector *bvec, dcerpc_ncacn_termination_fn term_fn, void *term_data); @@ -44,14 +42,13 @@ NTSTATUS dcesrv_create_endpoint_sockets(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, - struct dcerpc_binding_vector *bvec, struct pf_listen_fd *listen_fds, int *listen_fds_size); NTSTATUS rpc_setup_embedded(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, - const struct ndr_interface_table *t, - const char *pipe_name); + struct dcesrv_context *dce_ctx, + const struct dcesrv_interface *iface); #endif /* _RPC_EP_SETUP_H */ diff --git a/source3/rpc_server/rpc_sock_helper.c b/source3/rpc_server/rpc_sock_helper.c index 17d0b6bb451..28f319868fa 100644 --- a/source3/rpc_server/rpc_sock_helper.c +++ b/source3/rpc_server/rpc_sock_helper.c @@ -33,13 +33,11 @@ #define DBGC_CLASS DBGC_RPC_SRV NTSTATUS dcesrv_create_ncacn_ip_tcp_sockets(struct dcesrv_endpoint *e, - struct dcerpc_binding_vector *bvec, struct pf_listen_fd *listen_fd, int *listen_fd_size) { TALLOC_CTX *tmp_ctx; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; - int rc; uint16_t port = 0; char port_str[6]; const char *endpoint = NULL; @@ -69,8 +67,6 @@ NTSTATUS dcesrv_create_ncacn_ip_tcp_sockets(struct dcesrv_endpoint *e, for (i = 0; i < num_ifs; i++) { const struct sockaddr_storage *ifss = iface_n_sockaddr_storage(i); - struct tsocket_address *bind_addr; - const char *addr; int fd = -1; status = dcesrv_create_ncacn_ip_tcp_socket(ifss, @@ -82,43 +78,6 @@ NTSTATUS dcesrv_create_ncacn_ip_tcp_sockets(struct dcesrv_endpoint *e, listen_fd[*listen_fd_size].fd = fd; listen_fd[*listen_fd_size].fd_data = e; (*listen_fd_size)++; - - if (bvec != NULL) { - struct dcesrv_if_list *if_list = NULL; - - rc = tsocket_address_bsd_from_sockaddr(tmp_ctx, - (const struct sockaddr *)ifss, - sizeof(struct sockaddr_storage), - &bind_addr); - if (rc < 0) { - close(fd); - status = NT_STATUS_NO_MEMORY; - goto done; - } - - addr = tsocket_address_inet_addr_string(bind_addr, - tmp_ctx); - if (addr == NULL) { - close(fd); - status = NT_STATUS_NO_MEMORY; - goto done; - } - - for (if_list = e->interface_list; if_list; if_list = if_list->next) { - const struct ndr_interface_table *iface = NULL; - iface = ndr_table_by_syntax(&if_list->iface->syntax_id); - if (iface != NULL) { - status = dcerpc_binding_vector_add_port(iface, - bvec, - addr, - port); - if (!NT_STATUS_IS_OK(status)) { - close(fd); - goto done; - } - } - } - } } } else { const char *sock_addr; @@ -153,25 +112,6 @@ NTSTATUS dcesrv_create_ncacn_ip_tcp_sockets(struct dcesrv_endpoint *e, listen_fd[*listen_fd_size].fd = fd; listen_fd[*listen_fd_size].fd_data = e; (*listen_fd_size)++; - - if (bvec != NULL) { - struct dcesrv_if_list *if_list = NULL; - - for (if_list = e->interface_list; if_list; if_list = if_list->next) { - const struct ndr_interface_table *iface = NULL; - iface = ndr_table_by_syntax(&if_list->iface->syntax_id); - if (iface != NULL) { - status = dcerpc_binding_vector_add_port(iface, - bvec, - sock_tok, - port); - if (!NT_STATUS_IS_OK(status)) { - close(fd); - goto done; - } - } - } - } } } @@ -196,13 +136,11 @@ NTSTATUS dcesrv_setup_ncacn_ip_tcp_sockets(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, - struct dcerpc_binding_vector *bvec, dcerpc_ncacn_termination_fn t_fn, void *t_data) { TALLOC_CTX *tmp_ctx; NTSTATUS status; - int rc; tmp_ctx = talloc_stackframe(); if (tmp_ctx == NULL) { @@ -223,10 +161,6 @@ NTSTATUS dcesrv_setup_ncacn_ip_tcp_sockets(struct tevent_context *ev_ctx, for (i = 0; i < num_ifs; i++) { const struct sockaddr_storage *ifss = iface_n_sockaddr_storage(i); - struct tsocket_address *bind_addr; - const char *addr; - const char *endpoint; - uint16_t port = 0; status = dcesrv_setup_ncacn_ip_tcp_socket(ev_ctx, msg_ctx, @@ -238,46 +172,6 @@ NTSTATUS dcesrv_setup_ncacn_ip_tcp_sockets(struct tevent_context *ev_ctx, if (!NT_STATUS_IS_OK(status)) { goto done; } - - if (bvec != NULL) { - struct dcesrv_if_list *if_list = NULL; - - rc = tsocket_address_bsd_from_sockaddr(tmp_ctx, - (const struct sockaddr*)ifss, - sizeof(struct sockaddr_storage), - &bind_addr); - if (rc < 0) { - status = NT_STATUS_NO_MEMORY; - goto done; - } - - addr = tsocket_address_inet_addr_string(bind_addr, - tmp_ctx); - if (addr == NULL) { - status = NT_STATUS_NO_MEMORY; - goto done; - } - - endpoint = dcerpc_binding_get_string_option(e->ep_description, - "endpoint"); - if (endpoint != NULL) { - port = atoi(endpoint); - } - - for (if_list = e->interface_list; if_list; if_list = if_list->next) { - const struct ndr_interface_table *iface = NULL; - iface = ndr_table_by_syntax(&if_list->iface->syntax_id); - if (iface != NULL) { - status = dcerpc_binding_vector_add_port(iface, - bvec, - addr, - port); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - } - } - } } } else { const char *sock_addr; @@ -312,32 +206,6 @@ NTSTATUS dcesrv_setup_ncacn_ip_tcp_sockets(struct tevent_context *ev_ctx, if (!NT_STATUS_IS_OK(status)) { goto done; } - - if (bvec != NULL) { - struct dcesrv_if_list *if_list = NULL; - const char *endpoint; - uint16_t port = 0; - - endpoint = dcerpc_binding_get_string_option(e->ep_description, - "endpoint"); - if (endpoint != NULL) { - port = atoi(endpoint); - } - - for (if_list = e->interface_list; if_list; if_list = if_list->next) { - const struct ndr_interface_table *iface = NULL; - iface = ndr_table_by_syntax(&if_list->iface->syntax_id); - if (iface != NULL) { - status = dcerpc_binding_vector_add_port(iface, - bvec, - sock_tok, - port); - if (!NT_STATUS_IS_OK(status)) { - goto done; - } - } - } - } } } diff --git a/source3/rpc_server/rpc_sock_helper.h b/source3/rpc_server/rpc_sock_helper.h index 4577e920a1e..62ebf34def2 100644 --- a/source3/rpc_server/rpc_sock_helper.h +++ b/source3/rpc_server/rpc_sock_helper.h @@ -28,7 +28,6 @@ struct pf_listen_fd; NTSTATUS dcesrv_create_ncacn_ip_tcp_sockets(struct dcesrv_endpoint *e, - struct dcerpc_binding_vector *bvec, struct pf_listen_fd *listen_fd, int *listen_fd_size); @@ -36,7 +35,6 @@ NTSTATUS dcesrv_setup_ncacn_ip_tcp_sockets(struct tevent_context *ev_ctx, struct messaging_context *msg_ctx, struct dcesrv_context *dce_ctx, struct dcesrv_endpoint *e, - struct dcerpc_binding_vector *bvec, dcerpc_ncacn_termination_fn t_fn, void *t_data); -- 2.11.4.GIT