1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

librpc: Make "dcesrv_context->callbacks" a pointer

This structure just grew from 3 to 6 pointers, avoid making a copy of
this. All callers of dcesrv_init_context() have this as a static
struct in the C object, so a pointer to that won't change.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2021-02-02 15:07:35 +01:00 committed by Jeremy Allison
parent c8f47dfc03
commit 9614273aa3
6 changed files with 19 additions and 13 deletions

View File

@ -79,7 +79,7 @@ static bool dcesrv_auth_prepare_gensec(struct dcesrv_call_state *call)
{
struct dcesrv_connection *dce_conn = call->conn;
struct dcesrv_auth *auth = call->auth_state;
struct dcesrv_context_callbacks *cb = &call->conn->dce_ctx->callbacks;
struct dcesrv_context_callbacks *cb = call->conn->dce_ctx->callbacks;
NTSTATUS status;
if (auth->auth_started) {
@ -249,7 +249,7 @@ void dcesrv_default_auth_state_prepare_request(struct dcesrv_call_state *call)
{
struct dcesrv_connection *dce_conn = call->conn;
struct dcesrv_auth *auth = call->auth_state;
struct dcesrv_context_callbacks *cb = &call->conn->dce_ctx->callbacks;
struct dcesrv_context_callbacks *cb = call->conn->dce_ctx->callbacks;
if (auth->auth_audited) {
return;
@ -287,7 +287,7 @@ bool dcesrv_auth_bind(struct dcesrv_call_state *call)
{
struct ncacn_packet *pkt = &call->pkt;
struct dcesrv_auth *auth = call->auth_state;
struct dcesrv_context_callbacks *cb = &call->conn->dce_ctx->callbacks;
struct dcesrv_context_callbacks *cb = call->conn->dce_ctx->callbacks;
NTSTATUS status;
if (pkt->auth_length == 0) {

View File

@ -952,8 +952,8 @@ static NTSTATUS dcesrv_bind(struct dcesrv_call_state *call)
conn->max_recv_frag = max_rep;
conn->max_xmit_frag = max_rep;
status = dce_ctx->callbacks.assoc_group.find(
call, dce_ctx->callbacks.assoc_group.private_data);
status = dce_ctx->callbacks->assoc_group.find(
call, dce_ctx->callbacks->assoc_group.private_data);
if (!NT_STATUS_IS_OK(status)) {
DBG_NOTICE("Failed to find assoc_group 0x%08x: %s\n",
call->pkt.u.bind.assoc_group_id, nt_errstr(status));
@ -2311,6 +2311,10 @@ _PUBLIC_ NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
{
struct dcesrv_context *dce_ctx;
if (cb == NULL) {
return NT_STATUS_INVALID_PARAMETER;
}
dce_ctx = talloc_zero(mem_ctx, struct dcesrv_context);
NT_STATUS_HAVE_NO_MEMORY(dce_ctx);
@ -2330,9 +2334,7 @@ _PUBLIC_ NTSTATUS dcesrv_init_context(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
dce_ctx->broken_connections = NULL;
if (cb != NULL) {
dce_ctx->callbacks = *cb;
}
dce_ctx->callbacks = cb;
*_dce_ctx = dce_ctx;
return NT_STATUS_OK;

View File

@ -440,7 +440,7 @@ struct dcesrv_context {
struct dcesrv_connection *broken_connections;
struct dcesrv_context_callbacks callbacks;
struct dcesrv_context_callbacks *callbacks;
};
/* this structure is used by modules to determine the size of some critical types */

View File

@ -488,9 +488,9 @@ static struct tevent_req *rpcint_bh_raw_call_send(TALLOC_CTX *mem_ctx,
if (hs->conn->assoc_group == NULL) {
ZERO_STRUCT(state->call->pkt);
state->call->pkt.u.bind.assoc_group_id = 0;
status = dce_ctx->callbacks.assoc_group.find(
status = dce_ctx->callbacks->assoc_group.find(
state->call,
dce_ctx->callbacks.assoc_group.private_data);
dce_ctx->callbacks->assoc_group.private_data);
if (tevent_req_nterror(req, status)) {
return tevent_req_post(req, ev);
}

View File

@ -524,7 +524,7 @@ enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
ZERO_STRUCT(dcesrv_call->pkt);
dcesrv_call->pkt.u.bind.assoc_group_id = 0;
cb = &dcesrv_call->conn->dce_ctx->callbacks;
cb = dcesrv_call->conn->dce_ctx->callbacks;
status = cb->assoc_group.find(
dcesrv_call, cb->assoc_group.private_data);
if (!NT_STATUS_IS_OK(status)) {

View File

@ -21,6 +21,10 @@ struct test_state {
struct dcesrv_context *dce_ctx;
};
static struct dcesrv_context_callbacks srv_callbacks = {
.log.successful_authz = NULL,
};
static int setup_samr(void **state)
{
TALLOC_CTX *mem_ctx;
@ -42,7 +46,7 @@ static int setup_samr(void **state)
status = dcerpc_register_ep_server(ep_server);
assert_true(NT_STATUS_IS_OK(status));
status = dcesrv_init_context(s, NULL, NULL, &s->dce_ctx);
status = dcesrv_init_context(s, NULL, &srv_callbacks, &s->dce_ctx);
assert_true(NT_STATUS_IS_OK(status));
status = dcesrv_init_ep_server(s->dce_ctx, "samr");