From a043ef33dca19d5ac1cdead60a4faa8b3a950bf4 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vlendec@samba.org>
Date: Mon, 31 Oct 2005 20:28:08 +0000
Subject: [PATCH] r11423: Add some TALLOC_CTX

---
 source/winbind/wb_cmd_lookupname.c | 12 +++++++-----
 source/winbind/wb_cmd_lookupsid.c  | 11 ++++++-----
 source/winbind/wb_samba3_cmd.c     |  4 ++--
 source/winbind/wb_sid2domain.c     |  2 +-
 4 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/source/winbind/wb_cmd_lookupname.c b/source/winbind/wb_cmd_lookupname.c
index 619c268c29c..bf77b445b56 100644
--- a/source/winbind/wb_cmd_lookupname.c
+++ b/source/winbind/wb_cmd_lookupname.c
@@ -35,13 +35,14 @@ struct cmd_lookupname_state {
 static struct composite_context *lookupname_send_req(struct wbsrv_domain *domain, void *p);
 static NTSTATUS lookupname_recv_req(struct composite_context *ctx, void *p);
 
-struct composite_context *wb_cmd_lookupname_send(struct wbsrv_service *service,
+struct composite_context *wb_cmd_lookupname_send(TALLOC_CTX *mem_ctx,
+						 struct wbsrv_service *service,
 						 const char *dom_name,
 						 const char *name)
 {
 	struct cmd_lookupname_state *state;
 
-	state = talloc(NULL, struct cmd_lookupname_state);
+	state = talloc(mem_ctx, struct cmd_lookupname_state);
 	state->name = talloc_asprintf(state, "%s\\%s", dom_name, name);
 	if (state->name == NULL) goto failed;
 	state->ctx = wb_domain_request_send(state, service,
@@ -97,12 +98,13 @@ NTSTATUS wb_cmd_lookupname_recv(struct composite_context *c,
 	return status;
 }
 
-NTSTATUS wb_cmd_lookupname(struct wbsrv_service *service,
+NTSTATUS wb_cmd_lookupname(TALLOC_CTX *mem_ctx,
+			   struct wbsrv_service *service,
 			   const char *dom_name,
 			   const char *name,
-			   TALLOC_CTX *mem_ctx, struct wb_sid_object **sid)
+			   struct wb_sid_object **sid)
 {
 	struct composite_context *c =
-		wb_cmd_lookupname_send(service, dom_name, name);
+		wb_cmd_lookupname_send(mem_ctx, service, dom_name, name);
 	return wb_cmd_lookupname_recv(c, mem_ctx, sid);
 }
diff --git a/source/winbind/wb_cmd_lookupsid.c b/source/winbind/wb_cmd_lookupsid.c
index 1279cfe8771..a92b2ea1834 100644
--- a/source/winbind/wb_cmd_lookupsid.c
+++ b/source/winbind/wb_cmd_lookupsid.c
@@ -35,12 +35,13 @@ struct cmd_lookupsid_state {
 static struct composite_context *lookupsid_send_req(struct wbsrv_domain *domain, void *p);
 static NTSTATUS lookupsid_recv_req(struct composite_context *ctx, void *p);
 
-struct composite_context *wb_cmd_lookupsid_send(struct wbsrv_service *service,
+struct composite_context *wb_cmd_lookupsid_send(TALLOC_CTX *mem_ctx,
+						struct wbsrv_service *service,
 						const struct dom_sid *sid)
 {
 	struct cmd_lookupsid_state *state;
 
-	state = talloc(NULL, struct cmd_lookupsid_state);
+	state = talloc(mem_ctx, struct cmd_lookupsid_state);
 	state->sid = dom_sid_dup(state, sid);
 	if (state->sid == NULL) goto failed;
 	state->ctx = wb_domain_request_send(state, service,
@@ -95,11 +96,11 @@ NTSTATUS wb_cmd_lookupsid_recv(struct composite_context *c,
 	return status;
 }
 
-NTSTATUS wb_cmd_lookupsid(struct wbsrv_service *service,
+NTSTATUS wb_cmd_lookupsid(TALLOC_CTX *mem_ctx, struct wbsrv_service *service,
 			  const struct dom_sid *sid,
-			  TALLOC_CTX *mem_ctx, struct wb_sid_object **name)
+			  struct wb_sid_object **name)
 {
 	struct composite_context *c =
-		wb_cmd_lookupsid_send(service, sid);
+		wb_cmd_lookupsid_send(mem_ctx, service, sid);
 	return wb_cmd_lookupsid_recv(c, mem_ctx, name);
 }
diff --git a/source/winbind/wb_samba3_cmd.c b/source/winbind/wb_samba3_cmd.c
index 6c68398f484..25c80cb0993 100644
--- a/source/winbind/wb_samba3_cmd.c
+++ b/source/winbind/wb_samba3_cmd.c
@@ -371,7 +371,7 @@ NTSTATUS wbsrv_samba3_lookupname(struct wbsrv_samba3_call *s3call)
 
 	DEBUG(5, ("wbsrv_samba3_lookupname called\n"));
 
-	ctx = wb_cmd_lookupname_send(service,
+	ctx = wb_cmd_lookupname_send(s3call, service,
 				     s3call->request.data.name.dom_name,
 				     s3call->request.data.name.name);
 	NT_STATUS_HAVE_NO_MEMORY(ctx);
@@ -425,7 +425,7 @@ NTSTATUS wbsrv_samba3_lookupsid(struct wbsrv_samba3_call *s3call)
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	ctx = wb_cmd_lookupsid_send(service, sid);
+	ctx = wb_cmd_lookupsid_send(s3call, service, sid);
 	NT_STATUS_HAVE_NO_MEMORY(ctx);
 
 	/* setup the callbacks */
diff --git a/source/winbind/wb_sid2domain.c b/source/winbind/wb_sid2domain.c
index 83e81e1cd06..13cc318f766 100644
--- a/source/winbind/wb_sid2domain.c
+++ b/source/winbind/wb_sid2domain.c
@@ -127,7 +127,7 @@ struct composite_context *wb_sid2domain_send(struct wbsrv_service *service,
 		return result;
 	}
 
-	ctx = wb_cmd_lookupsid_send(service, state->my_domain, state->sid);
+	ctx = wb_cmd_lookupsid_send(state, service, state->sid);
 	if (ctx == NULL) goto failed;
 	ctx->async.fn = sid2domain_recv_name;
 	ctx->async.private_data = state;