summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2011-03-14 12:29:49 +0100
committerSimo Sorce <idra@samba.org>2011-03-23 17:19:22 +0100
commite69d92236744bb06d60faa4f21f3cd748ec5629d (patch)
tree835a3d79e8f20e21c628f8a23605696a7b44aeff /source3/rpc_server
parent044eabe425f9ae6e2fcea5ec1481b33c35b173f7 (diff)
downloadsamba-e69d92236744bb06d60faa4f21f3cd748ec5629d.tar.gz
samba-e69d92236744bb06d60faa4f21f3cd748ec5629d.tar.bz2
samba-e69d92236744bb06d60faa4f21f3cd748ec5629d.zip
s3-rpc_server: Added disconnect callback function.
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/epmd.c3
-rw-r--r--source3/rpc_server/rpc_ep_setup.c24
-rw-r--r--source3/rpc_server/rpc_server.c26
-rw-r--r--source3/rpc_server/rpc_server.h5
4 files changed, 43 insertions, 15 deletions
diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c
index 0b5d671775..5b0f4c4a52 100644
--- a/source3/rpc_server/epmd.c
+++ b/source3/rpc_server/epmd.c
@@ -263,7 +263,8 @@ void start_epmd(struct tevent_context *ev_ctx,
ok = setup_dcerpc_ncalrpc_socket(ev_ctx,
msg_ctx,
ndr_table_epmapper.syntax_id,
- "EPMAPPER");
+ "EPMAPPER",
+ NULL);
if (!ok) {
DEBUG(0, ("Failed to open epmd ncalrpc pipe!\n"));
exit(1);
diff --git a/source3/rpc_server/rpc_ep_setup.c b/source3/rpc_server/rpc_ep_setup.c
index 9baee276b2..4f23ae2891 100644
--- a/source3/rpc_server/rpc_ep_setup.c
+++ b/source3/rpc_server/rpc_ep_setup.c
@@ -451,7 +451,8 @@ static bool winreg_init_cb(void *ptr)
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
abstract_syntax,
- pipe_name);
+ pipe_name,
+ NULL);
if (!ok) {
return false;
}
@@ -520,7 +521,8 @@ static bool srvsvc_init_cb(void *ptr)
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
abstract_syntax,
- pipe_name);
+ pipe_name,
+ NULL);
if (!ok) {
return false;
}
@@ -590,7 +592,8 @@ static bool lsarpc_init_cb(void *ptr)
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
abstract_syntax,
- pipe_name);
+ pipe_name,
+ NULL);
if (!ok) {
return false;
}
@@ -660,7 +663,8 @@ static bool samr_init_cb(void *ptr)
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
abstract_syntax,
- pipe_name);
+ pipe_name,
+ NULL);
if (!ok) {
return false;
}
@@ -730,7 +734,8 @@ static bool netlogon_init_cb(void *ptr)
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
abstract_syntax,
- pipe_name);
+ pipe_name,
+ NULL);
if (!ok) {
return false;
}
@@ -1136,7 +1141,8 @@ static bool netdfs_init_cb(void *ptr)
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
abstract_syntax,
- pipe_name);
+ pipe_name,
+ NULL);
if (!ok) {
return false;
}
@@ -1205,7 +1211,8 @@ static bool dssetup_init_cb(void *ptr)
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
abstract_syntax,
- pipe_name);
+ pipe_name,
+ NULL);
if (!ok) {
return false;
}
@@ -1273,7 +1280,8 @@ static bool wkssvc_init_cb(void *ptr)
ok = setup_dcerpc_ncalrpc_socket(ep_ctx->ev_ctx,
ep_ctx->msg_ctx,
abstract_syntax,
- pipe_name);
+ pipe_name,
+ NULL);
if (!ok) {
return false;
}
diff --git a/source3/rpc_server/rpc_server.c b/source3/rpc_server/rpc_server.c
index 9f88531a98..94aa5a5453 100644
--- a/source3/rpc_server/rpc_server.c
+++ b/source3/rpc_server/rpc_server.c
@@ -232,6 +232,7 @@ struct dcerpc_ncacn_listen_state {
struct tevent_context *ev_ctx;
struct messaging_context *msg_ctx;
+ dcerpc_ncacn_disconnect_fn disconnect_fn;
};
static void named_pipe_listener(struct tevent_context *ev,
@@ -681,7 +682,8 @@ static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
uint16_t port,
struct tsocket_address *cli_addr,
struct tsocket_address *srv_addr,
- int s);
+ int s,
+ dcerpc_ncacn_disconnect_fn fn);
/********************************************************************
* Start listening on the tcp/ip socket
@@ -711,6 +713,7 @@ uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
state->syntax_id = syntax_id;
state->fd = -1;
state->ep.port = port;
+ state->disconnect_fn = NULL;
if (state->ep.port == 0) {
uint16_t i;
@@ -839,7 +842,8 @@ static void dcerpc_ncacn_tcpip_listener(struct tevent_context *ev,
state->ep.port,
cli_addr,
srv_addr,
- s);
+ s,
+ NULL);
}
/********************************************************************
@@ -854,7 +858,8 @@ static void dcerpc_ncalrpc_listener(struct tevent_context *ev,
bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
struct ndr_syntax_id syntax_id,
- const char *name)
+ const char *name,
+ dcerpc_ncacn_disconnect_fn fn)
{
struct dcerpc_ncacn_listen_state *state;
struct tevent_fd *fde;
@@ -867,6 +872,7 @@ bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
state->syntax_id = syntax_id;
state->fd = -1;
+ state->disconnect_fn = fn;
if (name == NULL) {
name = "DEFAULT";
@@ -962,7 +968,8 @@ static void dcerpc_ncalrpc_listener(struct tevent_context *ev,
state->msg_ctx,
state->syntax_id, NCALRPC,
state->ep.name, 0,
- cli_addr, NULL, sd);
+ cli_addr, NULL, sd,
+ state->disconnect_fn);
}
struct dcerpc_ncacn_conn {
@@ -978,6 +985,7 @@ struct dcerpc_ncacn_conn {
int sock;
struct pipes_struct *p;
+ dcerpc_ncacn_disconnect_fn disconnect_fn;
struct tevent_context *ev_ctx;
struct messaging_context *msg_ctx;
@@ -1006,7 +1014,8 @@ static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
uint16_t port,
struct tsocket_address *cli_addr,
struct tsocket_address *srv_addr,
- int s) {
+ int s,
+ dcerpc_ncacn_disconnect_fn fn) {
struct dcerpc_ncacn_conn *ncacn_conn;
struct tevent_req *subreq;
const char *cli_str;
@@ -1032,6 +1041,7 @@ static void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
ncacn_conn->ev_ctx = ev_ctx;
ncacn_conn->msg_ctx = msg_ctx;
ncacn_conn->sock = s;
+ ncacn_conn->disconnect_fn = fn;
ncacn_conn->client = talloc_move(ncacn_conn, &cli_addr);
if (tsocket_address_is_inet(ncacn_conn->client, "ip")) {
@@ -1215,6 +1225,12 @@ static void dcerpc_ncacn_packet_process(struct tevent_req *subreq)
status = dcerpc_read_ncacn_packet_recv(subreq, ncacn_conn, &pkt, &recv_buffer);
TALLOC_FREE(subreq);
if (!NT_STATUS_IS_OK(status)) {
+ if (ncacn_conn->disconnect_fn != NULL) {
+ ok = ncacn_conn->disconnect_fn(ncacn_conn->p);
+ if (!ok) {
+ DEBUG(3, ("Failed to call disconnect function\n"));
+ }
+ }
goto fail;
}
diff --git a/source3/rpc_server/rpc_server.h b/source3/rpc_server/rpc_server.h
index 18c790500c..3791589bb6 100644
--- a/source3/rpc_server/rpc_server.h
+++ b/source3/rpc_server/rpc_server.h
@@ -20,6 +20,8 @@
#ifndef _RPC_SERVER_H_
#define _RPC_SERVER_H_
+typedef bool (*dcerpc_ncacn_disconnect_fn)(struct pipes_struct *p);
+
void set_incoming_fault(struct pipes_struct *p);
void process_complete_pdu(struct pipes_struct *p);
bool setup_named_pipe_socket(const char *pipe_name,
@@ -34,6 +36,7 @@ uint16_t setup_dcerpc_ncacn_tcpip_socket(struct tevent_context *ev_ctx,
bool setup_dcerpc_ncalrpc_socket(struct tevent_context *ev_ctx,
struct messaging_context *msg_ctx,
struct ndr_syntax_id syntax_id,
- const char *name);
+ const char *name,
+ dcerpc_ncacn_disconnect_fn fn);
#endif /* _PRC_SERVER_H_ */