From: Gary Lockyer Date: Wed, 24 Oct 2018 21:52:27 +0000 (+1300) Subject: dsdb group audit: align dn_compare with memcmp X-Git-Tag: tdb-1.3.17~1109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8420a4d0fddd71af608635a707ef20f37fa9b627;p=thirdparty%2Fsamba.git dsdb group audit: align dn_compare with memcmp Rename the parameter names and adjust the return codes from dn_compare so that: dn_compare(a, b) => LESS_THAN means a is less than b. GREATER_THAN means a is greater than b. Thanks to metze for suggesting the correct semantics for dn_compare BUG: https://bugzilla.samba.org/show_bug.cgi?id=13664 Signed-off-by: Gary Lockyer Reviewed-by: Stefan Metzmacher --- diff --git a/selftest/knownfail.d/bug13664 b/selftest/knownfail.d/bug13664 deleted file mode 100644 index 6ffbf1297c3..00000000000 --- a/selftest/knownfail.d/bug13664 +++ /dev/null @@ -1 +0,0 @@ -^samba4.dsdb.samdb.ldb_modules.group_audit.test_log_membership_changes_removed diff --git a/source4/dsdb/samdb/ldb_modules/group_audit.c b/source4/dsdb/samdb/ldb_modules/group_audit.c index 1c74805eed0..47b69435195 100644 --- a/source4/dsdb/samdb/ldb_modules/group_audit.c +++ b/source4/dsdb/samdb/ldb_modules/group_audit.c @@ -311,35 +311,36 @@ enum dn_compare_result { GREATER_THAN }; /* - * @brief compare parsed_dns + * @brief compare parsed_dn, using GUID ordering * - * Compare two parsed_dn structures, parsing the entries if necessary. + * Compare two parsed_dn structures, using GUID ordering. * To avoid the overhead of parsing the DN's this function does a binary - * compare first. Only parsing the DN's they are not equal at a binary level. + * compare first. The DN's tre only parsed if they are not equal at a binary + * level. * * @param ctx talloc context that will own the parsed dsdb_dn * @param ldb ldb_context - * @param old_val The old value - * @param new_val The old value + * @param dn1 The first dn + * @param dn2 The second dn * * @return BINARY_EQUAL values are equal at a binary level * EQUAL DN's are equal but the meta data is different - * LESS_THAN old value < new value - * GREATER_THAN old value > new value + * LESS_THAN dn1's GUID is less than dn2's GUID + * GREATER_THAN dn1's GUID is greater than dn2's GUID * */ static enum dn_compare_result dn_compare( TALLOC_CTX *mem_ctx, struct ldb_context *ldb, - struct parsed_dn *old_val, - struct parsed_dn *new_val) { + struct parsed_dn *dn1, + struct parsed_dn *dn2) { int res = 0; /* * Do a binary compare first to avoid unnecessary parsing */ - if (data_blob_cmp(new_val->v, old_val->v) == 0) { + if (data_blob_cmp(dn1->v, dn2->v) == 0) { /* * Values are equal at a binary level so no need * for further processing @@ -351,22 +352,22 @@ static enum dn_compare_result dn_compare( * do a GUID ordering compare. To do this we will need to ensure * that the dn's have been parsed. */ - if (old_val->dsdb_dn == NULL) { + if (dn1->dsdb_dn == NULL) { really_parse_trusted_dn( mem_ctx, ldb, - old_val, + dn1, LDB_SYNTAX_DN); } - if (new_val->dsdb_dn == NULL) { + if (dn2->dsdb_dn == NULL) { really_parse_trusted_dn( mem_ctx, ldb, - new_val, + dn2, LDB_SYNTAX_DN); } - res = ndr_guid_compare(&new_val->guid, &old_val->guid); + res = ndr_guid_compare(&dn1->guid, &dn2->guid); if (res < 0) { return LESS_THAN; } else if (res == 0) { diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c b/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c index 1f4cf3ea5b3..743ce206bc0 100644 --- a/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c +++ b/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c @@ -562,7 +562,7 @@ static void test_dn_compare(void **state) b->v = &bb; res = dn_compare(ctx, ldb, a, b); - assert_int_equal(GREATER_THAN, res); + assert_int_equal(LESS_THAN, res); /* * DN's should have been parsed */ @@ -590,7 +590,7 @@ static void test_dn_compare(void **state) b->v = &bb; res = dn_compare(ctx, ldb, a, b); - assert_int_equal(LESS_THAN, res); + assert_int_equal(GREATER_THAN, res); /* * DN's should have been parsed */