summaryrefslogtreecommitdiff
path: root/lib/replace
AgeCommit message (Collapse)AuthorFilesLines
2026-03-20lib:replace add discard_align_pGary Lockyer1-0/+20
Add discard_align_p macro to allow the suppression of cast-align warnings Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Volker Lendecke <vl@samba.org>
2026-02-27vfs_aio_ratelimit: Add per-share TDB persistence for local rate limiter stateAvan Thakkar1-0/+8
Introduce local TDB storage for saving and restoring ratelimiter state (iops_tokens, bytes_tokens, last timestamp). Each share now persists its read/write limiter state under aio_ratelimit.tdb. Added VERSION pseudo-key for schema versioning On disconnect, save the latest state and close TDB. BUG: https://bugzilla.samba.org/show_bug.cgi?id=16000 Signed-off-by: Avan Thakkar <athakkar@redhat.com> Reviewed-by: Shweta Sodani <ssodani@redhat.com> Reviewed-by: Shachar Sharon <ssharon@redhat.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-11-11lib:replace: Remove memset_s()Andreas Schneider4-38/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Nov 11 14:51:45 UTC 2025 on atb-devel-224
2025-11-11Replace memset_s() with memset_explicit()Andreas Schneider1-9/+9
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2025-11-11lib:replace: Add test for memset_explicit()Douglas Bagnall2-0/+104
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2025-11-11lib:replace: Implement memset_explicit()Andreas Schneider4-1/+20
The memset_s() implementation is a bit obscure, as it requires a constraint handler to be set up. You don't really find any implmentations out there. With C23 memset_explicit() was added and this has been implemented for glibc 2.43 and also in FreeBSD. See https://sourceware.org/bugzilla/show_bug.cgi?id=32378 See https://reviews.freebsd.org/D47286 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2025-11-11lib:replace: Remove trailing spaces in READMEAndreas Schneider1-4/+4
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2025-10-22lib:replace: Implement setproctitle() based on PRCTL_MM_MAPAndreas Schneider1-0/+179
This should work on Linux. It requires CAP_SYS_RESOURCE, but our daemons run as root anyway. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Wed Oct 22 08:03:35 UTC 2025 on atb-devel-224
2025-10-22lib:replace: Remove trailing spacesAndreas Schneider1-28/+28
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2025-10-22lib:replace: There is special code already to check for HAVE_PRCTLAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2025-05-28Fix clang 20 format-truncation warningsGary Lockyer1-0/+6
Fix: lib/replace/tests/testsuite.c:387:6: error: 'snprintf' will always be truncated; specified size is 3, but format string expands to at least 5 [-Werror,-Wformat-truncation] 387 | if (snprintf(tmp, 3, "foo%d", 9) != 4) { | ^ As this is an explicit test of snprintf's truncation behaviour the warning can be safely suppressed. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-03-27replace: fix hex_upper -> hexchars_upperBjoern Jacke1-2/+3
It seems we don't have many systems without a working snprintf anymore... Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-01-21lib:replace: Don't use deprecated readline CPPFunction castAndreas Schneider1-1/+3
HAVE_RL_COMPLETION_FUNC_T was unused and not checking for the right function. libcli/smbreadline/smbreadline.c: In function ‘smb_readline’: libcli/smbreadline/smbreadline.c:139:17: warning: ‘CPPFunction’ is deprecated [-Wdeprecated-declarations] 139 | rl_attempted_completion_function = RL_COMPLETION_CAST completion_fn; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libcli/smbreadline/smbreadline.c:139:50: error: assignment to ‘char ** (*)(const char *, int, int)’ from incompatible pointer type ‘char ** (*)(void)’ [-Wincompatible-pointer-types] 139 | rl_attempted_completion_function = RL_COMPLETION_CAST completion_fn; | ^ BUG: https://bugzilla.samba.org/show_bug.cgi?id=15788 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Jan 21 19:38:37 UTC 2025 on atb-devel-224
2025-01-21lib:replace: Remove trailing spaces from readline.hAndreas Schneider1-3/+3
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15788 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2025-01-02remove usage of bzeroMichael Tokarev4-14/+1
bzero() function has been deprecated for a long time. In samba it is replaced with memset(). But samba also provides common memory-zeroing macros, like ZERO_STRUCT(). In all places where bzero() is used, it actually meant to zero a structure or an array. So replace these bzero() calls with ZERO_STRUCT() or ZERO_ARRAY() as appropriate, and remove bzero() replacement and testing entirely. While at it, also stop checking for presence of memset() - this function is standard for a very long time, and the only conditional where HAVE_MEMSET were used, was to provide replacement for bzero() - in all other places memset() is used unconditionally. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
2024-11-12libreplace: Introduce hexchars_{upper|lower}Volker Lendecke4-11/+14
We use that in quite a few places in our code. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2024-11-11lib/replace: memset_explicit() only takes three argumentsThomas Klausner1-1/+1
Signed-off-by: Thomas Klausner <wiz@gatalith.at> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon Nov 11 16:47:46 UTC 2024 on atb-devel-224
2024-08-21lib/replace: add renameat2() replacementStefan Metzmacher3-1/+90
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15693 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2024-08-20libreplace: add rep_copy_reflink()Ralph Boehme2-0/+37
FICLONERANGE was introduced in kernel version 4.5, so I guess we can just assume it is present if HAVE_LINUX_IOCTL is defined. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
2024-05-14lib/replace: make sure krb5_cc_default[_name]() is no longer used directlyStefan Metzmacher1-0/+3
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Tue May 14 11:22:28 UTC 2024 on atb-devel-224
2024-03-12lib: Simplify _hexcharvalVolker Lendecke1-1/+1
Saves a few bytes and conditional jumps Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-11-20lib:replace: Add python.hAndreas Schneider1-0/+30
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-10-13lib:replace: Properly check result of write() and read() (CID 1034925)Joseph Sutton1-2/+2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-14lib/replace: Ensure that __STDC_WANT_LIB_EXT1__ is set to 1Joseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-08lib/replace: fix strlcat/strlcpy compile for HonggfuzzDouglas Bagnall1-0/+11
Otherwise we getthis kind of thing: ../../lib/replace/replace.c:837:3: error: implicit declaration of function 'strlcpy' is invalid in C99 [-Werror,-Wimplicit-function-declaration] strlcpy(buf, s, buflen); ../../third_party/heimdal/lib/roken/getarg.c:288:6: error: implicit declaration of function 'strlcat' is invalid in C99 [-Werror,-Wimplicit-function-declaration] strlcat(buf, "]", sizeof(buf)); because we found the symbol names in libc, but didn't check that the functions are declared in <string.h>. We already include <bsd/string.h> whenever we have it. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue Aug 8 05:35:08 UTC 2023 on atb-devel-224
2023-08-08lib/replace: Const-qualify sys_errlistJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-07-19lib:replace: rely on epoll_create1() for epoll interfaceDmitry Antipov1-2/+2
Prefer epoll_create1(2) over epoll_create(2) and always require the former to use epoll(7) interface. Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-07-11configure: ensure sizeof(int) >= 4Douglas Bagnall1-0/+4
There are multiple places we make this assumption. For example, in source3/lib/tldap.c, we have this line if (ld->msgid == 2147483647) { where ld->msgid is an int. And in librpc/idl/security.idl we have several lines like: const int SEC_MASK_GENERIC = 0xF0000000; In lib/replace/inet_pton.c and inet_ntop.c we have /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ but no attempt to enforce that as far as I can see, until now. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Jul 11 22:44:15 UTC 2023 on atb-devel-224
2023-06-01lib/replace: check for valgrind/callgrind.hStefan Metzmacher1-1/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2023-04-14lib:replace: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-04-14lib:replace: Remove trailing white spaces in xattr.cAndreas Schneider1-4/+4
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-04-11lib:replace: Fix snprintf of rep_inet_ntop()Andreas Schneider1-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
2023-04-11lib:replace: Fix code spellingAndreas Schneider4-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>
2023-03-22replace: add ARRAY_INSERT_ELEMENT() helperStefan Metzmacher1-0/+15
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2023-02-06s3:modules: Ignore -Wunused-but-set-variable for autogenerated codeAndreas Schneider1-0/+3
source3/modules/getdate.c:1192:9: error: variable 'yynerrs' set but not used [-Werror,-Wunused-but-set-variable] int yynerrs; ^ Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2023-02-02replace: remove unused configure checks for port_create()Stefan Metzmacher2-9/+0
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15298 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2023-02-02replace: provide PIPE_BUF on GNU/HurdSamuel Thibault1-0/+12
There is no hardcoded PIPE_BUF pipe limitation on GNU/Hurd, but POSIX provides a minimum value that we can use. Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-05libreplace: require TLS support if pthread support is availableRalph Boehme2-0/+15
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-05libreplace: update comment on __thread supportRalph Boehme1-1/+2
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-01-02lib/replace - add extra check to bsd_attr_listAndrew Walker1-0/+12
The FreeBSD extattr API may return success and truncated namelist. We need to check for this in bsd_attr_list to ensure that we don't accidentally read off the end of the buffer. In the case of a truncated value, the pascal strings for attr names will reflect the lengths as if the value were not truncated. For example: `58DosStrea` In case of short read we now set error to ERANGE and fail. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15271 Signed-off-by: Andrew Walker <awalker@ixsystems.com> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Mon Jan 2 14:27:23 UTC 2023 on sn-devel-184
2022-11-24lib/replace: let rep_openat2() inject O_LARGEFILE as neededStefan Metzmacher1-0/+16
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15251 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2022-11-09lib/replace: fix memory leak in snprintf replacementsStefan Metzmacher1-0/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15230 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Nov 9 11:18:02 UTC 2022 on sn-devel-184
2022-10-27lib:replace: Require bool from C99Andreas Schneider2-7/+2
https://fedoraproject.org/wiki/Changes/PortingToModernC We define True to true from stdbool.h and the same for false. So we don't have to do a cleanup now. 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): Thu Oct 27 19:11:30 UTC 2022 on sn-devel-184
2022-10-27lib:replace: Fix trailing whitespace in wscriptAndreas Schneider1-3/+3
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-08-26lib:replace: Add macro BURN_STR() to zero memory of a stringPavel Filipenský1-0/+11
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2022-08-15lib/replace: let DISABLE_OPATH also undef __NR_openat2Stefan Metzmacher1-0/+8
The reason for DISABLE_OPATH is to simulate a non-linux system, so we should not use openat2() either. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-15lib/replace: add fallback defines for __NR_openat2Stefan Metzmacher1-0/+20
sys/syscall.h might be older than the runtime kernel. If the kernel has support for openat2() we should try to use if anyway. The callers have to deal with ENOSYS anyway, so there's no difference if we get that from syscall(__NR_openat2) or directly from rep_openat2(). Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-15lib/replace: use syscall(__NR_openat2) if availableStefan Metzmacher1-0/+8
There's no glibc wrapper for openat2() yet, so we need to use syscall(__NR_openat2) ourself. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-15lib/replace: always include <sys/syscall.h> in replace.c if availableStefan Metzmacher1-3/+4
It will be used for openat2() soon. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2022-08-15lib/replace: add a replacement for openat2() that returns ENOSYSStefan Metzmacher3-0/+45
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>