diff options
Diffstat (limited to 'source4/rpc_server')
-rw-r--r-- | source4/rpc_server/dcerpc_tcp.c | 9 | ||||
-rw-r--r-- | source4/rpc_server/lsa/dcesrv_lsa.c | 22 | ||||
-rw-r--r-- | source4/rpc_server/netlogon/dcerpc_netlogon.c | 38 |
3 files changed, 19 insertions, 50 deletions
diff --git a/source4/rpc_server/dcerpc_tcp.c b/source4/rpc_server/dcerpc_tcp.c index 78e46ed692..a77d02e796 100644 --- a/source4/rpc_server/dcerpc_tcp.c +++ b/source4/rpc_server/dcerpc_tcp.c @@ -108,14 +108,9 @@ void dcesrv_tcp_init(struct server_service *service, const struct model_ops *mod } } else { struct in_addr *ifip; - TALLOC_CTX *mem_ctx = talloc_init("open_sockets_smbd"); - if (!mem_ctx) { - smb_panic("No memory"); - } - - ifip = interpret_addr2(mem_ctx, lp_socket_address()); + ifip = interpret_addr2(dce_ctx, lp_socket_address()); add_socket_rpc(service, model_ops, dce_ctx, ifip); - talloc_destroy(mem_ctx); + talloc_free(ifip); } return; diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index f07997f3d6..f5bcae719b 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -38,7 +38,6 @@ enum lsa_handle { struct lsa_policy_state { int reference_count; void *sam_ctx; - TALLOC_CTX *mem_ctx; uint32_t access_mask; const char *domain_dn; }; @@ -51,7 +50,7 @@ static void lsa_Policy_close(struct lsa_policy_state *state) { state->reference_count--; if (state->reference_count == 0) { - talloc_destroy(state->mem_ctx); + talloc_free(state); } } @@ -145,40 +144,33 @@ static NTSTATUS lsa_OpenPolicy2(struct dcesrv_call_state *dce_call, TALLOC_CTX * { struct lsa_policy_state *state; struct dcesrv_handle *handle; - TALLOC_CTX *lsa_mem_ctx; ZERO_STRUCTP(r->out.handle); - lsa_mem_ctx = talloc_init("lsa_OpenPolicy"); - if (!lsa_mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - state = talloc_p(lsa_mem_ctx, struct lsa_policy_state); + state = talloc_p(dce_call->conn, struct lsa_policy_state); if (!state) { return NT_STATUS_NO_MEMORY; } - state->mem_ctx = lsa_mem_ctx; /* make sure the sam database is accessible */ - state->sam_ctx = samdb_connect(state->mem_ctx); + state->sam_ctx = samdb_connect(state); if (state->sam_ctx == NULL) { - talloc_destroy(state->mem_ctx); + talloc_free(state); return NT_STATUS_INVALID_SYSTEM_SERVICE; } /* work out the domain_dn - useful for so many calls its worth fetching here */ - state->domain_dn = samdb_search_string(state->sam_ctx, state->mem_ctx, NULL, + state->domain_dn = samdb_search_string(state->sam_ctx, state, NULL, "dn", "(&(objectClass=domain)(!(objectclass=builtinDomain)))"); if (!state->domain_dn) { - talloc_destroy(state->mem_ctx); + talloc_free(state); return NT_STATUS_NO_SUCH_DOMAIN; } handle = dcesrv_handle_new(dce_call->conn, LSA_HANDLE_POLICY); if (!handle) { - talloc_destroy(state->mem_ctx); + talloc_free(state); return NT_STATUS_NO_MEMORY; } diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c index 1451e17464..fdd5ead660 100644 --- a/source4/rpc_server/netlogon/dcerpc_netlogon.c +++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c @@ -24,7 +24,6 @@ #include "rpc_server/common/common.h" struct server_pipe_state { - TALLOC_CTX *mem_ctx; struct netr_Credential client_challenge; struct netr_Credential server_challenge; BOOL authenticated; @@ -44,34 +43,27 @@ static NTSTATUS netlogon_schannel_setup(struct dcesrv_call_state *dce_call) { struct server_pipe_state *state; NTSTATUS status; - TALLOC_CTX *mem_ctx; - mem_ctx = talloc_init("netlogon_bind"); - if (!mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - state = talloc_p(mem_ctx, struct server_pipe_state); + state = talloc_p(dce_call->conn, struct server_pipe_state); if (state == NULL) { - talloc_free(mem_ctx); return NT_STATUS_NO_MEMORY; } ZERO_STRUCTP(state); - state->mem_ctx = mem_ctx; state->authenticated = True; if (dce_call->conn->auth_state.session_info == NULL) { - talloc_free(mem_ctx); + talloc_free(state); smb_panic("No session info provided by schannel level setup!"); return NT_STATUS_NO_USER_SESSION_KEY; } status = dcerpc_schannel_creds(dce_call->conn->auth_state.gensec_security, - mem_ctx, + state, &state->creds); if (!NT_STATUS_IS_OK(status)) { DEBUG(3, ("getting schannel credentials failed with %s\n", nt_errstr(status))); - talloc_free(mem_ctx); + talloc_free(state); return status; } @@ -110,7 +102,7 @@ static void netlogon_unbind(struct dcesrv_connection *conn, const struct dcesrv_ struct server_pipe_state *pipe_state = conn->private; if (pipe_state) { - talloc_free(pipe_state->mem_ctx); + talloc_free(pipe_state); } conn->private = NULL; @@ -123,31 +115,21 @@ static NTSTATUS netr_ServerReqChallenge(struct dcesrv_call_state *dce_call, TALL struct netr_ServerReqChallenge *r) { struct server_pipe_state *pipe_state = dce_call->conn->private; - TALLOC_CTX *pipe_mem_ctx; ZERO_STRUCTP(r->out.credentials); /* destroyed on pipe shutdown */ if (pipe_state) { - talloc_free(pipe_state->mem_ctx); + talloc_free(pipe_state); dce_call->conn->private = NULL; } - pipe_mem_ctx = talloc_init("internal netlogon pipe state for %s", - r->in.computer_name); - - if (!pipe_mem_ctx) { - return NT_STATUS_NO_MEMORY; - } - - pipe_state = talloc_p(pipe_mem_ctx, struct server_pipe_state); + pipe_state = talloc_p(dce_call->conn, struct server_pipe_state); if (!pipe_state) { - talloc_free(pipe_mem_ctx); return NT_STATUS_NO_MEMORY; } - pipe_state->mem_ctx = pipe_mem_ctx; pipe_state->authenticated = False; pipe_state->creds = NULL; pipe_state->account_name = NULL; @@ -247,7 +229,7 @@ static NTSTATUS netr_ServerAuthenticate3(struct dcesrv_call_state *dce_call, TAL } if (!pipe_state->creds) { - pipe_state->creds = talloc_p(pipe_state->mem_ctx, struct creds_CredentialState); + pipe_state->creds = talloc_p(pipe_state, struct creds_CredentialState); if (!pipe_state->creds) { return NT_STATUS_NO_MEMORY; } @@ -269,14 +251,14 @@ static NTSTATUS netr_ServerAuthenticate3(struct dcesrv_call_state *dce_call, TAL talloc_free(pipe_state->account_name); } - pipe_state->account_name = talloc_strdup(pipe_state->mem_ctx, r->in.account_name); + pipe_state->account_name = talloc_strdup(pipe_state, r->in.account_name); if (pipe_state->computer_name) { /* We don't want a memory leak on this long-lived talloc context */ talloc_free(pipe_state->account_name); } - pipe_state->computer_name = talloc_strdup(pipe_state->mem_ctx, r->in.computer_name); + pipe_state->computer_name = talloc_strdup(pipe_state, r->in.computer_name); /* remember this session key state */ nt_status = schannel_store_session_key(mem_ctx, pipe_state->computer_name, pipe_state->creds); |