summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib: add round_timespec_to_nttime()Ralph Boehme2019-09-102-0/+10
| | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14121 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit 5403bb22e6cb39baf6dc1b91558744d41e9f6f64)
* ldb: Release ldb 2.0.7ldb-2.0.7Andrew Bartlett2019-09-043-1/+286
| | | | | | | | | | | * Robustness improvements against duplicate attributes in ldb_filter_attrs() (bug 13695) * Robustness improvements against invalid string DN values (bug 14049) Signed-off-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org> Autobuild-Date(v4-11-test): Wed Sep 4 10:24:56 UTC 2019 on sn-devel-184
* ldb: Extend the ldb_dn_explode test matrixAndrew Bartlett2019-09-041-4/+49
| | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14049 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit 10058bcfa16d5029e61252d64d142a8aab9ec296)
* ldb: Do not read beyond the end of the extended DN component when printingAndrew Bartlett2019-09-041-4/+8
| | | | | | | | | | The print functions used in Samba NULL terminate, but do not assume they will BUG: https://bugzilla.samba.org/show_bug.cgi?id=14049 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit a8a3cef3a768aaff01227dd7b229fb7b3aef926f)
* ldb: Add test with == true or false to boolean if statements in ldb_dn_explode()Andrew Bartlett2019-09-041-16/+16
| | | | | | | | | | | | | | | This is beyond the normal level of clarity we expect in Samba, and is of course rudundent, but this is a complex routine that has confusing tests, some of pointers and some of boolean state values. This tries to make the code as clear as possible pending a more comprehensive rewrite. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14049 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit 52bd2dde5ae809ecc115f7087e367327f4771e73)
* ldb: Rework all pointer NULL tests to use Samba's normal styleAndrew Bartlett2019-09-041-19/+33
| | | | | | | | | | Also avoid if () without braces BUG: https://bugzilla.samba.org/show_bug.cgi?id=14049 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit 3f290e95c2c133eb2c983ecc984d3dff4809f3d3)
* ldb: add some dn explode testsDouglas Bagnall2019-09-041-0/+70
| | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14049 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit a097ddf65ce56dcd2e0b072b6dd78f512a77a9da)
* ldb: don't try to save a value that isn't thereDouglas Bagnall2019-09-041-23/+24
| | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14049 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit 54f30f2fe3f03c9640664f9a11260b093fc57a5b)
* ldb: Call TALLOC_FREE(filtered_msg->elements) on ldb_filter_attrs() failureAndrew Bartlett2019-09-042-0/+3
| | | | | | | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue Aug 27 01:16:33 UTC 2019 on sn-devel-184 (cherry picked from commit 1521a22f4366c86ec955cb9d32b7a758315d8ce0)
* ldb: use TALLOC_FREE() over talloc_free() in ldb_filter_attrs()Andrew Bartlett2019-09-041-2/+1
| | | | | | | | | This is a macro that sets the pointer to NULL after the talloc_free() and is part of our standard coding practices. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit 2117789c35fbf6d0ed02f391f17593e11727ec3e)
* ldb: Correct Pigeonhole principle validation in ldb_filter_attrs()Andrew Bartlett2019-09-043-9/+1013
| | | | | | | | | | | | | | Thankfully this only fails if the DB is corrupt and has a duplicate record. The test was at the wrong end of the loop, and was for the wrong boundary condition. A write after the end of the array would occour before the condition was hit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13695 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit b1eec5b196e3d5a5716a5c74cf669ceaa5c0301f)
* ldb: Fix mem-leak if talloc_realloc failsSwen Schillig2019-09-041-5/+10
| | | | | | | | | | | | In case of a failing talloc_realloc(), the only reference to the originally allocated memory is overwritten. Instead use a temp var until success is verified. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Christof Schmitt <cs@samba.org> Reviewed-by: Matthias Dieter Wallnöfer <mdw@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> (cherry picked from commit 99b4791cfe423b19f1f21d5f9fb42157336019f1)
* ldb_dn: free dn components on explode failureDouglas Bagnall2019-09-041-1/+1
| | | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> (cherry picked from commit b136f153b83d80a91ec9d5350fdf08412d881964)
* ldb: do not allow adding a DN as a base to itselfDouglas Bagnall2019-09-041-0/+4
| | | | | | | | | | | | | | If you try to add a dn to itself, it expands as it goes. The resulting loop cannot end well. It looks like this in Python: dn = ldb.Dn(ldb.Ldb(), 'CN=y,DC=x') dn.add_base(dn) Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> (cherry picked from commit 19a13cbe0681b3996c33f7449f69b0fb0dc5d640)
* ldb: Release ldb 2.0.6ldb-2.0.6Andrew Bartlett2019-08-263-1/+286
| | | | | | | | | * log database repack so users know what is happening BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* ldb: Free memory when repacking databaseTim Beale2019-08-261-0/+1
| | | | | | | | | | | | | | | | | | | The msg for each database record is allocated on the module context, but never freed. The module seems like it could be a long-running context (as the database would normally get repacked by the samba executable). Even if it's not a proper leak, it shouldn't hurt to cleanup the memory. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Autobuild-User(master): Garming Sam <garming@samba.org> Autobuild-Date(master): Tue Aug 20 04:57:10 UTC 2019 on sn-devel-184 (cherry picked from commit b6516dbd24df8c78ed909c7ef9058b0844abb917)
* ldb: Log the partition we're repackingTim Beale2019-08-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | Firstly, with Samba AD this looks a little weird because we log the same message 5 times (once for every partition). If we log that we're doing this to records in different partitions, hopefully someone with a little Samba knowledge can figure out what's going on. Secondly, the info about what partitions are actually changing might be useful. E.g. if we hit a fatal error repacking the 3rd partition, and the transaction doesn't abort properly, then it would be useful to know what partitions were repacked and which ones weren't. There doesn't appear to be a useful name for the partition (ldb_kv->kv_ops->name() doesn't seem any more intelligible to a user), so just log the first record that we update. We can use that to infer the partition database). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> (cherry picked from commit ee6537c29e747206ee607493ce15d4532fb670c8)
* ldb: Log pack format in user-friendly wayTim Beale2019-08-261-2/+15
| | | | | | | | | | | | | The "format 0x26011968" log confused me (and I'm a developer). We can subtract the base offset from the pack format to get a more user-friendly number, e.g. v0 (not actually used), v1, v2, etc. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> (cherry picked from commit 5fee9388422e259c2a56e4dccbf44d22ba426ca3)
* ldb: Change pack format defines to enumTim Beale2019-08-261-5/+8
| | | | | | | | | | | | The main reason is so that any future pack formats will continue incrementing this number in a sequential fashion. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> (cherry picked from commit 38e3e7cd328edac302e95ac8839e858c4a225485)
* ldb: Move where we update the pack format versionTim Beale2019-08-263-2/+4
| | | | | | | | | | | | | | | | | Store it on the repack context so that we can log a more informative message "Repacking from format x to format y". While this is not really a big deal currently, it could be worth recording for potential future scenarios (i.e. supporting three or more pack versions), where upgrades could potentially skip an intermediary pack format version. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> (cherry picked from commit d427bd6c775d8117504e76eed42cd2c383512e34)
* ldb: Always log when the database pack format changesTim Beale2019-08-262-1/+4
| | | | | | | | | | | | | | | | LDB_DEBUG_WARNING gets logged by Samba as level 2, whereas the default log level for Samba is 0. It's not really fair to the user to change the format of their database on disk and potentially not tell them. This patch adds a log with level zero (using a alias define, as this technically isn't a fatal problem). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> (cherry picked from commit a2b0fc7c00360f37ed6819f21380294b70d4a195)
* tdb: Release tdb 1.4.2Stefan Metzmacher2019-08-212-1/+74
| | | | | | | | | | | | | | | | * Build fixes * Improve the performance by inlining the tdb_oob() checks Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Tue Aug 20 14:45:41 UTC 2019 on sn-devel-184 (cherry picked from commit 60cba7b3a17104da1543d59609f50c6638880dd1) Autobuild-User(v4-11-test): Karolin Seeger <kseeger@samba.org> Autobuild-Date(v4-11-test): Wed Aug 21 09:57:08 UTC 2019 on sn-devel-184
* tdb: Inline the common part of tdb_oobVolker Lendecke2019-08-212-9/+15
| | | | | | | | | | | | | | | When you set in tdbtorture.c to make it more similar to locking.tdb use, bin/tdbtorture -m -n 1 -l 100000 -s becomes twice as fast. This is a pretty extreme case, but all other tests that I did improve significantly as well. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit f5735e2c666a5a494131c1d25f7ba5c7fbeae923)
* tdb: Speed up tdb_oob()Volker Lendecke2019-08-212-1/+17
| | | | | | | | | This is common between both implementations of tdb_oob(). It's faster if we don't have to dereference function pointers. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 897bffa8166f643eb9063a848bb0c02455663317)
* tdb: Introduce tdb_oob()Volker Lendecke2019-08-218-20/+26
| | | | | | | | Initially just encapsulate the pointer dereferences Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 5a388453e0cb038fa3ed5fb46f972470f7793566)
* tdb: Rename tdb_oob() to tdb_notrans_oob()Volker Lendecke2019-08-212-4/+4
| | | | | | | | | tdb_oob() will become a public function encapsulating the pointer dereferences. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 885ba572efaac6c20388b8e119315c837e8f5236)
* docs/xml: change default for "mangled names" to "illegal"Ralph Boehme2019-07-081-1/+1
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* docs-xml: change "client min protocol" to SMB2_02Stefan Metzmacher2019-07-081-1/+1
| | | | | | | It's time to disable SMB1 by default... Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* docs-xml: change "server min protocol" to SMB2_02Stefan Metzmacher2019-07-081-1/+1
| | | | | | | | SMB2_02 was available with Windows Vista. It's time to turn SMB1 off by default. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib/param: clang: Fix Value stored is never readNoel Power2019-07-081-5/+5
| | | | | | | | | | | Fixes: lib/param/loadparm.c:2164:2: warning: Value stored to 'bRetval' is never read <--[clang] bRetval = false; ^ ~~~~~ 1 warning generated. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib/util: clang: Fix 'Null pointer passed as an argument'Noel Power2019-07-081-1/+1
| | | | | | | | | | Fixes lib/util/iov_buf.c:50:4: warning: Null pointer passed as an argument to a 'nonnull' parameter <--[clang] memcpy(p, iov[i].iov_base, thislen); ^ 1 warning generated. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* param: change default of "allocation roundup size" to 0Björn Jacke2019-07-071-2/+0
| | | | | Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* util: Fix off-by-one error in message about overflowMartin Schwenke2019-07-051-8/+10
| | | | | | | | | | | | | | len includes space for the NUL character, so the calculation needs to take the NUL character into account. While touching this, drop unnecessary casts by updating format string and update to modern debug macro. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Jul 5 02:24:52 UTC 2019 on sn-devel-184
* util: Avoid localised underflowMartin Schwenke2019-07-051-6/+6
| | | | | | | | | | | | | | Avoid parenthesising an unsigned subtraction that can be negative and, therefore, underflow. There is no need for the parentheses and removing them results in an expression that is evaluated left-to-right and can not underflow. It isn't clear that the underflow matters. lp <= ls, so if (li - lp) underflows then ls + (li - lp) will always overflow. This should produce the correct answer. However, depending on this seems wrong. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: Release ldb 2.0.5ldb-2.0.5Gary Lockyer2019-07-043-1/+286
| | | | | | | | | | | | | | * add ldb_options_get add a function to get the options passed in ldb connect. * add "batch_mode" option. This options stops sub transactions being started for key value operations. It is intended to improve the performance in batch operations. As it bypasses the protections on operations if an operation fails, the entire transaction will be aborted by a commit. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: Rework index_transaction_cache_size to allow caller to specify a larger ↵Gary Lockyer2019-07-041-5/+11
| | | | | | | | | | size The previous code would override the caller with the DB size estimate rather than allowing the caller to force the bigger size. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb ldb_key_value: test ldb batchGary Lockyer2019-07-041-0/+57
| | | | | | | Test the the ldb "batch_mode" option sets batch mode operation. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb key_value: Add batch_mode optionGary Lockyer2019-07-042-0/+76
| | | | | | | | | | | | | | | | When performing a join the overhead of the sub transactions protecting key value operations becomes significant. This commit adds a new "batch_mode" option that disables the sub transactions around key value operations. The operation level index cache is also disabled, which means the overall transaction level index cache can become inconsistent if an operation fails. To protect against this and other possible on disk inconsistencies, if any operation fails during a batch_mode transaction the commit will fail and transaction will be rolled back. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: Add new internal helper function ldb_options_get()Gary Lockyer2019-07-042-0/+12
| | | | | | | This is needed for modules to access the ldb->options array, as this in in ldb_private.h Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: Fix dependency on ldb_key_value_sub_txn_{mdb_}testAndrew Bartlett2019-07-041-2/+2
| | | | | | | | ldb_tdb can be a module, but the test is actually looking for ltdb_err_map() in ldb_tdb_err_map. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: Try to explain the confusing overload of the LDB_FLG_MOD_* enumeration ↵Andrew Bartlett2019-07-041-7/+11
| | | | | | | | | | and other flags Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Jul 4 03:51:58 UTC 2019 on sn-devel-184
* ldb: Add tests for Ldb.write_ldif() including the FLG_SHOW_BINARY and ↵Andrew Bartlett2019-07-041-0/+51
| | | | | | | FLAG_FORCE_NO_BASE64_LDIF Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* pyldb: Apply flags specified by ldb.Ldb(flags=...) even if the URL is not setAndrew Bartlett2019-07-041-0/+2
| | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb/ldb_ldif: add LDB_FLAG_FORCE_NO_BASE64_LDIF flagBjörn Baumbach2019-07-043-0/+11
| | | | | | | Flag is used to enforce binary encoded attribute values per attribute. Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb/ldb_ldif: add copy_raw_bytes helper variable to ldb_ldif_write_trace()Björn Baumbach2019-07-041-1/+3
| | | | | Signed-off-by: Björn Baumbach <bb@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib: Fix return of server_id_db_prune_name()Volker Lendecke2019-07-031-1/+6
| | | | | | | | | | | | The tdb routines return 0/-1 and return the specific error via tdb_error(). server_id_db_prune_name() is expected to return an errno, not 0/-1. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Wed Jul 3 10:51:32 UTC 2019 on sn-devel-184
* tdb: Adapt _tdb_transaction_cancel() to README.CodingVolker Lendecke2019-07-031-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Noel Power <npower@samba.org>
* tdb: Adapt tdb_rescue() to README.CodingVolker Lendecke2019-07-031-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Noel Power <npower@samba.org>
* lib/krb5_wrap: Fix leaking using mkstempNoel Power2019-07-031-2/+5
| | | | | | | | commit: 8b92539997a9df8e0d217790fd82fc8f59ea50cc introduced a leak by replacing mktemp with mkstemp (mkstemp returns an open fd) Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib ldb ldb_mdb: Pass the lmdb map size as an ldb optionGary Lockyer2019-07-021-17/+39
| | | | | | | | Allow the lmdb map size to be specified in the ldb option "lmdb_env_size". Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>