summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-09-16 16:59:37 +0000
committerAndrew Tridgell <tridge@samba.org>2006-09-16 16:59:37 +0000
commit638ece0f51a1f23a40ac205e7a0148119a55e938 (patch)
tree50cda47dc715fd1ebb0fd0c1b8557286e6f6a6d9
parentd0215a51f1855697ec25e29d8051d351806076e0 (diff)
downloadsamba-638ece0f51a1f23a40ac205e7a0148119a55e938.tar.gz
samba-638ece0f51a1f23a40ac205e7a0148119a55e938.tar.xz
samba-638ece0f51a1f23a40ac205e7a0148119a55e938.zip
r18584: 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
-rw-r--r--source/gtk/tools/gregedit.c4
-rw-r--r--source/lib/registry/reg_samba.c7
-rw-r--r--source/lib/registry/tools/regdiff.c4
-rw-r--r--source/lib/registry/tools/regpatch.c2
-rw-r--r--source/lib/registry/tools/regshell.c2
-rw-r--r--source/lib/registry/tools/regtree.c2
-rw-r--r--source/rpc_server/winreg/rpc_winreg.c5
7 files changed, 16 insertions, 10 deletions
diff --git a/source/gtk/tools/gregedit.c b/source/gtk/tools/gregedit.c
index e0717187d97..cf03eebec84 100644
--- a/source/gtk/tools/gregedit.c
+++ b/source/gtk/tools/gregedit.c
@@ -385,7 +385,7 @@ static void on_open_gconf_activate(GtkMenuItem *menuitem, gpointer user_data)
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 GtkWidget* create_savefilewin (void)
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;
diff --git a/source/lib/registry/reg_samba.c b/source/lib/registry/reg_samba.c
index 4a88d96042f..3553c4cb6d1 100644
--- a/source/lib/registry/reg_samba.c
+++ b/source/lib/registry/reg_samba.c
@@ -68,9 +68,12 @@ static WERROR reg_samba_get_predef (struct registry_context *ctx, uint32_t hkey,
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;
diff --git a/source/lib/registry/tools/regdiff.c b/source/lib/registry/tools/regdiff.c
index dbbe555ad69..b8bf654a6b7 100644
--- a/source/lib/registry/tools/regdiff.c
+++ b/source/lib/registry/tools/regdiff.c
@@ -54,8 +54,8 @@ int main(int argc, char **argv)
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)
diff --git a/source/lib/registry/tools/regpatch.c b/source/lib/registry/tools/regpatch.c
index 7ed246566cb..42cdac860be 100644
--- a/source/lib/registry/tools/regpatch.c
+++ b/source/lib/registry/tools/regpatch.c
@@ -52,7 +52,7 @@ int main(int argc, char **argv)
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)) {
diff --git a/source/lib/registry/tools/regshell.c b/source/lib/registry/tools/regshell.c
index 0bc1cfe3242..8436a3f505e 100644
--- a/source/lib/registry/tools/regshell.c
+++ b/source/lib/registry/tools/regshell.c
@@ -434,7 +434,7 @@ static char **reg_completion(const char *text, int start, int end)
} 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)) {
diff --git a/source/lib/registry/tools/regtree.c b/source/lib/registry/tools/regtree.c
index 31f5a89a1b6..6b3c20eae3c 100644
--- a/source/lib/registry/tools/regtree.c
+++ b/source/lib/registry/tools/regtree.c
@@ -122,7 +122,7 @@ int main(int argc, char **argv)
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));
diff --git a/source/rpc_server/winreg/rpc_winreg.c b/source/rpc_server/winreg/rpc_winreg.c
index adcbb749dac..e32f620e5b6 100644
--- a/source/rpc_server/winreg/rpc_winreg.c
+++ b/source/rpc_server/winreg/rpc_winreg.c
@@ -32,7 +32,10 @@ enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY };
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;