summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib:util: Avoid name confusion with config.hAndreas Schneider2018-11-281-5/+5
| | | | | | | | The HAVE_* is normally used for config.h definitions, so rename it to USE_ASM_BYTEORDER. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib:util: Use #ifdef instead of #if for config.h definitionsAndreas Schneider2018-11-282-3/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* tdb: Use #ifdef instead of #if for config.h definitionsAndreas Schneider2018-11-281-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* replace: Use #ifdef instead of #if for config.h definitionsAndreas Schneider2018-11-285-11/+11
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* krb5_wrap: Use #ifdef instead of #if for config.h definitionsAndreas Schneider2018-11-281-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* s3: Remove unsused MMAP_BLACKLIST ifdef checksAndreas Schneider2018-11-281-4/+0
| | | | | | | This doesn't get defined by anything. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib:replace: Check if HAVE_DECL_ENVIRON is defined firstAndreas Schneider2018-11-281-0/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* krb5_wrap: Fix a typoVolker Lendecke2018-11-281-1/+1
| | | | | | | | 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): Wed Nov 28 21:15:31 CET 2018 on sn-devel-144
* krb5_wrap: Add a talloc_ctx to smb_krb5_principal_get_realm()Volker Lendecke2018-11-282-10/+12
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tfork: add a README how to run test torture test under valgrindRalph Boehme2018-11-281-0/+22
| | | | | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed Nov 28 15:57:43 CET 2018 on sn-devel-144
* tfork: add a suppresssions file for drdRalph Boehme2018-11-281-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | drd reports: initialized twice: cond 0x514f188 at 0x4C3A399: pthread_cond_init_intercept (drd_pthread_intercepts.c:1022) by 0x4C3A399: pthread_cond_init@* (drd_pthread_intercepts.c:1030) by 0x50F3FF3: tfork_atfork_child (tfork.c:250) by 0x9A4B95D: fork (fork.c:204) by 0x50F4834: tfork_start_waiter_and_worker (tfork.c:581) by 0x50F4CDB: tfork_create (tfork.c:780) by 0x2F7469: tfork_thread (tfork.c:431) by 0x4C358F8: vgDrd_thread_wrapper (drd_pthread_intercepts.c:444) by 0x8D46593: start_thread (pthread_create.c:463) by 0x9A7EE6E: clone (clone.S:95) cond 0x514f188 was first observed at: at 0x4C3A399: pthread_cond_init_intercept (drd_pthread_intercepts.c:1022) by 0x4C3A399: pthread_cond_init@* (drd_pthread_intercepts.c:1030) by 0x50F413A: tfork_global_initialize (tfork.c:287) by 0x8D4DEA6: __pthread_once_slow (pthread_once.c:116) by 0x4C377FD: pthread_once_intercept (drd_pthread_intercepts.c:800) by 0x4C377FD: pthread_once (drd_pthread_intercepts.c:806) by 0x50F4C0E: tfork_create (tfork.c:743) by 0x2F7469: tfork_thread (tfork.c:431) by 0x4C358F8: vgDrd_thread_wrapper (drd_pthread_intercepts.c:444) by 0x8D46593: start_thread (pthread_create.c:463) by 0x9A7EE6E: clone (clone.S:95) This is intentional, the reinit is in a child process. Cf the comment in tfork.c. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tfork: add a suppresssions file for helgrindRalph Boehme2018-11-281-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tfork_atexit_unknown[1|2]: No idea what triggers this, definitely not tfork itself. tfork_pthread_get_specific: Helgrind reports: Possible data race during read of size 4 at 0x5141304 by thread #3 Locks held: none at 0x50E602E: tfork_global_get (tfork.c:301) by 0x50E69B1: tfork_create (tfork.c:737) by 0x2F7419: tfork_thread (tfork.c:431) by 0x4C35AC5: mythread_wrapper (hg_intercepts.c:389) by 0x8D38593: start_thread (pthread_create.c:463) by 0x9A70E6E: clone (clone.S:95) This conflicts with a previous write of size 4 by thread #2 Locks held: none at 0x8D3F7B7: pthread_key_create (pthread_key_create.c:41) by 0x50E5F79: tfork_global_initialize (tfork.c:280) by 0x8D3FEA6: __pthread_once_slow (pthread_once.c:116) by 0x50E6999: tfork_create (tfork.c:728) by 0x2F7419: tfork_thread (tfork.c:431) by 0x4C35AC5: mythread_wrapper (hg_intercepts.c:389) by 0x8D38593: start_thread (pthread_create.c:463) by 0x9A70E6E: clone (clone.S:95) Location 0x5141304 is 0 bytes inside global var "tfork_global_key" declared at tfork.c:122 This is nonsense, tfork_global_get() calls pthread_getspecific, so we're looking at the pthread_key_create()/pthread_[g|s]etspecific() API here which works with threads by design. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tfork: TFORK_ANNOTATE_BENIGN_RACERalph Boehme2018-11-281-0/+41
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tfork/test: ensure all threads start with SIGCHLD unblockedRalph Boehme2018-11-281-0/+17
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* libads: Give krb5_errs.c its own headerVolker Lendecke2018-11-271-3/+0
| | | | | | | | The protos were declared in lib/krb5_wrap but the functions are not available there. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* source4 smbd prefork: Add backoff to process restartGary Lockyer2018-11-231-0/+2
| | | | | | | | | Add new smbd.conf variables 'prefork backoff increment' and 'prefork maximum backoff' to control the rate at which failed pre-forked processes are restarted. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:compression: Fix undefined behavior in lzxpressAndreas Schneider2018-11-221-1/+1
| | | | | | | | | lib/compression/lzxpress.c:228 runtime error: store to misaligned address 0x5631d53ca9fe for type 'uint32_t', which requires 4 byte alignment Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib:util: Fix undefined behavior in bitmap.cAndreas Schneider2018-11-221-3/+3
| | | | | | | | lib/util/bitmap.c:77: runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib:util: Fix undefined behavior in idtreeAndreas Schneider2018-11-221-3/+3
| | | | | | | | lib/util/idtree.c:84 runtime error: left shift of 1 by 31 places cannot be represented in type 'int' Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib:util: Fix undefined behavior in asn1 parserAndreas Schneider2018-11-221-4/+7
| | | | | | | lib/util/asn1.c:969 runtime error: left shift of negative value -1 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib:crypto: Fix undefined behavior in md4Andreas Schneider2018-11-221-2/+4
| | | | | | | runtime error: left shift of 145 by 24 places cannot be represented in type 'int' Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib:util: Always include unistd.h for setgroupsAndreas Schneider2018-11-221-3/+3
| | | | | | | This is needed to pass configure checks Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* ldb_controls: Add some talloc error checking for controlsGarming Sam2018-11-201-2/+80
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13686 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* dirsync: Allow arbitrary length cookiesGarming Sam2018-11-201-5/+21
| | | | | | | | | | | The length of the cookie is proportional to the number of DCs ever in the domain (as it stores the uptodateness vector which has stale invocationID). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13686 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* libldb: Fix const char in pyldbAndreas Schneider2018-11-141-3/+3
| | | | | | | | | | | | | | | | | | | | | ../lib/ldb/pyldb.c: In function ‘PyDict_AsMessage’: ../lib/ldb/pyldb.c:90:22: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] #define PyStr_AsUTF8 PyUnicode_AsUTF8 ^~~~~~~~~~~~~~~~ ../lib/ldb/pyldb.c:1359:19: note: in expansion of macro ‘PyStr_AsUTF8’ char *key_str = PyStr_AsUTF8(key); ^~~~~~~~~~~~ ../lib/ldb/pyldb.c: In function ‘py_ldb_msg_getitem_helper’: ../lib/ldb/pyldb.c:3336:7: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] name = PyStr_AsUTF8(py_name); ^ ../lib/ldb/pyldb.c: In function ‘py_ldb_msg_setitem’: ../lib/ldb/pyldb.c:3502:12: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] attr_name = PyStr_AsUTF8(name); ^ Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
* lib:util Always initialize start and spaceAndreas Schneider2018-11-141-5/+2
| | | | | | | | | Found by cppcheck. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13680 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* replace: Add check for variable program_invocation_short_nameMartin Schwenke2018-11-132-5/+6
| | | | | | | | | | | | | | | | | | | | | It appears that wafsamba's configure() defines _GNU_SOURCE unconditionally, so checking _GNU_SOURCE isn't enough to know if this variable is available. For example, it isn't available on AIX with the xlc compiler: [ 6/10] Compiling lib/replace/replace.c ... "../../lib/replace/replace.c", line 991.16: 1506-045 (S) Undeclared identifier program_invocation_short_name. Instead, add a configure check for program_invocation_short_name and use it. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Nov 13 11:11:11 CET 2018 on sn-devel-144
* lib:replace: Do not leak the file pointer in rep_getprogname()Andreas Schneider2018-11-131-5/+12
| | | | | | | And return NULL on error. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib:replace: Add getprogname()Andreas Schneider2018-11-123-0/+77
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* debug: Use debuglevel_(get|set) functionAndreas Schneider2018-11-082-16/+26
| | | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Nov 8 11:03:11 CET 2018 on sn-devel-144
* lib:util: Fix DEBUGCLASS pointer initializiationAndreas Schneider2018-11-081-2/+2
| | | | | | | | | | | | | This fixes a segfault in pyglue: ==10142== Process terminating with default action of signal 11 (SIGSEGV) ==10142== Bad permissions for mapped region at address 0x6F00A20 ==10142== at 0x6F1074B: py_set_debug_level (pyglue.c:165) BUG: https://bugzilla.samba.org/show_bug.cgi?id=13679 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* source4 smbd prefork: Increase default worklers to 4Gary Lockyer2018-11-071-2/+1
| | | | | | | | Increase the default number of worker processes started by the pre-fork process model from 1 to 4. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* tdb: Align integer typesVolker Lendecke2018-11-061-1/+1
| | | | | | | | | | | | | tdb->max_dead_records is "int", as is the corresponding parameter to tdb_set_max_dead(). Not that a signed variable makes any sense, but this is old code and tdb_set_max_dead() is a public API which we should not change for this. 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): Tue Nov 6 21:52:32 CET 2018 on sn-devel-144
* tdb: Allow !CLEAR_IF_FIRST & MUTEX_LOCKINGVolker Lendecke2018-11-062-56/+42
| | | | | | | | This is a prerequisite to allow gencache to run on a non-transactioned database with mutexes. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: Version 1.3.17 for tdb_traverse_chainVolker Lendecke2018-11-062-1/+74
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: Add test for tdb_traverse_chainVolker Lendecke2018-11-062-0/+95
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: Add tdb_traverse_chainVolker Lendecke2018-11-062-0/+177
| | | | | | | | This is a lightweight readonly traverse of a single chain, see the comment in the header file. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: ldb: Remove use of talloc_autofree_context().Jeremy Allison2018-11-061-2/+2
| | | | | | | Just use NULL in test case. talloc_autofree_context() is deprecated. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* lib: talloc: Mark talloc_autofree_context() as deprecated.Jeremy Allison2018-11-061-8/+9
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
* audit_logging: Use dom_sid_str_bufVolker Lendecke2018-11-021-4/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* ldb/tests/py/index: remove dup value in dictionaryDouglas Bagnall2018-11-011-1/+0
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
* ldb/tests/py/api: use proper name for ldb.LdbErrorDouglas Bagnall2018-11-011-2/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
* tdb: Make record deletion circular-chain safeVolker Lendecke2018-10-303-102/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch we had 3 loops walking a hash chain to delete records: tdb_do_delete() to find the predecessor of the record that was to be deleted. tdb_count_dead(), the name says it all and tdb_purge_dead() to give back all dead records from a chain to the freelist. This patch introduces tdb_trim_dead that walks a hash chain just once. While it does so it counts the number of dead records, and all records beyond tdb->max_dead_records are moved to the freelist. Normal record deletion now works by always marking a record as dead in step 1 and then calling tdb_trim_dead. This is made safe against circular chains by doing the slow chain walk only in the case when we did not delete a dead record during our walk. It changes our dynamics a bit: When deleting a record with non-zero max_dead_records, now we always leave that number of records around when deleting, doing a blocking lock on the freelist when we found too many dead records. Previously when exceeding max_dead_records we wiped all dead records to start accumulating them from scratch, assuming we could lock the freelist in a nonblocking fashion. The net effect for an uncontended freelist is the same: In tdb_allocate() we still completely hand over all dead records to the freelist when we could lock it, it just happens later than without this patch. This means for a lightly loaded system we will potentially leave more dead records around in databases like locking.tdb. However, on a heavily loaded system we become more predictable: If the freelist is so heavily contended that across many deletes we can't get hold of it, previously we accumulated more dead records than max_dead_records would allow. This is a really lowlevel tradeoff that is likely hard to measure, but to me becoming more deterministic without sacrificing too much parallelism (we keep more dead records around) is worth trying. 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): Tue Oct 30 02:48:38 CET 2018 on sn-devel-144
* tdb: Do early RDONLY error check for tdb_deleteVolker Lendecke2018-10-291-0/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: Purge dead records whenever we block the freelistVolker Lendecke2018-10-291-0/+6
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: Don't delete dead records in traverseVolker Lendecke2018-10-291-6/+0
| | | | | | | | | | The next commit will change the handling of dead records, removing the "tdb_do_delete" function. As traverses should not happen in normal operations, dead records from them should be rare, and relying on traverses to remove them is a very bad idea IMHO. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: Align an integer typeVolker Lendecke2018-10-291-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* tdb: Fix a typoVolker Lendecke2018-10-291-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:socket: If returning early, set ifacesDavid Mulder2018-10-281-1/+2
| | | | | | | | | | | | | | | Prevents a segfault in load_interfaces() when total interfaces == 1. Fixes regression caused by da68a1b2f417ec82ea4ed3e7a4d867cef8ca8f93. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13665 Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Ralph Böhme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Sun Oct 28 00:35:35 CEST 2018 on sn-devel-144
* ldb/tests/py/api: reveal shadowed casefold testDouglas Bagnall2018-10-251-1/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>