From: Stefan Metzmacher Date: Sat, 14 Sep 2024 07:55:20 +0000 (+0200) Subject: s3:rpc_client: add rpccli_bh_auth_session_key() X-Git-Tag: samba-4.21.7~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b7ae6f61af91e4debb8eabfa559de61e9cc0092;p=thirdparty%2Fsamba.git s3:rpc_client: add rpccli_bh_auth_session_key() Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit af16ecece870846323956c37d3e15abe24e336fd) --- diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index 5f7cc33e20c..83869015d5e 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -2215,6 +2215,44 @@ static void rpccli_bh_auth_info(struct dcerpc_binding_handle *h, *auth_level = hs->rpc_cli->auth->auth_level; } +static NTSTATUS rpccli_bh_auth_session_key(struct dcerpc_binding_handle *h, + TALLOC_CTX *mem_ctx, + DATA_BLOB *session_key) +{ + struct rpccli_bh_state *hs = dcerpc_binding_handle_data(h, + struct rpccli_bh_state); + struct pipe_auth_data *auth = NULL; + NTSTATUS status; + + if (hs->rpc_cli == NULL) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + + if (hs->rpc_cli->auth == NULL) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + + auth = hs->rpc_cli->auth; + + if (auth->auth_type == DCERPC_AUTH_TYPE_NONE) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + + if (auth->auth_ctx == NULL) { + return NT_STATUS_NO_USER_SESSION_KEY; + } + + status = gensec_session_key(auth->auth_ctx, + mem_ctx, + session_key); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + talloc_keep_secret(session_key->data); + return NT_STATUS_OK; +} + struct rpccli_bh_raw_call_state { DATA_BLOB in_data; DATA_BLOB out_data; @@ -2388,6 +2426,7 @@ static const struct dcerpc_binding_handle_ops rpccli_bh_ops = { .set_timeout = rpccli_bh_set_timeout, .transport_session_key = rpccli_bh_transport_session_key, .auth_info = rpccli_bh_auth_info, + .auth_session_key = rpccli_bh_auth_session_key, .raw_call_send = rpccli_bh_raw_call_send, .raw_call_recv = rpccli_bh_raw_call_recv, .disconnect_send = rpccli_bh_disconnect_send,