dcesrv_core: Add dcesrv_loop_next_packet()
authorVolker Lendecke <vl@samba.org>
Thu, 21 Jan 2021 14:28:31 +0000 (15:28 +0100)
committerVolker Lendecke <vl@samba.org>
Fri, 10 Dec 2021 14:02:30 +0000 (14:02 +0000)
This is used by the helpers of samba-dcerpcd: When accepting a DCERPC
client, normally the server engine would read the initial bind
packet. In case of samba-dcerpcd the bind packet will already be read
from the socket, so we need to inject it into the rpc server engine
externally.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
librpc/rpc/dcesrv_core.c
librpc/rpc/dcesrv_core.h

index c0567bb27f0cf51db1be99b0c732ffc2aefd7c3c..ff38bba997be0bdd45c61c1faf80eef97a35ffb0 100644 (file)
@@ -2909,6 +2909,28 @@ static void dcesrv_read_fragment_done(struct tevent_req *subreq)
                return;
        }
 
+       dcesrv_loop_next_packet(dce_conn, pkt, buffer);
+}
+
+/**
+ * @brief Start the dcesrv loop, inducing the bind as a blob
+ *
+ * Like dcesrv_connection_loop_start() but used from connections
+ * where the caller has already read the dcerpc bind packet from
+ * the socket and is available as a DATA_BLOB.
+ *
+ * @param[in] dce_conn The connection to start
+ * @param[in] pkt The parsed bind packet
+ * @param[in] buffer The full binary bind including auth data
+ */
+void dcesrv_loop_next_packet(
+       struct dcesrv_connection *dce_conn,
+       struct ncacn_packet *pkt,
+       DATA_BLOB buffer)
+{
+       struct tevent_req *subreq = NULL;
+       NTSTATUS status;
+
        status = dcesrv_process_ncacn_packet(dce_conn, pkt, buffer);
        if (!NT_STATUS_IS_OK(status)) {
                dcesrv_terminate_connection(dce_conn, nt_errstr(status));
index 289cdebaa194fce5125c3796b9976188cf7ab48c..1c0d346bfe4fc73404876a5f7c1366576376f06c 100644 (file)
@@ -640,6 +640,11 @@ _PUBLIC_ void dcesrv_sock_report_output_data(struct dcesrv_connection *dce_conn)
 
 _PUBLIC_ NTSTATUS dcesrv_connection_loop_start(struct dcesrv_connection *conn);
 
+_PUBLIC_ void dcesrv_loop_next_packet(
+       struct dcesrv_connection *dce_conn,
+       struct ncacn_packet *pkt,
+       DATA_BLOB buffer);
+
 _PUBLIC_ NTSTATUS dcesrv_call_dispatch_local(struct dcesrv_call_state *call);
 
 _PUBLIC_ const struct dcesrv_interface *find_interface_by_syntax_id(