ldb_tdb: Do not check for duplicate values during a rename
authorGarming Sam <garming@catalyst.net.nz>
Thu, 9 Mar 2017 02:56:12 +0000 (15:56 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 13 Mar 2017 04:10:10 +0000 (05:10 +0100)
This is not the time to be pretending to be dbcheck, and there are
exceptions to the single-value rules in Samba. This is needed for
the same reasons as the modify case.

(Note: this error was triggered with the demote of an RODC with links)

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Pair-programmed-with: Andrew Bartlett <abartlet@samba.org>

lib/ldb/ldb_tdb/ldb_tdb.c

index 2dde0244f134631d47dca0d36529be7154a95e81..502afd9c3c81fab91b5880e740051aaca79756d6 100644 (file)
@@ -355,13 +355,17 @@ static int ltdb_add_internal(struct ldb_module *module,
                        continue;
                }
 
-               /* 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(msg->dn));
-                               return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
+               if (check_single_value) {
+                       /* 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(msg->dn));
+                                       return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
+                               }
                        }
                }
        }