From 5ea6708d819c392096413e53196d65108b1e9283 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 14 Dec 2016 09:38:28 +1300 Subject: [PATCH] s4-rpc_server: Add comments explaining the control flow around dcesrv_bind() Signed-off-by: Andrew Bartlett Reviewed-by: Stefan Metzmacher --- source4/rpc_server/dcerpc_server.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c index 072e35249c0..0d39744172e 100644 --- a/source4/rpc_server/dcerpc_server.c +++ b/source4/rpc_server/dcerpc_server.c @@ -792,6 +792,14 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) /* * Try to negotiate one new presentation context. + * + * Deep in here we locate the iface (by uuid) that the client + * requested, from the list of interfaces on the + * call->conn->endpoint, and call iface->bind() on that iface. + * + * call->conn was set up at the accept() of the socket, and + * call->conn->endpoint has a list of interfaces restricted to + * this port or pipe. */ status = dcesrv_negotiate_contexts(call, &call->pkt.u.bind, ack_ctx_list); if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTOCOL_ERROR)) { @@ -801,6 +809,12 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) return status; } + /* + * At this point we know which interface (eg netlogon, lsa, + * drsuapi) the caller requested. This is available on + * call->conntext->iface. + */ + if ((call->pkt.pfc_flags & DCERPC_PFC_FLAG_CONC_MPX) && (call->state_flags & DCESRV_CALL_STATE_FLAG_MULTIPLEXED)) { call->conn->state_flags |= DCESRV_CALL_STATE_FLAG_MULTIPLEXED; @@ -811,7 +825,11 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call) call->conn->state_flags |= DCESRV_CALL_STATE_FLAG_PROCESS_PENDING_CALL; } - /* handle any authentication that is being requested */ + /* + * After finding the interface and setting up the NDR + * transport negotiation etc, handle any authentication that + * is being requested. + */ if (!dcesrv_auth_bind(call)) { struct dcesrv_auth *auth = &call->conn->auth_state; @@ -2246,6 +2264,13 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn) } } + /* + * This fills in dcesrv_conn->endpoint with the endpoint + * associated with the socket. From this point on we know + * which (group of) services we are handling, but not the + * specific interface. + */ + status = dcesrv_endpoint_connect(dcesrv_sock->dcesrv_ctx, srv_conn, dcesrv_sock->endpoint, -- 2.11.4.GIT