summaryrefslogtreecommitdiff
path: root/lib/ldb-samba
Commit message (Collapse)AuthorAgeFilesLines
* ldb: Allow extended operations through ildapVolker Lendecke2023-04-261-0/+111
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* CVE-2023-0614 lib/ldb-samba Ensure ACLs are evaluated on ↵Andrew Bartlett2023-04-051-1/+6
| | | | | | | | | | | SAMBA_LDAP_MATCH_RULE_TRANSITIVE_EVAL / LDAP_MATCHING_RULE_IN_CHAIN Setting the LDB_HANDLE_FLAG_UNTRUSTED tells the acl_read module to operate on this request. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15270 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* CVE-2023-0614 lib/ldb-samba: Add test for ↵Andrew Bartlett2023-04-052-57/+174
| | | | | | | | | | | | SAMBA_LDAP_MATCH_RULE_TRANSITIVE_EVAL / LDAP_MATCHING_RULE_IN_CHAIN with and ACL hidden attributes The chain for transitive evaluation does consider ACLs, avoiding the disclosure of confidential information. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15270 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* CVE-2023-0614 dsdb: Add pre-cleanup and self.addCleanup() of OU created in ↵Andrew Bartlett2023-04-051-0/+8
| | | | | | | | | match_rules tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=15270 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* CVE-2023-0614 ldb: Centralise checking for inaccessible matchesJoseph Sutton2023-04-051-5/+0
| | | | | | | | | This makes it less likely that we forget to handle a case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15270 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* CVE-2023-0614 ldb: Prevent disclosure of confidential attributesJoseph Sutton2023-04-051-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a hook, acl_redact_msg_for_filter(), in the aclread module, that marks inaccessible any message elements used by an LDAP search filter that the user has no right to access. Make the various ldb_match_*() functions check whether message elements are accessible, and refuse to match any that are not. Remaining message elements, not mentioned in the search filter, are checked in aclread_callback(), and any inaccessible elements are removed at this point. Certain attributes, namely objectClass, distinguishedName, name, and objectGUID, are always present, and hence the presence of said attributes is always allowed to be checked in a search filter. This corresponds with the behaviour of Windows. Further, we unconditionally allow the attributes isDeleted and isRecycled in a check for presence or equality. Windows is not known to make this special exception, but it seems mostly harmless, and should mitigate the performance impact on searches made by the show_deleted module. As a result of all these changes, our behaviour regarding confidential attributes happens to match Windows more closely. For the test in confidential_attr.py, we can now model our attribute handling with DC_MODE_RETURN_ALL, which corresponds to the behaviour exhibited by Windows. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15270 Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib/ldb-samba: let ldif_read_ntSecurityDescriptor() only try sddl if isupper()Stefan Metzmacher2023-03-221-7/+17
| | | | | | | | | Trying ndr_pull_security_descriptor on SDDL produces just strange debug messages, which can cause confusion. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* lib:ldb-samba: Correctly handle search scopeAndreas Schneider2023-02-061-3/+10
| | | | | | | | | | | lib/ldb-samba/ldb_ildap.c:482:47: error: implicit conversion from enumeration type 'enum ldb_scope' to different enumeration type 'enum ldap_scope' [-Werror,-Wenum-conversion] msg->r.SearchRequest.scope = req->op.search.scope; ~ ~~~~~~~~~~~~~~~^~~~~ Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Use talloc_asprintf_addbuf() in ldif_write_prefixMap()Volker Lendecke2022-12-141-7/+4
| | | | | | | The first call of talloc_asprintf_append() did not have a NULL check. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix whitespaceVolker Lendecke2022-12-141-31/+31
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* pyldb: Fix typos in function namesJoseph Sutton2022-10-051-3/+3
| | | | | | | | Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Oct 5 05:23:50 UTC 2022 on sn-devel-184
* ldb: Avoid an "else"Volker Lendecke2022-04-261-1/+2
| | | | | | | We return in the if-branch, easier to read this way. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* ldb-samba: dns tombstone matching: constrict value lengthDouglas Bagnall2021-07-051-4/+6
| | | | | | | | | | | | We know the only values we want to see are uint32, ie < ~4 billion (and real values will be 7 digits for hundreds of years). We also know the caller (we have just checked) is a trusted system session which won't be padding the thing with spaces. But if they do, let's call them out. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:ldb-samba: Use debug level definesAndreas Schneider2021-06-231-4/+4
| | | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Wed Jun 23 09:03:42 UTC 2021 on sn-devel-184
* lib:ldb-samba: Set log level for ldb tracing to 11Andreas Schneider2021-06-231-1/+1
| | | | | | | | We should not enable ldb tracing on debug level 10 which is meant for Samba debug logs and not trace logs. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib:ldb-samba: Migrate samba extensions to new cmdline option parserAndreas Schneider2021-06-162-15/+40
| | | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Jun 16 01:25:28 UTC 2021 on sn-devel-184
* lib:ldb-samba: Use talloc_zero_array() and use ldb as the mem contextAndreas Schneider2021-06-161-1/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:ldb-samba: Improve calculate_popt_array_length()Andreas Schneider2021-06-161-5/+22
| | | | | | | | | | | | | | | | | | | | | Note that memcmp() doesn't work well with padding bytes. So avoid it! (gdb) ptype/o struct poptOption /* offset | size */ type = struct poptOption { /* 0 | 8 */ const char *longName; /* 8 | 1 */ char shortName; /* XXX 3-byte hole */ /* 12 | 4 */ unsigned int argInfo; /* 16 | 8 */ void *arg; /* 24 | 4 */ int val; /* XXX 4-byte hole */ /* 32 | 8 */ const char *descrip; /* 40 | 8 */ const char *argDescrip; /* total size (bytes): 48 */ Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb-samba: remove redundant negative checkDouglas Bagnall2021-03-301-1/+1
| | | | | | | | | | | smb_strtoull() already checks for negative numbers, but does it properly, catching " -2" as well as "-2". Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Mar 30 18:55:28 UTC 2021 on sn-devel-184
* ldb-samba: avoid VLA in dsdb match dns tombstoneDouglas Bagnall2021-03-301-1/+1
| | | | | | | We don't need it (only 64 bytes) and, well, they annoy people. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
* ldb-samba: avoid leak in dsdb_match_for_dns_to_tombstone_timeDouglas Bagnall2021-03-301-4/+4
| | | | | | | | | | After the first time through the loop, tmp_ctx has been freed and NULLed, so we end up allocating on NULL and never freeing. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14659 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
* Fix build after removal of an extra safe_string.hAlexander Bokovoy2020-10-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Move of strcasecmp redefine to lib/util/safe_string.h in https://gitlab.com/samba-team/samba/-/merge_requests/1507 broke build on Fedora 33 with GCC 10.2.1 for those compilation units that use ldb_att_cmp(). The reason for that is that ldb_attr_cmp() defined as #define ldb_attr_cmp(a, b) strcasecmp(a, b) because attribute names restricted to be ASCII by RFC2251 (LDAPv3 spec). A solution is to add #undef strcasecmp to all source code files which use ldb_attr_cmp(). Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Oct 1 22:45:29 UTC 2020 on sn-devel-184
* lib: relicense smb_strtoul(l) under LGPLv3Ralph Boehme2020-08-032-0/+2
| | | | | | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Mon Aug 3 22:21:04 UTC 2020 on sn-devel-184
* Fix clang 9 missing-field-initializer warningsGary Lockyer2020-05-082-3/+3
| | | | Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* pytests: heed assertEquals deprecation warning en-masseDouglas Bagnall2020-02-071-19/+19
| | | | | | | | | | | TestCase.assertEquals() is an alias for TestCase.assertEqual() and has been deprecated since Python 2.7. When we run our tests with in python developer mode (`PYTHONDEVMODE=1 make test`) we get 580 DeprecationWarnings about this. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
* pyldb: fork pyldb_Ldb_AsLdbContext macro to reflect unsafenessDouglas Bagnall2019-07-101-7/+7
| | | | | | | | | | | | | | | | | | | In the Python/C API, conversion functions which check the types of their arguments have names like: double PyFloat_AsDouble(PyObject *pyfloat); while conversion macros that don't check have names like: PyFloat_AS_DOUBLE(pyfloat) The pyldb_Ldb_AsLdbContext() macro looks like one of the checking functions but it actually isn't. This has fooled us more than once. Here we fork the macro into two -- one which performs checks and keeps the camel case, and one with a shouty name that keeps the check-free behaviour. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* lib: Update all consumers of strtoul_err(), strtoull_err() to new APISwen Schillig2019-06-302-7/+13
| | | | | | Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* lib/ldb-samba: squash 'cast between incompatible function types' warningNoel Power2019-05-161-2/+4
| | | | | | | | | | To avoid warning above produced by using -Wcast-function-type we; + ensure PyCFunctions of type METH_NOARGS defined dummy arg Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
* common-lib: Update error check for new string conversion wrapperSwen Schillig2019-04-111-12/+2
| | | | | | | | | | | The new string conversion wrappers detect and flag errors which occured during the string to integer conversion. Those modifications required an update of the callees error checks. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* ldb: tests for <= and >= integer indexing with duplicatesGarming Sam2019-04-081-0/+43
| | | | | | | | | We need to make sure that duplicates are correctly returned (uSNChanged for instance is UNIQUE but, we should be able to index on attributes which are not unique). Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: tests for <= and >= integer indexingAaron Haslett2019-04-082-0/+180
| | | | | | | | | | | | | | | | Testing max, min and negative values for indexed 32 and 64 bit types. This has to be done in two different files because the 64 bit type is LDB_SYNTAX_INTEGER which is implemented at the ldb level, while the 32 bit is added in the ldb-samba module. Schema syntax binding added for ldb-samba. We also need to make sure that full scans are not invoked for LMDB. Pair-programmed-with: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* schema_syntax: Add comments for our index format functionsGarming Sam2019-04-081-1/+20
| | | | | | | | | | | We had to devise our own scheme for writing integers in a human readable format which also sorted correctly numerically. This might look a bit confusing to outsiders, so here's a large comment as a peace offering. Pair-programmed-with: Tim Beale <timbeale@catalyst.net.nz> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: activating <= and >= indexing for integersAaron Haslett2019-04-081-0/+45
| | | | | | | | | | | | | | | Activating <= and >= mdb indexing in samba for int32 and int64 attributes by: 1. Adding index_format_fn to LDB_SYNTAX_SAMBA_INT32 in ldb_samba 2. Cloning the 64bit LDB_SYNTAX_INTEGER type as LDB_SYNTAX_ORDERED_INTEGER 3. Adding index_format_fn to the new type 4. Modifying LargeInteger use the new type in samba schema 5. Bumping the index version to trigger reindexing Pair-programmed-with: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* build: Remove bld.gen_python_environments()Andrew Bartlett2019-03-211-7/+6
| | | | | | | This was part of --extra-python support. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* build: Remove --extra-pythonAndrew Bartlett2019-03-211-2/+0
| | | | | | | | | | | This option is quite invasive in waf and was mainly for the python3 transition. Testing with multiple python versions can be done by testing a full compile against multiple versions, likewise multiple different binding versions can be created the same way. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* samba-o3: fix -Werror=strict-overflow error in lib/ldb-samba/ldb_ildap moduleJoe Guo2019-03-081-4/+4
| | | | | | | | | | | | | | | | | | | | samba-o3 test failed in ubuntu:16.04 docker container: ==> /home/samba/samba/samba-o3.stderr <== ../../lib/ldb-samba/ldb_ildap.c: In function ‘ildb_handle_request’: ../../lib/ldb-samba/ldb_ildap.c:535:2: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] for (i = 0; i < n; i++) { ^ ../../lib/ldb-samba/ldb_ildap.c:579:2: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow] for (i = 0; i < n; i++) { ^ cc1: all warnings being treated as errors Change type to mute errors. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* common-lib: Use wrapper for string to integer conversionSwen Schillig2019-03-012-7/+23
| | | | | | | | | | | | In order to detect an value overflow error during the string to integer conversion with strtoul/strtoull, the errno variable must be set to zero before the execution and checked after the conversion is performed. This is achieved by using the wrapper function strtoul_err and strtoull_err. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Böhme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Cleanup references to module objects returned from PyImport_ImportModuleNoel Power2019-02-071-2/+8
| | | | | Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PY3: change shebang to python3 in lib dirJoe Guo2018-12-141-1/+1
| | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
* lib/ldb-samba/tests: PY3 port samba4.ldap.match_rulesNoel Power2018-12-101-11/+11
| | | | | | | | | | | Various fixes a) schema_format_value can return bytes (esp. for objectSid, objectGUID b) embedded NULL now cause ValueError in py3 (was TypeError in py2) Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb-samba/tests/match-rules: remove unused importsDouglas Bagnall2018-10-251-4/+0
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
* ldb tests: remove unused code from match_rules.pyDouglas Bagnall2018-08-241-3/+0
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* PEP8: fix E713: test for membership should be 'not in'Joe Guo2018-08-241-1/+1
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E305: expected 2 blank lines after class or function definition, ↵Joe Guo2018-08-241-0/+1
| | | | | | | | found 1 Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E303: too many blank lines (2)Joe Guo2018-08-241-1/+0
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E302: expected 2 blank lines, found 1Joe Guo2018-08-241-0/+3
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E226: missing whitespace around arithmetic operatorJoe Guo2018-08-241-1/+1
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E202: whitespace before ')'Joe Guo2018-08-241-8/+8
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E128: continuation line under-indented for visual indentJoe Guo2018-08-241-154/+163
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E127: continuation line over-indented for visual indentJoe Guo2018-08-241-255/+255
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>