svn commit: samba r12895 - in branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules: .

abartlet at samba.org abartlet at samba.org
Fri Jan 13 04:49:50 GMT 2006


Author: abartlet
Date: 2006-01-13 04:49:49 +0000 (Fri, 13 Jan 2006)
New Revision: 12895

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

Log:
Error strings save lives.  

err, they save time at least.  The correct use of an error string in
this case quickly pinpoited an overzealous check, and saved me hours
of painful debugging.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/password_hash.c


Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/password_hash.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/password_hash.c	2006-01-13 04:36:58 UTC (rev 12894)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/password_hash.c	2006-01-13 04:49:49 UTC (rev 12895)
@@ -71,7 +71,7 @@
 	uint_t pwdProperties, pwdHistoryLength;
 	uint_t userAccountControl;
 	const char *dnsDomain, *realm;
-	const char *sambaPassword;
+	const char *sambaPassword = NULL;
 	struct samr_Password *sambaLMPwdHistory, *sambaNTPwdHistory;
 	struct samr_Password *lmPwdHash, *ntPwdHash;
 	struct samr_Password *lmOldHash = NULL, *ntOldHash = NULL;
@@ -165,26 +165,32 @@
 	 * the second modify.  We might not want it written to disk */
 	
 	if (req->operation == LDB_REQ_ADD) {
-		if (attribute->num_values != 1) {
+		if (attribute->num_values > 1) {
 			ldb_set_errstring(module, 
 					  talloc_asprintf(mem_ctx, "sambaPassword_handle: "
 							  "attempted set of multiple sambaPassword attributes on %s rejected",
 							  ldb_dn_linearize(mem_ctx, dn)));
 			return LDB_ERR_CONSTRAINT_VIOLATION;
 		}
-	
-		sambaPassword = (const char *)attribute->values[0].data;
-		ldb_msg_remove_attr(msg2, "sambaPassword");
+
+		if (attribute->num_values == 1) {
+			sambaPassword = (const char *)attribute->values[0].data;
+			ldb_msg_remove_attr(msg2, "sambaPassword");
+		}
 	} else if (((attribute->flags & LDB_FLAG_MOD_MASK) == LDB_FLAG_MOD_ADD)
 		   || ((attribute->flags & LDB_FLAG_MOD_MASK) == LDB_FLAG_MOD_REPLACE)) {
-		if (attribute->num_values != 1) {
+		if (attribute->num_values > 1) {
+			ldb_set_errstring(module, 
+					  talloc_asprintf(mem_ctx, "sambaPassword_handle: "
+							  "attempted set of multiple sambaPassword attributes on %s rejected",
+							  ldb_dn_linearize(mem_ctx, dn)));
 			return LDB_ERR_CONSTRAINT_VIOLATION;
 		}
 		
-		sambaPassword = (const char *)attribute->values[0].data;
-		ldb_msg_remove_attr(msg2, "sambaPassword");
-	} else {
-		sambaPassword = NULL;
+		if (attribute->num_values == 1) {
+			sambaPassword = (const char *)attribute->values[0].data;
+			ldb_msg_remove_attr(msg2, "sambaPassword");
+		}
 	}
 
 	modified_orig_request = talloc(mem_ctx, struct ldb_request);



More information about the samba-cvs mailing list