librpc: Add "private_data" to struct dcesrv_context_callbacks
authorVolker Lendecke <vl@samba.org>
Fri, 29 Jan 2021 17:16:08 +0000 (18:16 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 16 Mar 2021 17:09:31 +0000 (17:09 +0000)
Not used right now, but we should never have callbacks without a
"private_data" pointer. Some of the callbacks could even today benefit
from this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
librpc/rpc/dcesrv_auth.c
librpc/rpc/dcesrv_core.c
librpc/rpc/dcesrv_core.h
source3/rpc_server/rpc_ncacn_np.c
source3/rpc_server/rpc_server.c
source3/rpc_server/rpc_server.h
source3/winbindd/winbindd_dual_ndr.c
source4/rpc_server/dcerpc_server.c

index 8ac90f2a2bd9140b8e85ff5977ad9b1c62183a19..1f09bf0d18e17df89a166d3790920612c92e606a 100644 (file)
@@ -79,6 +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;
        NTSTATUS status;
 
        if (auth->auth_started) {
@@ -127,9 +128,11 @@ static bool dcesrv_auth_prepare_gensec(struct dcesrv_call_state *call)
        auth->auth_level = call->in_auth_info.auth_level;
        auth->auth_context_id = call->in_auth_info.auth_context_id;
 
-       status = call->conn->dce_ctx->callbacks.auth.gensec_prepare(auth,
-                                               call,
-                                               &auth->gensec_security);
+       status = cb->auth.gensec_prepare(
+               auth,
+               call,
+               &auth->gensec_security,
+               cb->auth.private_data);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("Failed to call samba_server_gensec_start %s\n",
                          nt_errstr(status)));
@@ -246,6 +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;
 
        if (auth->auth_audited) {
                return;
@@ -267,11 +271,11 @@ void dcesrv_default_auth_state_prepare_request(struct dcesrv_call_state *call)
                return;
        }
 
-       if (!call->conn->dce_ctx->callbacks.log.successful_authz) {
+       if (cb->log.successful_authz == NULL) {
                return;
        }
 
-       call->conn->dce_ctx->callbacks.log.successful_authz(call);
+       cb->log.successful_authz(call, cb->log.private_data);
 }
 
 /*
@@ -283,6 +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;
        NTSTATUS status;
 
        if (pkt->auth_length == 0) {
@@ -291,8 +296,8 @@ bool dcesrv_auth_bind(struct dcesrv_call_state *call)
                auth->auth_context_id = 0;
                auth->auth_started = true;
 
-               if (call->conn->dce_ctx->callbacks.log.successful_authz) {
-                       call->conn->dce_ctx->callbacks.log.successful_authz(call);
+               if (cb->log.successful_authz != NULL) {
+                       cb->log.successful_authz(call, cb->log.private_data);
                }
 
                return true;
index 7a20ffe71a0e2899ee4fdae7628c080911b813cd..a5bfac507f54b4bf47cbe799902197371184a4cc 100644 (file)
@@ -952,7 +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);
+       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));
index 6371552a56dd3d350e5ec7411a1de640227492ff..d566aa532172155318b12274c311d47737f717fe 100644 (file)
@@ -381,15 +381,22 @@ struct dcesrv_assoc_group {
 
 struct dcesrv_context_callbacks {
        struct {
-               void (*successful_authz)(struct dcesrv_call_state *);
+               void (*successful_authz)(
+                       struct dcesrv_call_state *call, void *private_data);
+               void *private_data;
        } log;
        struct {
-               NTSTATUS (*gensec_prepare)(TALLOC_CTX *mem_ctx,
-                                       struct dcesrv_call_state *call,
-                                       struct gensec_security **out);
+               NTSTATUS (*gensec_prepare)(
+                       TALLOC_CTX *mem_ctx,
+                       struct dcesrv_call_state *call,
+                       struct gensec_security **out,
+                       void *private_data);
+               void *private_data;
        } auth;
        struct {
-               NTSTATUS (*find)(struct dcesrv_call_state *);
+               NTSTATUS (*find)(
+                       struct dcesrv_call_state *call, void *private_data);
+               void *private_data;
        } assoc_group;
 };
 
index 569304b3467e3338c6fa0ed19424ae2442f00c5b..30f2d88d4bf84ac44ad26649c4a1aa54801337ad 100644 (file)
@@ -488,7 +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(state->call);
+               status = dce_ctx->callbacks.assoc_group.find(
+                       state->call,
+                       dce_ctx->callbacks.assoc_group.private_data);
                if (tevent_req_nterror(req, status)) {
                        return tevent_req_post(req, ev);
                }
index badb63ad84b4f84dec6140c571d908840a60b442..adf2ba70628bbeb783b13af5d1c2fd845b08b715 100644 (file)
@@ -533,9 +533,11 @@ static void dcesrv_ncacn_accept_step2(struct dcerpc_ncacn_conn *ncacn_conn)
        return;
 }
 
-NTSTATUS dcesrv_auth_gensec_prepare(TALLOC_CTX *mem_ctx,
-                                   struct dcesrv_call_state *call,
-                                   struct gensec_security **out)
+NTSTATUS dcesrv_auth_gensec_prepare(
+       TALLOC_CTX *mem_ctx,
+       struct dcesrv_call_state *call,
+       struct gensec_security **out,
+       void *private_data)
 {
        struct gensec_security *gensec = NULL;
        NTSTATUS status;
@@ -559,7 +561,9 @@ NTSTATUS dcesrv_auth_gensec_prepare(TALLOC_CTX *mem_ctx,
        return NT_STATUS_OK;
 }
 
-void dcesrv_log_successful_authz(struct dcesrv_call_state *call)
+void dcesrv_log_successful_authz(
+       struct dcesrv_call_state *call,
+       void *private_data)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct auth4_context *auth4_context = NULL;
@@ -631,7 +635,9 @@ static NTSTATUS dcesrv_assoc_group_new(struct dcesrv_call_state *call,
        return NT_STATUS_OK;
 }
 
-NTSTATUS dcesrv_assoc_group_find(struct dcesrv_call_state *call)
+NTSTATUS dcesrv_assoc_group_find(
+       struct dcesrv_call_state *call,
+       void *private_data)
 {
        uint32_t assoc_group_id = call->pkt.u.bind.assoc_group_id;
 
index f735c394e8322d1ca5763243f2f4f82fda9fd60a..1774809491995ab9b469cfadc2d9bb6655e6a8dd 100644 (file)
@@ -90,11 +90,17 @@ void dcerpc_ncacn_accept(struct tevent_context *ev_ctx,
                         dcerpc_ncacn_termination_fn termination_fn,
                         void *termination_data);
 
-NTSTATUS dcesrv_auth_gensec_prepare(TALLOC_CTX *mem_ctx,
-                                   struct dcesrv_call_state *call,
-                                   struct gensec_security **out);
-void dcesrv_log_successful_authz(struct dcesrv_call_state *call);
-NTSTATUS dcesrv_assoc_group_find(struct dcesrv_call_state *call);
+NTSTATUS dcesrv_auth_gensec_prepare(
+       TALLOC_CTX *mem_ctx,
+       struct dcesrv_call_state *call,
+       struct gensec_security **out,
+       void *private_data);
+void dcesrv_log_successful_authz(
+       struct dcesrv_call_state *call,
+       void *private_data);
+NTSTATUS dcesrv_assoc_group_find(
+       struct dcesrv_call_state *call,
+       void *private_data);
 
 NTSTATUS dcesrv_endpoint_by_ncacn_np_name(struct dcesrv_context *dce_ctx,
                                          const char *endpoint,
index 0cc86faeab62ff2e4c3c81b35d3740a56173e2df..39c3a146c037e15917b92485935ca7189dfbdfe7 100644 (file)
@@ -481,6 +481,7 @@ enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
        struct dcesrv_connection *dcesrv_conn = NULL;
        struct dcesrv_call_state *dcesrv_call = NULL;
        struct data_blob_list_item *rep = NULL;
+       struct dcesrv_context_callbacks *cb = NULL;
        uint32_t opnum = state->request->data.ndrcmd;
        TALLOC_CTX *mem_ctx;
        NTSTATUS status;
@@ -522,8 +523,10 @@ enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
 
        ZERO_STRUCT(dcesrv_call->pkt);
        dcesrv_call->pkt.u.bind.assoc_group_id = 0;
-       status = dcesrv_call->conn->dce_ctx->callbacks.assoc_group.find(
-                                                               dcesrv_call);
+
+       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)) {
                goto out;
        }
index 94f7146517a6ea59fd635d1c84562a264212b883..2b63305cde272d683fe818d1146dfdaca0e3cd6e 100644 (file)
@@ -115,7 +115,9 @@ static struct dcesrv_assoc_group *dcesrv_assoc_group_new(struct dcesrv_connectio
        return assoc_group;
 }
 
-NTSTATUS dcesrv_assoc_group_find(struct dcesrv_call_state *call)
+NTSTATUS dcesrv_assoc_group_find(
+       struct dcesrv_call_state *call,
+       void *private_data)
 {
        /*
          if provided, check the assoc_group is valid
@@ -635,7 +637,9 @@ _PUBLIC_ struct server_id dcesrv_server_id(struct dcesrv_connection *conn)
        return srv_conn->server_id;
 }
 
-void log_successful_dcesrv_authz_event(struct dcesrv_call_state *call)
+void log_successful_dcesrv_authz_event(
+       struct dcesrv_call_state *call,
+       void *private_data)
 {
        struct dcesrv_auth *auth = call->auth_state;
        enum dcerpc_transport_t transport =
@@ -666,9 +670,11 @@ void log_successful_dcesrv_authz_event(struct dcesrv_call_state *call)
        auth->auth_audited = true;
 }
 
-NTSTATUS dcesrv_gensec_prepare(TALLOC_CTX *mem_ctx,
-                              struct dcesrv_call_state *call,
-                              struct gensec_security **out)
+NTSTATUS dcesrv_gensec_prepare(
+       TALLOC_CTX *mem_ctx,
+       struct dcesrv_call_state *call,
+       struct gensec_security **out,
+       void *private_data)
 {
        struct cli_credentials *server_creds = NULL;
        struct imessaging_context *imsg_ctx =