svn commit: samba r18584 - in branches/SAMBA_4_0/source: gtk/tools lib/registry lib/registry/tools rpc_server/winreg

tridge at samba.org tridge at samba.org
Sat Sep 16 16:59:37 GMT 2006


Author: tridge
Date: 2006-09-16 16:59:37 +0000 (Sat, 16 Sep 2006)
New Revision: 18584

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18584

Log:

found one of the fd leaks. The registry backend was using a
talloc(NULL, xxx) to allocate the registry context. That had two
consequences

1) it was a massive memory leak, as all winreg operations leaked their
   entire context (including an open ldb database) every time

2) event_context_find() never found the exsting event context, so we
   used a new event context each time, which called epoll_create()
   each time, which caused a fd to be allocated

Modified:
   branches/SAMBA_4_0/source/gtk/tools/gregedit.c
   branches/SAMBA_4_0/source/lib/registry/reg_samba.c
   branches/SAMBA_4_0/source/lib/registry/tools/regdiff.c
   branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c
   branches/SAMBA_4_0/source/lib/registry/tools/regshell.c
   branches/SAMBA_4_0/source/lib/registry/tools/regtree.c
   branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c


Changeset:
Modified: branches/SAMBA_4_0/source/gtk/tools/gregedit.c
===================================================================
--- branches/SAMBA_4_0/source/gtk/tools/gregedit.c	2006-09-16 16:27:46 UTC (rev 18583)
+++ branches/SAMBA_4_0/source/gtk/tools/gregedit.c	2006-09-16 16:59:37 UTC (rev 18584)
@@ -385,7 +385,7 @@
 
 static void on_open_local_activate(GtkMenuItem *menuitem, gpointer user_data)
 {
-	WERROR error = reg_open_local(&registry, NULL, NULL);
+	WERROR error = reg_open_local(NULL, &registry, NULL, NULL);
 	if(!W_ERROR_IS_OK(error)) {
 		gtk_show_werror(mainwin, "Error while opening local registry", error);
 		return;
@@ -953,7 +953,7 @@
 
 static int gregedit_load_defaults(void)
 {
-	WERROR error = reg_open_local(&registry, NULL, NULL);
+	WERROR error = reg_open_local(NULL, &registry, NULL, NULL);
 	if(!W_ERROR_IS_OK(error)) {
 		gtk_show_werror(mainwin, "Error while loading local registry", error);
 		return -1;

Modified: branches/SAMBA_4_0/source/lib/registry/reg_samba.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/reg_samba.c	2006-09-16 16:27:46 UTC (rev 18583)
+++ branches/SAMBA_4_0/source/lib/registry/reg_samba.c	2006-09-16 16:59:37 UTC (rev 18584)
@@ -68,9 +68,12 @@
 	return error;
 }
 
-_PUBLIC_ WERROR reg_open_local (struct registry_context **ctx, struct auth_session_info *session_info, struct cli_credentials *credentials)
+_PUBLIC_ WERROR reg_open_local (TALLOC_CTX *mem_ctx, 
+				struct registry_context **ctx, 
+				struct auth_session_info *session_info, 
+				struct cli_credentials *credentials)
 {
-	*ctx = talloc(NULL, struct registry_context);
+	*ctx = talloc(mem_ctx, struct registry_context);
 	(*ctx)->credentials = talloc_reference(*ctx, credentials);
 	(*ctx)->session_info = talloc_reference(*ctx, session_info);
 	(*ctx)->get_predefined_key = reg_samba_get_predef;

Modified: branches/SAMBA_4_0/source/lib/registry/tools/regdiff.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/tools/regdiff.c	2006-09-16 16:27:46 UTC (rev 18583)
+++ branches/SAMBA_4_0/source/lib/registry/tools/regdiff.c	2006-09-16 16:59:37 UTC (rev 18584)
@@ -54,8 +54,8 @@
 		error = WERR_OK;
 		switch(opt)	{
 		case 'L':
-			if (!h1 && !from_null) error = reg_open_local(&h1, NULL, cmdline_credentials);
-			else if (!h2) error = reg_open_local(&h2, NULL, cmdline_credentials);
+			if (!h1 && !from_null) error = reg_open_local(NULL, &h1, NULL, cmdline_credentials);
+			else if (!h2) error = reg_open_local(NULL, &h2, NULL, cmdline_credentials);
 			break;
 		case 'R':
 			if (!h1 && !from_null) 

Modified: branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c	2006-09-16 16:27:46 UTC (rev 18583)
+++ branches/SAMBA_4_0/source/lib/registry/tools/regpatch.c	2006-09-16 16:59:37 UTC (rev 18584)
@@ -52,7 +52,7 @@
 	if (remote) {
 		error = reg_open_remote (&h, NULL, cmdline_credentials, remote, NULL);
 	} else {
-		error = reg_open_local (&h, NULL, cmdline_credentials);
+		error = reg_open_local (NULL, &h, NULL, cmdline_credentials);
 	}
 
 	if (W_ERROR_IS_OK(error)) {

Modified: branches/SAMBA_4_0/source/lib/registry/tools/regshell.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/tools/regshell.c	2006-09-16 16:27:46 UTC (rev 18583)
+++ branches/SAMBA_4_0/source/lib/registry/tools/regshell.c	2006-09-16 16:59:37 UTC (rev 18584)
@@ -434,7 +434,7 @@
 	} else if (backend) {
 		error = reg_open_hive(NULL, backend, poptGetArg(pc), NULL, cmdline_credentials, &curkey);
 	} else {
-		error = reg_open_local(&h, NULL, cmdline_credentials);
+		error = reg_open_local(NULL, &h, NULL, cmdline_credentials);
 	}
 
 	if(!W_ERROR_IS_OK(error)) {

Modified: branches/SAMBA_4_0/source/lib/registry/tools/regtree.c
===================================================================
--- branches/SAMBA_4_0/source/lib/registry/tools/regtree.c	2006-09-16 16:27:46 UTC (rev 18583)
+++ branches/SAMBA_4_0/source/lib/registry/tools/regtree.c	2006-09-16 16:59:37 UTC (rev 18584)
@@ -122,7 +122,7 @@
 			return 1;
 		}
 	} else {
-		error = reg_open_local (&h, NULL, cmdline_credentials);
+		error = reg_open_local (NULL, &h, NULL, cmdline_credentials);
 
 		if(!W_ERROR_IS_OK(error)) {
 			fprintf(stderr, "Unable to open local registry:%s \n", win_errstr(error));

Modified: branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c	2006-09-16 16:27:46 UTC (rev 18583)
+++ branches/SAMBA_4_0/source/rpc_server/winreg/rpc_winreg.c	2006-09-16 16:59:37 UTC (rev 18584)
@@ -32,8 +32,11 @@
 static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
 {
 	struct registry_context *ctx;
-	reg_open_local(&ctx, dce_call->conn->auth_state.session_info, NULL);
+	WERROR err;
 
+	err = reg_open_local(dce_call->context,
+			     &ctx, dce_call->conn->auth_state.session_info, NULL);
+
 	dce_call->context->private = ctx;
 
 	return NT_STATUS_OK;



More information about the samba-cvs mailing list