svn commit: samba r17201 - in branches/SOC/mkhl/ldb-map: common include ldb_tdb modules

mkhl at samba.org mkhl at samba.org
Sun Jul 23 10:54:07 GMT 2006


Author: mkhl
Date: 2006-07-23 10:54:06 +0000 (Sun, 23 Jul 2006)
New Revision: 17201

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17201

Log:
Fetch missing updates from mainline (missed them while merging...).

Martin

Modified:
   branches/SOC/mkhl/ldb-map/common/ldb.c
   branches/SOC/mkhl/ldb-map/common/ldb_dn.c
   branches/SOC/mkhl/ldb-map/common/ldb_msg.c
   branches/SOC/mkhl/ldb-map/include/ldb.h
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.c
   branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.h
   branches/SOC/mkhl/ldb-map/modules/objectclass.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/common/ldb.c
===================================================================
--- branches/SOC/mkhl/ldb-map/common/ldb.c	2006-07-23 09:50:04 UTC (rev 17200)
+++ branches/SOC/mkhl/ldb-map/common/ldb.c	2006-07-23 10:54:06 UTC (rev 17201)
@@ -296,7 +296,7 @@
 	return ldb_transaction_cancel_internal(ldb);
 }
 
-int ldb_autotransaction_start(struct ldb_context *ldb)
+static int ldb_autotransaction_start(struct ldb_context *ldb)
 {
 	/* explicit transaction active, ignore autotransaction request */
 	if (ldb->transaction_active)
@@ -305,7 +305,7 @@
 	return ldb_transaction_start_internal(ldb);
 }
 
-int ldb_autotransaction_commit(struct ldb_context *ldb)
+static int ldb_autotransaction_commit(struct ldb_context *ldb)
 {
 	/* explicit transaction active, ignore autotransaction request */
 	if (ldb->transaction_active)
@@ -314,7 +314,7 @@
 	return ldb_transaction_commit_internal(ldb);
 }
 
-int ldb_autotransaction_cancel(struct ldb_context *ldb)
+static int ldb_autotransaction_cancel(struct ldb_context *ldb)
 {
 	/* explicit transaction active, ignore autotransaction request */
 	if (ldb->transaction_active)
@@ -529,11 +529,8 @@
 	struct ldb_request *req;
 	int ret;
 
-	*res = talloc_zero(ldb, struct ldb_result);
-	if (! *res) {
-		return LDB_ERR_OPERATIONS_ERROR;
-	}
-
+	*res = NULL;
+	
 	req = talloc(ldb, struct ldb_request);
 	if (req == NULL) {
 		ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
@@ -551,6 +548,12 @@
 		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
+	*res = talloc_zero(ldb, struct ldb_result);
+	if (! *res) {
+		talloc_free(req);
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
+
 	req->op.search.attrs = attrs;
 	req->controls = NULL;
 	req->context = res;
@@ -583,9 +586,11 @@
 	struct ldb_request *req;
 	int ret;
 
-	ret = ldb_msg_sanity_check(message);
-	if (ret != LDB_SUCCESS) return ret;
-
+	ret = ldb_msg_sanity_check(ldb, message);
+	if (ret != LDB_SUCCESS) {
+		return ret;
+	}
+		
 	req = talloc(ldb, struct ldb_request);
 	if (req == NULL) {
 		ldb_set_errstring(ldb, talloc_strdup(ldb, "Out of memory!"));
@@ -615,7 +620,7 @@
 	struct ldb_request *req;
 	int ret;
 
-	ret = ldb_msg_sanity_check(message);
+	ret = ldb_msg_sanity_check(ldb, message);
 	if (ret != LDB_SUCCESS) return ret;
 
 	req = talloc(ldb, struct ldb_request);

Modified: branches/SOC/mkhl/ldb-map/common/ldb_dn.c
===================================================================
--- branches/SOC/mkhl/ldb-map/common/ldb_dn.c	2006-07-23 09:50:04 UTC (rev 17200)
+++ branches/SOC/mkhl/ldb-map/common/ldb_dn.c	2006-07-23 10:54:06 UTC (rev 17201)
@@ -578,32 +578,37 @@
 	if (edn == NULL) return NULL;
 
 	cedn = ldb_dn_new(ldb);
-	LDB_DN_NULL_FAILED(cedn);
+	if (!cedn) {
+		return NULL;
+	}
 
 	cedn->comp_num = edn->comp_num;
 	cedn->components = talloc_array(cedn, struct ldb_dn_component, edn->comp_num);
-	LDB_DN_NULL_FAILED(cedn->components);
+	if (!cedn->components) {
+		talloc_free(cedn);
+		return NULL;
+	}
 
 	for (i = 0; i < edn->comp_num; i++) {
 		struct ldb_dn_component dc;
 		const struct ldb_attrib_handler *h;
 
 		dc.name = ldb_attr_casefold(cedn, edn->components[i].name);
-		LDB_DN_NULL_FAILED(dc.name);
+		if (!dc.name) {
+			talloc_free(cedn);
+			return NULL;
+		}
 
 		h = ldb_attrib_handler(ldb, dc.name);
 		if (h->canonicalise_fn(ldb, cedn, &(edn->components[i].value), &(dc.value)) != 0) {
-			goto failed;
+			talloc_free(cedn);
+			return NULL;
 		}
 
 		cedn->components[i] = dc;
 	}
 
 	return cedn;
-
-failed:
-	talloc_free(cedn);
-	return NULL;
 }
 
 struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn)

Modified: branches/SOC/mkhl/ldb-map/common/ldb_msg.c
===================================================================
--- branches/SOC/mkhl/ldb-map/common/ldb_msg.c	2006-07-23 09:50:04 UTC (rev 17200)
+++ branches/SOC/mkhl/ldb-map/common/ldb_msg.c	2006-07-23 10:54:06 UTC (rev 17201)
@@ -550,18 +550,20 @@
 	return mod;
 }
 
-int ldb_msg_sanity_check(const struct ldb_message *msg)
+int ldb_msg_sanity_check(struct ldb_context *ldb, 
+			 const struct ldb_message *msg)
 {
 	int i, j;
 
 	/* basic check on DN */
 	if (msg->dn == NULL) {
 		/* TODO: return also an error string */
+		ldb_set_errstring(ldb, talloc_strdup(ldb, "ldb message lacks a DN!"));
 		return LDB_ERR_INVALID_DN_SYNTAX;
 	}
 	if (msg->dn->comp_num == 0) {
 		/* root dse has empty dn */
-		/* TODO: return also an error string */
+		ldb_set_errstring(ldb, talloc_strdup(ldb, "DN on new ldb message is '' (not permitted)!"));
 		return LDB_ERR_ENTRY_ALREADY_EXISTS;
 	}
 
@@ -569,8 +571,13 @@
 	for (i = 0; i < msg->num_elements; i++) {
 		for (j = 0; j < msg->elements[i].num_values; j++) {
 			if (msg->elements[i].values[j].length == 0) {
+				TALLOC_CTX *mem_ctx = talloc_new(ldb);
 				/* an attribute cannot be empty */
 				/* TODO: return also an error string */
+				ldb_set_errstring(ldb, talloc_asprintf(mem_ctx, "Element %s has empty attribute in ldb message (%s)!",
+								       msg->elements[i].name, 
+								       ldb_dn_linearize(mem_ctx, msg->dn)));
+				talloc_free(mem_ctx);
 				return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
 			}
 		}

Modified: branches/SOC/mkhl/ldb-map/include/ldb.h
===================================================================
--- branches/SOC/mkhl/ldb-map/include/ldb.h	2006-07-23 09:50:04 UTC (rev 17200)
+++ branches/SOC/mkhl/ldb-map/include/ldb.h	2006-07-23 10:54:06 UTC (rev 17201)
@@ -1222,7 +1222,8 @@
    LDB_ERR_INVALID_ATTRIBUTE_SYNTAX) if there is a problem with a
    message.
 */
-int ldb_msg_sanity_check(const struct ldb_message *msg);
+int ldb_msg_sanity_check(struct ldb_context *ldb,
+			 const struct ldb_message *msg);
 
 /**
    Duplicate an ldb_val structure

Modified: branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.c
===================================================================
--- branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.c	2006-07-23 09:50:04 UTC (rev 17200)
+++ branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.c	2006-07-23 10:54:06 UTC (rev 17201)
@@ -969,7 +969,6 @@
 	.sequence_number   = ltdb_sequence_number
 };
 
-
 /*
   connect to the database
 */
@@ -1012,7 +1011,8 @@
 	}
 
 	/* note that we use quite a large default hash size */
-	ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000, tdb_flags, open_flags, 0666);
+	ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000, 
+				   tdb_flags, open_flags, 0666, ldb);
 	if (!ltdb->tdb) {
 		ldb_debug(ldb, LDB_DEBUG_ERROR, "Unable to open tdb '%s'\n", path);
 		talloc_free(ltdb);

Modified: branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.h
===================================================================
--- branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.h	2006-07-23 09:50:04 UTC (rev 17200)
+++ branches/SOC/mkhl/ldb-map/ldb_tdb/ldb_tdb.h	2006-07-23 10:54:06 UTC (rev 17201)
@@ -116,5 +116,6 @@
 
 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
 				   const char *path, int hash_size, int tdb_flags,
-				   int open_flags, mode_t mode);
+				   int open_flags, mode_t mode,
+				   struct ldb_context *ldb);
 

Modified: branches/SOC/mkhl/ldb-map/modules/objectclass.c
===================================================================
--- branches/SOC/mkhl/ldb-map/modules/objectclass.c	2006-07-23 09:50:04 UTC (rev 17200)
+++ branches/SOC/mkhl/ldb-map/modules/objectclass.c	2006-07-23 10:54:06 UTC (rev 17201)
@@ -554,7 +554,7 @@
 		}
 	}
 
-	ret = ldb_msg_sanity_check(msg);
+	ret = ldb_msg_sanity_check(ac->module->ldb, msg);
 	if (ret != LDB_SUCCESS) {
 		talloc_free(mem_ctx);
 		return ret;



More information about the samba-cvs mailing list