]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
librpc/rpc: allow dcesrv_context to propose the preferred ndr syntax
authorStefan Metzmacher <metze@samba.org>
Mon, 14 Aug 2023 10:48:28 +0000 (12:48 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 17 Oct 2023 19:20:38 +0000 (19:20 +0000)
This allows specific services to use ndr64.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
librpc/rpc/dcesrv_core.c
librpc/rpc/dcesrv_core.h
librpc/rpc/dcesrv_reply.c

index ee0ac2ce7ade2c41428042bb172425b12ee5bfa3..00ac8e421e361a20dcfb55f528abb6eed2132e47 100644 (file)
@@ -704,10 +704,7 @@ _PUBLIC_ NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
 
        p->default_auth_state = auth;
 
-       /*
-        * For now we only support NDR32.
-        */
-       p->preferred_transfer = &ndr_transfer_syntax_ndr;
+       p->preferred_transfer = dce_ctx->preferred_transfer;
 
        *_p = p;
        return NT_STATUS_OK;
@@ -1594,6 +1591,8 @@ static NTSTATUS dcesrv_check_or_create_context(struct dcesrv_call_state *call,
        context->context_id = ctx->context_id;
        context->iface = iface;
        context->transfer_syntax = *selected_transfer;
+       context->ndr64 = ndr_syntax_id_equal(&context->transfer_syntax,
+                                            &ndr_transfer_syntax_ndr64);
        DLIST_ADD(call->conn->contexts, context);
        call->context = context;
        talloc_set_destructor(context, dcesrv_connection_context_destructor);
@@ -2034,6 +2033,10 @@ static NTSTATUS dcesrv_request(struct dcesrv_call_state *call)
                return dcesrv_fault(call, faultcode);
        }
 
+       if (call->context->ndr64) {
+               call->ndr_pull->flags |= LIBNDR_FLAG_NDR64;
+       }
+
        /* unravel the NDR for the packet */
        status = call->context->iface->ndr_pull(call, call, pull, &call->r);
        if (!NT_STATUS_IS_OK(status)) {
@@ -2566,6 +2569,11 @@ _PUBLIC_ NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
        dce_ctx->broken_connections = NULL;
        dce_ctx->callbacks = cb;
 
+       /*
+        * For now we only support NDR32.
+        */
+       dce_ctx->preferred_transfer = &ndr_transfer_syntax_ndr;
+
        *_dce_ctx = dce_ctx;
        return NT_STATUS_OK;
 }
index 3e23e125cbc71b1f2fe76fa20134d67fda7dc827..98f8dd9750672a42fab45d7ca6cf2a1e2f066684 100644 (file)
@@ -232,6 +232,7 @@ struct dcesrv_connection_context {
 
        /* the negotiated transfer syntax */
        struct ndr_syntax_id transfer_syntax;
+       bool ndr64;
 };
 
 
@@ -454,6 +455,11 @@ struct dcesrv_context {
 
        struct dcesrv_connection *broken_connections;
 
+       /*
+        * Our preferred transfer syntax.
+        */
+       const struct ndr_syntax_id *preferred_transfer;
+
        struct dcesrv_context_callbacks *callbacks;
 };
 
index 5b4429956e75f37f8f1648acbf493be0c86ac284..bc103e51171d94647d19275e3ec38976ba280671 100644 (file)
@@ -168,6 +168,10 @@ _PUBLIC_ NTSTATUS dcesrv_reply(struct dcesrv_call_state *call)
                push->flags |= LIBNDR_FLAG_BIGENDIAN;
        }
 
+       if (context->ndr64) {
+               push->flags |= LIBNDR_FLAG_NDR64;
+       }
+
        status = context->iface->ndr_push(call, call, push, call->r);
        if (!NT_STATUS_IS_OK(status)) {
                return dcesrv_fault(call, call->fault_code);