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

s4:rpc_server: Remove imessaging_context from dcerpc core structs

Add a helper function to retrieve the imessaging_context from the
stream connection.

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Samuel Cabrero 2019-01-23 20:37:21 +01:00 committed by Andreas Schneider
parent 3d529762df
commit 3d7167f4f4
11 changed files with 98 additions and 44 deletions

View File

@ -74,6 +74,8 @@ void dcesrv_irpc_forward_rpc_call(struct dcesrv_call_state *dce_call, TALLOC_CTX
struct tevent_req *subreq;
struct auth_session_info *session_info =
dcesrv_call_session_info(dce_call);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
st = talloc(mem_ctx, struct dcesrv_forward_state);
if (st == NULL) {
@ -93,8 +95,10 @@ void dcesrv_irpc_forward_rpc_call(struct dcesrv_call_state *dce_call, TALLOC_CTX
return;
}
binding_handle = irpc_binding_handle_by_name(st, dce_call->msg_ctx,
dest_task, ndr_table);
binding_handle = irpc_binding_handle_by_name(st,
imsg_ctx,
dest_task,
ndr_table);
if (binding_handle == NULL) {
DEBUG(0,("%s: Failed to forward request to %s task\n",
opname, dest_task));

View File

@ -609,7 +609,6 @@ static NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
const struct dcesrv_endpoint *ep,
struct auth_session_info *session_info,
struct tevent_context *event_ctx,
struct imessaging_context *msg_ctx,
struct server_id server_id,
uint32_t state_flags,
struct dcesrv_connection **_p)
@ -628,7 +627,6 @@ static NTSTATUS dcesrv_endpoint_connect(struct dcesrv_context *dce_ctx,
p->endpoint = ep;
p->packet_log_dir = lpcfg_lock_directory(dce_ctx->lp_ctx);
p->event_ctx = event_ctx;
p->msg_ctx = msg_ctx;
p->server_id = server_id;
p->state_flags = state_flags;
p->allow_bind = true;
@ -2043,7 +2041,6 @@ static NTSTATUS dcesrv_process_ncacn_packet(struct dcesrv_connection *dce_conn,
}
call->conn = dce_conn;
call->event_ctx = dce_conn->event_ctx;
call->msg_ctx = dce_conn->msg_ctx;
call->state_flags = call->conn->state_flags;
call->time = timeval_current();
call->list = DCESRV_LIST_NONE;
@ -2825,7 +2822,6 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
dcesrv_sock->endpoint,
srv_conn->session_info,
srv_conn->event.ctx,
srv_conn->msg_ctx,
srv_conn->server_id,
DCESRV_CALL_STATE_FLAG_MAY_ASYNC,
&dcesrv_conn);
@ -3389,3 +3385,12 @@ _PUBLIC_ void dcesrv_call_auth_info(struct dcesrv_call_state *dce_call,
*auth_level = auth->auth_level;
}
}
_PUBLIC_ struct imessaging_context *dcesrv_imessaging_context(
struct dcesrv_connection *conn)
{
struct stream_connection *srv_conn =
talloc_get_type_abort(conn->transport.private_data,
struct stream_connection);
return srv_conn->msg_ctx;
}

View File

@ -127,9 +127,6 @@ struct dcesrv_call_state {
/* the backend can use this event context for async replies */
struct tevent_context *event_ctx;
/* the message_context that will be used for async replies */
struct imessaging_context *msg_ctx;
/* this is the pointer to the allocated function struct */
void *r;
@ -263,9 +260,6 @@ struct dcesrv_connection {
/* the event_context that will be used for this connection */
struct tevent_context *event_ctx;
/* the message_context that will be used for this connection */
struct imessaging_context *msg_ctx;
/* the server_id that will be used for this connection */
struct server_id server_id;
@ -581,4 +575,7 @@ _PUBLIC_ void *_dcesrv_iface_state_find_conn(
_dcesrv_iface_state_find_conn((call), (magic)), \
_type)
_PUBLIC_ struct imessaging_context *dcesrv_imessaging_context(
struct dcesrv_connection *conn);
#endif /* SAMBA_DCERPC_SERVER_H */

View File

@ -81,6 +81,8 @@ static bool dcesrv_auth_prepare_gensec(struct dcesrv_call_state *call)
struct cli_credentials *server_credentials = NULL;
struct dcesrv_connection *dce_conn = call->conn;
struct dcesrv_auth *auth = call->auth_state;
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(call->conn);
NTSTATUS status;
if (auth->auth_started) {
@ -146,7 +148,7 @@ static bool dcesrv_auth_prepare_gensec(struct dcesrv_call_state *call)
status = samba_server_gensec_start(auth,
call->event_ctx,
call->msg_ctx,
imsg_ctx,
call->conn->dce_ctx->lp_ctx,
server_credentials,
NULL,
@ -236,6 +238,8 @@ static void log_successful_dcesrv_authz_event(struct dcesrv_call_state *call)
struct dcesrv_auth *auth = call->auth_state;
enum dcerpc_transport_t transport =
dcerpc_binding_get_transport(call->conn->endpoint->ep_description);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(call->conn);
const char *auth_type = derpc_transport_string_by_transport(transport);
const char *transport_protection = AUTHZ_TRANSPORT_PROTECTION_NONE;
@ -248,7 +252,7 @@ static void log_successful_dcesrv_authz_event(struct dcesrv_call_state *call)
* covered ncacn_np pass-through auth, and anonymous
* DCE/RPC (eg epmapper, netlogon etc)
*/
log_successful_authz_event(call->conn->msg_ctx,
log_successful_authz_event(imsg_ctx,
call->conn->dce_ctx->lp_ctx,
call->conn->remote_address,
call->conn->local_address,

View File

@ -2675,6 +2675,8 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_
{
struct auth_session_info *session_info =
dcesrv_call_session_info(dce_call);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
struct drsuapi_DsReplicaObjectIdentifier *ncRoot;
int ret;
uint32_t i, k;
@ -3450,9 +3452,11 @@ allowed:
to send notifies using the GC SPN */
ureq.options |= (req10->replica_flags & DRSUAPI_DRS_REF_GCSPN);
werr = drsuapi_UpdateRefs(dce_call->msg_ctx,
dce_call->event_ctx, b_state,
mem_ctx, &ureq);
werr = drsuapi_UpdateRefs(imsg_ctx,
dce_call->event_ctx,
b_state,
mem_ctx,
&ureq);
if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,(__location__ ": Failed UpdateRefs on %s for %s in DsGetNCChanges - %s\n",
drs_ObjectIdentifier_to_string(mem_ctx, ncRoot), ureq.dest_dsa_dns_name,

View File

@ -338,6 +338,8 @@ WERROR dcesrv_drsuapi_DsReplicaUpdateRefs(struct dcesrv_call_state *dce_call, TA
{
struct auth_session_info *session_info =
dcesrv_call_session_info(dce_call);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
struct dcesrv_handle *h;
struct drsuapi_bind_state *b_state;
struct drsuapi_DsReplicaUpdateRefsRequest1 *req;
@ -378,8 +380,11 @@ WERROR dcesrv_drsuapi_DsReplicaUpdateRefs(struct dcesrv_call_state *dce_call, TA
}
}
werr = drsuapi_UpdateRefs(dce_call->msg_ctx, dce_call->event_ctx,
b_state, mem_ctx, req);
werr = drsuapi_UpdateRefs(imsg_ctx,
dce_call->event_ctx,
b_state,
mem_ctx,
req);
#if 0
NDR_PRINT_FUNCTION_DEBUG(drsuapi_DsReplicaUpdateRefs, NDR_BOTH, r);

View File

@ -1105,6 +1105,8 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc
char *dns_encoded = NULL;
char *netbios_encoded = NULL;
char *sid_encoded = NULL;
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
DCESRV_PULL_HANDLE(policy_handle, r->in.policy_handle, LSA_HANDLE_POLICY);
ZERO_STRUCTP(r->out.trustdom_handle);
@ -1364,13 +1366,16 @@ static NTSTATUS dcesrv_lsa_CreateTrustedDomain_base(struct dcesrv_call_state *dc
/*
* Notify winbindd that we have a new trust
*/
status = irpc_servers_byname(dce_call->msg_ctx,
status = irpc_servers_byname(imsg_ctx,
mem_ctx,
"winbind_server",
&num_server_ids, &server_ids);
&num_server_ids,
&server_ids);
if (NT_STATUS_IS_OK(status) && num_server_ids >= 1) {
imessaging_send(dce_call->msg_ctx, server_ids[0],
MSG_WINBIND_RELOAD_TRUSTED_DOMAINS, NULL);
imessaging_send(imsg_ctx,
server_ids[0],
MSG_WINBIND_RELOAD_TRUSTED_DOMAINS,
NULL);
}
TALLOC_FREE(server_ids);
@ -4403,6 +4408,8 @@ static NTSTATUS dcesrv_lsa_lsaRSetForestTrustInformation(struct dcesrv_call_stat
enum ndr_err_code ndr_err;
int ret;
bool in_transaction = false;
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY);
@ -4641,17 +4648,20 @@ static NTSTATUS dcesrv_lsa_lsaRSetForestTrustInformation(struct dcesrv_call_stat
/*
* Notify winbindd that we have a acquired forest trust info
*/
status = irpc_servers_byname(dce_call->msg_ctx,
status = irpc_servers_byname(imsg_ctx,
mem_ctx,
"winbind_server",
&num_server_ids, &server_ids);
&num_server_ids,
&server_ids);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("irpc_servers_byname failed\n");
goto done;
}
imessaging_send(dce_call->msg_ctx, server_ids[0],
MSG_WINBIND_RELOAD_TRUSTED_DOMAINS, NULL);
imessaging_send(imsg_ctx,
server_ids[0],
MSG_WINBIND_RELOAD_TRUSTED_DOMAINS,
NULL);
status = NT_STATUS_OK;

View File

@ -1878,6 +1878,8 @@ static NTSTATUS dcesrv_lsa_lookup_name_winbind(
NTSTATUS status;
const char *check_domain_name = NULL;
bool expect_domain = false;
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(state->dce_call->conn);
if (item->name == NULL) {
/*
@ -1994,9 +1996,9 @@ static NTSTATUS dcesrv_lsa_lookup_name_winbind(
}
state->wb.irpc_handle = irpc_binding_handle_by_name(state,
state->dce_call->msg_ctx,
"winbind_server",
&ndr_table_lsarpc);
imsg_ctx,
"winbind_server",
&ndr_table_lsarpc);
if (state->wb.irpc_handle == NULL) {
DEBUG(0,("Failed to get binding_handle for winbind_server task\n"));
state->dce_call->fault_code = DCERPC_FAULT_CANT_PERFORM;
@ -2021,6 +2023,8 @@ static NTSTATUS dcesrv_lsa_lookup_sid_winbind(
struct dom_sid domain_sid = {0,};
NTSTATUS status;
bool match;
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(state->dce_call->conn);
/*
* Verify the sid is not INVALID.
@ -2111,9 +2115,9 @@ static NTSTATUS dcesrv_lsa_lookup_sid_winbind(
}
state->wb.irpc_handle = irpc_binding_handle_by_name(state,
state->dce_call->msg_ctx,
"winbind_server",
&ndr_table_lsarpc);
imsg_ctx,
"winbind_server",
&ndr_table_lsarpc);
if (state->wb.irpc_handle == NULL) {
DEBUG(0,("Failed to get binding_handle for winbind_server task\n"));
state->dce_call->fault_code = DCERPC_FAULT_CANT_PERFORM;

View File

@ -523,6 +523,8 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(
struct dom_sid *sid = NULL;
const char *trust_account_for_search = NULL;
const char *trust_account_in_db = NULL;
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
struct auth_usersupplied_info ui = {
.local_host = dce_call->conn->local_address,
.remote_host = dce_call->conn->remote_address,
@ -549,7 +551,7 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(
ui.netlogon_trust_account.account_name = trust_account_in_db;
ui.mapped.account_name = trust_account_for_search;
log_authentication_event(
dce_call->conn->msg_ctx,
imsg_ctx,
dce_call->conn->dce_ctx->lp_ctx,
NULL,
&ui,
@ -947,6 +949,8 @@ static void dcesrv_netr_LogonSamLogon_base_reply(
static NTSTATUS dcesrv_netr_LogonSamLogon_base_call(struct dcesrv_netr_LogonSamLogon_base_state *state)
{
struct dcesrv_call_state *dce_call = state->dce_call;
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
TALLOC_CTX *mem_ctx = state->mem_ctx;
struct netr_LogonSamLogonEx *r = &state->r;
struct netlogon_creds_CredentialState *creds = state->creds;
@ -992,7 +996,8 @@ static NTSTATUS dcesrv_netr_LogonSamLogon_base_call(struct dcesrv_netr_LogonSamL
case NetlogonNetworkTransitiveInformation:
nt_status = auth_context_create_for_netlogon(mem_ctx,
dce_call->event_ctx, dce_call->msg_ctx,
dce_call->event_ctx,
imsg_ctx,
dce_call->conn->dce_ctx->lp_ctx,
&auth_context);
NT_STATUS_NOT_OK_RETURN(nt_status);
@ -1111,7 +1116,7 @@ static NTSTATUS dcesrv_netr_LogonSamLogon_base_call(struct dcesrv_netr_LogonSamL
= r->in.logon->generic->identity_info.logon_id;
irpc_handle = irpc_binding_handle_by_name(mem_ctx,
dce_call->msg_ctx,
imsg_ctx,
"kdc_server",
&ndr_table_irpc);
if (irpc_handle == NULL) {
@ -1648,6 +1653,8 @@ static WERROR dcesrv_netr_LogonControl_base_call(struct dcesrv_netr_LogonControl
struct loadparm_context *lp_ctx = state->dce_call->conn->dce_ctx->lp_ctx;
struct auth_session_info *session_info =
dcesrv_call_session_info(state->dce_call);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(state->dce_call->conn);
enum security_user_level security_level;
struct dcerpc_binding_handle *irpc_handle;
struct tevent_req *subreq;
@ -1827,7 +1834,7 @@ static WERROR dcesrv_netr_LogonControl_base_call(struct dcesrv_netr_LogonControl
}
irpc_handle = irpc_binding_handle_by_name(state,
state->dce_call->msg_ctx,
imsg_ctx,
"winbind_server",
&ndr_table_winbind);
if (irpc_handle == NULL) {
@ -2914,6 +2921,8 @@ static WERROR dcesrv_netr_DsRGetDCName_base_call(struct dcesrv_netr_DsRGetDCName
struct dcesrv_call_state *dce_call = state->dce_call;
struct auth_session_info *session_info =
dcesrv_call_session_info(dce_call);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
TALLOC_CTX *mem_ctx = state->mem_ctx;
struct netr_DsRGetDCNameEx2 *r = &state->r;
struct ldb_context *sam_ctx;
@ -3058,7 +3067,7 @@ static WERROR dcesrv_netr_DsRGetDCName_base_call(struct dcesrv_netr_DsRGetDCName
false);
irpc_handle = irpc_binding_handle_by_name(state,
dce_call->msg_ctx,
imsg_ctx,
"winbind_server",
&ndr_table_winbind);
if (irpc_handle == NULL) {
@ -3826,6 +3835,8 @@ static WERROR dcesrv_netr_DsRGetForestTrustInformation(struct dcesrv_call_state
struct loadparm_context *lp_ctx = dce_call->conn->dce_ctx->lp_ctx;
struct auth_session_info *session_info =
dcesrv_call_session_info(dce_call);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
enum security_user_level security_level;
struct ldb_context *sam_ctx = NULL;
struct dcesrv_netr_DsRGetForestTrustInformation_state *state = NULL;
@ -3914,7 +3925,7 @@ static WERROR dcesrv_netr_DsRGetForestTrustInformation(struct dcesrv_call_state
state->r = r;
irpc_handle = irpc_binding_handle_by_name(state,
state->dce_call->msg_ctx,
imsg_ctx,
"winbind_server",
&ndr_table_winbind);
if (irpc_handle == NULL) {
@ -4262,6 +4273,8 @@ static NTSTATUS dcesrv_netr_DsrUpdateReadOnlyServerDnsRecords(struct dcesrv_call
struct dcerpc_binding_handle *binding_handle;
struct netr_dnsupdate_RODC_state *st;
struct tevent_req *subreq;
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
nt_status = dcesrv_netr_creds_server_step_check(dce_call,
mem_ctx,
@ -4289,8 +4302,10 @@ static NTSTATUS dcesrv_netr_DsrUpdateReadOnlyServerDnsRecords(struct dcesrv_call
st->r2->in.dns_names = r->in.dns_names;
st->r2->out.dns_names = r->out.dns_names;
binding_handle = irpc_binding_handle_by_name(st, dce_call->msg_ctx,
"dnsupdate", &ndr_table_irpc);
binding_handle = irpc_binding_handle_by_name(st,
imsg_ctx,
"dnsupdate",
&ndr_table_irpc);
if (binding_handle == NULL) {
DEBUG(0,("Failed to get binding_handle for dnsupdate task\n"));
dce_call->fault_code = DCERPC_FAULT_CANT_PERFORM;

View File

@ -103,6 +103,8 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
{
struct auth_session_info *session_info =
dcesrv_call_session_info(dce_call);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
NTSTATUS status = NT_STATUS_WRONG_PASSWORD;
DATA_BLOB new_password, new_unicode_password;
char *new_pass;
@ -289,7 +291,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
failed:
log_password_change_event(dce_call->conn->msg_ctx,
log_password_change_event(imsg_ctx,
dce_call->conn->dce_ctx->lp_ctx,
dce_call->conn->remote_address,
dce_call->conn->local_address,
@ -323,6 +325,8 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
{
struct auth_session_info *session_info =
dcesrv_call_session_info(dce_call);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
NTSTATUS status = NT_STATUS_WRONG_PASSWORD;
DATA_BLOB new_password;
struct ldb_context *sam_ctx = NULL;
@ -515,7 +519,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
failed:
log_password_change_event(dce_call->conn->msg_ctx,
log_password_change_event(imsg_ctx,
dce_call->conn->dce_ctx->lp_ctx,
dce_call->conn->remote_address,
dce_call->conn->local_address,

View File

@ -41,6 +41,8 @@ NTSTATUS srvsvc_create_ntvfs_context(struct dcesrv_call_state *dce_call,
{
struct auth_session_info *session_info =
dcesrv_call_session_info(dce_call);
struct imessaging_context *imsg_ctx =
dcesrv_imessaging_context(dce_call->conn);
NTSTATUS status;
struct srvsvc_ntvfs_ctx *c;
struct ntvfs_request *ntvfs_req;
@ -92,7 +94,7 @@ NTSTATUS srvsvc_create_ntvfs_context(struct dcesrv_call_state *dce_call,
PROTOCOL_NT1,
0,/* ntvfs_client_caps */
dce_call->event_ctx,
dce_call->conn->msg_ctx,
imsg_ctx,
dce_call->conn->dce_ctx->lp_ctx,
dce_call->conn->server_id,
&c->ntvfs);