The branch, v4-7-test has been updated via 237bead s4:kdc: only map SDB_ERR_NOT_FOUND_HERE to HDB_ERR_NOT_FOUND_HERE via 8be0198 s3:smb2_server: allow logoff, close, unlock, cancel and echo on expired sessions via 2108b10 s3:smbd: return the correct error for cancelled SMB2 notifies on expired sessions via b5e8614 s4:torture: add smb2.session.expire2 test via 3648ab0 g_lock: fix cleanup of stale entries in g_lock_trylock() via 7249bc1 dns_server: Use the indexed "name" attribute in wildcard lookup via 6c5481b dns_server: Do not look for a wildcard for @ via 7d60443 dns_server: Do the exact match query first, then do the wildcard lookup via 2cd8389 ldb: Release 1.2.3 via 82764c9 ldb: Intersect the index from SCOPE_ONELEVEL with the index for the search expression via 5f51561 ldb_tdb: Provide struct ltdb_private to index routines via 6ddcbfd selftest: Do not use dn= filter string from edc0c99 s4:samba: Fix default to be running samba as a deamon
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-7-test - Log ----------------------------------------------------------------- commit 237bead2f243224264aca0b5c65bf3bfadef78aa Author: Stefan Metzmacher <me...@samba.org> Date: Thu Sep 21 12:02:25 2017 +0200 s4:kdc: only map SDB_ERR_NOT_FOUND_HERE to HDB_ERR_NOT_FOUND_HERE HDB_ERR_NOT_FOUND_HERE indicated a very specific error on an RODC. We should not map any error to HDB_ERR_NOT_FOUND_HERE, we should just pass errors along unmapped. Otherwise we'll hit the logic bug in: if (ret == KDC_PROXY_REQUEST) { uint16_t port; if (!sock->kdc_socket->kdc->am_rodc) { DEBUG(0,("kdc_udp_call_loop: proxying requested when not RODC")); talloc_free(call); goto done; } And just don't send an error message to the client. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13132 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org> Autobuild-Date(master): Wed Dec 6 23:16:54 CET 2017 on sn-devel-144 (cherry picked from commit aaa946bb9eb8088389b8ffdec460023f1961616c) Autobuild-User(v4-7-test): Stefan Metzmacher <me...@samba.org> Autobuild-Date(v4-7-test): Fri Dec 22 14:23:12 CET 2017 on sn-devel-144 commit 8be019859010a12874e0e78ebec2d44e5b2abe5c Author: Stefan Metzmacher <me...@samba.org> Date: Wed Dec 20 14:05:54 2017 +0100 s3:smb2_server: allow logoff, close, unlock, cancel and echo on expired sessions Windows client at least doesn't have code to replay a SMB2 Close after getting NETWORK_SESSION_EXPIRED, which locks out a the client and generates an endless loop around NT_STATUS_SHARING_VIOLATION. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13197 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Thu Dec 21 23:28:42 CET 2017 on sn-devel-144 (cherry picked from commit c4919d4d5f78aeb54a438b95d4eab2f082a8174e) commit 2108b1092e3106f59ae2383c34c7bfbeb896314b Author: Stefan Metzmacher <me...@samba.org> Date: Thu Dec 21 14:47:06 2017 +0100 s3:smbd: return the correct error for cancelled SMB2 notifies on expired sessions BUG: https://bugzilla.samba.org/show_bug.cgi?id=13197 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit cfaba684785529d656138df454165aa08a775a01) commit b5e86148c6c6c465805486fcfd628dc4d6d8a6a5 Author: Stefan Metzmacher <me...@samba.org> Date: Thu Dec 21 12:53:02 2017 +0100 s4:torture: add smb2.session.expire2 test This demonstrates the interaction of NT_STATUS_NETWORK_SESSION_EXPIRED and various SMB2 opcodes. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13197 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit f60af3b61c4a374d7d1c575049a932d1824489b6) commit 3648ab02d4188f6441b83806faa79ae7c06bdb61 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Dec 20 08:25:19 2017 +0100 g_lock: fix cleanup of stale entries in g_lock_trylock() g_lock_trylock() always incremented the counter 'i', even after cleaning a stale entry at position 'i', which means it skipped checking for a conflict against the new entry at position 'i'. As result a process could get a write lock, while there're still some read lock holders. Once we get into that problem, also more than one write lock are possible. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13195 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> Autobuild-User(master): Volker Lendecke <v...@samba.org> Autobuild-Date(master): Wed Dec 20 20:31:48 CET 2017 on sn-devel-144 (similar to commit 576fb4fb5dc506bf55e5cf87973999dca444149b) commit 7249bc196c46b950341f99f6d7ba9ce0173fcc94 Author: Andrew Bartlett <abart...@samba.org> Date: Mon Dec 18 16:22:23 2017 +1300 dns_server: Use the indexed "name" attribute in wildcard lookup (the RDN, being 'dc' in this use case, does not have an index in the AD schema). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13191 Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> (cherry picked from commit 071ad56aef33c2bfb3840e1a114e17272e926890) commit 6c5481b93a3ab506f73a10b9ef5ceb7d169ec4d3 Author: Andrew Bartlett <abart...@samba.org> Date: Fri Dec 15 11:40:28 2017 +1300 dns_server: Do not look for a wildcard for @ This query is made for every record returned via BIND9 DLZ. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13191 Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> (cherry picked from commit 948791aca70ca973755adcef27dc02da4c46f267) commit 7d60443c5d02f4a06e45e592ad136c16ca7e2ddb Author: Andrew Bartlett <abart...@samba.org> Date: Fri Dec 15 12:30:50 2017 +1300 dns_server: Do the exact match query first, then do the wildcard lookup The wildcard lookup is SCOPE_ONELEVEL combined with an index on the name attribute. This is not as efficient as a base DN lookup, so we try for that first. A not-found and wildcard response will still fall back to the ONELEVEL index. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13191 Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> (cherry picked from commit 3efc879d98ba136d4d70e0e2d77fac9614186ab3) commit 2cd8389320af9d1f346193f448f8870a8cee2188 Author: Andrew Bartlett <abart...@samba.org> Date: Mon Dec 18 10:14:31 2017 +1300 ldb: Release 1.2.3 - Intersect the index from SCOPE_ONELEVEL with the index for the search expression This helps ensure we do not have to scan all objects at this level which could be very many (one per DNS zone entry). However, due to the O(n*m) behaviour in the LDB index code we only do this for small numbers of matches on the filter tree. This behaviour will only be for ldb 1.2 and will not be kept long-term in LDB, versions 1.3.1 and above will instead only intersect when the more efficient GUID index is in use. Finally, disallowDNFilter now applies to SCOPE_ONELEVEL banning dn= as a filter string when so configured. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13191 Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> commit 82764c9f3ec35b728c66dddd40b724ce27720a3e Author: Andrew Bartlett <abart...@samba.org> Date: Mon Dec 18 16:22:01 2017 +1300 ldb: Intersect the index from SCOPE_ONELEVEL with the index for the search expression This helps ensure we do not have to scan all objects at this level which could be very many (one per DNS zone entry). However, due to the O(n*m) behaviour in list_intersect() for ldb 1.2 and earlier, we only do this for small numbers of matches on the filter tree. This behaviour will only be for ldb 1.2 and will not be kept long-term in LDB, versions 1.3.1 and above will instead only intersect when the GUID index is in use. NOTE WELL: the behaviour of disallowDNFilter is enforced in the index code, so this fixes SCOPE_ONELEVEL to also honour disallowDNFilter if there @IDXONE is enabled. Again, this will change again in 1.3.1 and above. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13191 Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> (adapted from ef240aaca0ef693a96726ac2366c454294b87b96 in master) commit 5f515616f4cb1ea1ee7dede1a0d47e6f18c5d1ce Author: Andrew Bartlett <abart...@samba.org> Date: Thu Aug 10 16:23:33 2017 +1200 ldb_tdb: Provide struct ltdb_private to index routines This will make it easier to switch the GUID index mode on and off BUG: https://bugzilla.samba.org/show_bug.cgi?id=13191 Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> (cherry picked from commit 3d952157d72b3a4635f3942449c1727c438c97c6) commit 6ddcbfddcddda0944a13d513d496641fe8092d85 Author: Andrew Bartlett <abart...@samba.org> Date: Wed Dec 20 14:55:04 2017 +1300 selftest: Do not use dn= filter string This accidentially worked with SCOPE_ONELEVEL against Samba but dn= filters are not valid in AD. Signed-off-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Garming Sam <garm...@catalyst.net.nz> (cherry picked from commit 44eee9ce9e9818df8387b2b3782504408112f12c) ----------------------------------------------------------------------- Summary of changes: lib/ldb/ABI/{ldb-1.2.2.sigs => ldb-1.2.3.sigs} | 0 ...yldb-util-1.1.10.sigs => pyldb-util-1.2.3.sigs} | 0 ...-util-1.1.10.sigs => pyldb-util.py3-1.2.3.sigs} | 0 lib/ldb/ldb_tdb/ldb_index.c | 141 ++++++-- lib/ldb/ldb_tdb/ldb_tdb.c | 38 ++- lib/ldb/ldb_tdb/ldb_tdb.h | 16 +- lib/ldb/wscript | 2 +- python/samba/tests/samba_tool/sites.py | 4 +- source3/lib/g_lock.c | 6 +- source3/smbd/notify.c | 17 +- source3/smbd/smb2_lock.c | 17 + source3/smbd/smb2_server.c | 19 ++ source4/dns_server/dnsserver_common.c | 36 +- source4/kdc/hdb-samba4.c | 24 +- source4/libcli/smb2/keepalive.c | 7 +- source4/torture/smb2/session.c | 362 +++++++++++++++++++++ 16 files changed, 620 insertions(+), 69 deletions(-) copy lib/ldb/ABI/{ldb-1.2.2.sigs => ldb-1.2.3.sigs} (100%) copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util-1.2.3.sigs} (100%) copy lib/ldb/ABI/{pyldb-util-1.1.10.sigs => pyldb-util.py3-1.2.3.sigs} (100%) Changeset truncated at 500 lines: diff --git a/lib/ldb/ABI/ldb-1.2.2.sigs b/lib/ldb/ABI/ldb-1.2.3.sigs similarity index 100% copy from lib/ldb/ABI/ldb-1.2.2.sigs copy to lib/ldb/ABI/ldb-1.2.3.sigs diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util-1.2.3.sigs similarity index 100% copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs copy to lib/ldb/ABI/pyldb-util-1.2.3.sigs diff --git a/lib/ldb/ABI/pyldb-util-1.1.10.sigs b/lib/ldb/ABI/pyldb-util.py3-1.2.3.sigs similarity index 100% copy from lib/ldb/ABI/pyldb-util-1.1.10.sigs copy to lib/ldb/ABI/pyldb-util.py3-1.2.3.sigs diff --git a/lib/ldb/ldb_tdb/ldb_index.c b/lib/ldb/ldb_tdb/ldb_index.c index 3510dd9..56ecf93 100644 --- a/lib/ldb/ldb_tdb/ldb_index.c +++ b/lib/ldb/ldb_tdb/ldb_index.c @@ -79,7 +79,9 @@ static int dn_list_cmp(const struct ldb_val *v1, const struct ldb_val *v2) find a entry in a dn_list, using a ldb_val. Uses a case sensitive comparison with the dn returns -1 if not found */ -static int ltdb_dn_list_find_val(const struct dn_list *list, const struct ldb_val *v) +static int ltdb_dn_list_find_val(struct ltdb_private *ltdb, + const struct dn_list *list, + const struct ldb_val *v) { unsigned int i; for (i=0; i<list->count; i++) { @@ -94,12 +96,14 @@ static int ltdb_dn_list_find_val(const struct dn_list *list, const struct ldb_va find a entry in a dn_list. Uses a case sensitive comparison with the dn returns -1 if not found */ -static int ltdb_dn_list_find_str(struct dn_list *list, const char *dn) +static int ltdb_dn_list_find_str(struct ltdb_private *ltdb, + struct dn_list *list, + const char *dn) { struct ldb_val v; v.data = discard_const_p(unsigned char, dn); v.length = strlen(dn); - return ltdb_dn_list_find_val(list, &v); + return ltdb_dn_list_find_val(ltdb, list, &v); } /* @@ -219,7 +223,9 @@ normal_index: /* save a dn_list into a full @IDX style record */ -static int ltdb_dn_list_store_full(struct ldb_module *module, struct ldb_dn *dn, +static int ltdb_dn_list_store_full(struct ldb_module *module, + struct ltdb_private *ltdb, + struct ldb_dn *dn, struct dn_list *list) { struct ldb_message *msg; @@ -274,7 +280,8 @@ static int ltdb_dn_list_store(struct ldb_module *module, struct ldb_dn *dn, struct dn_list *list2; if (ltdb->idxptr == NULL) { - return ltdb_dn_list_store_full(module, dn, list); + return ltdb_dn_list_store_full(module, ltdb, + dn, list); } if (ltdb->idxptr->itdb == NULL) { @@ -345,7 +352,8 @@ static int ltdb_index_traverse_store(struct tdb_context *tdb, TDB_DATA key, TDB_ return -1; } - ltdb->idxptr->error = ltdb_dn_list_store_full(module, dn, list); + ltdb->idxptr->error = ltdb_dn_list_store_full(module, ltdb, + dn, list); talloc_free(dn); if (ltdb->idxptr->error != 0) { return -1; @@ -575,6 +583,7 @@ static int ltdb_index_dn_leaf(struct ldb_module *module, list = list & list2 */ static bool list_intersect(struct ldb_context *ldb, + struct ltdb_private *ltdb, struct dn_list *list, const struct dn_list *list2) { struct dn_list *list3; @@ -622,7 +631,8 @@ static bool list_intersect(struct ldb_context *ldb, list3->count = 0; for (i=0;i<list->count;i++) { - if (ltdb_dn_list_find_val(list2, &list->dn[i]) != -1) { + if (ltdb_dn_list_find_val(ltdb, list2, + &list->dn[i]) != -1) { list3->dn[list3->count] = list->dn[i]; list3->count++; } @@ -846,7 +856,8 @@ static int ltdb_index_dn_and(struct ldb_module *module, list->dn = list2->dn; list->count = list2->count; found = true; - } else if (!list_intersect(ldb, list, list2)) { + } else if (!list_intersect(ldb, ltdb, + list, list2)) { talloc_free(list2); return LDB_ERR_OPERATIONS_ERROR; } @@ -952,7 +963,8 @@ static int ltdb_index_dn(struct ldb_module *module, filter a candidate dn_list from an indexed search into a set of results extracting just the given attributes */ -static int ltdb_index_filter(const struct dn_list *dn_list, +static int ltdb_index_filter(struct ltdb_private *ltdb, + const struct dn_list *dn_list, struct ltdb_context *ac, uint32_t *match_count) { @@ -1063,6 +1075,7 @@ static void ltdb_dn_list_remove_duplicates(struct dn_list *list) */ int ltdb_search_indexed(struct ltdb_context *ac, uint32_t *match_count) { + struct ldb_context *ldb = ldb_module_get_ctx(ac->module); struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(ac->module), struct ltdb_private); struct dn_list *dn_list; int ret; @@ -1097,6 +1110,8 @@ int ltdb_search_indexed(struct ltdb_context *ac, uint32_t *match_count) break; case LDB_SCOPE_ONELEVEL: + { + struct dn_list *idx_one_tree_list = NULL; if (!ltdb->cache->one_level_indexes) { talloc_free(dn_list); return LDB_ERR_OPERATIONS_ERROR; @@ -1106,8 +1121,54 @@ int ltdb_search_indexed(struct ltdb_context *ac, uint32_t *match_count) talloc_free(dn_list); return ret; } - break; + /* + * If we have too many matches, also try the filter + * tree and do index work there + * + * We only do this in the GUID index mode, which is + * O(n*log(m)) otherwise the intersection below will + * be too costly at O(n*m). + */ + idx_one_tree_list + = talloc_zero(ac, struct dn_list); + if (idx_one_tree_list == NULL) { + return ldb_module_oom(ac->module); + } + + if (!ltdb->cache->attribute_indexes) { + talloc_free(idx_one_tree_list); + talloc_free(dn_list); + return LDB_ERR_OPERATIONS_ERROR; + } + /* + * Here we load the index for the tree. + */ + ret = ltdb_index_dn(ac->module, ltdb, ac->tree, + idx_one_tree_list); + if (ret != LDB_SUCCESS) { + talloc_free(idx_one_tree_list); + talloc_free(dn_list); + return ret; + } + + /* + * We have to avoid the O(n*m) behaviour here blowing + * up, so we only intersect the lists if it will + * really help + */ + if (idx_one_tree_list->count < 10) { + if (!list_intersect(ldb, ltdb, + dn_list, idx_one_tree_list)) { + talloc_free(idx_one_tree_list); + talloc_free(dn_list); + return LDB_ERR_OPERATIONS_ERROR; + } + } else { + talloc_free(idx_one_tree_list); + } + break; + } case LDB_SCOPE_SUBTREE: case LDB_SCOPE_DEFAULT: if (!ltdb->cache->attribute_indexes) { @@ -1123,7 +1184,7 @@ int ltdb_search_indexed(struct ltdb_context *ac, uint32_t *match_count) break; } - ret = ltdb_index_filter(dn_list, ac, match_count); + ret = ltdb_index_filter(ltdb, dn_list, ac, match_count); talloc_free(dn_list); return ret; } @@ -1148,7 +1209,9 @@ int ltdb_search_indexed(struct ltdb_context *ac, uint32_t *match_count) * * @return An ldb error code */ -static int ltdb_index_add1(struct ldb_module *module, const char *dn, +static int ltdb_index_add1(struct ldb_module *module, + struct ltdb_private *ltdb, + const char *dn, struct ldb_message_element *el, int v_idx) { struct ldb_context *ldb; @@ -1227,12 +1290,15 @@ static int ltdb_index_add1(struct ldb_module *module, const char *dn, /* add index entries for one elements in a message */ -static int ltdb_index_add_el(struct ldb_module *module, const char *dn, +static int ltdb_index_add_el(struct ldb_module *module, + struct ltdb_private *ltdb, + const char *dn, struct ldb_message_element *el) { unsigned int i; for (i = 0; i < el->num_values; i++) { - int ret = ltdb_index_add1(module, dn, el, i); + int ret = ltdb_index_add1(module, ltdb, + dn, el, i); if (ret != LDB_SUCCESS) { return ret; } @@ -1244,11 +1310,12 @@ static int ltdb_index_add_el(struct ldb_module *module, const char *dn, /* add index entries for all elements in a message */ -static int ltdb_index_add_all(struct ldb_module *module, const char *dn, +static int ltdb_index_add_all(struct ldb_module *module, + struct ltdb_private *ltdb, + const char *dn, struct ldb_message_element *elements, unsigned int num_el) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); unsigned int i; if (dn[0] == '@') { @@ -1265,7 +1332,7 @@ static int ltdb_index_add_all(struct ldb_module *module, const char *dn, if (!ltdb_is_indexed(module, ltdb, elements[i].name)) { continue; } - ret = ltdb_index_add_el(module, dn, &elements[i]); + ret = ltdb_index_add_el(module, ltdb, dn, &elements[i]); if (ret != LDB_SUCCESS) { struct ldb_context *ldb = ldb_module_get_ctx(module); ldb_asprintf_errstring(ldb, @@ -1321,9 +1388,9 @@ static int ltdb_index_onelevel(struct ldb_module *module, el.num_values = 1; if (add) { - ret = ltdb_index_add1(module, dn, &el, 0); + ret = ltdb_index_add1(module, ltdb, dn, &el, 0); } else { /* delete */ - ret = ltdb_index_del_value(module, msg->dn, &el, 0); + ret = ltdb_index_del_value(module, ltdb, msg->dn, &el, 0); } talloc_free(pdn); @@ -1335,23 +1402,27 @@ static int ltdb_index_onelevel(struct ldb_module *module, add the index entries for a new element in a record The caller guarantees that these element values are not yet indexed */ -int ltdb_index_add_element(struct ldb_module *module, struct ldb_dn *dn, +int ltdb_index_add_element(struct ldb_module *module, + struct ltdb_private *ltdb, + struct ldb_dn *dn, struct ldb_message_element *el) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); if (ldb_dn_is_special(dn)) { return LDB_SUCCESS; } if (!ltdb_is_indexed(module, ltdb, el->name)) { return LDB_SUCCESS; } - return ltdb_index_add_el(module, ldb_dn_get_linearized(dn), el); + return ltdb_index_add_el(module, ltdb, + ldb_dn_get_linearized(dn), el); } /* add the index entries for a new record */ -int ltdb_index_add_new(struct ldb_module *module, const struct ldb_message *msg) +int ltdb_index_add_new(struct ldb_module *module, + struct ltdb_private *ltdb, + const struct ldb_message *msg) { const char *dn; int ret; @@ -1365,7 +1436,8 @@ int ltdb_index_add_new(struct ldb_module *module, const struct ldb_message *msg) return LDB_ERR_OPERATIONS_ERROR; } - ret = ltdb_index_add_all(module, dn, msg->elements, msg->num_elements); + ret = ltdb_index_add_all(module, ltdb, dn, msg->elements, + msg->num_elements); if (ret != LDB_SUCCESS) { return ret; } @@ -1377,7 +1449,9 @@ int ltdb_index_add_new(struct ldb_module *module, const struct ldb_message *msg) /* delete an index entry for one message element */ -int ltdb_index_del_value(struct ldb_module *module, struct ldb_dn *dn, +int ltdb_index_del_value(struct ldb_module *module, + struct ltdb_private *ltdb, + struct ldb_dn *dn, struct ldb_message_element *el, unsigned int v_idx) { struct ldb_context *ldb; @@ -1422,7 +1496,7 @@ int ltdb_index_del_value(struct ldb_module *module, struct ldb_dn *dn, return ret; } - i = ltdb_dn_list_find_str(list, dn_str); + i = ltdb_dn_list_find_str(ltdb, list, dn_str); if (i == -1) { /* nothing to delete */ talloc_free(dn_key); @@ -1452,10 +1526,11 @@ int ltdb_index_del_value(struct ldb_module *module, struct ldb_dn *dn, delete the index entries for a element return -1 on failure */ -int ltdb_index_del_element(struct ldb_module *module, struct ldb_dn *dn, +int ltdb_index_del_element(struct ldb_module *module, + struct ltdb_private *ltdb, + struct ldb_dn *dn, struct ldb_message_element *el) { - struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), struct ltdb_private); const char *dn_str; int ret; unsigned int i; @@ -1478,7 +1553,7 @@ int ltdb_index_del_element(struct ldb_module *module, struct ldb_dn *dn, return LDB_SUCCESS; } for (i = 0; i < el->num_values; i++) { - ret = ltdb_index_del_value(module, dn, el, i); + ret = ltdb_index_del_value(module, ltdb, dn, el, i); if (ret != LDB_SUCCESS) { return ret; } @@ -1512,7 +1587,8 @@ int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg) } for (i = 0; i < msg->num_elements; i++) { - ret = ltdb_index_del_element(module, msg->dn, &msg->elements[i]); + ret = ltdb_index_del_element(module, ltdb, + msg->dn, &msg->elements[i]); if (ret != LDB_SUCCESS) { return ret; } @@ -1677,6 +1753,8 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * struct ldb_context *ldb; struct ltdb_reindex_context *ctx = (struct ltdb_reindex_context *)state; struct ldb_module *module = ctx->module; + struct ltdb_private *ltdb = talloc_get_type(ldb_module_get_private(module), + struct ltdb_private); struct ldb_message *msg; const char *dn = NULL; unsigned int nb_elements_in_db; @@ -1738,7 +1816,8 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void * return -1; } - ret = ltdb_index_add_all(module, dn, msg->elements, msg->num_elements); + ret = ltdb_index_add_all(module, ltdb, dn, + msg->elements, msg->num_elements); if (ret != LDB_SUCCESS) { ctx->error = ret; diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index ccad816..afa0f9e 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -355,6 +355,7 @@ static bool ldb_tdb_single_valued(const struct ldb_schema_attribute *a, } static int ltdb_add_internal(struct ldb_module *module, + struct ltdb_private *ltdb, const struct ldb_message *msg, bool check_single_value) { @@ -419,7 +420,7 @@ static int ltdb_add_internal(struct ldb_module *module, return ret; } - ret = ltdb_index_add_new(module, msg); + ret = ltdb_index_add_new(module, ltdb, msg); if (ret != LDB_SUCCESS) { return ret; } @@ -436,6 +437,8 @@ static int ltdb_add(struct ltdb_context *ctx) { struct ldb_module *module = ctx->module; struct ldb_request *req = ctx->req; + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); int ret = LDB_SUCCESS; ret = ltdb_check_special_dn(module, req->op.add.message); @@ -449,7 +452,8 @@ static int ltdb_add(struct ltdb_context *ctx) return LDB_ERR_OPERATIONS_ERROR; } - ret = ltdb_add_internal(module, req->op.add.message, true); + ret = ltdb_add_internal(module, ltdb, + req->op.add.message, true); return ret; } @@ -609,6 +613,7 @@ static int ltdb_msg_add_element(struct ldb_message *msg, delete all elements having a specified attribute name */ static int msg_delete_attribute(struct ldb_module *module, + struct ltdb_private *ltdb, struct ldb_message *msg, const char *name) { unsigned int i; @@ -621,7 +626,7 @@ static int msg_delete_attribute(struct ldb_module *module, } i = el - msg->elements; - ret = ltdb_index_del_element(module, msg->dn, el); + ret = ltdb_index_del_element(module, ltdb, msg->dn, el); if (ret != LDB_SUCCESS) { return ret; } @@ -643,6 +648,7 @@ static int msg_delete_attribute(struct ldb_module *module, return LDB Error on failure */ static int msg_delete_element(struct ldb_module *module, + struct ltdb_private *ltdb, struct ldb_message *msg, const char *name, const struct ldb_val *val) @@ -675,10 +681,11 @@ static int msg_delete_element(struct ldb_module *module, } if (matched) { if (el->num_values == 1) { - return msg_delete_attribute(module, msg, name); + return msg_delete_attribute(module, + ltdb, msg, name); } - ret = ltdb_index_del_value(module, msg->dn, el, i); + ret = ltdb_index_del_value(module, ltdb, msg->dn, el, i); if (ret != LDB_SUCCESS) { return ret; } @@ -715,6 +722,8 @@ int ltdb_modify_internal(struct ldb_module *module, struct ldb_request *req) { struct ldb_context *ldb = ldb_module_get_ctx(module); + void *data = ldb_module_get_private(module); + struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private); struct ldb_message *msg2; unsigned int i, j; int ret = LDB_SUCCESS, idx; @@ -800,7 +809,8 @@ int ltdb_modify_internal(struct ldb_module *module, ret = LDB_ERR_OTHER; goto done; } - ret = ltdb_index_add_element(module, msg2->dn, + ret = ltdb_index_add_element(module, ltdb, + msg2->dn, el); if (ret != LDB_SUCCESS) { goto done; @@ -881,7 +891,8 @@ int ltdb_modify_internal(struct ldb_module *module, el2->values = vals; el2->num_values += el->num_values; - ret = ltdb_index_add_element(module, msg2->dn, el); + ret = ltdb_index_add_element(module, ltdb, + msg2->dn, el); if (ret != LDB_SUCCESS) { goto done; } @@ -945,7 +956,8 @@ int ltdb_modify_internal(struct ldb_module *module, } /* Delete the attribute if it exists in the DB */ - if (msg_delete_attribute(module, msg2, + if (msg_delete_attribute(module, ltdb, + msg2, el->name) != 0) { ret = LDB_ERR_OTHER; goto done; @@ -958,7 +970,8 @@ int ltdb_modify_internal(struct ldb_module *module, goto done; } - ret = ltdb_index_add_element(module, msg2->dn, el); + ret = ltdb_index_add_element(module, ltdb, + msg2->dn, el); if (ret != LDB_SUCCESS) { -- Samba Shared Repository