937546
From 5cceb47667c0665629bb474f73be1d2d8f1e1b5b Mon Sep 17 00:00:00 2001
937546
From: Sumit Bose <sbose@redhat.com>
937546
Date: Tue, 19 Feb 2019 12:30:40 +0100
937546
Subject: [PATCH] ipa_sam: remove dependency to talloc_strackframe.h
937546
MIME-Version: 1.0
937546
Content-Type: text/plain; charset=UTF-8
937546
Content-Transfer-Encoding: 8bit
937546
937546
Recent Samba versions removed some header files which did include
937546
non-public APIs. As a result talloc_strackframe.h and memory.h (for
937546
SAFE_FREE) are not available anymore. This patch replaces the use of the
937546
non-public APIs with public ones.
937546
937546
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
937546
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
937546
Reviewed-By: François Cami <fcami@redhat.com>
937546
(cherry picked from commit d1f5ed64e16d65b9df45cc0eac7d2724dcae7b67)
937546
---
937546
 daemons/ipa-sam/ipa_sam.c | 16 ++++++++++++----
937546
 1 file changed, 12 insertions(+), 4 deletions(-)
937546
937546
diff --git a/daemons/ipa-sam/ipa_sam.c b/daemons/ipa-sam/ipa_sam.c
937546
index 2251f3ddc..755f44d68 100644
937546
--- a/daemons/ipa-sam/ipa_sam.c
937546
+++ b/daemons/ipa-sam/ipa_sam.c
937546
@@ -19,7 +19,6 @@
937546
 #include <util/data_blob.h>
937546
 #include <util/time.h>
937546
 #include <util/debug.h>
937546
-#include <util/talloc_stack.h>
937546
 
937546
 #ifndef _SAMBA_UTIL_H_
937546
 bool trim_string(char *s, const char *front, const char *back);
937546
@@ -881,9 +880,13 @@ static bool ipasam_uid_to_sid(struct pdb_methods *methods, uid_t uid,
937546
 	struct dom_sid *user_sid = NULL;
937546
 	int rc;
937546
 	enum idmap_error_code err;
937546
-	TALLOC_CTX *tmp_ctx = talloc_stackframe();
937546
 	struct unixid id;
937546
 
937546
+	TALLOC_CTX *tmp_ctx = talloc_new(priv);
937546
+	if (tmp_ctx == NULL) {
937546
+		goto done;
937546
+	}
937546
+
937546
 	/* Fast fail if we get a request for uidNumber=0 because it currently
937546
 	 * will never exist in the directory
937546
 	 * Saves an expensive LDAP call of which failure will never be cached
937546
@@ -968,9 +971,13 @@ static bool ipasam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
937546
 	size_t c;
937546
 	int rc;
937546
 	enum idmap_error_code err;
937546
-	TALLOC_CTX *tmp_ctx = talloc_stackframe();
937546
 	struct unixid id;
937546
 
937546
+	TALLOC_CTX *tmp_ctx = talloc_new(priv);
937546
+	if (tmp_ctx == NULL) {
937546
+		goto done;
937546
+	}
937546
+
937546
 	filter = talloc_asprintf(tmp_ctx,
937546
 				 "(|(&(gidNumber=%u)"
937546
 				     "(objectClass=%s))"
937546
@@ -3749,7 +3756,8 @@ static void ipasam_free_private_data(void **vp)
937546
 		(*ipasam_state)->result = NULL;
937546
 	}
937546
 	if ((*ipasam_state)->domain_dn != NULL) {
937546
-		SAFE_FREE((*ipasam_state)->domain_dn);
937546
+		free((*ipasam_state)->domain_dn);
937546
+		(*ipasam_state)->domain_dn = NULL;
937546
 	}
937546
 
937546
 	*ipasam_state = NULL;
937546
-- 
937546
2.21.0
937546