summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* lib: Fix illegal use of 0-length arraysVolker Lendecke2017-06-061-2/+8
| | | | | | | Found and confirmed to work by albert chin (china@thewrittenword.com) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* waf: Do not trhow a format-truncation error for test/snprintf.cAndreas Schneider2017-06-011-1/+1
| | | | | | | | | | | | This fixes building with GCC 7.1 Error: ../lib/replace/test/testsuite.c:355:6: error: ‘%d’ directive output truncated writing 1 byte into a region of size 0 [-Werror=format-truncation=] Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* replace: Use the same size as d_name member of struct direntAndreas Schneider2017-06-011-1/+1
| | | | | | | This fixes an error with GCC 7.1 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* password_hash: conditional compilation for crypt_rGary Lockyer2017-06-011-0/+1
| | | | | | | Add check for crypt_r, and if absent fall back to crypt Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Volker Lendecke <vl@samba.org>
* ldb: Version 1.1.30ldb-1.1.30Andrew Bartlett2017-05-315-5/+277
| | | | | | | | | | | | | | | | | | | * let ldbdump parse the -i option * don't allow the reveal_internals control for ldbedit * only allow --show-binary for ldbsearch * don't let ldbsearch create non-existing files * fix ldb_tdb search inconsistencies * add cmocka based tests * provide an interface for improved indexing for callers like Samba, which will allow much better performance. * Makes ldb access to tdb:// databases use a private event context rather than the global event context passed in by the caller. This is because running other operations while locks are held or a search is being conducted is not safe. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* ldb: Add Doxygen documentation for ldb_handle_use_global_event_context()Andrew Bartlett2017-05-311-9/+13
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: Add Doxygen docs for ldb_set_require_private_event_context()Andrew Bartlett2017-05-311-0/+9
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: Add Doxygen docs for ldb_handle_get_event_context()Andrew Bartlett2017-05-311-4/+9
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: Add Doxygen docs for ldb_schema_set_override_indexlist()Andrew Bartlett2017-05-311-0/+10
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: Add Doxygen docs for ldb_schema_attribute_set_override_handlerAndrew Bartlett2017-05-311-0/+8
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: Add Doxygen comments for ldb_req_*trusted() functionsAndrew Bartlett2017-05-311-5/+18
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: Add test for ldb_build_search_req()Andrew Bartlett2017-05-311-0/+52
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* ldb: Add tests for new ldb handle and event context behaviourAndrew Bartlett2017-05-311-0/+54
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>