summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* lib:audit_logging: Fix typo in log messageJoseph Sutton2023-05-181-1/+1
| | | | | Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:audit_logging: Add function to add a formatted time value to a JSON messageJoseph Sutton2023-05-182-17/+44
| | | | | | | | | json_add_timestamp() is limited to adding a ‘timestamp’ field with the current time. The new function can add an arbitrary timestamp with an arbitrary field name. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:audit_logging: Add function to add an optional boolean value to a JSON ↵Joseph Sutton2023-05-182-0/+47
| | | | | | | message Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:audit_logging: Add function to add flags to a JSON messageJoseph Sutton2023-05-182-0/+55
| | | | | | | | | This replaces a couple of calls to snprintf() in log_authentication_event_json() and log_successful_authz_event_json() respectively. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python: Safely clear structure membersJoseph Sutton2023-05-163-14/+11
| | | | | | | | Using Py_CLEAR() ensures that these structures are observed in a consistent state by any Python code that may run during deconstruction. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:util: prefer size_t for random data generation functionsDmitry Antipov2023-05-162-7/+7
| | | | | | | | | | Prefer 'size_t' over 'int' in generate_random_buffer(), generate_secret_buffer() and generate_nonce_buffer() to match an underlying gnutls_rnd() calls. Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* param: Add new parameter "ad dc functional level"Andrew Bartlett2023-05-162-0/+11
| | | | | | | | This allows the new unsupported functional levels to be unlocked, but with an smb.conf option that is easily seen. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:ldb: do not offset against NULL pointer in ldb_ldif_read()Dmitry Antipov2023-05-091-4/+4
| | | | | | | | | | | | | | | | | | | | Fix the following error observed running samba.test.registry compiled with clang-17 and UBsan: lib/ldb/common/ldb_ldif.c:881:9: runtime error: applying non-zero offset 137438953440 to null pointer #0 0x7faa0eb3932f in ldb_ldif_read lib/ldb/common/ldb_ldif.c:881 #1 0x7faa0eb3aec6 in ldb_ldif_read_string lib/ldb/common/ldb_ldif.c:1004 #2 0x7faa077ed759 in dsdb_set_schema_from_ldif source4/dsdb/schema/schema_set.c:1113 #3 0x7faa068fcbbf in py_dsdb_set_schema_from_ldif source4/dsdb/pydsdb.c:929 #4 0x7faa1d1d4507 in cfunction_call (/lib64/libpython3.11.so.1.0+0x1d4507) [... a lot of Python calls skipped...] I.e. number of elements should be checked against zero before making an attempt to access an element by index. Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:addns: Don’t call memcpy() with a NULL pointerJoseph Sutton2023-05-051-1/+3
| | | | | | | Doing so is undefined behaviour. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:util: Fix undefined bitshiftJoseph Sutton2023-05-051-1/+1
| | | | | | | runtime error: left shift of 65535 by 16 places cannot be represented in type 'int' Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib/fuzzing: add fuzzer for sddl_parseDouglas Bagnall2023-04-282-0/+70
| | | | | | | | | Apart from catching crashes in the actual parsing, we abort if the SD we end up with will not round trip back through SDDL to an identical SD. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:krb5_wrap: Fix debug statements when princ_s is NULLAndreas Schneider2023-04-271-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In file included from source4/include/includes.h:61, from lib/krb5_wrap/krb5_samba.c:23: lib/krb5_wrap/krb5_samba.c: In function ‘smb_krb5_kt_seek_and_delete_old_entries’: lib/util/debug.h:200:12: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 200 | && (dbgtext body) ) | ~^~~~~~~~~~~~~ lib/krb5_wrap/krb5_samba.c:1753:25: note: in expansion of macro ‘DEBUG’ 1753 | DEBUG(5, (__location__ ": Saving previous (kvno %d) " | ^~~~~ lib/util/debug.h:200:12: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 200 | && (dbgtext body) ) | ~^~~~~~~~~~~~~ lib/krb5_wrap/krb5_samba.c:1763:25: note: in expansion of macro ‘DEBUG’ 1763 | DEBUG(5, (__location__ ": Saving entry with kvno [%d] " | ^~~~~ lib/util/debug.h:200:12: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 200 | && (dbgtext body) ) | ~^~~~~~~~~~~~~ lib/krb5_wrap/krb5_samba.c:1769:17: note: in expansion of macro ‘DEBUG’ 1769 | DEBUG(5, (__location__ ": Found old entry for principal: %s " | ^~~~~ lib/util/debug.h:200:12: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 200 | && (dbgtext body) ) | ~^~~~~~~~~~~~~ lib/krb5_wrap/krb5_samba.c:1787:17: note: in expansion of macro ‘DEBUG’ 1787 | DEBUG(5, (__location__ ": removed old entry for principal: " | ^~~~~ Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldb: Implement ldap_whoami in pyldbVolker Lendecke2023-04-261-0/+36
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* 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>
* ldb: Add the RFC4532 LDB_EXTENDED_WHOAMI_OID definitionVolker Lendecke2023-04-261-0/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* Add ROLE_IPA_DC into two more placesAlexander Bokovoy2023-04-251-0/+1
| | | | | | | | | | Missed two more places originally when introduced ROLE_IPA_DC. Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Alexander Bokovoy <ab@samba.org> Autobuild-Date(master): Tue Apr 25 07:46:36 UTC 2023 on atb-devel-224
* debug: Only initialize gpfs wrapper when gpfs logging is enabledChristof Schmitt2023-04-141-1/+3
| | | | | | | | | | | | This avoids unnecessary attempts to load libgpfs.so when it is not needed. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Apr 14 12:28:23 UTC 2023 on atb-devel-224
* lib:util: Fix code spellingAndreas Schneider2023-04-1423-230/+230
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:util: Remove trailing white spaces in byteorder.hAndreas Schneider2023-04-141-6/+6
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:tsocket: Fix code spellingAndreas Schneider2023-04-142-4/+4
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:tevent: Fix code spellingAndreas Schneider2023-04-147-13/+13
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:tdb: Fix code spellingAndreas Schneider2023-04-147-13/+13
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:talloc: Fix code spellingAndreas Schneider2023-04-143-5/+5
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:socket: Fix code spellingAndreas Schneider2023-04-141-1/+1
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:smbconf: Fix code spellingAndreas Schneider2023-04-142-5/+5
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:replace: Fix code spellingAndreas Schneider2023-04-141-1/+1
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:replace: Remove trailing white spaces in xattr.cAndreas Schneider2023-04-141-4/+4
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib/torture: Don't overwrite test outcomesJoseph Sutton2023-04-122-12/+20
| | | | | | | | | | | | | If a test fails an assertion, and later calls torture_skip() to skip part of the test, the TORTURE_SKIP result will overwrite the TORTURE_FAIL result, and the overall outcome will be successful. To avoid this, we now arrange possible outcomes in order of priority, and ensure we always keep the higher priority one. This reveals some failing tests. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* pyldb: Handle allocation failureJoseph Sutton2023-04-121-0/+4
| | | | | | | | If we don't check for NULL after each loop iteration, the failure could be masked in the next iteration by talloc_asprintf_append() allocating on the NULL context. That could result in values getting lost. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* ldb: Avoid undefined pointer arithmeticJoseph Sutton2023-04-121-9/+9
| | | | | | | | Computing a pointer that points outside of an array, and not to one past the last element, is undefined behaviour. To avoid this, do our comparisons in terms of lengths, not pointers. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* ldb: Fix function documentation to be consistentJoseph Sutton2023-04-121-12/+12
| | | | Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* ldb: Don't wrongly claim to return message elementsJoseph Sutton2023-04-121-0/+2
| | | | | | | | If the LDB_UNPACK_DATA_FLAG_NO_ATTRS flag is set, we don't return any elements, so we should set num_elements accordingly. This ensures callers don't try to access elements that aren't there. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* ldb: Remove misleading commentJoseph Sutton2023-04-121-2/+2
| | | | | | | That an attribute has been access checked doesn't mean that the user has the right to view it. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* ldb: Remove old misleading commentsJoseph Sutton2023-04-121-4/+0
| | | | | | | | | | | | Commit bed9efa6cda17ecca91bdf71227ec656b94dcf94 introduced ldb_msg_add_linearized_dn() to replace ldb_msg_add_dn(), but retained the now-incorrect associated comment. The comment later made its way into a function added later by commit 'CVE-2022-32746 ldb: Add functions for appending to an ldb_message'. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15008 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* talloc: Remove unneeded va_copy()Joseph Sutton2023-04-121-3/+1
| | | | | | We don't use 'ap' again after this. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* talloc: Put comment back in appropriate placeJoseph Sutton2023-04-121-1/+1
| | | | | | | | This comment originally referred, not to a va_copy() call, but to the use of &c with vsnprintf() rather than passing in NULL with a length of zero. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib:replace: Fix snprintf of rep_inet_ntop()Andreas Schneider2023-04-111-6/+8
| | | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Apr 11 10:08:54 UTC 2023 on atb-devel-224
* lib:replace: Fix code spellingAndreas Schneider2023-04-114-7/+7
| | | | | | Best reviewed with: `git show --word-diff`. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:pthreadpool: Fix code spellingAndreas Schneider2023-04-111-1/+1
| | | | | | Best reviewed with: `git show --word-diff`. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:param: Fix code spellingAndreas Schneider2023-04-113-6/+6
| | | | | | Best reviewed with: `git show --word-diff`. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:messaging: Fix code spellingAndreas Schneider2023-04-111-1/+1
| | | | | | Best reviewed with: `git show --word-diff`. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib:ldb: Fix code spellingAndreas Schneider2023-04-114-5/+5
| | | | | | Best reviewed with: `git show --word-diff`. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
* lib/util: Add "debug syslog format = always", which logs to stdout in syslog ↵Andrew Bartlett2023-04-063-9/+50
| | | | | | | style Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* lib:ldb:tests: Fix signedness build errorAndreas Schneider2023-04-061-1/+1
| | | | | | | | | | | | | lib/ldb/tests/ldb_filter_attrs_in_place_test.c:836:55: error: pointer targets in passing argument 1 of ‘_assert_string_equal’ differ in signedness [-Werror=pointer-sign] 836 | assert_string_equal(msg->elements[0].values[0].data, | ^ | | | uint8_t * {aka unsigned char *} Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* CVE-2023-0922 set default ldap client sasl wrapping to sealRob van der Linde2023-04-051-1/+1
| | | | | | | | | | | | | | This avoids sending new or reset passwords in the clear (integrity protected only) from samba-tool in particular. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15315 Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Apr 5 03:08:51 UTC 2023 on atb-devel-224
* ldb: Use correct member of unionJoseph Sutton2023-04-052-9/+18
| | | | | Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> 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: Filter on search base before redacting messageJoseph Sutton2023-04-055-23/+48
| | | | | | | | | | | Redaction may be expensive if we end up needing to fetch a security descriptor to verify rights to an attribute. Checking the search scope is probably cheaper, so do that first. 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>