summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2011-07-01 18:40:38 +0200
committerAndreas Schneider <asn@samba.org>2011-08-01 08:50:35 +0200
commit0fef6766b9e4c8612b2ad547720ec47463917192 (patch)
treed5be238102a2ca1d9855bc8f6803fa0dbdc1cf5c /source3
parent498e53c22008c918e2ae5ca8126a8b1b2e8322df (diff)
downloadsamba-0fef6766b9e4c8612b2ad547720ec47463917192.tar.gz
samba-0fef6766b9e4c8612b2ad547720ec47463917192.tar.bz2
samba-0fef6766b9e4c8612b2ad547720ec47463917192.zip
s3-rpc_server: Use binding vector in rpc_ep_try_register().
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/spoolssd.c24
-rw-r--r--source3/rpc_server/rpc_ep_register.c34
-rw-r--r--source3/rpc_server/rpc_ep_register.h9
-rw-r--r--source3/rpc_server/rpc_service_setup.c1135
-rw-r--r--source3/rpc_server/wscript_build2
5 files changed, 685 insertions, 519 deletions
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index bd8a62fb33..48509b3967 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -29,6 +29,7 @@
#include "rpc_server/rpc_server.h"
#include "rpc_server/rpc_ep_register.h"
#include "rpc_server/spoolss/srv_spoolss_nt.h"
+#include "librpc/rpc/dcerpc_ep.h"
#define SPOOLSS_PIPE_NAME "spoolss"
#define DAEMON_NAME "spoolssd"
@@ -149,6 +150,8 @@ void start_spoolssd(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx)
{
struct rpc_srv_callbacks spoolss_cb;
+ struct dcerpc_binding_vector *v;
+ TALLOC_CTX *mem_ctx;
pid_t pid;
NTSTATUS status;
int ret;
@@ -199,6 +202,11 @@ void start_spoolssd(struct tevent_context *ev_ctx,
messaging_register(msg_ctx, ev_ctx,
MSG_SMB_CONF_UPDATED, smb_conf_updated);
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ exit(1);
+ }
+
/*
* Initialize spoolss with an init function to convert printers first.
* static_init_rpc will try to initialize the spoolss server too but you
@@ -222,17 +230,29 @@ void start_spoolssd(struct tevent_context *ev_ctx,
exit(1);
}
- if (!setup_named_pipe_socket(SPOOLSS_PIPE_NAME, ev_ctx, msg_ctx)) {
+ status = dcerpc_binding_vector_new(mem_ctx, &v);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Failed to create binding vector (%s)\n",
+ nt_errstr(status)));
exit(1);
}
- status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_spoolss, NULL, 0);
+ status = dcerpc_binding_vector_add_np_default(&ndr_table_spoolss, v);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Failed to add np to binding vector (%s)\n",
+ nt_errstr(status)));
+ exit(1);
+ }
+
+ status = rpc_ep_register(ev_ctx, msg_ctx, &ndr_table_spoolss, v);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to register spoolss endpoint! (%s)\n",
nt_errstr(status)));
exit(1);
}
+ talloc_free(mem_ctx);
+
DEBUG(1, ("SPOOLSS Daemon Started (%d)\n", getpid()));
/* loop forever */
diff --git a/source3/rpc_server/rpc_ep_register.c b/source3/rpc_server/rpc_ep_register.c
index 906dd6c59e..9db0e65975 100644
--- a/source3/rpc_server/rpc_ep_register.c
+++ b/source3/rpc_server/rpc_ep_register.c
@@ -32,8 +32,7 @@ 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 char *ncalrpc,
- uint16_t port,
+ const struct dcerpc_binding_vector *v,
struct dcerpc_binding_handle **pbh);
struct rpc_ep_regsiter_state {
@@ -44,9 +43,7 @@ struct rpc_ep_regsiter_state {
struct messaging_context *msg_ctx;
const struct ndr_interface_table *iface;
-
- const char *ncalrpc;
- uint16_t port;
+ const struct dcerpc_binding_vector *vector;
uint32_t wait_time;
};
@@ -54,8 +51,7 @@ struct rpc_ep_regsiter_state {
NTSTATUS rpc_ep_register(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const struct ndr_interface_table *iface,
- const char *ncalrpc,
- uint16_t port)
+ const struct dcerpc_binding_vector *v)
{
struct rpc_ep_regsiter_state *state;
struct tevent_req *req;
@@ -78,8 +74,11 @@ NTSTATUS rpc_ep_register(struct tevent_context *ev_ctx,
state->ev_ctx = ev_ctx;
state->msg_ctx = msg_ctx;
state->iface = iface;
- state->ncalrpc = talloc_strdup(state, ncalrpc);
- state->port = port;
+ 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->mem_ctx,
state->ev_ctx,
@@ -115,8 +114,7 @@ static void rpc_ep_register_loop(struct tevent_req *subreq)
state->ev_ctx,
state->msg_ctx,
state->iface,
- state->ncalrpc,
- state->port,
+ state->vector,
&state->h);
if (NT_STATUS_IS_OK(status)) {
/* endpoint registered, monitor the connnection. */
@@ -155,22 +153,11 @@ 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 char *ncalrpc,
- uint16_t port,
+ const struct dcerpc_binding_vector *v,
struct dcerpc_binding_handle **pbh)
{
- struct dcerpc_binding_vector *v = NULL;
NTSTATUS status;
- status = dcerpc_binding_vector_create(mem_ctx,
- iface,
- port,
- ncalrpc,
- &v);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
status = dcerpc_ep_register(mem_ctx,
msg_ctx,
iface,
@@ -178,7 +165,6 @@ static NTSTATUS rpc_ep_try_register(TALLOC_CTX *mem_ctx,
&iface->syntax_id.uuid,
iface->name,
pbh);
- talloc_free(v);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
diff --git a/source3/rpc_server/rpc_ep_register.h b/source3/rpc_server/rpc_ep_register.h
index 4a74a91d75..54ef58f76b 100644
--- a/source3/rpc_server/rpc_ep_register.h
+++ b/source3/rpc_server/rpc_ep_register.h
@@ -22,7 +22,7 @@
#ifndef _RPC_EP_REGISTER_H
#define _RPC_EP_REGISTER_H
-struct ndr_interface_table;
+struct dcerpc_binding_vector;
/**
* @brief Register an endpoint at the endpoint mapper.
@@ -36,17 +36,14 @@ struct ndr_interface_table;
*
* @param[in] iface The interface table to register.
*
- * @param[in] ncalrpc The name of the ncalrpc pipe or NULL.
- *
- * @param[in] port The tcpip port or 0.
+ * @param[in] v The binding vector to register.
*
* @return NT_STATUS_OK on success or a corresponding error code.
*/
NTSTATUS rpc_ep_register(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
const struct ndr_interface_table *iface,
- const char *ncalrpc,
- uint16_t port);
+ const struct dcerpc_binding_vector *v);
#endif /* _RPC_EP_REGISTER_H */
diff --git a/source3/rpc_server/rpc_service_setup.c b/source3/rpc_server/rpc_service_setup.c
index a234f2350d..f5716cdab9 100644
--- a/source3/rpc_server/rpc_service_setup.c
+++ b/source3/rpc_server/rpc_service_setup.c
@@ -45,118 +45,61 @@
#include "rpc_server/spoolss/srv_spoolss_nt.h"
#include "rpc_server/svcctl/srv_svcctl_nt.h"
+#include "librpc/rpc/dcerpc_ep.h"
+#include "rpc_server/rpc_sock_helper.h"
#include "rpc_server/rpc_service_setup.h"
#include "rpc_server/rpc_ep_register.h"
#include "rpc_server/rpc_server.h"
#include "rpc_server/epmapper/srv_epmapper.h"
-struct dcesrv_ep_context {
- struct tevent_context *ev_ctx;
- struct messaging_context *msg_ctx;
-};
-
-static uint16_t _open_sockets(struct tevent_context *ev_ctx,
- struct messaging_context *msg_ctx,
- struct ndr_syntax_id syntax_id,
- uint16_t port)
+static bool rpc_setup_epmapper(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx)
{
- uint32_t num_ifs = iface_count();
- uint32_t i;
- uint16_t p = 0;
-
- if (lp_interfaces() && lp_bind_interfaces_only()) {
- /*
- * We have been given an interfaces line, and been told to only
- * bind to those interfaces. Create a socket per interface and
- * bind to only these.
- */
-
- /* Now open a listen socket for each of the interfaces. */
- for(i = 0; i < num_ifs; i++) {
- const struct sockaddr_storage *ifss =
- iface_n_sockaddr_storage(i);
-
- p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
- msg_ctx,
- ifss,
- port);
- if (p == 0) {
- return 0;
- }
- port = p;
- }
- } else {
- const char *sock_addr = lp_socket_address();
- const char *sock_ptr;
- char *sock_tok;
-
- if (strequal(sock_addr, "0.0.0.0") ||
- strequal(sock_addr, "::")) {
-#if HAVE_IPV6
- sock_addr = "::,0.0.0.0";
-#else
- sock_addr = "0.0.0.0";
-#endif
- }
-
- for (sock_ptr = sock_addr;
- next_token_talloc(talloc_tos(), &sock_ptr, &sock_tok, " \t,");
- ) {
- struct sockaddr_storage ss;
+ const char *rpcsrv_type;
+ NTSTATUS status;
- /* open an incoming socket */
- if (!interpret_string_addr(&ss,
- sock_tok,
- AI_NUMERICHOST|AI_PASSIVE)) {
- continue;
- }
+ /* start endpoint mapper only if enabled */
+ rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+ "rpc_server",
+ "epmapper",
+ "none");
- p = setup_dcerpc_ncacn_tcpip_socket(ev_ctx,
- msg_ctx,
- &ss,
- port);
- if (p == 0) {
- return 0;
- }
- port = p;
+ if (strcasecmp_m(rpcsrv_type, "none") == 0) {
+ status = rpc_epmapper_init(NULL);
+ if (!NT_STATUS_IS_OK(rpc_epmapper_init(NULL))) {
+ return false;
}
}
- return p;
-}
-
-static bool epmapper_init_cb(void *ptr)
-{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- uint16_t port;
-
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- ndr_table_epmapper.syntax_id,
- 135);
- if (port == 135) {
- return true;
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
+ status = rpc_setup_tcpip_sockets(ev_ctx,
+ msg_ctx,
+ &ndr_table_epmapper,
+ NULL,
+ 135);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
}
- return false;
-}
-
-static bool epmapper_shutdown_cb(void *ptr)
-{
- srv_epmapper_cleanup();
-
return true;
}
-static bool winreg_init_cb(void *ptr)
+static bool rpc_setup_winreg(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct dcerpc_binding_vector *v)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- struct ndr_syntax_id abstract_syntax = ndr_table_winreg.syntax_id;
+ const struct ndr_interface_table *t = &ndr_table_winreg;
const char *pipe_name = "winreg";
+ struct dcerpc_binding_vector *v2;
const char *rpcsrv_type;
- uint16_t port;
+ NTSTATUS status;
+ bool ok;
+
+ status = rpc_winreg_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
@@ -165,29 +108,38 @@ static bool winreg_init_cb(void *ptr)
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
- bool ok;
+ v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
+ if (v2 == NULL) {
+ return false;
+ }
- ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
+ status = dcerpc_binding_vector_replace_iface(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_np_default(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
pipe_name,
NULL);
if (!ok) {
return false;
}
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- abstract_syntax,
- 0);
- if (port == 0) {
+
+ status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_winreg,
- pipe_name,
- port);
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v2);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -196,14 +148,21 @@ static bool winreg_init_cb(void *ptr)
return true;
}
-static bool srvsvc_init_cb(void *ptr)
+static bool rpc_setup_srvsvc(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct dcerpc_binding_vector *v)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- struct ndr_syntax_id abstract_syntax = ndr_table_srvsvc.syntax_id;
+ const struct ndr_interface_table *t = &ndr_table_srvsvc;
const char *pipe_name = "srvsvc";
+ struct dcerpc_binding_vector *v2;
const char *rpcsrv_type;
- uint16_t port;
+ NTSTATUS status;
+ bool ok;
+
+ status = rpc_srvsvc_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
@@ -212,30 +171,38 @@ static bool srvsvc_init_cb(void *ptr)
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
- bool ok;
+ v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
+ if (v2 == NULL) {
+ return false;
+ }
- ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
+ status = dcerpc_binding_vector_replace_iface(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_np_default(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
pipe_name,
NULL);
if (!ok) {
return false;
}
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- abstract_syntax,
- 0);
- if (port == 0) {
+ status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_srvsvc,
- pipe_name,
- port);
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v2);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -244,14 +211,21 @@ static bool srvsvc_init_cb(void *ptr)
return true;
}
-static bool lsarpc_init_cb(void *ptr)
+static bool rpc_setup_lsarpc(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct dcerpc_binding_vector *v)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- struct ndr_syntax_id abstract_syntax = ndr_table_lsarpc.syntax_id;
+ const struct ndr_interface_table *t = &ndr_table_lsarpc;
const char *pipe_name = "lsarpc";
+ struct dcerpc_binding_vector *v2;
const char *rpcsrv_type;
- uint16_t port;
+ NTSTATUS status;
+ bool ok;
+
+ status = rpc_lsarpc_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
@@ -260,30 +234,38 @@ static bool lsarpc_init_cb(void *ptr)
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
- bool ok;
+ v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
+ if (v2 == NULL) {
+ return false;
+ }
- ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
+ status = dcerpc_binding_vector_replace_iface(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_np_default(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
pipe_name,
NULL);
if (!ok) {
return false;
}
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- abstract_syntax,
- 0);
- if (port == 0) {
+ status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_lsarpc,
- pipe_name,
- port);
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v2);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -292,14 +274,21 @@ static bool lsarpc_init_cb(void *ptr)
return true;
}
-static bool samr_init_cb(void *ptr)
+static bool rpc_setup_samr(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct dcerpc_binding_vector *v)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- struct ndr_syntax_id abstract_syntax = ndr_table_samr.syntax_id;
+ const struct ndr_interface_table *t = &ndr_table_samr;
const char *pipe_name = "samr";
+ struct dcerpc_binding_vector *v2;
const char *rpcsrv_type;
- uint16_t port;
+ NTSTATUS status;
+ bool ok;
+
+ status = rpc_samr_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
@@ -308,30 +297,38 @@ static bool samr_init_cb(void *ptr)
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
- bool ok;
+ v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
+ if (v2 == NULL) {
+ return false;
+ }
- ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
+ status = dcerpc_binding_vector_replace_iface(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_np_default(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
pipe_name,
NULL);
if (!ok) {
return false;
}
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- abstract_syntax,
- 0);
- if (port == 0) {
+ status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_samr,
- pipe_name,
- port);
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v2);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -340,14 +337,21 @@ static bool samr_init_cb(void *ptr)
return true;
}
-static bool netlogon_init_cb(void *ptr)
+static bool rpc_setup_netlogon(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct dcerpc_binding_vector *v)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- struct ndr_syntax_id abstract_syntax = ndr_table_netlogon.syntax_id;
+ const struct ndr_interface_table *t = &ndr_table_netlogon;
const char *pipe_name = "netlogon";
+ struct dcerpc_binding_vector *v2;
const char *rpcsrv_type;
- uint16_t port;
+ NTSTATUS status;
+ bool ok;
+
+ status = rpc_netlogon_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
@@ -356,30 +360,38 @@ static bool netlogon_init_cb(void *ptr)
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
- bool ok;
+ v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
+ if (v2 == NULL) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_replace_iface(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_np_default(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
- ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
pipe_name,
NULL);
if (!ok) {
return false;
}
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- abstract_syntax,
- 0);
- if (port == 0) {
+ status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_netlogon,
- pipe_name,
- port);
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v2);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -388,99 +400,149 @@ static bool netlogon_init_cb(void *ptr)
return true;
}
-static bool spoolss_init_cb(void *ptr)
+static bool rpc_setup_netdfs(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct dcerpc_binding_vector *v)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
+ const struct ndr_interface_table *t = &ndr_table_netdfs;
+ const char *pipe_name = "netdfs";
+ struct dcerpc_binding_vector *v2;
const char *rpcsrv_type;
+ NTSTATUS status;
bool ok;
+ status = rpc_netdfs_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
"epmapper",
"none");
- /*
- * Migrate the printers first.
- */
- ok = nt_printing_tdb_migrate(ep_ctx->msg_ctx);
- if (!ok) {
- return false;
- }
-
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
+ v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
+ if (v2 == NULL) {
+ return false;
+ }
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_spoolss,
- "spoolss",
- 0);
+ status = dcerpc_binding_vector_replace_iface(t, v2);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
- }
- return true;
-}
+ status = dcerpc_binding_vector_add_np_default(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
-static bool spoolss_shutdown_cb(void *ptr)
-{
- srv_spoolss_cleanup();
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
+ pipe_name,
+ NULL);
+ if (!ok) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+ }
return true;
}
-static bool svcctl_init_cb(void *ptr)
+#ifdef DEVELOPER
+static bool rpc_setup_rpcecho(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct dcerpc_binding_vector *v)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
+ const struct ndr_interface_table *t = &ndr_table_rpcecho;
+ const char *pipe_name = "rpcecho";
+ struct dcerpc_binding_vector *v2;
const char *rpcsrv_type;
+ NTSTATUS status;
bool ok;
+ status = rpc_rpcecho_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
"epmapper",
"none");
- ok = svcctl_init_winreg(ep_ctx->msg_ctx);
- if (!ok) {
- return false;
- }
-
- /* initialize the control hooks */
- init_service_op_table();
-
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
+ v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
+ if (v2 == NULL) {
+ return false;
+ }
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_svcctl,
- "svcctl",
- 0);
+ status = dcerpc_binding_vector_replace_iface(t, v2);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
- }
- return true;
-}
+ status = dcerpc_binding_vector_add_np_default(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
-static bool svcctl_shutdown_cb(void *ptr)
-{
- shutdown_service_op_table();
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
+ pipe_name,
+ NULL);
+ if (!ok) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+ }
return true;
}
+#endif
-static bool ntsvcs_init_cb(void *ptr)
+static bool rpc_setup_dssetup(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct dcerpc_binding_vector *v)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
+ const struct ndr_interface_table *t = &ndr_table_dssetup;
+ const char *pipe_name = "dssetup";
+ struct dcerpc_binding_vector *v2;
const char *rpcsrv_type;
+ NTSTATUS status;
+ bool ok;
+
+ status = rpc_dssetup_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
@@ -489,13 +551,38 @@ static bool ntsvcs_init_cb(void *ptr)
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
+ v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
+ if (v2 == NULL) {
+ return false;
+ }
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_ntsvcs,
- "ntsvcs",
- 0);
+ status = dcerpc_binding_vector_replace_iface(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_np_default(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
+ pipe_name,
+ NULL);
+ if (!ok) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v2);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -504,32 +591,61 @@ static bool ntsvcs_init_cb(void *ptr)
return true;
}
-static bool eventlog_init_cb(void *ptr)
+static bool rpc_setup_wkssvc(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx,
+ const struct dcerpc_binding_vector *v)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
+ const struct ndr_interface_table *t = &ndr_table_wkssvc;
+ const char *pipe_name = "wkssvc";
+ struct dcerpc_binding_vector *v2;
const char *rpcsrv_type;
+ NTSTATUS status;
bool ok;
+ status = rpc_wkssvc_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
"epmapper",
"none");
- ok = eventlog_init_winreg(ep_ctx->msg_ctx);
- if (!ok) {
- return false;
- }
-
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
+ v2 = dcerpc_binding_vector_dup(talloc_tos(), v);
+ if (v2 == NULL) {
+ return false;
+ }
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_eventlog,
- "eventlog",
- 0);
+ status = dcerpc_binding_vector_replace_iface(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_np_default(t, v2);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
+ pipe_name,
+ NULL);
+ if (!ok) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_unix(t, v2, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v2);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -538,112 +654,167 @@ static bool eventlog_init_cb(void *ptr)
return true;
}
-static bool initshutdown_init_cb(void *ptr)
+static bool spoolss_init_cb(void *ptr)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- const char *rpcsrv_type;
+ struct messaging_context *msg_ctx =
+ talloc_get_type_abort(ptr, struct messaging_context);
+ bool ok;
- rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
- "rpc_server",
- "epmapper",
- "none");
+ /*
+ * Migrate the printers first.
+ */
+ ok = nt_printing_tdb_migrate(msg_ctx);
+ if (!ok) {
+ return false;
+ }
- if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
- strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
+ return true;
+}
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_initshutdown,
- "initshutdown",
- 0);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
- }
- }
+static bool spoolss_shutdown_cb(void *ptr)
+{
+ srv_spoolss_cleanup();
return true;
}
-#ifdef DEVELOPER
-static bool rpcecho_init_cb(void *ptr) {
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
+static bool rpc_setup_spoolss(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx)
+{
+ const struct ndr_interface_table *t = &ndr_table_spoolss;
+ struct rpc_srv_callbacks spoolss_cb;
const char *rpcsrv_type;
- uint16_t port;
+ struct dcerpc_binding_vector *v;
+ NTSTATUS status;
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
- "epmapper",
- "none");
+ "spoolss",
+ "embedded");
- if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
- strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
+ spoolss_cb.init = spoolss_init_cb;
+ spoolss_cb.shutdown = spoolss_shutdown_cb;
+ spoolss_cb.private_data = msg_ctx;
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- ndr_table_rpcecho.syntax_id,
- 0);
- if (port == 0) {
- return false;
- }
+ status = rpc_spoolss_init(&spoolss_cb);
+ } else if (strcasecmp_m(rpcsrv_type, "daemon") == 0 ||
+ strcasecmp_m(rpcsrv_type, "external") == 0) {
+ status = rpc_spoolss_init(NULL);
+ }
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_rpcecho,
- "rpcecho",
- port);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
+ if (strcasecmp_m(rpcsrv_type, "embedded")) {
+ rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+ "rpc_server",
+ "epmapper",
+ "none");
+
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
+ status = dcerpc_binding_vector_new(talloc_tos(), &v);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_np_default(t, v);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
}
}
return true;
}
-#endif
+static bool svcctl_init_cb(void *ptr)
+{
+ struct messaging_context *msg_ctx =
+ talloc_get_type_abort(ptr, struct messaging_context);
+ bool ok;
+
+ /* initialize the control hooks */
+ init_service_op_table();
-static bool netdfs_init_cb(void *ptr)
+ ok = svcctl_init_winreg(msg_ctx);
+ if (!ok) {
+ return false;
+ }
+
+ return true;
+}
+
+static bool svcctl_shutdown_cb(void *ptr)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- struct ndr_syntax_id abstract_syntax = ndr_table_netdfs.syntax_id;
- const char *pipe_name = "netdfs";
+ shutdown_service_op_table();
+
+ return true;
+}
+
+static bool 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";
+ struct dcerpc_binding_vector *v;
+ struct rpc_srv_callbacks svcctl_cb;
const char *rpcsrv_type;
- uint16_t port;
+ NTSTATUS status;
+ bool ok;
+
+ svcctl_cb.init = svcctl_init_cb;
+ svcctl_cb.shutdown = svcctl_shutdown_cb;
+ svcctl_cb.private_data = msg_ctx;
+
+ status = rpc_svcctl_init(&svcctl_cb);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
"epmapper",
"none");
+
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
- bool ok;
+ status = dcerpc_binding_vector_new(talloc_tos(), &v);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
+
+ status = dcerpc_binding_vector_add_np_default(t, v);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
- ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
+ ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
+ msg_ctx,
pipe_name,
NULL);
if (!ok) {
return false;
}
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- abstract_syntax,
- 0);
- if (port == 0) {
+ status = dcerpc_binding_vector_add_unix(t, v, pipe_name);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_netdfs,
- pipe_name,
- port);
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -652,14 +823,18 @@ static bool netdfs_init_cb(void *ptr)
return true;
}
-static bool dssetup_init_cb(void *ptr)
+static bool rpc_setup_ntsvcs(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- struct ndr_syntax_id abstract_syntax = ndr_table_dssetup.syntax_id;
- const char *pipe_name = "dssetup";
+ const struct ndr_interface_table *t = &ndr_table_ntsvcs;
+ struct dcerpc_binding_vector *v;
const char *rpcsrv_type;
- uint16_t port;
+ NTSTATUS status;
+
+ status = rpc_ntsvcs_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
@@ -668,30 +843,20 @@ static bool dssetup_init_cb(void *ptr)
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
- bool ok;
-
- ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- pipe_name,
- NULL);
- if (!ok) {
+ status = dcerpc_binding_vector_new(talloc_tos(), &v);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- abstract_syntax,
- 0);
- if (port == 0) {
+ status = dcerpc_binding_vector_add_np_default(t, v);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_dssetup,
- "dssetup",
- port);
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -700,45 +865,59 @@ static bool dssetup_init_cb(void *ptr)
return true;
}
-static bool wkssvc_init_cb(void *ptr)
+static bool eventlog_init_cb(void *ptr)
{
- struct dcesrv_ep_context *ep_ctx =
- talloc_get_type_abort(ptr, struct dcesrv_ep_context);
- struct ndr_syntax_id abstract_syntax = ndr_table_wkssvc.syntax_id;
- const char *pipe_name = "wkssvc";
+ struct messaging_context *msg_ctx =
+ talloc_get_type_abort(ptr, struct messaging_context);
+ bool ok;
+
+ ok = eventlog_init_winreg(msg_ctx);
+ if (!ok) {
+ return false;
+ }
+
+ return true;
+}
+
+static bool rpc_setup_eventlog(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx)
+{
+ const struct ndr_interface_table *t = &ndr_table_eventlog;
+ struct rpc_srv_callbacks eventlog_cb;
+ struct dcerpc_binding_vector *v;
const char *rpcsrv_type;
- uint16_t port;
+ NTSTATUS status;
+
+ eventlog_cb.init = eventlog_init_cb;
+ eventlog_cb.shutdown = NULL;
+ eventlog_cb.private_data = msg_ctx;
+
+ status = rpc_eventlog_init(&eventlog_cb);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
"epmapper",
"none");
+
if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- NTSTATUS status;
- bool ok;
-
- ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- pipe_name,
- NULL);
- if (!ok) {
+ status = dcerpc_binding_vector_new(talloc_tos(), &v);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- port = _open_sockets(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- abstract_syntax,
- 0);
- if (port == 0) {
+ status = dcerpc_binding_vector_add_np_default(t, v);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- status = rpc_ep_register(ep_ctx->ev_ctx,
- ep_ctx->msg_ctx,
- &ndr_table_wkssvc,
- "wkssvc",
- port);
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v);
if (!NT_STATUS_IS_OK(status)) {
return false;
}
@@ -747,174 +926,158 @@ static bool wkssvc_init_cb(void *ptr)
return true;
}
-bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
- struct messaging_context *msg_ctx)
+static bool rpc_setup_initshutdown(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx)
{
- struct dcesrv_ep_context *ep_ctx;
-
- struct rpc_srv_callbacks epmapper_cb;
-
- struct rpc_srv_callbacks winreg_cb;
- struct rpc_srv_callbacks srvsvc_cb;
-
- struct rpc_srv_callbacks lsarpc_cb;
- struct rpc_srv_callbacks samr_cb;
- struct rpc_srv_callbacks netlogon_cb;
-
- struct rpc_srv_callbacks spoolss_cb;
- struct rpc_srv_callbacks svcctl_cb;
- struct rpc_srv_callbacks ntsvcs_cb;
- struct rpc_srv_callbacks eventlog_cb;
- struct rpc_srv_callbacks initshutdown_cb;
- struct rpc_srv_callbacks netdfs_cb;
-#ifdef DEVELOPER
- struct rpc_srv_callbacks rpcecho_cb;
-#endif
- struct rpc_srv_callbacks dssetup_cb;
- struct rpc_srv_callbacks wkssvc_cb;
-
+ const struct ndr_interface_table *t = &ndr_table_initshutdown;
+ struct dcerpc_binding_vector *v;
const char *rpcsrv_type;
+ NTSTATUS status;
- ep_ctx = talloc(ev_ctx, struct dcesrv_ep_context);
- if (ep_ctx == NULL) {
+ status = rpc_initshutdown_init(NULL);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- ep_ctx->ev_ctx = ev_ctx;
- ep_ctx->msg_ctx = msg_ctx;
-
- /* start endpoint mapper only if enabled */
rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
"rpc_server",
"epmapper",
"none");
- if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
- epmapper_cb.init = epmapper_init_cb;
- epmapper_cb.shutdown = epmapper_shutdown_cb;
- epmapper_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_epmapper_init(&epmapper_cb))) {
+ if (strcasecmp_m(rpcsrv_type, "embedded") == 0 ||
+ strcasecmp_m(rpcsrv_type, "daemon") == 0) {
+ status = dcerpc_binding_vector_new(talloc_tos(), &v);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- } else if (strcasecmp_m(rpcsrv_type, "daemon") == 0) {
- if (!NT_STATUS_IS_OK(rpc_epmapper_init(NULL))) {
+
+ status = dcerpc_binding_vector_add_np_default(t, v);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- }
- winreg_cb.init = winreg_init_cb;
- winreg_cb.shutdown = NULL;
- winreg_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_winreg_init(&winreg_cb))) {
- return false;
+ status = rpc_ep_register(ev_ctx,
+ msg_ctx,
+ t,
+ v);
+ if (!NT_STATUS_IS_OK(status)) {
+ return false;
+ }
}
- srvsvc_cb.init = srvsvc_init_cb;
- srvsvc_cb.shutdown = NULL;
- srvsvc_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_srvsvc_init(&srvsvc_cb))) {
- return false;
- }
+ return true;
+}
+bool dcesrv_ep_setup(struct tevent_context *ev_ctx,
+ struct messaging_context *msg_ctx)
+{
+ struct dcerpc_binding_vector *v;
+ TALLOC_CTX *tmp_ctx;
+ NTSTATUS status;
+ bool ok;
- lsarpc_cb.init = lsarpc_init_cb;
- lsarpc_cb.shutdown = NULL;
- lsarpc_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_lsarpc_init(&lsarpc_cb))) {
+ tmp_ctx = talloc_stackframe();
+ if (tmp_ctx == NULL) {
return false;
}
- samr_cb.init = samr_init_cb;
- samr_cb.shutdown = NULL;
- samr_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_samr_init(&samr_cb))) {
- return false;
+ status = dcerpc_binding_vector_new(tmp_ctx,
+ &v);
+ if (!NT_STATUS_IS_OK(status)) {
+ ok = false;
+ goto done;
}
- netlogon_cb.init = netlogon_init_cb;
- netlogon_cb.shutdown = NULL;
- netlogon_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_netlogon_init(&netlogon_cb))) {
- return false;
+ ok = rpc_setup_epmapper(ev_ctx, msg_ctx);
+ if (!ok) {
+ goto done;
}
- rpcsrv_type = lp_parm_const_string(GLOBAL_SECTION_SNUM,
- "rpc_server",
- "spoolss",
- "embedded");
- if (strcasecmp_m(rpcsrv_type, "embedded") == 0) {
- spoolss_cb.init = spoolss_init_cb;
- spoolss_cb.shutdown = spoolss_shutdown_cb;
- spoolss_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_spoolss_init(&spoolss_cb))) {
- return false;
- }
- } else if (strcasecmp_m(rpcsrv_type, "daemon") == 0 ||
- strcasecmp_m(rpcsrv_type, "external") == 0) {
- if (!NT_STATUS_IS_OK(rpc_spoolss_init(NULL))) {
- return false;
- }
+ status = rpc_setup_tcpip_sockets(ev_ctx,
+ msg_ctx,
+ &ndr_table_winreg,
+ v,
+ 0);
+ if (!NT_STATUS_IS_OK(status)) {
+ ok = false;
+ goto done;
}
- svcctl_cb.init = svcctl_init_cb;
- svcctl_cb.shutdown = svcctl_shutdown_cb;
- svcctl_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_svcctl_init(&svcctl_cb))) {
- return false;
+ ok = rpc_setup_winreg(ev_ctx, msg_ctx, v);
+ if (!ok) {
+ goto done;
}
- ntsvcs_cb.init = ntsvcs_init_cb;
- ntsvcs_cb.shutdown = NULL;
- ntsvcs_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_ntsvcs_init(&ntsvcs_cb))) {
- return false;
+ ok = rpc_setup_srvsvc(ev_ctx, msg_ctx, v);
+ if (!ok) {
+ goto done;
}
- eventlog_cb.init = eventlog_init_cb;
- eventlog_cb.shutdown = NULL;
- eventlog_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_eventlog_init(&eventlog_cb))) {
- return false;
+ ok = rpc_setup_lsarpc(ev_ctx, msg_ctx, v);
+ if (!ok) {
+ goto done;
}
- initshutdown_cb.init = initshutdown_init_cb;
- initshutdown_cb.shutdown = NULL;
- initshutdown_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_initshutdown_init(&initshutdown_cb))) {
- return false;
+ ok = rpc_setup_samr(ev_ctx, msg_ctx, v);
+ if (!ok) {
+ goto done;
}
- netdfs_cb.init = netdfs_init_cb;
- netdfs_cb.shutdown = NULL;
- netdfs_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_netdfs_init(&netdfs_cb))) {
- return false;
+ ok = rpc_setup_netlogon(ev_ctx, msg_ctx, v);
+ if (!ok) {
+ goto done;
+ }
+
+ ok = rpc_setup_netdfs(ev_ctx, msg_ctx, v);
+ if (!ok) {
+ goto done;
}
#ifdef DEVELOPER
- rpcecho_cb.init = rpcecho_init_cb;
- rpcecho_cb.shutdown = NULL;
- rpcecho_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_rpcecho_init(&rpcecho_cb))) {
- return false;
+ ok = rpc_setup_rpcecho(ev_ctx, msg_ctx, v);
+ if (!ok) {
+ goto done;
}
#endif
- dssetup_cb.init = dssetup_init_cb;
- dssetup_cb.shutdown = NULL;
- dssetup_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_dssetup_init(&dssetup_cb))) {
- return false;
+ ok = rpc_setup_dssetup(ev_ctx, msg_ctx, v);
+ if (!ok) {
+ goto done;
}
- wkssvc_cb.init = wkssvc_init_cb;
- wkssvc_cb.shutdown = NULL;
- wkssvc_cb.private_data = ep_ctx;
- if (!NT_STATUS_IS_OK(rpc_wkssvc_init(&wkssvc_cb))) {
- return false;
+ ok = rpc_setup_wkssvc(ev_ctx, msg_ctx, v);
+ if (!ok) {
+ goto done;
}
- return true;
+ ok = rpc_setup_spoolss(ev_ctx, msg_ctx);
+ if (!ok) {
+ goto done;
+ }
+
+ ok = rpc_setup_svcctl(ev_ctx, msg_ctx);
+ if (!ok) {
+ goto done;
+ }
+
+ ok = rpc_setup_ntsvcs(ev_ctx, msg_ctx);
+ if (!ok) {
+ goto done;
+ }
+
+ ok = rpc_setup_eventlog(ev_ctx, msg_ctx);
+ if (!ok) {
+ goto done;
+ }
+
+ ok = rpc_setup_initshutdown(ev_ctx, msg_ctx);
+ if (!ok) {
+ goto done;
+ }
+
+done:
+ talloc_free(tmp_ctx);
+ return ok;
}
/* vim: set ts=8 sw=8 noet cindent ft=c.doxygen: */
diff --git a/source3/rpc_server/wscript_build b/source3/rpc_server/wscript_build
index 947cb2d0d6..894f393c58 100644
--- a/source3/rpc_server/wscript_build
+++ b/source3/rpc_server/wscript_build
@@ -129,7 +129,7 @@ bld.SAMBA3_SUBSYSTEM('RPC_EPMAPPER',
vars=locals())
bld.SAMBA3_SUBSYSTEM('RPC_SERVER',
- source='srv_pipe_hnd.c srv_pipe.c rpc_service_setup.c',
+ source='srv_pipe_hnd.c srv_pipe.c rpc_sock_helper.c rpc_service_setup.c',
deps='''RPC_NCACN_NP RPC_SERVICE RPC_CRYPTO
RPC_SAMR RPC_LSARPC RPC_WINREG RPC_INITSHUTDOWN
RPC_DSSETUP RPC_WKSSVC RPC_SVCCTL RPC_NTSVCS