[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Mon Jun 27 02:14:03 UTC 2016


The branch, master has been updated
       via  1ce7721 Revert "source4/scripting: add an option to samba_dnsupdate to add ns records."
       via  552fc4a dsdb: Make less talloc() for parsed_dn.guid
       via  bbf0532 dsdb: Avoid talloc() calls in dsdb_get_extended_dn_*()
       via  5fe2607 dsdb: Apply linked attribute backlinks as we apply the forward links
       via  4fb2363 ldb: Do not allocate the extended DN name
       via  ab4cd63 ldb: Allow repl_meta_data to override the O(^2) loop checking for duplciates
       via  4304eac librpc: Avoid talloc in GUID_from_data_blob()
       via  f5ca34e dsdb: Only fetch changed attributes in replmd_update_rpmd
       via  ea86f5e dsdb: Fix use-after-free of parent_dn in operational module
       via  2aeae27 dsdb: Provide shortcuut for repl_meta_data avoiding search of link targets
       via  947996b selftest: Do not run winbind tests against ad_dc_ntvfs
       via  1bd56a0 selftest: Avoid running local.nss test against ad_dc_ntvfs
      from  8813faf libutil: Support systemd 230

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1ce7721b17331df2310812cf8563fda56f6cf008
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Jun 27 07:15:02 2016 +1200

    Revert "source4/scripting: add an option to samba_dnsupdate to add ns records."
    
    This reverts a totally unnecessary change to samba_dnsupdate. The self test
    environment does the correct things with NS records now.
    
    This reverts commit af08cb2eee9dc9fabad6ca62ca11728209297222.
    
    Signed-off-by: Richard Sharpe <rsharpe at samba.org>
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Mon Jun 27 04:13:04 CEST 2016 on sn-devel-144

commit 552fc4acaa99cd93ef3f08a2ea75510c399a25bb
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 17 15:04:21 2016 +1200

    dsdb: Make less talloc() for parsed_dn.guid
    
    This is always allocated, so do not make it a pointer.
    
    This now also uses the talloc-less GUID_buf_string() when printing
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit bbf0532f07079ee21e5fd6d256b5079301bddf8f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Jun 16 14:04:44 2016 +1200

    dsdb: Avoid talloc() calls in dsdb_get_extended_dn_*()
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 5fe26076932f65c6a0387ed02cddb485aa0b4cf0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Jun 16 09:31:21 2016 +1200

    dsdb: Apply linked attribute backlinks as we apply the forward links
    
    Otherwise, we spend a lot of time checking if the link is in the list, which is pointless
    and very costly in large domains
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 4fb23630ba3f5e17f41c40b90f423a20987db594
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Jun 17 13:28:59 2016 +1200

    ldb: Do not allocate the extended DN name
    
    The name must be a hard-coded value from struct ldb_dn_extended_syntax
    so just point to that constant pointer
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit ab4cd63e102c6ef9e4fa9af83b7c763a5e901a40
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jun 15 16:11:28 2016 +1200

    ldb: Allow repl_meta_data to override the O(^2) loop checking for duplciates
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 4304eac85437d72f4aed36fc7797004cd97fbc9a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jun 15 15:54:06 2016 +1200

    librpc: Avoid talloc in GUID_from_data_blob()
    
    This is often found in inner loops in the dsdb code, because LDB DNs often contain a GUID string
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit f5ca34e6e813a5b92ea084995ffc0ebb3c8b1368
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jun 15 15:43:55 2016 +1200

    dsdb: Only fetch changed attributes in replmd_update_rpmd
    
    This avoids fetching every attribute, including in particular links that may
    require additional work to resolve, when we will not look at them anyway
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit ea86f5eb0ceeb8ee18918ff956c060827608f5f6
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jun 15 10:36:16 2016 +1200

    dsdb: Fix use-after-free of parent_dn in operational module
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 2aeae27cb4fc1d78e899e93716fddcc717ad044d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Jun 15 09:59:57 2016 +1200

    dsdb: Provide shortcuut for repl_meta_data avoiding search of link targets
    
    This makes processing of large numbers of linked attributes much faster, as we never care about the
    names during that processing
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 947996b7cbb5353775116d40fc2cc236cae0497b
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jun 14 20:25:21 2016 +1200

    selftest: Do not run winbind tests against ad_dc_ntvfs
    
    This runs the same winbindd as ad_dc, there is no need to duplicate the runs

commit 1bd56a0d66ef79a1a37d56e1e07e1cffafbad8bb
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jun 14 20:02:03 2016 +1200

    selftest: Avoid running local.nss test against ad_dc_ntvfs
    
    This environment uses the same winbindd as ad_dc
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

-----------------------------------------------------------------------

Summary of changes:
 lib/ldb/common/ldb_dn.c                          | 21 +++-----
 lib/ldb/ldb_tdb/ldb_tdb.c                        | 24 ++++++---
 librpc/ndr/uuid.c                                | 24 +++------
 source3/selftest/tests.py                        |  2 +-
 source4/dsdb/common/util.c                       | 32 +++++------
 source4/dsdb/samdb/ldb_modules/extended_dn_out.c | 20 ++++---
 source4/dsdb/samdb/ldb_modules/operational.c     |  8 +--
 source4/dsdb/samdb/ldb_modules/repl_meta_data.c  | 69 +++++++++++++-----------
 source4/scripting/bin/samba_dnsupdate            | 10 ----
 source4/selftest/tests.py                        |  6 +--
 10 files changed, 108 insertions(+), 108 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/common/ldb_dn.c b/lib/ldb/common/ldb_dn.c
index ab78776..3fa5ab5 100644
--- a/lib/ldb/common/ldb_dn.c
+++ b/lib/ldb/common/ldb_dn.c
@@ -54,7 +54,7 @@ struct ldb_dn_component {
 
 struct ldb_dn_ext_component {
 
-	char *name;
+	const char *name;
 	struct ldb_val value;
 };
 
@@ -408,11 +408,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
 					goto failed;
 				}
 
-				dn->ext_components[dn->ext_comp_num].name = talloc_strdup(dn->ext_components, ex_name);
-				if (!dn->ext_components[dn->ext_comp_num].name) {
-					/* ouch */
-					goto failed;
-				}
+				dn->ext_components[dn->ext_comp_num].name = ext_syntax->name;
 				ret = ext_syntax->read_fn(dn->ldb, dn->ext_components,
 							  &ex_val, &dn->ext_components[dn->ext_comp_num].value);
 				if (ret != LDB_SUCCESS) {
@@ -1990,12 +1986,14 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
 	struct ldb_dn_ext_component *p;
 	unsigned int i;
 	struct ldb_val v2;
-
+	const struct ldb_dn_extended_syntax *ext_syntax;
+	
 	if ( ! ldb_dn_validate(dn)) {
 		return LDB_ERR_OTHER;
 	}
 
-	if (!ldb_dn_extended_syntax_by_name(dn->ldb, name)) {
+	ext_syntax = ldb_dn_extended_syntax_by_name(dn->ldb, name);
+	if (ext_syntax == NULL) {
 		/* We don't know how to handle this type of thing */
 		return LDB_ERR_INVALID_DN_SYNTAX;
 	}
@@ -2006,10 +2004,8 @@ int ldb_dn_set_extended_component(struct ldb_dn *dn,
 				dn->ext_components[i].value =
 					ldb_val_dup(dn->ext_components, val);
 
-				dn->ext_components[i].name =
-					talloc_strdup(dn->ext_components, name);
-				if (!dn->ext_components[i].name ||
-				    !dn->ext_components[i].value.data) {
+				dn->ext_components[i].name = ext_syntax->name;
+				if (!dn->ext_components[i].value.data) {
 					ldb_dn_mark_invalid(dn);
 					return LDB_ERR_OPERATIONS_ERROR;
 				}
@@ -2170,7 +2166,6 @@ bool ldb_dn_minimise(struct ldb_dn *dn)
 	 */
 
 	for (i = 1; i < dn->ext_comp_num; i++) {
-		LDB_FREE(dn->ext_components[i].name);
 		LDB_FREE(dn->ext_components[i].value.data);
 	}
 	dn->ext_comp_num = 1;
diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c
index 6a91f05..1a4f4ca 100644
--- a/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -858,14 +858,22 @@ int ltdb_modify_internal(struct ldb_module *module,
 				goto done;
 			}
 
-			/* TODO: This is O(n^2) - replace with more efficient check */
-			for (j=0; j<el->num_values; j++) {
-				if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
-					ldb_asprintf_errstring(ldb,
-							       "attribute '%s': value #%u on '%s' provided more than once",
-							       el->name, j, ldb_dn_get_linearized(msg2->dn));
-					ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
-					goto done;
+			/*
+			 * We don't need to check this if we have been
+			 * pre-screened by the repl_meta_data module
+			 * in Samba, or someone else who can claim to
+			 * know what they are doing. 
+			 */
+			if (!(el->flags & LDB_FLAG_INTERNAL_DISABLE_SINGLE_VALUE_CHECK)) { 
+				/* TODO: This is O(n^2) - replace with more efficient check */
+				for (j=0; j<el->num_values; j++) {
+					if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
+						ldb_asprintf_errstring(ldb,
+								       "attribute '%s': value #%u on '%s' provided more than once",
+								       el->name, j, ldb_dn_get_linearized(msg2->dn));
+						ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
+						goto done;
+					}
 				}
 			}
 
diff --git a/librpc/ndr/uuid.c b/librpc/ndr/uuid.c
index 9d955ab..fbd305e 100644
--- a/librpc/ndr/uuid.c
+++ b/librpc/ndr/uuid.c
@@ -71,13 +71,10 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid)
 	switch(s->length) {
 	case 36:
 	{
-		TALLOC_CTX *mem_ctx;
-		const char *string;
+		char string[37];
+		memcpy(string, s->data, 36);
+		string[36] = 0;
 
-		mem_ctx = talloc_new(NULL);
-		NT_STATUS_HAVE_NO_MEMORY(mem_ctx);
-		string = talloc_strndup(mem_ctx, (const char *)s->data, s->length);
-		NT_STATUS_HAVE_NO_MEMORY(string);
 		if (11 == sscanf(string,
 				 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
 				 &time_low, &time_mid, &time_hi_and_version, 
@@ -85,26 +82,21 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid)
 				 &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
 			status = NT_STATUS_OK;
 		}
-		talloc_free(mem_ctx);
 		break;
 	}
 	case 38:
 	{
-		TALLOC_CTX *mem_ctx;
-		const char *string;
-
-		mem_ctx = talloc_new(NULL);
-		NT_STATUS_HAVE_NO_MEMORY(mem_ctx);
-		string = talloc_strndup(mem_ctx, (const char *)s->data, s->length);
-		NT_STATUS_HAVE_NO_MEMORY(string);
-		if (11 == sscanf((const char *)s->data, 
+		char string[39];
+		memcpy(string, s->data, 38);
+		string[38] = 0;
+
+		if (11 == sscanf(string, 
 				 "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
 				 &time_low, &time_mid, &time_hi_and_version, 
 				 &clock_seq[0], &clock_seq[1],
 				 &node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
 			status = NT_STATUS_OK;
 		}
-		talloc_free(mem_ctx);
 		break;
 	}
 	case 32:
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 371ec2a..2441b19 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -401,7 +401,7 @@ for t in tests:
         plansmbtorture4testsuite(t, "nt4_dc_schannel", '//$SERVER_IP/tmp -U$%', description="anonymous password set (schannel enforced server-side)")
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$%', description="anonymous password set")
     elif t == "local.nss":
-        for env in ["nt4_dc:local", "ad_member:local", "nt4_member:local", "ad_dc:local", "ad_dc_ntvfs:local"]:
+        for env in ["nt4_dc:local", "ad_member:local", "nt4_member:local", "ad_dc:local"]:
             plansmbtorture4testsuite(t, env, '//$SERVER/tmp -U$USERNAME%$PASSWORD')
     elif t == "smb2.change_notify_disabled":
         plansmbtorture4testsuite(t, "simpleserver", '//$SERVER/tmp -U$USERNAME%$PASSWORD')
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index cfa1376..667bd86 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -3642,18 +3642,19 @@ NTSTATUS dsdb_get_extended_dn_guid(struct ldb_dn *dn, struct GUID *guid, const c
 NTSTATUS dsdb_get_extended_dn_uint64(struct ldb_dn *dn, uint64_t *val, const char *component_name)
 {
 	const struct ldb_val *v;
-	char *s;
 
 	v = ldb_dn_get_extended_component(dn, component_name);
 	if (v == NULL) {
 		return NT_STATUS_OBJECT_NAME_NOT_FOUND;
 	}
-	s = talloc_strndup(dn, (const char *)v->data, v->length);
-	NT_STATUS_HAVE_NO_MEMORY(s);
 
-	*val = strtoull(s, NULL, 0);
+	{
+		char s[v->length+1];
+		memcpy(s, v->data, v->length);
+		s[v->length] = 0;
 
-	talloc_free(s);
+		*val = strtoull(s, NULL, 0);
+	}
 	return NT_STATUS_OK;
 }
 
@@ -3671,19 +3672,19 @@ NTSTATUS dsdb_get_extended_dn_nttime(struct ldb_dn *dn, NTTIME *nttime, const ch
 NTSTATUS dsdb_get_extended_dn_uint32(struct ldb_dn *dn, uint32_t *val, const char *component_name)
 {
 	const struct ldb_val *v;
-	char *s;
 
 	v = ldb_dn_get_extended_component(dn, component_name);
 	if (v == NULL) {
 		return NT_STATUS_OBJECT_NAME_NOT_FOUND;
 	}
 
-	s = talloc_strndup(dn, (const char *)v->data, v->length);
-	NT_STATUS_HAVE_NO_MEMORY(s);
-
-	*val = strtoul(s, NULL, 0);
+	{
+		char s[v->length + 1];
+		memcpy(s, v->data, v->length);
+		s[v->length] = 0;
+		*val = strtoul(s, NULL, 0);
+	}
 
-	talloc_free(s);
 	return NT_STATUS_OK;
 }
 
@@ -3693,7 +3694,6 @@ NTSTATUS dsdb_get_extended_dn_uint32(struct ldb_dn *dn, uint32_t *val, const cha
 NTSTATUS dsdb_get_extended_dn_sid(struct ldb_dn *dn, struct dom_sid *sid, const char *component_name)
 {
 	const struct ldb_val *sid_blob;
-	struct TALLOC_CTX *tmp_ctx;
 	enum ndr_err_code ndr_err;
 
 	sid_blob = ldb_dn_get_extended_component(dn, component_name);
@@ -3701,17 +3701,13 @@ NTSTATUS dsdb_get_extended_dn_sid(struct ldb_dn *dn, struct dom_sid *sid, const
 		return NT_STATUS_OBJECT_NAME_NOT_FOUND;
 	}
 
-	tmp_ctx = talloc_new(NULL);
-
-	ndr_err = ndr_pull_struct_blob_all(sid_blob, tmp_ctx, sid,
-					   (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
+	ndr_err = ndr_pull_struct_blob_all_noalloc(sid_blob, sid,
+						   (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
 	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
 		NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
-		talloc_free(tmp_ctx);
 		return status;
 	}
 
-	talloc_free(tmp_ctx);
 	return NT_STATUS_OK;
 }
 
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c
index bdb35be..31835a7 100644
--- a/source4/dsdb/samdb/ldb_modules/extended_dn_out.c
+++ b/source4/dsdb/samdb/ldb_modules/extended_dn_out.c
@@ -472,6 +472,20 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
 		}
 	}
 
+	if (!checked_reveal_control) {
+		have_reveal_control =
+			ldb_request_get_control(req, LDB_CONTROL_REVEAL_INTERNALS) != NULL;
+		checked_reveal_control = true;
+	}
+
+	/* 
+	 * Shortcut for repl_meta_data.  We asked for the data
+	 * 'as-is', so stop processing here!
+	 */
+	if (have_reveal_control && p->normalise == false && ac->inject == true) {
+		return ldb_module_send_entry(ac->req, msg, ares->controls);
+	}
+	
 	/* Walk the returned elements (but only if we have a schema to
 	 * interpret the list with) */
 	for (i = 0; ac->schema && i < msg->num_elements; i++) {
@@ -518,12 +532,6 @@ static int extended_callback(struct ldb_request *req, struct ldb_reply *ares,
 			struct ldb_val *plain_dn = &msg->elements[i].values[j];		
 			bool is_deleted_objects = false;
 
-			if (!checked_reveal_control) {
-				have_reveal_control =
-					ldb_request_get_control(req, LDB_CONTROL_REVEAL_INTERNALS) != NULL;
-				checked_reveal_control = true;
-			}
-
 			/* this is a fast method for detecting deleted
 			   linked attributes, working on the unparsed
 			   ldb_val */
diff --git a/source4/dsdb/samdb/ldb_modules/operational.c b/source4/dsdb/samdb/ldb_modules/operational.c
index 4205c4b..08a8454 100644
--- a/source4/dsdb/samdb/ldb_modules/operational.c
+++ b/source4/dsdb/samdb/ldb_modules/operational.c
@@ -357,17 +357,19 @@ static int construct_parent_guid(struct ldb_module *module,
 	ret = dsdb_module_search_dn(module, msg, &parent_res, parent_dn, attrs2,
 	                            DSDB_FLAG_NEXT_MODULE |
 	                            DSDB_SEARCH_SHOW_RECYCLED, parent);
-	talloc_free(parent_dn);
-
 	/* not NC, so the object should have a parent*/
 	if (ret == LDB_ERR_NO_SUCH_OBJECT) {
-		return ldb_error(ldb_module_get_ctx(module), LDB_ERR_OPERATIONS_ERROR, 
+		ret = ldb_error(ldb_module_get_ctx(module), LDB_ERR_OPERATIONS_ERROR, 
 				 talloc_asprintf(msg, "Parent dn %s for %s does not exist",
 						 ldb_dn_get_linearized(parent_dn),
 						 ldb_dn_get_linearized(msg->dn)));
+		talloc_free(parent_dn);
+		return ret;
 	} else if (ret != LDB_SUCCESS) {
+		talloc_free(parent_dn);
 		return ret;
 	}
+	talloc_free(parent_dn);
 
 	parent_guid = ldb_msg_find_ldb_val(parent_res->msgs[0], "objectGUID");
 	if (!parent_guid) {
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 0d37820..347cf0f 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -1407,7 +1407,6 @@ static int replmd_update_rpmd(struct ldb_module *module,
 	const struct GUID *our_invocation_id;
 	int ret;
 	const char * const *attrs = NULL;
-	const char * const attrs1[] = { "replPropertyMetaData", "*", NULL };
 	const char * const attrs2[] = { "uSNChanged", "objectClass", "instanceType", NULL };
 	struct ldb_result *res;
 	struct ldb_context *ldb;
@@ -1415,11 +1414,19 @@ static int replmd_update_rpmd(struct ldb_module *module,
 	enum urgent_situation situation;
 	bool rmd_is_provided;
 	bool rmd_is_just_resorted = false;
-
+	const char *not_rename_attrs[4 + msg->num_elements];
+	
 	if (rename_attrs) {
 		attrs = rename_attrs;
 	} else {
-		attrs = attrs1;
+		for (i = 0; i < msg->num_elements; i++) {
+			not_rename_attrs[i] = msg->elements[i].name;
+		}
+		not_rename_attrs[i] = "replPropertyMetaData";
+		not_rename_attrs[i+1] = "objectClass";
+		not_rename_attrs[i+2] = "instanceType";
+		not_rename_attrs[i+3] = NULL;
+		attrs = not_rename_attrs;
 	}
 
 	ldb = ldb_module_get_ctx(module);
@@ -1653,13 +1660,18 @@ static int replmd_update_rpmd(struct ldb_module *module,
 
 struct parsed_dn {
 	struct dsdb_dn *dsdb_dn;
-	struct GUID *guid;
+	struct GUID guid;
 	struct ldb_val *v;
 };
 
 static int parsed_dn_compare(struct parsed_dn *pdn1, struct parsed_dn *pdn2)
 {
-	return GUID_compare(pdn1->guid, pdn2->guid);
+	return GUID_compare(&pdn1->guid, &pdn2->guid);
+}
+
+static int GUID_compare_struct(struct GUID *g1, struct GUID g2)
+{
+	return GUID_compare(g1, &g2);
 }
 
 static struct parsed_dn *parsed_dn_find(struct parsed_dn *pdn,
@@ -1679,7 +1691,7 @@ static struct parsed_dn *parsed_dn_find(struct parsed_dn *pdn,
 		}
 		return NULL;
 	}
-	BINARY_ARRAY_SEARCH(pdn, count, guid, guid, GUID_compare, ret);
+	BINARY_ARRAY_SEARCH(pdn, count, guid, guid, GUID_compare_struct, ret);
 	return ret;
 }
 
@@ -1720,16 +1732,10 @@ static int get_parsed_dns(struct ldb_module *module, TALLOC_CTX *mem_ctx,
 
 		dn = p->dsdb_dn->dn;
 
-		p->guid = talloc(*pdn, struct GUID);
-		if (p->guid == NULL) {
-			ldb_module_oom(module);
-			return LDB_ERR_OPERATIONS_ERROR;
-		}
-
-		status = dsdb_get_extended_dn_guid(dn, p->guid, "GUID");
+		status = dsdb_get_extended_dn_guid(dn, &p->guid, "GUID");
 		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
 			/* we got a DN without a GUID - go find the GUID */
-			int ret = dsdb_module_guid_by_dn(module, dn, p->guid, parent);
+			int ret = dsdb_module_guid_by_dn(module, dn, &p->guid, parent);
 			if (ret != LDB_SUCCESS) {
 				ldb_asprintf_errstring(ldb, "Unable to find GUID for DN %s\n",
 						       ldb_dn_get_linearized(dn));
@@ -1740,7 +1746,7 @@ static int get_parsed_dns(struct ldb_module *module, TALLOC_CTX *mem_ctx,
 				}
 				return ret;
 			}
-			ret = dsdb_set_extended_dn_guid(dn, p->guid, "GUID");
+			ret = dsdb_set_extended_dn_guid(dn, &p->guid, "GUID");
 			if (ret != LDB_SUCCESS) {
 				return ret;
 			}
@@ -2030,7 +2036,7 @@ static int replmd_modify_la_add(struct ldb_module *module,
 
 	/* for each new value, see if it exists already with the same GUID */
 	for (i=0; i<el->num_values; i++) {
-		struct parsed_dn *p = parsed_dn_find(old_dns, old_num_values, dns[i].guid, NULL);
+		struct parsed_dn *p = parsed_dn_find(old_dns, old_num_values, &dns[i].guid, NULL);
 		if (p == NULL) {
 			/* this is a new linked attribute value */
 			new_values = talloc_realloc(tmp_ctx, new_values, struct ldb_val, num_new_values+1);
@@ -2052,8 +2058,9 @@ static int replmd_modify_la_add(struct ldb_module *module,
 			uint32_t rmd_flags = dsdb_dn_rmd_flags(p->dsdb_dn->dn);
 
 			if (!(rmd_flags & DSDB_RMD_FLAG_DELETED)) {
+				struct GUID_txt_buf guid_str;
 				ldb_asprintf_errstring(ldb, "Attribute %s already exists for target GUID %s",
-						       el->name, GUID_string(tmp_ctx, p->guid));
+						       el->name, GUID_buf_string(&p->guid, &guid_str));
 				talloc_free(tmp_ctx);
 				/* error codes for 'member' need to be
 				   special cased */
@@ -2071,7 +2078,7 @@ static int replmd_modify_la_add(struct ldb_module *module,
 			}
 		}
 
-		ret = replmd_add_backlink(module, schema, msg_guid, dns[i].guid, true, schema_attr, true);
+		ret = replmd_add_backlink(module, schema, msg_guid, &dns[i].guid, true, schema_attr, true);
 		if (ret != LDB_SUCCESS) {
 			talloc_free(tmp_ctx);
 			return ret;
@@ -2169,10 +2176,11 @@ static int replmd_modify_la_delete(struct ldb_module *module,
 		struct parsed_dn *p2;
 		uint32_t rmd_flags;
 
-		p2 = parsed_dn_find(old_dns, old_el->num_values, p->guid, NULL);
+		p2 = parsed_dn_find(old_dns, old_el->num_values, &p->guid, NULL);
 		if (!p2) {
+			struct GUID_txt_buf buf;
 			ldb_asprintf_errstring(ldb, "Attribute %s doesn't exist for target GUID %s",
-					       el->name, GUID_string(tmp_ctx, p->guid));
+					       el->name, GUID_buf_string(&p->guid, &buf));
 			if (ldb_attr_cmp(el->name, "member") == 0) {
 				return LDB_ERR_UNWILLING_TO_PERFORM;
 			} else {
@@ -2181,8 +2189,9 @@ static int replmd_modify_la_delete(struct ldb_module *module,
 		}
 		rmd_flags = dsdb_dn_rmd_flags(p2->dsdb_dn->dn);
 		if (rmd_flags & DSDB_RMD_FLAG_DELETED) {
+			struct GUID_txt_buf buf;
 			ldb_asprintf_errstring(ldb, "Attribute %s already deleted for target GUID %s",
-					       el->name, GUID_string(tmp_ctx, p->guid));
+					       el->name, GUID_buf_string(&p->guid, &buf));
 			if (ldb_attr_cmp(el->name, "member") == 0) {
 				return LDB_ERR_UNWILLING_TO_PERFORM;
 			} else {
@@ -2198,7 +2207,7 @@ static int replmd_modify_la_delete(struct ldb_module *module,
 		struct parsed_dn *p = &old_dns[i];
 		uint32_t rmd_flags;
 
-		if (el->num_values && parsed_dn_find(dns, el->num_values, p->guid, NULL) == NULL) {
+		if (el->num_values && parsed_dn_find(dns, el->num_values, &p->guid, NULL) == NULL) {
 			continue;
 		}
 
@@ -2212,7 +2221,7 @@ static int replmd_modify_la_delete(struct ldb_module *module,
 			return ret;
 		}
 
-		ret = replmd_add_backlink(module, schema, msg_guid, old_dns[i].guid, false, schema_attr, true);
+		ret = replmd_add_backlink(module, schema, msg_guid, &old_dns[i].guid, false, schema_attr, true);
 		if (ret != LDB_SUCCESS) {
 			talloc_free(tmp_ctx);
 			return ret;
@@ -2295,13 +2304,13 @@ static int replmd_modify_la_replace(struct ldb_module *module,
 
 		if (rmd_flags & DSDB_RMD_FLAG_DELETED) continue;
 
-		ret = replmd_add_backlink(module, schema, msg_guid, old_dns[i].guid, false, schema_attr, false);
+		ret = replmd_add_backlink(module, schema, msg_guid, &old_dns[i].guid, false, schema_attr, false);
 		if (ret != LDB_SUCCESS) {
 			talloc_free(tmp_ctx);
 			return ret;
 		}
 
-		p = parsed_dn_find(dns, el->num_values, old_p->guid, NULL);
+		p = parsed_dn_find(dns, el->num_values, &old_p->guid, NULL);
 		if (p) {
 			/* we don't delete it if we are re-adding it */
 			continue;
@@ -2323,7 +2332,7 @@ static int replmd_modify_la_replace(struct ldb_module *module,
 
 		if (old_dns &&
 		    (old_p = parsed_dn_find(old_dns,
-					    old_num_values, p->guid, NULL)) != NULL) {
+					    old_num_values, &p->guid, NULL)) != NULL) {
 			/* update in place */


-- 
Samba Shared Repository



More information about the samba-cvs mailing list