summaryrefslogtreecommitdiff
path: root/lib/util
Commit message (Collapse)AuthorAgeFilesLines
* lib/util: improve debug message about unknown classesStefan Metzmacher2021-07-011-2/+1
| | | | | | | debug classes registered by vfs modules are not available immediately. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib: add sys_io_ranges_overlap()Ralph Boehme2021-06-304-0/+143
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=12033 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* util/charset: warn loudly on unexpected E2BIGDouglas Bagnall2021-06-181-2/+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): Fri Jun 18 04:27:17 UTC 2021 on sn-devel-184
* util/iconv: reject improperly packed UTF-8Douglas Bagnall2021-06-181-11/+21
| | | | | | | | | | | If we allow a string that encodes say '\0' as a multi-byte sequence, we are open to confusion where we mix NUL terminated strings with sized data blobs, which is to say EVERYWHERE. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14684 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
* torture: talloc_string_sub tests for utf-8 brevityDouglas Bagnall2021-06-181-0/+58
| | | | | | | | | | | | | If we allow overly long UTF-8 sequences (in the tests, encoding '\0' as 2, 3, or 4 bytes), it might be possible for bad strings to slip through. We fail. But wait for the next commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14684 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Slightly simplify server_id_set_disconnected()Volker Lendecke2021-06-041-8/+6
| | | | | | | | | | | The NULL assert is not really required, it will crash nicely if that's not fulfilled. 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): Fri Jun 4 17:34:06 UTC 2021 on sn-devel-184
* lib:util: Fix log level for normal startup messageDmytro Bagrii2021-05-201-1/+1
| | | | | | | | | | | | | Message "daemon 'smbd' finished starting up and ready to serve connections" indicates normal startup but printed with 'error' log level and may be mistakenly treated as error during logs analisys. This patch changes log level to 'info'. Signed-off-by: Dmytro Bagrii <dimich.dmb@gmail.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu May 20 15:07:28 UTC 2021 on sn-devel-184
* lib:util: Fix return value of tdb_fetch_uint32_byblob()Andreas Schneider2021-05-121-1/+6
| | | | | | | | | | | | | | | | | | The initialize_winbindd_cache() function uses tdb_fetch_uint32_byblob() to check if the cache version is valid and up to date. As tdb_fetch_uint32_byblob() returns false for a successful fetch, we always remove the winbind cache database. This breaks the winbind offline logon feature. This also affects other caches and pdb. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14702 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed May 12 21:19:03 UTC 2021 on sn-devel-184
* lib: Add str_list_add_printf()Volker Lendecke2021-05-113-2/+84
| | | | | | | Build up execv argument lists Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Simplify str_list_make_empty()Volker Lendecke2021-05-111-9/+1
| | | | | | | We have talloc_zero_array() for this. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib:util: Add debug_get_log_type() functionAndreas Schneider2021-04-292-0/+6
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib: Remove close_low_fds()Volker Lendecke2021-04-272-36/+0
| | | | | | | There were only two callers, it did not do proper error handling, and it was confusing to call. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib: Directly call close_low_fd() in become_daemon()Volker Lendecke2021-04-271-1/+12
| | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib:util: Remove NIS support from string_match()Andreas Schneider2021-04-222-55/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* util: Ensure debugger is not started until it is allowed to attachJoseph Sutton2021-04-201-10/+39
| | | | | | | | | | | | | Use a pipe to ensure that the debugger is not started until after the prctl() call allowing it to attach to the parent, avoiding a potential race condition. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Apr 20 12:33:40 UTC 2021 on sn-devel-184
* util: Ensure debugger can be attached to processJoseph Sutton2021-04-201-12/+18
| | | | | | | | | | | | | | | | | | | | samba_start_debugger() attempts to start a debugger attached to the calling process by calling system() to start a background process. However, if the spawned shell exits before the debugger has had a chance to attach, the debugger process will no longer be a child of the parent process (as it will have been reparented). If the system does not allow tracing by non-child processes, attachment may fail as a result. This commit replaces the system() call and the implicit shell around xterm with an explicit fork()/exec() so that the debugger remains a child of the calling process, ensuring the attachment succeeds unless tracing is disabled completely. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlet <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* lib: Fix a typoVolker Lendecke2021-04-191-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): Mon Apr 19 19:07:01 UTC 2021 on sn-devel-184
* lib: Simplify tdb_fetch_int32()Volker Lendecke2021-04-191-11/+10
| | | | | | | | | | With tdb_parse_record we don't need malloc/SAFE_FREE. The semantics are a bit different from tdb_parse_uint32: We just return -1 on error, but this could be overloaded with a valid -1 record value. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Simplify tdb_fetch_uint32_t()Volker Lendecke2021-04-191-11/+11
| | | | | | | With tdb_parse_record() we don't need malloc/SAFE_FREE Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove unused tdb_traverse_delete_fn()Volker Lendecke2021-04-192-16/+0
| | | | | | | We have tdb_wipe_all() for that now. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix nonempty line endingsVolker Lendecke2021-04-192-16/+16
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix includes in util_tdb.hVolker Lendecke2021-04-191-0/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix includes in strv.hVolker Lendecke2021-04-191-1/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* gpfswrap: Remove wrapper for gpfs_set_times_path()Samuel Cabrero2021-04-192-16/+0
| | | | | Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* gpfswrap: Add wrapper for gpfs_set_times()Samuel Cabrero2021-04-192-0/+13
| | | | | Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib/util: fix timespec normalizationPhilipp Gesang2021-04-163-8/+99
| | | | | | | | | | When fixing up timespec structs, negative values for the ns part should be taken into account. Also, the range for a valid ns part is [0, 1000000000), not [0, 1000000000]. Signed-off-by: Philipp Gesang <philipp.gesang@intra2net.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* asn1: Remove unused function asn1_check_enumerated()Joseph Sutton2021-04-012-15/+0
| | | | | | | | | | | | | | This function was reported as containing a bug, but it is unused and so can be safely removed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=4153 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Mulder <dmulder@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Apr 1 17:50:49 UTC 2021 on sn-devel-184
* lib: Make pidfile_path_create() return the existing PID on conflictVolker Lendecke2021-03-162-35/+53
| | | | | | | | | | Use F_GETLK to get the lock holder PID, this is more accurate than reading the file contents: A conflicting process might not have written its PID yet. Also, F_GETLK easily allows to do a retry if the lock holder just died. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* util:str_sub: talloc_free on errorDouglas Bagnall2021-03-111-0/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
* util: don't mark impure functions as pureDouglas Bagnall2021-03-112-4/+4
| | | | | | | | nothing that allocates memory can be pure, unless it guarantees to allocate exactly the same pointer very time (which it does not). Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib/util: Replace buggy string_sub_talloc() with talloc_string_sub() in lib/utilAndrew Bartlett2021-03-103-62/+138
| | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14658 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Mar 10 08:06:25 UTC 2021 on sn-devel-184
* lib: Fix samba_sockaddr_[get|set]_portVolker Lendecke2021-03-091-4/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Align integer typesVolker Lendecke2021-03-091-2/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Avoid a memleak in pidfile_unlink()Volker Lendecke2021-03-091-5/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Avoid ZERO_STRUCT in pidfile_pid()Volker Lendecke2021-03-091-3/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Make socket options output less chattyVolker Lendecke2021-03-091-16/+38
| | | | | | | | All the socket options were a large block in debug output. Put them on one line. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* daemons: Do not notify systemd in child processes started by main sambaSamuel Cabrero2021-03-012-5/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When samba runs as ADDC only the main 'samba' daemon have to notify its status to systemd because our systemd unit files contains implied NotifyAccess=main since commit d1740fb3d5a72cb49e30b330bb0b01e7ef3e09cc. This commit adds a function to disable the systemd notification in the smbd and winbinddd child processes started by the main 'samba' daemon in AD DC mode to avoid warnings like: systemd[1]: samba-ad-dc.service: Got notification message from PID 26194, but reception only permitted for main PID 26187 systemd[1]: samba-ad-dc.service: Got notification message from PID 26222, but reception only permitted for main PID 26187 $ pstree -p ... ├─samba(26187)─┬─tfork(26189)(26188)───s3fs[master](26189)───tfork(26194)(26193)───smbd(26194)─┬─cleanupd(+ │ │ ├─lpqd(2623+ │ │ └─smbd-noti+ │ ├─tfork(26191)(26190)───rpc[master](26191)─┬─tfork(26198)(26195)───rpc(0)(26198) │ │ ├─tfork(26200)(26199)───rpc(1)(26200) │ │ ├─tfork(26206)(26201)───rpc(2)(26206) │ │ └─tfork(26212)(26207)───rpc(3)(26212) │ ├─tfork(26196)(26192)───nbt[master](26196) │ ├─tfork(26202)(26197)───wrepl[master](26202) │ ├─tfork(26204)(26203)───ldap[master](26204)─┬─tfork(26242)(26241)───ldap(0)(26242) │ │ ├─tfork(26244)(26243)───ldap(1)(26244) │ │ ├─tfork(26246)(26245)───ldap(2)(26246) │ │ └─tfork(26248)(26247)───ldap(3)(26248) │ ├─tfork(26208)(26205)───cldap[master](26208) │ ├─tfork(26210)(26209)───kdc[master](26210)───tfork(26218)(26215)───krb5kdc(26218) │ ├─tfork(26213)(26211)───drepl[master](26213) │ ├─tfork(26216)(26214)───winbindd[master(26216)───tfork(26222)(26219)───winbindd(26222)───wi+ │ ├─tfork(26220)(26217)───ntp_signd[maste(26220) │ ├─tfork(26223)(26221)───kcc[master](26223) │ ├─tfork(26225)(26224)───dnsupdate[maste(26225) │ └─tfork(26227)(26226)───dns[master](26227) Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:util: Move variable initialization out of conditional compilation blockSamuel Cabrero2021-03-011-1/+1
| | | | | Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* lib:util: Avoid free'ing our own pointerAndreas Schneider2021-02-031-4/+15
| | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14625 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed Feb 3 10:57:01 UTC 2021 on sn-devel-184
* lib:util: Add cache oversize test for memcacheAndreas Schneider2021-02-031-0/+39
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14625 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib:util: Add basic memcache unit testAndreas Schneider2021-02-032-0/+128
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14625 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* lib: Simplify parse_guid_string() and ndr_syntax_id_from_string()Volker Lendecke2021-01-282-75/+39
| | | | | | | | | Return "bool" instead of NTSTATUS, use hex_byte() instead of read_hex_bytes(). And parse directly into a struct GUID instead of the components. 99 lines less code. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Samuel Cabrero <scabrero@samba.org>
* lib: Provide a meaningful errno if FD_CLOEXEC is missingVolker Lendecke2021-01-261-0/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix the build on FreeBSDMartin Schwenke2021-01-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 7d0981f5e78bc881ca6521932379c69604c33a38 broke the build on FreeBSD: [1589/3917] Compiling lib/util/util_runcmd.c ../../lib/util/util_runcmd.c:310:7: warning: implicit declaration of function 'WIFEXITED' is invalid in C99 [-Wimplicit-function-declaration] if (WIFEXITED(status)) { ^ ../../lib/util/util_runcmd.c:311:13: warning: implicit declaration of function 'WEXITSTATUS' is invalid in C99 [-Wimplicit-function-declaration] status = WEXITSTATUS(status); ^ ../../lib/util/util_runcmd.c:312:14: warning: implicit declaration of function 'WIFSIGNALED' is invalid in C99 [-Wimplicit-function-declaration] } else if (WIFSIGNALED(status)) { ^ ../../lib/util/util_runcmd.c:313:13: warning: implicit declaration of function 'WTERMSIG' is invalid in C99 [-Wimplicit-function-declaration] status = WTERMSIG(status); ^ 4 warnings generated. [1590/3917] Linking bin/default/source4/dsdb/libsamdb-common-samba4.so ld: error: undefined symbol: WIFEXITED >>> referenced by util_runcmd.c >>> lib/util/util_runcmd.c.94.o:(samba_runcmd_io_handler) ld: error: undefined symbol: WEXITSTATUS >>> referenced by util_runcmd.c >>> lib/util/util_runcmd.c.94.o:(samba_runcmd_io_handler) ld: error: undefined symbol: WIFSIGNALED >>> referenced by util_runcmd.c >>> lib/util/util_runcmd.c.94.o:(samba_runcmd_io_handler) ld: error: undefined symbol: WTERMSIG >>> referenced by util_runcmd.c >>> lib/util/util_runcmd.c.94.o:(samba_runcmd_io_handler) clang: error: linker command failed with exit code 1 (use -v to see invocation) Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon Jan 25 09:48:09 UTC 2021 on sn-devel-184
* lib: Use hex_byte() in strhex_to_str()Volker Lendecke2021-01-221-27/+6
| | | | | | | I had completely missed that one in the last round... Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Avoid an "includes.h"Volker Lendecke2021-01-221-1/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Fix 'charset' dependenciesVolker Lendecke2021-01-121-1/+1
| | | | | | | | | | With this, 'charset' could be a SAMBA_LIBRARY without any undefined symbols 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 Jan 12 01:19:26 UTC 2021 on sn-devel-184
* lib: Avoid "includes.h" in lib/util/charset/Volker Lendecke2021-01-126-6/+20
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Remove using talloc_stack from lib/util/charset/Volker Lendecke2021-01-121-16/+20
| | | | | | | | 'charset' should be as standalone as possible, and for this one use talloc_stackframe() is not really necessary. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* lib: Move utf16_len[_n]() to lib/util/charset/Volker Lendecke2021-01-124-44/+43
| | | | | | | util_unistr.c references it, avoid broken dependencies Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>