[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Mon Nov 30 03:17:47 MST 2009


The branch, master has been updated
       via  7399c04... s4-drs: Test situations for runtime constructed parentGUID
       via  71e29cb... s4-drs: Using dsdb_msg_add_guid() utility function
      from  0003b5f... s3:docs: Document "cache directory" and "state directory".

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


- Log -----------------------------------------------------------------
commit 7399c04fd0b509079117426b28853a0aa3f87d2d
Author: Fernando J V da Silva <fernandojvsilva at yahoo.com.br>
Date:   Fri Nov 27 12:25:18 2009 -0200

    s4-drs: Test situations for runtime constructed parentGUID
    
    Includes the following verifications for the constructed parentGUID:
    - Checks if it returns nothing when there is no parent object
    - Ensures that attributes mentioned after the parentGUID
    are returned correctly (this avoid a bug pointed out by Tridge
    during sync constructed parentGUID development)
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

commit 71e29cbf56048791057ccf07b859654312f3882e
Author: Fernando J V da Silva <fernandojvsilva at yahoo.com.br>
Date:   Wed Nov 25 17:01:55 2009 -0300

    s4-drs: Using dsdb_msg_add_guid() utility function
    
    Uses the dsdb_msg_add_guid() to add any kind of GUID attribute
    to a ldb_message in several places of samba4 code.
    
    Signed-off-by: Andrew Tridgell <tridge at samba.org>

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

Summary of changes:
 source4/dsdb/samdb/ldb_modules/objectguid.c     |   13 +---------
 source4/dsdb/samdb/ldb_modules/repl_meta_data.c |   12 +---------
 source4/dsdb/samdb/ldb_modules/samldb.c         |   26 +---------------------
 source4/lib/ldb/tests/python/ldap.py            |   25 +++++++++++++++++++++-
 source4/utils/oLschema2ldif.c                   |    9 +-------
 5 files changed, 30 insertions(+), 55 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c
index 12dd402..bfbf2b4 100644
--- a/source4/dsdb/samdb/ldb_modules/objectguid.c
+++ b/source4/dsdb/samdb/ldb_modules/objectguid.c
@@ -31,6 +31,7 @@
 
 #include "includes.h"
 #include "ldb_module.h"
+#include "dsdb/samdb/samdb.h"
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "param/param.h"
 
@@ -136,10 +137,8 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
 	struct ldb_request *down_req;
 	struct ldb_message_element *attribute;
 	struct ldb_message *msg;
-	struct ldb_val v;
 	struct GUID guid;
 	uint64_t seq_num;
-	enum ndr_err_code ndr_err;
 	int ret;
 	time_t t = time(NULL);
 	struct og_context *ac;
@@ -174,15 +173,7 @@ static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
 	/* a new GUID */
 	guid = GUID_random();
 
-	ndr_err = ndr_push_struct_blob(&v, msg, 
-				       lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
-				       &guid,
-				       (ndr_push_flags_fn_t)ndr_push_GUID);
-	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-		return LDB_ERR_OPERATIONS_ERROR;
-	}
-
-	ret = ldb_msg_add_value(msg, "objectGUID", &v, NULL);
+	ret = dsdb_msg_add_guid(msg, &guid, "objectGUID");
 	if (ret) {
 		return ret;
 	}
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 37aa399..bfde2df 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -411,7 +411,6 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req)
 	struct ldb_message *msg;
         const DATA_BLOB *guid_blob;
 	struct GUID guid;
-	struct ldb_val guid_value;
 	struct replPropertyMetaDataBlob nmd;
 	struct ldb_val nmd_value;
 	const struct GUID *our_invocation_id;
@@ -580,15 +579,6 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req)
 	}
 
 	/* generated NDR encoded values */
-	ndr_err = ndr_push_struct_blob(&guid_value, msg, 
-				       NULL,
-				       &guid,
-				       (ndr_push_flags_fn_t)ndr_push_GUID);
-	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-		ldb_oom(ldb);
-		talloc_free(ac);
-		return LDB_ERR_OPERATIONS_ERROR;
-	}
 	ndr_err = ndr_push_struct_blob(&nmd_value, msg, 
 				       lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
 				       &nmd,
@@ -602,7 +592,7 @@ static int replmd_add(struct ldb_module *module, struct ldb_request *req)
 	/*
 	 * add the autogenerated values
 	 */
-	ret = ldb_msg_add_value(msg, "objectGUID", &guid_value, NULL);
+	ret = dsdb_msg_add_guid(msg, &guid, "objectGUID");
 	if (ret != LDB_SUCCESS) {
 		ldb_oom(ldb);
 		talloc_free(ac);
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index c5161db..e49b493 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -1161,21 +1161,10 @@ static int samldb_fill_object(struct samldb_ctx *ac, const char *type)
 		}
 
 		if (!ldb_msg_find_element(ac->msg, "schemaIDGUID")) {
-			enum ndr_err_code ndr_err;
-			struct ldb_val guid_value;
 			struct GUID guid;
 			/* a new GUID */
 			guid = GUID_random();
-			/* generated NDR encoded values */
-			ndr_err = ndr_push_struct_blob(&guid_value, ac->msg,
-						       NULL,
-						       &guid,
-						       (ndr_push_flags_fn_t)ndr_push_GUID);
-			if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-				ldb_oom(ldb);
-				return LDB_ERR_OPERATIONS_ERROR;
-			}
-			ret = ldb_msg_add_value(ac->msg, "schemaIDGUID", &guid_value, NULL);
+			ret = dsdb_msg_add_guid(ac->msg, &guid, "schemaIDGUID");
 			if (ret != LDB_SUCCESS) {
 				ldb_oom(ldb);
 				return ret;
@@ -1211,21 +1200,10 @@ static int samldb_fill_object(struct samldb_ctx *ac, const char *type)
 		if (ret != LDB_SUCCESS) return ret;
 
 		if (!ldb_msg_find_element(ac->msg, "schemaIDGUID")) {
-			enum ndr_err_code ndr_err;
-			struct ldb_val guid_value;
 			struct GUID guid;
 			/* a new GUID */
 			guid = GUID_random();
-			/* generated NDR encoded values */
-			ndr_err = ndr_push_struct_blob(&guid_value, ac->msg,
-						       NULL,
-						       &guid,
-						       (ndr_push_flags_fn_t)ndr_push_GUID);
-			if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-				ldb_oom(ldb);
-				return LDB_ERR_OPERATIONS_ERROR;
-			}
-			ret = ldb_msg_add_value(ac->msg, "schemaIDGUID", &guid_value, NULL);
+			ret = dsdb_msg_add_guid(ac->msg, &guid, "schemaIDGUID");
 			if (ret != LDB_SUCCESS) {
 				ldb_oom(ldb);
 				return ret;
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index 408246b..0292422 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -566,11 +566,34 @@ objectClass: container
             "objectclass":"user",
             "samaccountname":"parentguidtest"});
         res1 = ldb.search(base="cn=parentguidtest,cn=users," + self.base_dn, scope=SCOPE_BASE,
-                          attrs=["parentGUID"]);
+                          attrs=["parentGUID", "samaccountname"]);
         res2 = ldb.search(base="cn=users," + self.base_dn,scope=SCOPE_BASE,
                           attrs=["objectGUID"]);
+        res3 = ldb.search(base=self.base_dn, scope=SCOPE_BASE,
+                          attrs=["parentGUID"]);
+
+        """Check if the parentGUID is valid """
         self.assertEquals(res1[0]["parentGUID"], res2[0]["objectGUID"]);
 
+        """Check if it returns nothing when there is no parent object"""
+        has_parentGUID = False
+        for key in res3[0].keys():
+            if key == "parentGUID":
+                has_parentGUID = True
+                break
+        self.assertFalse(has_parentGUID);
+
+        """Ensures that if you look for another object attribute after the constructed
+            parentGUID, it will return correctly"""
+        has_another_attribute = False
+        for key in res1[0].keys():
+            if key == "sAMAccountName":
+                has_another_attribute = True
+                break
+        self.assertTrue(has_another_attribute)
+        self.assertTrue(len(res1[0]["samaccountname"]) == 1)
+        self.assertEquals(res1[0]["samaccountname"][0], "parentguidtest");
+
         print "Testing parentGUID behaviour on rename\n"
 
         self.ldb.add({
diff --git a/source4/utils/oLschema2ldif.c b/source4/utils/oLschema2ldif.c
index f337432..22a458c 100644
--- a/source4/utils/oLschema2ldif.c
+++ b/source4/utils/oLschema2ldif.c
@@ -399,14 +399,7 @@ static struct ldb_message *process_entry(TALLOC_CTX *mem_ctx, const char *entry)
 
 	memcpy(&guid, digest, sizeof(struct GUID));
 
-	ndr_err = ndr_push_struct_blob(&schemaIdGuid, ctx, NULL, &guid,
-			(ndr_push_flags_fn_t)ndr_push_GUID);
-
-	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-		goto failed;
-	}
-
-	if (ldb_msg_add_value(msg, "schemaIdGuid", &schemaIdGuid, NULL) != 0) {
+	if (dsdb_msg_add_guid(msg, &guid, "schemaIdGuid") != 0) {
 		goto failed;
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list