[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha5-503-ga383b8b

Andrew Bartlett abartlet at samba.org
Thu Sep 11 21:46:04 GMT 2008


The branch, v4-0-test has been updated
       via  a383b8bf88a5681f9c9c6839ba645c872a735051 (commit)
      from  d60977cc7f89f89f34187f310c91d1ab7db6ccf2 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit a383b8bf88a5681f9c9c6839ba645c872a735051
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Sep 12 07:45:28 2008 +1000

    Fix failure to load the schema on read-only DB.
    
    This also tries to simplify the logic in the schema -> @ATTRIBUTES and
    @INDEXES code.
    
    Andrew Bartlett

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

Summary of changes:
 source/dsdb/schema/schema_set.c |   36 +++++++++++++-----------------------
 1 files changed, 13 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/dsdb/schema/schema_set.c b/source/dsdb/schema/schema_set.c
index 3f5ddd8..2303b88 100644
--- a/source/dsdb/schema/schema_set.c
+++ b/source/dsdb/schema/schema_set.c
@@ -79,13 +79,13 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
 			ret = ldb_msg_add_string(msg, attr->lDAPDisplayName, "CASE_INSENSITIVE");
 		} 
 		if (ret != LDB_SUCCESS) {
-			return ret;
+			break;
 		}
 
 		if (attr->searchFlags & SEARCH_FLAG_ATTINDEX) {
 			ret = ldb_msg_add_string(msg_idx, "@IDXATTR", attr->lDAPDisplayName);
 			if (ret != LDB_SUCCESS) {
-				return ret;
+				break;
 			}
 		}
 
@@ -105,11 +105,11 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
 		}
 		
 		if (ret != LDB_SUCCESS) {
-			return ret;
+			break;
 		}
 	}
 
-	if (!write_attributes) {
+	if (!write_attributes || ret != LDB_SUCCESS) {
 		talloc_free(mem_ctx);
 		return ret;
 	}
@@ -120,19 +120,13 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
 	if (ret == LDB_ERR_NO_SUCH_OBJECT) {
 		ret = ldb_add(ldb, msg);
 	} else if (ret != LDB_SUCCESS) {
-		talloc_free(mem_ctx);
-		return ret;
+	} else if (res->count != 1) {
+		ret = ldb_add(ldb, msg);
 	} else {
-
-		if (res->count != 1) {
-			talloc_free(mem_ctx);
-			return LDB_ERR_NO_SUCH_OBJECT;
-		}
-		
 		ret = LDB_SUCCESS;
 		/* Annoyingly added to our search results */
 		ldb_msg_remove_attr(res->msgs[0], "distinguishedName");
-
+		
 		mod_msg = ldb_msg_diff(ldb, res->msgs[0], msg);
 		if (mod_msg->num_elements > 0) {
 			ret = ldb_modify(ldb, mod_msg);
@@ -141,10 +135,11 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
 
 	if (ret == LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS) {
 		/* We might be on a read-only DB */
+		ret = LDB_SUCCESS;
+	}
+	if (ret != LDB_SUCCESS) {
 		talloc_free(mem_ctx);
 		return ret;
-	} else if (ret != LDB_SUCCESS) {
-		return ret;
 	}
 
 	/* Now write out the indexs, as found in the schema (if they have changed) */
@@ -153,14 +148,10 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
 	if (ret == LDB_ERR_NO_SUCH_OBJECT) {
 		ret = ldb_add(ldb, msg_idx);
 	} else if (ret != LDB_SUCCESS) {
-		talloc_free(mem_ctx);
-		return ret;
+	} else if (res->count != 1) {
+		ret = ldb_add(ldb, msg_idx);
 	} else {
-		if (res_idx->count != 1) {
-			talloc_free(mem_ctx);
-			return LDB_ERR_NO_SUCH_OBJECT;
-		}
-		
+		ret = LDB_SUCCESS;
 		/* Annoyingly added to our search results */
 		ldb_msg_remove_attr(res_idx->msgs[0], "distinguishedName");
 
@@ -171,7 +162,6 @@ static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schem
 	}
 	if (ret == LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS) {
 		/* We might be on a read-only DB */
-		talloc_free(mem_ctx);
 		ret = LDB_SUCCESS;
 	}
 	talloc_free(mem_ctx);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list