summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* 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 E502: the backslash is redundant between bracketsJoe 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 E306: expected 1 blank line before a nested definition, found 0Joe Guo2018-08-242-0/+4
| | | | | | 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-244-0/+4
| | | | | | | | 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-242-8/+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-244-0/+27
| | | | | | 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 E301: expected 1 blank line, found 0Joe Guo2018-08-242-0/+17
| | | | | | 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 E231: missing whitespace after ','Joe Guo2018-08-241-2/+2
| | | | | | 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-242-2/+2
| | | | | | 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 E203: whitespace before ':'Joe Guo2018-08-241-6/+6
| | | | | | 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-243-168/+177
| | | | | | 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-242-256/+256
| | | | | | 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 E124: closing bracket does not match visual indentationJoe 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 E123: closing bracket does not match indentation of opening ↵Joe Guo2018-08-241-1/+1
| | | | | | | | bracket's line 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 E101: indentation contains mixed spaces and tabsJoe Guo2018-08-241-37/+37
| | | | | | 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>
* s3: util: Do not take over stderr when there is no log filePaulo Alcantara2018-08-181-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case we don't have either a /var/log/samba directory, or pass a non-existent log directory through '-l' option, all commands that are daemonized with '-D' option hang when executed within a subshell. An example on how to trigger that: # rm -r /var/log/samba # s=$(nmbd -D -s /etc/samba/smb.conf -l /foo123) (never returns) So, when the above command is executed within a subshell the following happens: (a) Parent shell creates a pipe, sets write side of it to fd 1 (stdout), call read() on read-side fd, forks off a new child process and then executes nmbd in it. (b) nmbd sets up initial logging to go through fd 1 (stdout) by calling setup_logging(..., DEBUG_DEFAULT_STDOUT). 'state.fd' is now set to 1. (c) reopen_logs() is called by the first time which then calls reopen_logs_internal() (d) in reopen_logs_internal(), it attempts to create log.nmbd file in /foo123 directory and fails because directory doesn't exist. (e) Regardless whether the log file was created or not, it calls dup2(state.fd, 2) which dups fd 1 into fd 2. (f) At some point, fd 0 and 1 are closed and set to /dev/null The problem with that is because parent shell in (a) is still blocked in read() call and the new write side of the pipe is now fd 2 -- after dup2() in (e) -- and remains unclosed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13578 Signed-off-by: Paulo Alcantara <palcantara@suse.de> Reviewed-by: Jim McDonough <jmcd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Aug 18 01:32:25 CEST 2018 on sn-devel-144
* dbwrap: Fix a typoVolker Lendecke2018-08-171-1/+1
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Rowland Penny <rpenny@samba.org>
* ldb: Release LDB 1.5.1ldb-1.5.1Andrew Bartlett2018-08-154-1/+285
| | | | | | | | | | | * New API ldb_dn_add_child_val() avoids passing untrusted input to ldb_dn_add_child_fmt() (bug 13466) * Free memory nearer to the allocation in calls made by ldbsearch * Do not overwrite ldb_transaction_commit failure error messages with a pointless del_transaction() Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: extend API testsAndrew Bartlett2018-08-151-3/+44
| | | | | | | | These additional API tests just check that an invalid base DN is never accepted. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: Add new function ldb_dn_add_child_val()Andrew Bartlett2018-08-154-0/+161
| | | | | | | | | This is safer for untrusted input than ldb_dn_add_child_fmt() BUG: https://bugzilla.samba.org/show_bug.cgi?id=13466 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb_tdb: Remove pointless check of ldb_dn_is_valid()Andrew Bartlett2018-08-151-8/+0
| | | | | | | | | If the DN is not valid the ltdb_search_dn1() will catch it with ldb_dn_validate() which is the only safe way to check this. ldb_dn_is_valid() does not actually check, but instead returns only the result of the previous checks, if there was one. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* fix mem leak in ldbsearchAndrej Gessel2018-08-151-0/+5
| | | | | | Signed-off-by: Andrej Gessel <Andrej.Gessel@janztec.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* fix mem leak in ltdb_index_dn_base_dn and ltdb_search_indexedAndrej Gessel2018-08-151-0/+2
| | | | | | Signed-off-by: Andrej Gessel <Andrej.Gessel@janztec.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* ldb: no need to call del_transaction in ldb_transaction_commitJoe Guo2018-08-151-3/+0
| | | | | | | | | | | | | | | | | No matter commit succeeded or failed, transation will be delete afterwards. So there is no need to delete it here. Aganst Samba this causes an `LDAP error 51 LDAP_BUSY` error when the transaction fails, say while we try to add users to groups in large amount and the original error is lost. In Samba, the rootdse module fails early in the del part of the start/end/del pattern, and in ldb_tdb and ldb_mdb a failed commit always ends the transaction, even on failure. 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>
* ldb tests: fix assertion on wrong pointerTimur I. Bakeyev2018-08-141-1/+1
| | | | | | | | | We are allocating msg02, but check in assertion msg01, which makes no sense here. Signed-off-by: Timur I. Bakeyev <timur@freebsd.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
* Release LDB 1.5.0 for CVE-2018-1140ldb-1.5.0Andrew Bartlett2018-08-144-1/+284
| | | | | | | | * Security fix for CVE-2018-1140 (NULL pointer de-reference, bug 13374) * Fix memory leaks and missing error checks (bug 13459, 13471, 13475) Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* CVE-2018-1140 ldb: Add tests for search add and rename with a bad dn= DNAndrew Bartlett2018-08-141-0/+156
| | | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13374
* CVE-2018-1140 ldb_tdb: Check for DN validity in add, rename and searchAndrew Bartlett2018-08-142-1/+42
| | | | | | | | | This ensures we fail with a good error code before an eventual ldb_dn_get_casefold() which would otherwise fail. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13374
* CVE-2018-1140 ldb_tdb: Ensure the dn in distinguishedName= is valid before useAndrew Bartlett2018-08-141-0/+9
| | | | | | | | | ldb_dn_from_ldb_val() does not validate this untrusted input, so a later call to ldb_dn_get_casefold() can fail if the input is not valid. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13374
* CVE-2018-1140 ldb: Check for ldb_dn_get_casefold() failure in ldb_sqliteAndrew Bartlett2018-08-141-0/+3
| | | | | | Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13374
* CVE-2018-1140 Add NULL check for ldb_dn_get_casefold() in ltdb_index_dn_attr()Andrej Gessel2018-08-141-0/+9
| | | | | | | Signed-off-by: Andrej Gessel <Andrej.Gessel@janztec.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13374
* lib: Add support to parse MS Catalog filesAndreas Schneider2018-08-097-0/+1978
| | | | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Aug 9 19:57:02 CEST 2018 on sn-devel-144
* Minor, really small, documentation fix.Richard Sharpe2018-08-061-1/+1
| | | | | Signed-off-by: Richard Sharpe <realrichardsharpe@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
* tdb: test for readonly locks mode on tdbbackup commandAaron Haslett2018-08-063-0/+65
| | | | | | | | | | | | | | Simple bash test for readonly locks on tdbbackup: 1. Running tdbbackup on a database with and without readonly locks enabled. 2. Dump both backups and original. 3. Check all three dumps match. A binary sample_tdb.tdb file is included for the test because the existing sample tdbs in lib/tdb/test are either corrupt or empty. Signed-off-by: Aaron Haslett <aaron.haslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* tdb: adding readonly locks mode to tdbbackup toolAaron Haslett2018-08-061-7/+28
| | | | | | | | | | | | The netcmd 'domain backup offline' command will use the tdbbackup tool but require readonly locking of tdb databases, otherwise all database access would be blocked during a backup. This patch adds the option. A backup script should use this tool with the readonly locks option after taking a transaction lock on the target database. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* pthreadpool: reset monitor_fd after calling tevent_fd_set_auto_close()Stefan Metzmacher2018-07-311-0/+1
| | | | | | | | | | This tries to convince Coverity that we don't have a resource leak: CID 1438157: (RESOURCE_LEAK) Handle variable "monitor_fd" going out of scope leaks the handle. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* pthreadpool: ignore the return value of poll(NULL, 0UL, 1)Stefan Metzmacher2018-07-311-2/+2
| | | | | | | | | | | Otherwise Coverity reports this: CID 1438160: (CHECKED_RETURN) Calling "poll(NULL, 0UL, 1)" without checking return value. This library function may fail and return an error code. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* lib ldb key value: convert TDB_DATA structs to ldb_valGary Lockyer2018-07-304-137/+109
| | | | | | | | | | Convert the key value functions to use ldb_val instead of TDB_DATA. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Mon Jul 30 17:23:22 CEST 2018 on sn-devel-144
* lib ldb: rename LTDB_* constants to LDB_KV_*Gary Lockyer2018-07-305-108/+108
| | | | | | | | Rename all the LTDB_* constants to LDB_KV_* as they are key value level constants and not tdb specific. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb: move key value code to lib/ldb/ldb_key_valueGary Lockyer2018-07-3013-2209/+2338
| | | | | | | Move the key value code to a separate subdirectory. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb: rename ltdb_parse_data_unpack_ctxGary Lockyer2018-07-301-3/+3
| | | | | | | | Rename ltdb_parse_data_unpack_ctx to ldb_kv_parse_data_unpack_ctx, as it's a key value level structure and not ltdb specific. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb: remove unused function prototypesGary Lockyer2018-07-301-4/+0
| | | | | | | Remove unused function prototypes Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb: rename ltdb_idxptr to ldb_kv_idxptrGary Lockyer2018-07-302-3/+3
| | | | | | | | Rename ltdb_idxptr to ldb_kv_idxptr as it's key value level and not tdb specific. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb: rename tdb_key_ctx to key_ctxGary Lockyer2018-07-301-7/+7
| | | | | | | | Rename tdb_key_ctx to key_ctx, as it's key value level and not tdb specific. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb: rename ltdb_cache to ldb_kv_cacheGary Lockyer2018-07-302-2/+2
| | | | | | | | Rename ltdb_cache to ldb_kv_cache as it's key value level and not tdb specific Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb: format rename ldb_kv_privateGary Lockyer2018-07-307-251/+329
| | | | | | | | Tidy up the code format after the rename of ltdb_private to ldb_kv_private Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb: rename ltdb_private to ldb_kv_privateGary Lockyer2018-07-309-659/+659
| | | | | | | | | | | Rename ltdb_private to ldb_kv_private as it contains key value operation context. Note there is still some tdb specific context that can be refactored into a separate structure along the lines of the lmdb context. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib ldb: format rename of ltdb_req_spyGary Lockyer2018-07-301-1/+2
| | | | | | | | Fix up the code formatting after the rename of ltdb_req_spy to ldb_kv_req_spy Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>