svn commit: samba r2635 - in branches/SAMBA_4_0/source/rpc_server: . lsa netlogon

tridge at samba.org tridge at samba.org
Sat Sep 25 13:28:38 GMT 2004


Author: tridge
Date: 2004-09-25 13:28:38 +0000 (Sat, 25 Sep 2004)
New Revision: 2635

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/rpc_server&rev=2635&nolog=1

Log:
mem_ctx cleanups on the lsa and netlogon pipes in the rpc server




Modified:
   branches/SAMBA_4_0/source/rpc_server/dcerpc_tcp.c
   branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c
   branches/SAMBA_4_0/source/rpc_server/netlogon/dcerpc_netlogon.c


Changeset:
Modified: branches/SAMBA_4_0/source/rpc_server/dcerpc_tcp.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/dcerpc_tcp.c	2004-09-25 12:48:56 UTC (rev 2634)
+++ branches/SAMBA_4_0/source/rpc_server/dcerpc_tcp.c	2004-09-25 13:28:38 UTC (rev 2635)
@@ -108,14 +108,9 @@
 		}
 	} 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;	

Modified: branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c	2004-09-25 12:48:56 UTC (rev 2634)
+++ branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c	2004-09-25 13:28:38 UTC (rev 2635)
@@ -38,7 +38,6 @@
 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 @@
 {
 	state->reference_count--;
 	if (state->reference_count == 0) {
-		talloc_destroy(state->mem_ctx);
+		talloc_free(state);
 	}
 }
 
@@ -145,40 +144,33 @@
 {
 	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;
 	}
 

Modified: branches/SAMBA_4_0/source/rpc_server/netlogon/dcerpc_netlogon.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/netlogon/dcerpc_netlogon.c	2004-09-25 12:48:56 UTC (rev 2634)
+++ branches/SAMBA_4_0/source/rpc_server/netlogon/dcerpc_netlogon.c	2004-09-25 13:28:38 UTC (rev 2635)
@@ -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 @@
 {
 	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 @@
 	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 @@
 					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 @@
 	}
 
 	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 @@
 		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);



More information about the samba-cvs mailing list