summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* ldb: Add read_lock and read_unlock to ldb_module_opsAndrew Bartlett2017-07-023-0/+52
| | | | | | | | This will be used to implement read locking in ldb_tdb Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* ldb:tests: Add test encoding current locking behaviour during ldb_search()Andrew Bartlett2017-07-021-0/+238
| | | | | | | | | | | | | Currently, a lock is not held against modifications once the final record is returned via a callback, so modifications can be made during the DONE callback. This makes it hard to write modules that interpert an ldb search result and do further processing so will change in the future to allow the full search to be atomic. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* ldb:tests: Show that writes do not appear during an ldb_search()Andrew Bartlett2017-07-021-0/+349
| | | | | | | | | | A modify or rename during a search must not cause a search to change output, and attributes having an index should in particular not see any change in behaviour in this respect Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* ldb:tests: don't assert the results before doing the final search finishedAndrew Bartlett2017-07-021-5/+10
| | | | | | | | This is required to pass the test in future, because otherwise the clean up will fail because we hold locks. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* ldb:tdb: Ensure we correctly decrement ltdb->read_lock_countGarming Sam2017-07-021-0/+1
| | | | | | | | | If we do not do this, then we never take the all record lock, and instead do a lock for every record as we go, which is very slow during a large search Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* ldb_pack: use ldb_dn_from_ldb_val() and avoid a duplicate strlen() callAndrew Bartlett2017-07-021-1/+4
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: version 1.3.14tdb-1.3.14Stefan Metzmacher2017-07-022-1/+72
| | | | | | | | | * allow tdb_traverse_read before tdb_transaction[_prepare]_commit() * Improve documentation for tdb_transaction_start() * Add new function tdb_transaction_active() Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb: Add new function tdb_transaction_active()Andrew Bartlett2017-07-023-0/+29
| | | | | | | | | | This will allow callers to avoid their own reference counting of transactions. Additionally, this will always line up with the acutal transaction state, even in the error cases where tdb can cancel the transaction Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: Improve documentation for tdb_transaction_start()Andrew Bartlett2017-07-021-4/+7
| | | | | | | It now references the TDB_ALLOW_NESTING and TDB_DISALLOW_NESTING flags Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tdb: Remove locking from tdb_traverse_read()Andrew Bartlett2017-07-022-13/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This restores the original intent of tdb_traverse_read() in 7dd31288a701d772e45b1960ac4ce4cc1be782ed This is needed to avoid a deadlock with tdb_lockall() and the transaction start, as ldb_tdb should take the allrecord lock during a search (which calls tdb_traverse), and can otherwise deadlock against a transaction starting in another process We add a test to show that a transaction can now start while a read traverse is in progress This allows more operations to happen in parallel. The blocking point is moved to the prepare commit. This in turn permits a roughly doubling of unindexed search performance, because currently ldb_tdb omits to take the lock due to an unrelated bug, but taking the allrecord lock triggers the above-mentioned deadlock. This behaviour was added in 251aaafe3a9213118ac3a92def9ab2104c40d12a for Solaris 10 in 2005. But the run-fcntl-deadlock test works also on Solaris 10, see https://lists.samba.org/archive/samba-technical/2017-April/119876.html. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3: VFS: Change SMB_VFS_GETWD to return struct smb_filename * instead of char *.Jeremy Allison2017-07-011-0/+1
| | | | | | | | We need to migrate all pathname based VFS calls to use a struct to finish modernising the VFS with extra timestamp and flags parameters. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
* debug: new debug class for kerberosAndrew Bartlett2017-06-302-0/+3
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* param: change the effective default for "client max protocol" to the latest ↵Stefan Metzmacher2017-06-271-1/+1
| | | | | | | | | supported protocol Currently it's SMB3_11. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* krb5_wrap: add smb_krb5_salt_principal2data()Stefan Metzmacher2017-06-272-1/+72
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* krb5_wrap: add smb_krb5_salt_principal()Stefan Metzmacher2017-06-272-0/+126
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib: Give util_paths.c its own headerVolker Lendecke2017-06-245-25/+57
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* waf:lib/replace: Fix building with older GCC versionsBjörn Baumbach2017-06-231-1/+7
| | | | | | | | | Using gcc 4.3.2: cc1: error: unrecognized command line option "-Wno-format-truncation" Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tevent: version 0.9.32tevent-0.9.32Stefan Metzmacher2017-06-222-1/+100
| | | | | | | | | | | | | * Fix mutex locking in tevent_threaded_context_destructor(). * Fix a memleak on FreeBSD. * Re-init threading in tevent_re_initialise(). * Include the finish location in tevent_req_default_print(). Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Thu Jun 22 17:17:33 CEST 2017 on sn-devel-144
* tevent: include the finish location in tevent_req_default_print()Stefan Metzmacher2017-06-221-2/+3
| | | | | | | | It's verify useful when debugging code without a debugger to be able to use tevent_req_print() in DEBUG statements. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* dbwrap: Remove unused dbwrap_fileVolker Lendecke2017-06-212-456/+0
| | | | | | | | This has stopped working ages ago. The idea is clear, but if someone wants to revive it, I think it needs a completely fresh start. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* dbwrap: Remove unused dbwrap_cacheVolker Lendecke2017-06-213-256/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tevent: Simplify create_immediateVolker Lendecke2017-06-211-10/+1
| | | | | | | Not much change, just 9 lines less of code. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* ldb: Fix CID 1412926 Unchecked return valueVolker Lendecke2017-06-201-1/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* krb5_wrap: handle KRB5_ERR_HOST_REALM_UNKNOWN in ↵Stefan Metzmacher2017-06-161-0/+4
| | | | | | | smb_krb5_get_realm_from_hostname() Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tevent_threads: Fix a rundown race introduced with 1828011317bVolker Lendecke2017-06-161-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The race is easily reproduced by adding a poll(NULL,0,10) in between the two pthread_mutex_unlock calls in _tevent_threaded_schedule_immediate. Before 1828011317b, the main thread was signalled only after the helper had already unlocked event_ctx_mutex. Full explaination follows: ----------------------------------------------------------------- Inside _tevent_threaded_schedule_immediate() we have: 476 ret = pthread_mutex_unlock(&ev->scheduled_mutex); 477 if (ret != 0) { 478 abort(); 479 } HERE!!!! 481 ret = pthread_mutex_unlock(&tctx->event_ctx_mutex); 482 if (ret != 0) { 483 abort(); 484 } At the HERE!!! point, what happens is tevent_common_threaded_activate_immediate(), which is blocked on ev->scheduled_mutex, get released and does: 514 while (ev->scheduled_immediates != NULL) { 515 struct tevent_immediate *im = ev->scheduled_immediates; 516 DLIST_REMOVE(ev->scheduled_immediates, im); 517 DLIST_ADD_END(ev->immediate_events, im); 518 } - making an immediate event ready to be scheduled. This then returns into epoll_event_loop_once(), which then calls: 910 if (ev->immediate_events && 911 tevent_common_loop_immediate(ev)) { 912 return 0; 913 } which causes the immediate event to fire. This immediate event is the pthread job terminate event, which was previously set up in pthreadpool_tevent_job_signal() by: 198 if (state->tctx != NULL) { 199 /* with HAVE_PTHREAD */ 200 tevent_threaded_schedule_immediate(state->tctx, state->im, 201 pthreadpool_tevent_job_done, 202 state); So we now call pthreadpool_tevent_job_done() - which does: 225 TALLOC_FREE(state->tctx); calling tevent_threaded_context_destructor(): 384 ret = pthread_mutex_destroy(&tctx->event_ctx_mutex); <---------------- BOOM returns an error ! 385 if (ret != 0) { 386 abort(); 387 } as we haven't gotten to line 481 above (the line after HERE!!!!) so the tctx->event_ctx_mutex is still locked when we try to destroy it. So doing an additional: ret = pthread_mutex_lock(&tctx->event_ctx_mutex); ret = pthread_mutex_unlock(&tctx->event_ctx_mutex); (error checking elided) forces tevent_threaded_context_destructor() to wait until tctx->event_ctx_mutex is unlocked before it locks/unlocks and then is guaranteed safe to destroy. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* docs-xml: change the default for "map untrusted to domain" to "auto"Stefan Metzmacher2017-06-161-0/+2
| | | | | | | | | | | | | | This makes the behaviour much more robust, particularly with forest child domains over one-way forest trusts. Sadly we don't support this kind of setup with our current ADDC, so there's no way to have automated tests for this behaviour, but at least we know it doesn't break any existing tests. BUG: https://bugzilla.samba.org/show_bug.cgi?id=8630 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* replmd: check single values in replmd_add_fix_laGarming Sam2017-06-151-1/+3
| | | | | | | | | repl_meta_data knows whether linked attributes are appropriately [un-]duplicated, and this is how it tells ldb_tdb that. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Pair-programmed-with: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: 1.1.31ldb-1.1.31Douglas Bagnall2017-06-154-1/+279
| | | | | | | * Add efficient function to find duplicate values in ldb messages (this makes large multi-valued attributes in ldb_tdb more efficient) Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: relatively efficient functions for finding duplicate valuesDouglas Bagnall2017-06-156-57/+730
| | | | | | | | | | | | | | | | | | ldb backends need to make sure they are not adding duplicate values to multi-valued attributes in ADD and MODIFY operations. Until now they have done this inefficiently using nested loops. Here we add common functions that deal with large numbers of values in O(n log n) time, but continue to use the simple methods for small numbers of values. These functions take a struct ldb_context pointer and an options flag arguments, although the ldb is not used, and only one bit of the options has meaning. This is to allow further patches to switch on schema-aware comparisons. This entails an ABI jump to add the two new functions. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb.h whitespaceDouglas Bagnall2017-06-151-91/+91
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb tests/ldb_mod_op_test: don't double include cmocka.hDouglas Bagnall2017-06-151-2/+0
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: fix a typoDouglas Bagnall2017-06-151-1/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: fix whitespace in ldb_msg.cDouglas Bagnall2017-06-151-35/+35
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: Rename module -> next_module for clarityAndrew Bartlett2017-06-151-39/+41
| | | | | | | This helps make some future commits less confusing Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* tdb: add run-fcntl-deadlock testStefan Metzmacher2017-06-152-0/+203
| | | | | | | | | | | | | | | This verifies the F_RDLCK => F_WRLCK upgrade logic in the kernel for conflicting locks. This is a standalone test to check the traverse_read vs. allrecord_lock/prepare_commit interaction. This is based on the example from https://lists.samba.org/archive/samba-technical/2017-April/119861.html from Douglas Bagnall <douglas.bagnall@catalyst.net.nz> and Volker Lendecke <vl@samba.org>. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* ldb_tdb: Improve logging on unique index violationAndrew Bartlett2017-06-151-1/+14
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* ldb_tdb: Remove the idxptr DB before we re-indexAndrew Bartlett2017-06-151-0/+12
| | | | | | | | | | | | | | | We do not want the cache or any of the values in it, we want to read the real DB @INDEX: records. This matters if a re-index is tiggered in the same transaction as the modify of the values in the index. Otherwise we won't see the old index record (it will not show up in the tdb_traverse) and so fail to remove it. That in turn can cause a spurious unqiue index violation. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* ldb_tdb: Check for memory allocation failure in ltdb_index_transaction_start()Andrew Bartlett2017-06-151-0/+4
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* strerror_r: provide XSI-compliant strerror_rGary Lockyer2017-06-133-1/+26
| | | | | | | | | | | | | Provide a XSI-compliant strerror_r on GNU based systems. The default GNU strerror_r is not XSI-compliant, this patch wraps the GNU-specific call in an XSI-compliant wrapper. This reverts 18ed32ce0821d11c0c06d82c07ba1c27b0c2b886 which tried to make Heimdal use roken, rather than libreplace for strerror_r. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* libbreplace: compatibility fix for AIXGuillaume Xavier Taillon2017-06-132-2/+10
| | | | | | | | | | | | | | Adds macros for preprocessor compares and replaces an incomptatible compare with one of the new macros. This fixes a comptability bug on AIX. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11621 Signed-off-by: Guillaume Xavier Taillon <gtaillon@ca.ibm.com> Reviewed-by: Björn Jacke <bjacke@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Björn Jacke <bj@sernet.de> Autobuild-Date(master): Tue Jun 13 09:11:56 CEST 2017 on sn-devel-144
* tevent: Fix a race condition in tevent context rundownVolker Lendecke2017-06-091-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | We protect setting tctx->event_ctx=NULL with tctx->event_ctx_mutex. But in _tevent_threaded_schedule_immediate we have the classic TOCTOU race: After we checked "ev==NULL", looking at tevent_common_context_destructor the event context can go after _tevent_threaded_schedule_immediate checked. We need to serialize things a bit by keeping tctx->event_ctx_mutex locked while we reference "ev", in particular in the DLIST_ADD_END(ev->scheduled_immediates,im); I think the locking hierarchy is still maintained, tevent_atfork_prepare() first locks all the tctx locks, and then the scheduled_mutex. Also, I don't think this will impact parallelism too badly: event_ctx_mutex is only used to protect setting tctx->ev. Found by staring at code while fixing the FreeBSD memleak due to not destroying scheduled_mutex. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Jun 9 00:45:26 CEST 2017 on sn-devel-144
* tevent: Fix a memleak on FreeBSDVolker Lendecke2017-06-081-0/+5
| | | | | | | | | FreeBSD has malloc'ed memory attached to mutexes. We need to clean this up. valgrind really helped here Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tevent: Add tevent_re_initialise to threaded testVolker Lendecke2017-06-081-0/+8
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tevent: Re-init threading in tevent_re_initialiseVolker Lendecke2017-06-081-0/+2
| | | | | | | Without this threading is not usable after that call Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tevent: Factor out context initializationVolker Lendecke2017-06-081-25/+34
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tevent: Fix a typoVolker Lendecke2017-06-081-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:util: Make loading of modules more secureAndreas Schneider2017-06-061-59/+42
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12780 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:util: Make probing of modules more secureAndreas Schneider2017-06-062-1/+66
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12780 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:util: Rename smb_load_modules()Andreas Schneider2017-06-062-2/+2
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12780 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:util: Add new function to load modules from absolute pathAndreas Schneider2017-06-061-2/+40
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12780 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>