diff options
author | Gary Lockyer <gary@catalyst.net.nz> | 2018-10-25 10:52:27 +1300 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2018-11-05 12:44:32 +0100 |
commit | 5d06550108c119c7b79e30e9a6e17d19ed63e477 (patch) | |
tree | 55b9b883465f6a1bbe4f5b599901b2558ce28be1 /source4 | |
parent | fd43fd88a8df96f8ad31159bd2ee13ef96a1d070 (diff) | |
download | samba-5d06550108c119c7b79e30e9a6e17d19ed63e477.tar.gz |
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 <gary@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 8420a4d0fddd71af608635a707ef20f37fa9b627)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/group_audit.c | 31 | ||||
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c | 4 |
2 files changed, 18 insertions, 17 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/group_audit.c b/source4/dsdb/samdb/ldb_modules/group_audit.c index 47929aa8764..eb592adc336 100644 --- a/source4/dsdb/samdb/ldb_modules/group_audit.c +++ b/source4/dsdb/samdb/ldb_modules/group_audit.c @@ -252,35 +252,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 @@ -292,22 +293,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 1c1bd29958e..47ffb4be7a8 100644 --- a/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c +++ b/source4/dsdb/samdb/ldb_modules/tests/test_group_audit.c @@ -586,7 +586,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 */ @@ -614,7 +614,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 */ |