diff options
Diffstat (limited to 'source4/librpc/rpc')
-rw-r--r-- | source4/librpc/rpc/dcerpc.c | 29 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc.h | 4 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_auth.c | 6 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_schannel.c | 4 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_smb.c | 13 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_sock.c | 15 | ||||
-rw-r--r-- | source4/librpc/rpc/dcerpc_util.c | 32 |
7 files changed, 49 insertions, 54 deletions
diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index fa7fe728d4..1f4e72639e 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -67,8 +67,11 @@ static int dcerpc_connection_destructor(void *ptr) } -/* initialise a dcerpc connection. */ -struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx) +/* initialise a dcerpc connection. + the event context is optional +*/ +struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx, + struct event_context *ev) { struct dcerpc_connection *c; @@ -77,6 +80,15 @@ struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx) return NULL; } + if (ev == NULL) { + ev = event_context_init(c); + if (ev == NULL) { + talloc_free(c); + return NULL; + } + } + + c->event_ctx = ev; c->call_id = 1; c->security_state.auth_info = NULL; c->security_state.session_key = dcerpc_generic_session_key; @@ -93,7 +105,7 @@ struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx) } /* initialise a dcerpc pipe. */ -struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx) +struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx, struct event_context *ev) { struct dcerpc_pipe *p; @@ -102,7 +114,7 @@ struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx) return NULL; } - p->conn = dcerpc_connection_init(p); + p->conn = dcerpc_connection_init(p, ev); if (p->conn == NULL) { talloc_free(p); return NULL; @@ -559,13 +571,12 @@ static NTSTATUS full_request(struct dcerpc_connection *c, return status; } - event_add_timed(c->transport.event_context(c), state, + event_add_timed(c->event_ctx, state, timeval_current_ofs(DCERPC_REQUEST_TIMEOUT, 0), dcerpc_full_timeout_handler, state); while (NT_STATUS_IS_OK(state->status) && state->reply_blob) { - struct event_context *ctx = c->transport.event_context(c); - if (event_loop_once(ctx) != 0) { + if (event_loop_once(c->event_ctx) != 0) { return NT_STATUS_CONNECTION_DISCONNECTED; } } @@ -850,7 +861,7 @@ static void dcerpc_request_recv_data(struct dcerpc_connection *c, handle timeouts of individual dcerpc requests */ static void dcerpc_timeout_handler(struct event_context *ev, struct timed_event *te, - struct timeval t, void *private) + struct timeval t, void *private) { struct rpc_request *req = talloc_get_type(private, struct rpc_request); @@ -985,7 +996,7 @@ struct rpc_request *dcerpc_request_send(struct dcerpc_pipe *p, */ struct event_context *dcerpc_event_context(struct dcerpc_pipe *p) { - return p->conn->transport.event_context(p->conn); + return p->conn->event_ctx; } diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h index 2f64c0ef34..3b1cc20bca 100644 --- a/source4/librpc/rpc/dcerpc.h +++ b/source4/librpc/rpc/dcerpc.h @@ -48,6 +48,7 @@ struct dcerpc_connection { uint_t flags; struct dcerpc_security security_state; const char *binding_string; + struct event_context *event_ctx; struct dcerpc_transport { enum dcerpc_transport_t transport; @@ -63,9 +64,6 @@ struct dcerpc_connection { /* send a read request to the server */ NTSTATUS (*send_read)(struct dcerpc_connection *); - /* get an event context for the connection */ - struct event_context *(*event_context)(struct dcerpc_connection *); - /* a callback to the dcerpc code when a full fragment has been received */ void (*recv_data)(struct dcerpc_connection *, DATA_BLOB *, NTSTATUS status); diff --git a/source4/librpc/rpc/dcerpc_auth.c b/source4/librpc/rpc/dcerpc_auth.c index ae0a89910e..7aa563cb9d 100644 --- a/source4/librpc/rpc/dcerpc_auth.c +++ b/source4/librpc/rpc/dcerpc_auth.c @@ -51,7 +51,8 @@ NTSTATUS dcerpc_bind_auth(struct dcerpc_pipe *p, uint8_t auth_type, uint8_t auth DATA_BLOB null_data_blob = data_blob(NULL, 0); if (!p->conn->security_state.generic_state) { - status = gensec_client_start(p, &p->conn->security_state.generic_state); + status = gensec_client_start(p, &p->conn->security_state.generic_state, + p->conn->event_ctx); if (!NT_STATUS_IS_OK(status)) goto done; status = gensec_start_mech_by_authtype(p->conn->security_state.generic_state, @@ -153,7 +154,8 @@ NTSTATUS dcerpc_bind_auth_password(struct dcerpc_pipe *p, p->conn->flags |= DCERPC_CONNECT; } - status = gensec_client_start(p, &p->conn->security_state.generic_state); + status = gensec_client_start(p, &p->conn->security_state.generic_state, + p->conn->event_ctx); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Failed to start GENSEC client mode: %s\n", nt_errstr(status))); return status; diff --git a/source4/librpc/rpc/dcerpc_schannel.c b/source4/librpc/rpc/dcerpc_schannel.c index cc6cbe7b46..1b83b2ec0b 100644 --- a/source4/librpc/rpc/dcerpc_schannel.c +++ b/source4/librpc/rpc/dcerpc_schannel.c @@ -64,7 +64,9 @@ static NTSTATUS dcerpc_schannel_key(TALLOC_CTX *tmp_ctx, } /* Make binding string for netlogon, not the other pipe */ - status = dcerpc_epm_map_binding(tmp_ctx, b, DCERPC_NETLOGON_UUID, DCERPC_NETLOGON_VERSION); + status = dcerpc_epm_map_binding(tmp_ctx, b, + DCERPC_NETLOGON_UUID, DCERPC_NETLOGON_VERSION, + p->conn->event_ctx); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("Failed to map DCERPC/TCP NCACN_NP pipe for '%s' - %s\n", DCERPC_NETLOGON_UUID, nt_errstr(status))); diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c index 1a5a31c330..9096168b64 100644 --- a/source4/librpc/rpc/dcerpc_smb.c +++ b/source4/librpc/rpc/dcerpc_smb.c @@ -310,18 +310,6 @@ static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob, B } /* - return the event context for the pipe, so the caller can wait - for events asynchronously -*/ -static struct event_context *smb_event_context(struct dcerpc_connection *c) -{ - struct smb_private *smb = c->transport.private; - - return smb->tree->session->transport->socket->event.ctx; -} - - -/* shutdown SMB pipe connection */ static NTSTATUS smb_shutdown_pipe(struct dcerpc_connection *c) @@ -426,7 +414,6 @@ NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_connection *c, c->transport.send_request = smb_send_request; c->transport.send_read = send_read_request; - c->transport.event_context = smb_event_context; c->transport.recv_data = NULL; /* Over-ride the default session key with the SMB session key */ diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c index 90013e9778..8bfba008a2 100644 --- a/source4/librpc/rpc/dcerpc_sock.c +++ b/source4/librpc/rpc/dcerpc_sock.c @@ -36,7 +36,6 @@ struct sock_blob { /* transport private information used by general socket pipe transports */ struct sock_private { - struct event_context *event_ctx; struct fd_event *fde; struct socket_context *sock; char *server_name; @@ -260,16 +259,6 @@ static NTSTATUS sock_send_request(struct dcerpc_connection *p, DATA_BLOB *data, } /* - return the event context so the caller can process asynchronously -*/ -static struct event_context *sock_event_context(struct dcerpc_connection *p) -{ - struct sock_private *sock = p->transport.private; - - return sock->event_ctx; -} - -/* shutdown sock pipe connection */ static NTSTATUS sock_shutdown_pipe(struct dcerpc_connection *p) @@ -331,7 +320,6 @@ static NTSTATUS dcerpc_pipe_open_socket(struct dcerpc_connection *c, c->transport.send_request = sock_send_request; c->transport.send_read = sock_send_read; - c->transport.event_context = sock_event_context; c->transport.recv_data = NULL; c->transport.shutdown_pipe = sock_shutdown_pipe; @@ -339,13 +327,12 @@ static NTSTATUS dcerpc_pipe_open_socket(struct dcerpc_connection *c, sock->sock = socket_ctx; sock->server_name = strupper_talloc(sock, server); - sock->event_ctx = event_context_init(sock); sock->pending_send = NULL; sock->recv.received = 0; sock->recv.data = data_blob(NULL, 0); sock->recv.pending_count = 0; - sock->fde = event_add_fd(sock->event_ctx, sock, socket_get_fd(sock->sock), + sock->fde = event_add_fd(c->event_ctx, sock, socket_get_fd(sock->sock), 0, sock_io_handler, c); c->transport.private = sock; diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index 8ae7814c26..d4a0ad2874 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -792,7 +792,7 @@ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding * } NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, - const char *uuid, uint_t version) + const char *uuid, uint_t version, struct event_context *ev) { struct dcerpc_pipe *p; NTSTATUS status; @@ -850,7 +850,7 @@ NTSTATUS dcerpc_epm_map_binding(TALLOC_CTX *mem_ctx, struct dcerpc_binding *bind epmapper_binding, DCERPC_EPMAPPER_UUID, DCERPC_EPMAPPER_VERSION, - anon_creds); + anon_creds, ev); if (!NT_STATUS_IS_OK(status)) { return status; @@ -994,12 +994,12 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx, status = smbcli_full_connection(p->conn, &cli, binding->host, "IPC$", NULL, - anon_creds); + anon_creds, p->conn->event_ctx); } else { status = smbcli_full_connection(p->conn, &cli, binding->host, "IPC$", NULL, - credentials); + credentials, p->conn->event_ctx); } if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("Failed to connect to %s - %s\n", binding->host, nt_errstr(status))); @@ -1008,7 +1008,9 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_np(TALLOC_CTX *tmp_ctx, /* Look up identifier using the epmapper */ if (!binding->endpoint) { - status = dcerpc_epm_map_binding(tmp_ctx, binding, pipe_uuid, pipe_version); + status = dcerpc_epm_map_binding(tmp_ctx, binding, + pipe_uuid, pipe_version, + p->conn->event_ctx); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("Failed to map DCERPC/TCP NCACN_NP pipe for '%s' - %s\n", pipe_uuid, nt_errstr(status))); @@ -1040,7 +1042,9 @@ static NTSTATUS dcerpc_pipe_connect_ncalrpc(TALLOC_CTX *tmp_ctx, /* Look up identifier using the epmapper */ if (!binding->endpoint) { - status = dcerpc_epm_map_binding(tmp_ctx, binding, pipe_uuid, pipe_version); + status = dcerpc_epm_map_binding(tmp_ctx, binding, + pipe_uuid, pipe_version, + p->conn->event_ctx); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("Failed to map DCERPC/TCP NCALRPC identifier for '%s' - %s\n", pipe_uuid, nt_errstr(status))); @@ -1100,7 +1104,8 @@ static NTSTATUS dcerpc_pipe_connect_ncacn_ip_tcp(TALLOC_CTX *tmp_ctx, if (!binding->endpoint) { status = dcerpc_epm_map_binding(tmp_ctx, binding, - pipe_uuid, pipe_version); + pipe_uuid, pipe_version, + p->conn->event_ctx); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("Failed to map DCERPC/TCP port for '%s' - %s\n", pipe_uuid, nt_errstr(status))); @@ -1129,7 +1134,8 @@ NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx, struct dcerpc_binding *binding, const char *pipe_uuid, uint32_t pipe_version, - struct cli_credentials *credentials) + struct cli_credentials *credentials, + struct event_context *ev) { NTSTATUS status = NT_STATUS_INVALID_PARAMETER; struct dcerpc_pipe *p; @@ -1138,7 +1144,7 @@ NTSTATUS dcerpc_pipe_connect_b(TALLOC_CTX *parent_ctx, (*pp) = NULL; - p = dcerpc_pipe_init(parent_ctx); + p = dcerpc_pipe_init(parent_ctx, ev); if (p == NULL) { return NT_STATUS_NO_MEMORY; } @@ -1189,7 +1195,8 @@ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, const char *binding, const char *pipe_uuid, uint32_t pipe_version, - struct cli_credentials *credentials) + struct cli_credentials *credentials, + struct event_context *ev) { struct dcerpc_binding *b; NTSTATUS status; @@ -1210,7 +1217,8 @@ NTSTATUS dcerpc_pipe_connect(TALLOC_CTX *parent_ctx, DEBUG(3,("Using binding %s\n", dcerpc_binding_string(tmp_ctx, b))); status = dcerpc_pipe_connect_b(tmp_ctx, - pp, b, pipe_uuid, pipe_version, credentials); + pp, b, pipe_uuid, pipe_version, + credentials, ev); if (NT_STATUS_IS_OK(status)) { *pp = talloc_reference(parent_ctx, *pp); @@ -1235,7 +1243,7 @@ NTSTATUS dcerpc_secondary_connection(struct dcerpc_pipe *p, struct dcerpc_pipe * struct smbcli_tree *tree; NTSTATUS status = NT_STATUS_INVALID_PARAMETER; - (*p2) = dcerpc_pipe_init(p); + (*p2) = dcerpc_pipe_init(p, p->conn->event_ctx); if (*p2 == NULL) { return NT_STATUS_NO_MEMORY; } |