struct lsa_policy_state {
int reference_count;
void *sam_ctx;
- TALLOC_CTX *mem_ctx;
uint32_t access_mask;
const char *domain_dn;
};
{
state->reference_count--;
if (state->reference_count == 0) {
- talloc_destroy(state->mem_ctx);
+ talloc_free(state);
}
}
{
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;
}
#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;
{
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;
}
struct server_pipe_state *pipe_state = conn->private;
if (pipe_state) {
- talloc_free(pipe_state->mem_ctx);
+ talloc_free(pipe_state);
}
conn->private = NULL;
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;
}
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;
}
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);