]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
7 months agosilence "Can not convert group sid" warnings in the log
Michael Tokarev [Wed, 14 Feb 2024 12:26:29 +0000 (15:26 +0300)] 
silence "Can not convert group sid" warnings in the log

/var/log/samba/log.winbind is full of messages like:

[2024/02/09 06:25:04.788182,  1, pid=74620] source3/winbindd/winbindd_getgroups.c:259(winbindd_getgroups_recv)
  Could not convert sid S-0-0: NT_STATUS_NONE_MAPPED

On a busy server these are logged several 1000s times per minute,
making any other messages basically invisible.

This is a work-around, a proper solution is to handle some
special SIDs (like this one) separately.  Once this is done,
this change can be reverted.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosilence DNS lookup mismatch messages
Michael Tokarev [Mon, 23 Dec 2024 20:26:52 +0000 (23:26 +0300)] 
silence DNS lookup mismatch messages

There's just too much useless noise in the logs,
especially when the PTR record just doesn't exist.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibsamba-errors: eliminate dependency on samba-debug
Michael Tokarev [Mon, 18 Nov 2024 09:45:08 +0000 (12:45 +0300)] 
libsamba-errors: eliminate dependency on samba-debug

libsamba-errors is a collection of error codes/descriptions
like strerror(), - it is a set of simple functions converting
error code to string or the like.  However, in one single
place there's a DBG_DEBUG() "call" in errmap_unix.c, in
map_errno_from_nt_status(), which is here for a very long time
(since before samba3, initially with debug level 10).

Drop this debugging info, and eliminate extra dependency.
This makes libsamba-errors independent and self-contained,
with a well-known and stable ABI.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agospecify some deps on private libs actually used directly
Michael Tokarev [Thu, 19 May 2022 17:37:21 +0000 (20:37 +0300)] 
specify some deps on private libs actually used directly

Lots of samba libraries has incomplete dependencies listed
in wscript files.  This usually is not a problem since the
link line includes dependencies of their dependencies of
their dependencies, and somewhere down that line all immediate
dependencies which are missing are actually present.  But
sometimes this becomes a problem when a library does not
declare direct dependency on at least one private library
which it actually uses: in case no private library is
listed as direct dependency, private library directory is
not put into RUNPATH of the resulting binary, so the binary
can not find its own dependencies.

Fix a few such places, including some libraries which are
a part of public abi (libsmbldap, libndr).

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agoHappy New Year 2025!
Stefan Metzmacher [Wed, 1 Jan 2025 07:36:35 +0000 (07:36 +0000)] 
Happy New Year 2025!

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Wed Jan  1 19:16:03 UTC 2025 on atb-devel-224

7 months agoldb: fix Coverity 1636883
Douglas Bagnall [Mon, 23 Dec 2024 00:07:40 +0000 (13:07 +1300)] 
ldb: fix Coverity 1636883

oops.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Mon Dec 30 04:17:46 UTC 2024 on atb-devel-224

7 months agoutil:datablob: data_blob_pad checks its alignment assumption
Douglas Bagnall [Wed, 11 Dec 2024 01:31:18 +0000 (14:31 +1300)] 
util:datablob: data_blob_pad checks its alignment assumption

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Dec 20 07:59:51 UTC 2024 on atb-devel-224

7 months agobootstrap: we don't need python-crypt-r anymore
Douglas Bagnall [Wed, 11 Dec 2024 21:35:02 +0000 (10:35 +1300)] 
bootstrap: we don't need python-crypt-r anymore

Recent commits made pyglue wrap the same crypt[_r] that dsdb modules
use, which removes an extenal dependency.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agopytest: password_hash uses internal _glue.crypt
Douglas Bagnall [Wed, 11 Dec 2024 21:46:16 +0000 (10:46 +1300)] 
pytest: password_hash uses internal _glue.crypt

This will remove an external dependency.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agosamba-tool user: hashlib.sha1 is always present
Douglas Bagnall [Wed, 11 Dec 2024 02:56:20 +0000 (15:56 +1300)] 
samba-tool user: hashlib.sha1 is always present

We maybe thought we were checking that sha1 was in hashlib, but we were
only checking that hashlib is in the Python library (`hashlib.sha1()`
would not raise ImportError).

The documentation says hashlib always contains sha1 -- if that
changes, it is better we know by failing noisily with the import error
at the top of the file.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agosamba-tool user: use _glue.crypt, not crypt.crypt
Douglas Bagnall [Wed, 11 Dec 2024 02:54:48 +0000 (15:54 +1300)] 
samba-tool user: use _glue.crypt, not crypt.crypt

Because we know we have _glue.crypt, and we know it raises exceptions
rather than returning None, we can simplify the checks.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agopytest: test that _glue.crypt works
Douglas Bagnall [Wed, 11 Dec 2024 21:44:07 +0000 (10:44 +1300)] 
pytest: test that _glue.crypt works

The test vectors were generated via Python 3.10 crypt module, which
directly wraps crypt(3), which in this case is from glibc 2.39-0ubuntu8.3.

We mainly test the sha256 and sha512 vectors, which seems to be all we
use, and which are said to be widely supported.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agopyglue: add crypt() function
Douglas Bagnall [Wed, 11 Dec 2024 01:30:15 +0000 (14:30 +1300)] 
pyglue: add crypt() function

This wraps talloc_crypt_blob() from lib/util/util_crypt.c which in
turn wraps the system crypt[_r[n]].

We want this because the Python standard library crypt module is going
away. That one also wrapped the system crypt or crypt_r, so there
should be no change.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoutil: add a crypt strerror helper
Douglas Bagnall [Wed, 11 Dec 2024 01:30:04 +0000 (14:30 +1300)] 
util: add a crypt strerror helper

This will be used by Python also.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agodsdb:password_hash: use talloc_crypt_blob()
Douglas Bagnall [Wed, 11 Dec 2024 22:16:22 +0000 (11:16 +1300)] 
dsdb:password_hash: use talloc_crypt_blob()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agodsdb:password_hash: move hash_blob allocation up
Douglas Bagnall [Wed, 11 Dec 2024 01:29:21 +0000 (14:29 +1300)] 
dsdb:password_hash: move hash_blob allocation up

This will make the next patch simpler.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoutil: add a crypt wrapper, derived from dsdb:password_hash
Douglas Bagnall [Thu, 5 Dec 2024 03:35:51 +0000 (16:35 +1300)] 
util: add a crypt wrapper, derived from dsdb:password_hash

This is going to be used by the dsdb password_hash module, and exposed
to Python via pyglue.

We're doing this because Python 3.13 has dropped crypt from the Python
standard library.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agosamba-tool: no traceback for unauthenticated rootdse access
Douglas Bagnall [Mon, 29 Jul 2024 21:53:14 +0000 (09:53 +1200)] 
samba-tool: no traceback for unauthenticated rootdse access

Under some circumstances rootdse returns an operations error with
"Operation unavailable without authentication" instead of insufficient
access rights.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Fri Dec 20 00:00:02 UTC 2024 on atb-devel-224

7 months agoldb:dn_compare_base: avoid unlikely int overflow
Douglas Bagnall [Thu, 22 Aug 2024 22:14:04 +0000 (10:14 +1200)] 
ldb:dn_compare_base: avoid unlikely int overflow

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:dn_compare: be a bit more transitive
Douglas Bagnall [Thu, 22 Aug 2024 22:17:17 +0000 (10:17 +1200)] 
ldb:dn_compare: be a bit more transitive

If neither dn can casefold, they should be considered equal. Otherwise
cmp(dn1, dn2) will be inconsistent with cmp(dn2, dn1).

These will still sort to the end of the list, relative to any valid
DNs.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:kv_cache: s/ltdb/ldb_kv/ in comments and messages
Douglas Bagnall [Thu, 22 Aug 2024 04:23:09 +0000 (16:23 +1200)] 
ldb:kv_cache: s/ltdb/ldb_kv/ in comments and messages

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:kv: s/ltdb/ldb_kv/ in comments and messages
Douglas Bagnall [Thu, 22 Aug 2024 04:22:28 +0000 (16:22 +1200)] 
ldb:kv: s/ltdb/ldb_kv/ in comments and messages

with some subsequent tidy-ups for style.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:ldb_pack: filter avoids looping over msg when attrs contain "*"
Douglas Bagnall [Fri, 26 Jul 2024 03:47:03 +0000 (15:47 +1200)] 
ldb:ldb_pack: filter avoids looping over msg when attrs contain "*"

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:dn_casefold_internal: TALLOC_FREE only what we talloced
Douglas Bagnall [Wed, 21 Aug 2024 23:03:13 +0000 (11:03 +1200)] 
ldb:dn_casefold_internal: TALLOC_FREE only what we talloced

If the failure is not on the last component, we would have
TALLOC_FREE()ed some components that we hadn't set.

I think in all pathways we initialise the unset components to zero,
but we should be careful just in case.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoldb:tests: add tests ensuring indexes don't change search results
Douglas Bagnall [Sat, 17 Aug 2024 01:34:01 +0000 (13:34 +1200)] 
ldb:tests: add tests ensuring indexes don't change search results

The index code (lib/ldb_key_value/ldb_kv_index.c) recapitulates LDB
expression logic, and it seemed less than completely obvious that it
would never make a mistake and return a different result than an
unindexed search.

Here we run the same search on an unindexed database and on some that
have been indexed with a variety of options. We assert that the
results are identical over a number of searches.

By default, when run from the command line, that number is 495161,
which takes a couple of minutes. But if the SKIP_SLOW_TESTS
environment variable is set, the number is 33569, which takes 20
seconds or so. In selftest we set the variable and run the smaller
number.

The tests will print the cumulative search time for each database for
each testsuite, like this:

$ python3 lib/ldb/tests/python/index_transparency.py
..........................................................[...]
<class '__main__.SearchTest'>
25.78186821937561 <ldb connection tdb:///tmp/tmpf1x72x7l/tdb-indexed-dn.ldb>
17.73349642753601 <ldb connection tdb:///tmp/tmpf1x72x7l/tdb-half-indexed.ldb>
15.14864206314087 <ldb connection tdb:///tmp/tmpf1x72x7l/tdb-indexed-guid.ldb>
13.107165575027466 <ldb connection mdb:///tmp/tmpf1x72x7l/mdb-indexed.ldb>

Like all benchmarks it is interesting but misleading. One caveat here
is that you have (probably) compiled tdb in developer mode without
optimisation, while lmdb is probably a system package compiled with -O2,
though perhaps not tuned to your exact architecture.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agolib:ldb-samba: use 'ldb' debug class more widely
Douglas Bagnall [Wed, 16 Oct 2024 23:12:46 +0000 (12:12 +1300)] 
lib:ldb-samba: use 'ldb' debug class more widely

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoselftest:S4: use PY_DEV_PROVISION for python dev-mode
Douglas Bagnall [Wed, 18 Sep 2024 01:52:17 +0000 (13:52 +1200)] 
selftest:S4: use PY_DEV_PROVISION for python dev-mode

Maybe we could look also at other -X options and -v.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
\18

7 months agoselftest:S4: use RR_PROVISION for rr recording
Douglas Bagnall [Wed, 18 Sep 2024 01:40:23 +0000 (13:40 +1200)] 
selftest:S4: use RR_PROVISION for rr recording

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agoselftest:S4: do not add 'env python' multiple times'
Douglas Bagnall [Wed, 18 Sep 2024 01:38:52 +0000 (13:38 +1200)] 
selftest:S4: do not add 'env python' multiple times'

While we have no sane reason to use

VALGRIND_PROVISION=1 GDB_PROVISION=1 make test...

we will soon gain PY_DEV_PROVISION, which could be useful in tandem
with valgrind, rr, or gdb, and this will allow that.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agolibcli/util: let nt_errstr() fallback to hresult_errstr()
Stefan Metzmacher [Mon, 16 Dec 2024 13:46:19 +0000 (14:46 +0100)] 
libcli/util: let nt_errstr() fallback to hresult_errstr()

Sometimes NTSTATUS fields return things like
HRES_SEC_E_WRONG_PRINCIPAL.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Dec 18 18:30:08 UTC 2024 on atb-devel-224

7 months agos4:scripting: fix gen_hresult.py
Stefan Metzmacher [Mon, 16 Dec 2024 13:43:41 +0000 (14:43 +0100)] 
s4:scripting: fix gen_hresult.py

Commit 6877e4849e81ed8f7f355fa4069f13a134e999ce reversed the
return values of hresult_errstr() and hresult_errstr_const().

hresult_errstr() should return "HRES_SEC_E_WRONG_PRINCIPAL",
while hresult_errstr_const() should return
"The target principal name is incorrect.".

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15769

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
7 months agolib: Fix error path memleaks in read_ea_list_entry()
Volker Lendecke [Thu, 12 Dec 2024 14:17:05 +0000 (15:17 +0100)] 
lib: Fix error path memleaks in read_ea_list_entry()

Don't leak the result on error

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Dec 18 09:30:33 UTC 2024 on atb-devel-224

7 months agolib: Fix a comment
Volker Lendecke [Thu, 12 Dec 2024 12:59:45 +0000 (13:59 +0100)] 
lib: Fix a comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agosmbd: Simplify smbd_do_qfsinfo()
Volker Lendecke [Tue, 10 Dec 2024 10:42:59 +0000 (11:42 +0100)] 
smbd: Simplify smbd_do_qfsinfo()

Do early returns, avoid else statements

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agoFix whitespace
Volker Lendecke [Tue, 10 Dec 2024 15:57:47 +0000 (16:57 +0100)] 
Fix whitespace

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs: Slightly speed up stream_dir()
Volker Lendecke [Mon, 9 Dec 2024 09:01:19 +0000 (10:01 +0100)] 
vfs: Slightly speed up stream_dir()

lp_parm_bool() is a relatively expensive string-based operation. Do it
only when needed.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agovfs: Simplify stream_dir()
Volker Lendecke [Mon, 9 Dec 2024 07:09:53 +0000 (08:09 +0100)] 
vfs: Simplify stream_dir()

We know in advance how large "id_hex" is.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agoModernize DEBUGs
Volker Lendecke [Mon, 9 Dec 2024 06:55:45 +0000 (07:55 +0100)] 
Modernize DEBUGs

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agopam_winbind: Fix Bug 15771
Volker Lendecke [Mon, 16 Dec 2024 16:49:43 +0000 (17:49 +0100)] 
pam_winbind: Fix Bug 15771

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15771

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
7 months agos3:winbindd: Remove unused set_routing_domain()
Pavel Filipenský [Mon, 16 Dec 2024 13:39:54 +0000 (14:39 +0100)] 
s3:winbindd: Remove unused set_routing_domain()

Commit 9a613f4 winbindd: add routing_domain as parameter to add_trusted_domain
deleted all calls of set_routing_domain().

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Dec 17 13:30:25 UTC 2024 on atb-devel-224

7 months agonsswitch:winbind: Remove WINBINDD_SHOW_SEQUENCE
Pavel Filipenský [Mon, 16 Dec 2024 13:10:48 +0000 (14:10 +0100)] 
nsswitch:winbind: Remove WINBINDD_SHOW_SEQUENCE

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agos3:winbindd: Remove implementation of WINBINDD_SHOW_SEQUENCE
Pavel Filipenský [Mon, 16 Dec 2024 13:16:07 +0000 (14:16 +0100)] 
s3:winbindd: Remove implementation of WINBINDD_SHOW_SEQUENCE

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agos4:torture: Remove test for deprecated WINBINDD_SHOW_SEQUENCE
Pavel Filipenský [Mon, 16 Dec 2024 13:12:22 +0000 (14:12 +0100)] 
s4:torture: Remove test for deprecated WINBINDD_SHOW_SEQUENCE

torture_winbind_struct_show_sequence() is failing if run as:

make -j8 test TESTS="samba4.rpc.lsa.trusted.*ad_dc samba4.winbind.struct.ad_dc"

The reason is that the test constructs two lists of domains and assumes
that the list contain same domains in the same order.

However:

- the list based on DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep) contains 51 domains
- the list based on DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep) contains 39 domains

and we got:

failure: show_sequence [ ../../source4/torture/winbind/struct_based.c:824: domlist[i].netbios_name was TORTURE201, expected TORTURE200: inconsistent order of domain lists
]

Both list are based on full domain list, however the smaller one filters
out domain without trust_type in winbindd_list_trusted_domains():

trust_type = get_trust_type_string(talloc_tos(), d, domain);
if (trust_type == NULL) {
continue;
}

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agonsswitch:wbinfo: Remove implementation of deprecated '--sequence'
Pavel Filipenský [Mon, 16 Dec 2024 12:57:17 +0000 (13:57 +0100)] 
nsswitch:wbinfo: Remove implementation of deprecated '--sequence'

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agodocs-xml:manpages: Remove deprecated 'wbinfo --sequence'
Pavel Filipenský [Mon, 16 Dec 2024 13:01:42 +0000 (14:01 +0100)] 
docs-xml:manpages: Remove deprecated 'wbinfo --sequence'

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agonsswitch:tests: Remove test for deprecated wbinfo --sequence
Pavel Filipenský [Mon, 16 Dec 2024 13:01:42 +0000 (14:01 +0100)] 
nsswitch:tests: Remove test for deprecated wbinfo --sequence

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
7 months agosmbd: Simplify rmdir_internals()
Volker Lendecke [Fri, 6 Dec 2024 08:23:21 +0000 (09:23 +0100)] 
smbd: Simplify rmdir_internals()

Remove another "copy" of recursive_rmdir()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Streamline recursive_rmdir()
Volker Lendecke [Fri, 6 Dec 2024 08:19:08 +0000 (09:19 +0100)] 
smbd: Streamline recursive_rmdir()

By factoring out recursive_rmdir_fsp() we can do the recursion using
openat_pathref_fsp_lcomp(). This makes strace for a recursive
directory removal look a *lot* cleaner.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Simplify rmdir_internals()
Volker Lendecke [Thu, 5 Dec 2024 16:20:41 +0000 (17:20 +0100)] 
smbd: Simplify rmdir_internals()

Remove a "copy" of can_delete_directory_hnd()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Factor out can_delete_directory_hnd()
Volker Lendecke [Thu, 5 Dec 2024 16:17:59 +0000 (17:17 +0100)] 
smbd: Factor out can_delete_directory_hnd()

To be used in close.c next

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Make can_delete_directory_fsp() look cleaner in strace
Volker Lendecke [Thu, 5 Dec 2024 15:50:12 +0000 (16:50 +0100)] 
smbd: Make can_delete_directory_fsp() look cleaner in strace

I'm not sure, but it might be that we don't have a full fd coming into
can_delete_directory_fsp() without O_PATH. We open a real fd for
readdir() in all cases, which we can use for sure in openat &
friends. Use that as dirfsp for openat.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Fix can_delete_directory_fsp()
Volker Lendecke [Fri, 6 Dec 2024 10:31:56 +0000 (11:31 +0100)] 
smbd: Fix can_delete_directory_fsp()

We should only ignore veto files if they are about to deleted anyway

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: simplify can_delete_directory_fsp()
Volker Lendecke [Thu, 5 Dec 2024 12:08:32 +0000 (13:08 +0100)] 
smbd: simplify can_delete_directory_fsp()

openat_pathref_fsp_lcomp does all of what we do here manually
anyway. Use it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Remove a pointless and partially wrong comment
Volker Lendecke [Thu, 5 Dec 2024 19:07:03 +0000 (20:07 +0100)] 
smbd: Remove a pointless and partially wrong comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Fix typos
Volker Lendecke [Thu, 5 Dec 2024 10:38:51 +0000 (11:38 +0100)] 
smbd: Fix typos

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Simplify ReadDirName()
Volker Lendecke [Thu, 5 Dec 2024 10:37:15 +0000 (11:37 +0100)] 
smbd: Simplify ReadDirName()

"fp" is only used for DBG messages where I don't think we need the
full accuracy of full_path_from_dirfsp_at_basename(). Save a talloc.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolib: Simplify ad_get_internal()
Volker Lendecke [Wed, 4 Dec 2024 18:37:20 +0000 (19:37 +0100)] 
lib: Simplify ad_get_internal()

We have metadata_fsp() for this

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Pass "dirfsp" through open_streams_for_delete()
Volker Lendecke [Wed, 4 Dec 2024 18:29:03 +0000 (19:29 +0100)] 
smbd: Pass "dirfsp" through open_streams_for_delete()

One SMB_VFS_CREATE_FILE call less with "NULL" as dirfsp

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Fix a %d/%u format string hickup
Volker Lendecke [Wed, 4 Dec 2024 18:19:57 +0000 (19:19 +0100)] 
smbd: Fix a %d/%u format string hickup

num_streams is an unsigned int

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agorpcclient: Fix Coverity ID 1508978 Use of 32-bit time_t
Volker Lendecke [Wed, 4 Dec 2024 16:03:46 +0000 (17:03 +0100)] 
rpcclient: Fix Coverity ID 1508978 Use of 32-bit time_t

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agonet: Fix Coverity ID 1508974 Use of 32-bit time_t
Volker Lendecke [Wed, 4 Dec 2024 16:00:50 +0000 (17:00 +0100)] 
net: Fix Coverity ID 1508974 Use of 32-bit time_t

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agoeventlog: Fix Coverity ID 1508977 Use of 32-bit time_t
Volker Lendecke [Wed, 4 Dec 2024 15:59:01 +0000 (16:59 +0100)] 
eventlog: Fix Coverity ID 1508977 Use of 32-bit time_t

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agowinbind: Fix Coverity ID 1509002 Use of 32-bit time_t
Volker Lendecke [Wed, 4 Dec 2024 15:38:47 +0000 (16:38 +0100)] 
winbind: Fix Coverity ID 1509002 Use of 32-bit time_t

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agoprinting: Remove a few obsolete openat_pathref_fsp() calls
Volker Lendecke [Wed, 4 Dec 2024 15:30:03 +0000 (16:30 +0100)] 
printing: Remove a few obsolete openat_pathref_fsp() calls

driver_convert_unix calls filename_convert_dirfsp, which these days
fills smb_fname->fsp. So openat_pathref_fsp() will immediately return
success as it finds smb_fname->fsp != NULL.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Remove an obsolete comment
Volker Lendecke [Wed, 4 Dec 2024 15:11:44 +0000 (16:11 +0100)] 
smbd: Remove an obsolete comment

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Simplify smb_set_file_end_of_file_info()
Volker Lendecke [Wed, 4 Dec 2024 15:06:10 +0000 (16:06 +0100)] 
smbd: Simplify smb_set_file_end_of_file_info()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Simplify call_trans2setfileinfo()
Volker Lendecke [Wed, 4 Dec 2024 14:53:41 +0000 (15:53 +0100)] 
smbd: Simplify call_trans2setfileinfo()

Avoid an "else"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolib: Fix Coverity ID 1636566 Untrusted loop bound
Volker Lendecke [Wed, 4 Dec 2024 13:03:12 +0000 (14:03 +0100)] 
lib: Fix Coverity ID 1636566 Untrusted loop bound

Sanitize num_auths to [0,15] in sid_copy()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Modernize DEBUGs
Volker Lendecke [Wed, 4 Dec 2024 11:42:43 +0000 (12:42 +0100)] 
smbd: Modernize DEBUGs

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Avoid a (double) cast
Volker Lendecke [Wed, 4 Dec 2024 11:42:00 +0000 (12:42 +0100)] 
smbd: Avoid a (double) cast

We don't need floating point here, intmax_t and %jd should be
sufficient

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Pass "dirfsp" to get_posix_fsp()
Volker Lendecke [Wed, 4 Dec 2024 11:28:34 +0000 (12:28 +0100)] 
smbd: Pass "dirfsp" to get_posix_fsp()

The two places where get_posix_fsp() is called we do have the dirfsp
around. Pass this through to SMB_VFS_CREATE_FILE(), looks much cleaner
in strace.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Simplify smb_set_posix_acl()
Volker Lendecke [Wed, 4 Dec 2024 08:01:15 +0000 (09:01 +0100)] 
smbd: Simplify smb_set_posix_acl()

Call get_posix_fsp() in the caller, this removes if-conditions in
smb_set_posix_acl() itself

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Simplify smb_q_posix_acl()
Volker Lendecke [Wed, 4 Dec 2024 07:54:19 +0000 (08:54 +0100)] 
smbd: Simplify smb_q_posix_acl()

Ensure it's called with a valid fsp. In the pathinfo case, use
get_posix_fsp() in the caller, in the fileinfo case the client has
sent us the fid. A client-visible fid is always a fsa fsp.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Simplify get_posix_fsp()
Volker Lendecke [Tue, 3 Dec 2024 16:24:40 +0000 (17:24 +0100)] 
smbd: Simplify get_posix_fsp()

Remove three variables only set at initialization time

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibcli: Modernize a DEBUG
Volker Lendecke [Fri, 29 Nov 2024 14:35:50 +0000 (15:35 +0100)] 
libcli: Modernize a DEBUG

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibcli: Fix a potential 32-bit problem with PRIu32
Volker Lendecke [Thu, 28 Nov 2024 17:44:02 +0000 (18:44 +0100)] 
libcli: Fix a potential 32-bit problem with PRIu32

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibcli: Make handling implicit_owner_rights bit easier to read
Volker Lendecke [Fri, 29 Nov 2024 12:06:03 +0000 (13:06 +0100)] 
libcli: Make handling implicit_owner_rights bit easier to read

The first time I came across this I missed the "FALL_THROUGH" and had
to look closely at what happens. I had expected
IMPLICIT_OWNER_READ_CONTROL_AND_WRITE_DAC_RIGHTS to grant two rights,
which to me is now more obvious. It was correct before, but to me this
is now more obvious. YMMV.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibcli: Simplify disp_sec_ace_object()
Volker Lendecke [Thu, 28 Nov 2024 17:41:50 +0000 (18:41 +0100)] 
libcli: Simplify disp_sec_ace_object()

Directly use GUID_buf_string()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibcli: Align an integer type
Volker Lendecke [Tue, 3 Dec 2024 12:33:48 +0000 (13:33 +0100)] 
libcli: Align an integer type

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibcli: Remove the "mem_ctx" argument from pull_integer()
Volker Lendecke [Thu, 28 Nov 2024 17:01:21 +0000 (18:01 +0100)] 
libcli: Remove the "mem_ctx" argument from pull_integer()

Not needed anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibcli: Simplify pull_integer()
Volker Lendecke [Thu, 28 Nov 2024 16:58:59 +0000 (17:58 +0100)] 
libcli: Simplify pull_integer()

Use ndr_pull_struct_blob_noalloc, we don't need talloc here.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agovfs: Simplify connect_acl_tdb()
Volker Lendecke [Thu, 28 Nov 2024 14:48:45 +0000 (15:48 +0100)] 
vfs: Simplify connect_acl_tdb()

We don't need talloc for printing a mask with %o

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agovfs: Simplify connect_acl_xattr()
Volker Lendecke [Thu, 28 Nov 2024 14:48:45 +0000 (15:48 +0100)] 
vfs: Simplify connect_acl_xattr()

We don't need talloc for printing a mask with %o

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agosmbd: Pass "dirfsp" through posix_mkdir()
Volker Lendecke [Sat, 23 Nov 2024 15:51:15 +0000 (16:51 +0100)] 
smbd: Pass "dirfsp" through posix_mkdir()

One less caller of SMB_VFS_CREATE_FILE with dirfsp==NULL

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibcli: Avoid an unnecessary "else"
Volker Lendecke [Mon, 25 Nov 2024 11:04:53 +0000 (12:04 +0100)] 
libcli: Avoid an unnecessary "else"

We return in the if-branch

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agolibcli: Use ndr_deepcopy_struct() in security_token_duplicate()
Volker Lendecke [Thu, 28 Nov 2024 12:56:19 +0000 (13:56 +0100)] 
libcli: Use ndr_deepcopy_struct() in security_token_duplicate()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
7 months agos3:open.c: Fix a typo
Pavel Filipenský [Wed, 11 Dec 2024 21:33:17 +0000 (22:33 +0100)] 
s3:open.c: Fix a typo

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Tue Dec 17 11:23:50 UTC 2024 on atb-devel-224

7 months agoselftest: Add test for vfs crossrename module
Pavel Filipenský [Wed, 4 Dec 2024 10:02:18 +0000 (11:02 +0100)] 
selftest: Add test for vfs crossrename module

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15724

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agodocs:manpage: vfs_crossrename is not fully stackable VFS module
Pavel Filipenský [Mon, 2 Dec 2024 21:27:39 +0000 (22:27 +0100)] 
docs:manpage: vfs_crossrename is not fully stackable VFS module

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15724

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3:vfs_crossrename: add back checking for errno ENOENT
Jones Syue [Thu, 26 Sep 2024 09:17:14 +0000 (17:17 +0800)] 
s3:vfs_crossrename: add back checking for errno ENOENT

strace gives a clue: samba try to remove 'file.txt' in the dst folder but
actually it is not existed yet, and got an errno = ENOENT,

renameat(32, "file.txt", 31, "file.txt") = -1 EXDEV (Invalid cross-device link)
unlinkat(31, "file.txt", 0)             = -1 ENOENT (No such file or directory)

Commit 5c18f074be92 ("s3: VFS: crossrename. Use real dirfsp for
SMB_VFS_RENAMEAT()") seems unintentionally removed errno ENOENT checking,
so add it back could address 1st issue.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15724

Signed-off-by: Jones Syue <jonessyue@qnap.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3:vfs_crossrename: crossrename_renameat() needs to return 0 if copy_reg() is successful
Pavel Filipenský [Thu, 28 Nov 2024 17:32:25 +0000 (18:32 +0100)] 
s3:vfs_crossrename: crossrename_renameat() needs to return 0 if copy_reg() is successful

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15724

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agos3:vfs_crossrename: avoid locking panic in copy_reg()
Pavel Filipenský [Thu, 28 Nov 2024 17:39:53 +0000 (18:39 +0100)] 
s3:vfs_crossrename: avoid locking panic in copy_reg()

Use low level backend functions that don't go through the FSA layer.
Done via calling transfer_file() as it was in version before 5c18f07

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15724

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
7 months agodocs:manpages: Update 'net ads keytab create'
Pavel Filipenský [Tue, 3 Dec 2024 15:21:26 +0000 (16:21 +0100)] 
docs:manpages:  Update 'net ads keytab create'

Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Mon Dec 16 19:32:32 UTC 2024 on atb-devel-224

8 months agoctdb-scripts: Change default persistent DB for statd_callout_helper
Martin Schwenke [Tue, 25 Jun 2024 01:06:19 +0000 (11:06 +1000)] 
ctdb-scripts: Change default persistent DB for statd_callout_helper

This database isn't use throughout CTDB, so name the it more
specifically.

Note that this might cause locks to be lost during upgrade to the
first version containing this change.

For testing, a different name is chosen to exercise related
functionality.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Fri Dec 13 15:01:10 UTC 2024 on atb-devel-224

8 months agoctdb-scripts: Support CTDB_STATD_CALLOUT_SHARED_STORAGE=none
Martin Schwenke [Tue, 30 Apr 2024 02:12:32 +0000 (12:12 +1000)] 
ctdb-scripts: Support CTDB_STATD_CALLOUT_SHARED_STORAGE=none

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
8 months agoctdb-tests: Update statd-callout tests to handle both modes
Martin Schwenke [Fri, 30 Jun 2023 11:50:10 +0000 (21:50 +1000)] 
ctdb-tests: Update statd-callout tests to handle both modes

Add support for shared_dir mode.

Instead of duplicating all of the tests, update them so they can be
wrapped.  Created new tests for shared_dir mode that source the
"original" tests.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
8 months agoctdb-scripts: Support storing statd-callout state in cluster filesystem
Martin Schwenke [Wed, 28 Jun 2023 04:01:44 +0000 (14:01 +1000)] 
ctdb-scripts: Support storing statd-callout state in cluster filesystem

CTDB_STATD_CALLOUT_SHARED_STORAGE is a new configuration variable
indicating where statd-callout should store its NFS client locking
data.  See the update to ctdb-script.options(5) for details.

This adds back functionality that was removed in commit
12cc82623150ca4a83482f1b7165401cbdecd3de.  The commit message doesn't
say why this was changed but it was most likely due to a cluster
filesystem hanging at inopportune times.  Hence, this is re-added as a
non-default option.  There are 2 justifications for re-adding it:

* The existing method (persistent_db) relies on dequeuing data during
  the monitor event, which loses any queued data on node crash.

* NFS-Ganesha writes NFSv4 client locking data to a cluster
  filesystem, by default.  Something similar might as well exist for
  NFSv3.

Note that this could create the files for sm-notify in add-client.
However, this would require an alternate implementation of
send_notifies() (or a change to the implementation for persistent_db
too).  It seems better to leave add-client lightweight and do the work
in notify, since add-client is a more frequent operation.

Unconditionally create the state directory on startup.  This is
currently implicitly created for persistent_db when the queue
directory is created.  However, it isn't created anywhere else for
shared_dir, so do it in a common place.

In test mode, the shared storage location has a prefix added so files
are created within the test environment.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
8 months agoctdb-scripts: Fix impending SM_NOTIFY versus record deletion race
Martin Schwenke [Tue, 4 Jun 2024 23:32:21 +0000 (09:32 +1000)] 
ctdb-scripts: Fix impending SM_NOTIFY versus record deletion race

SM_NOTIFYs are sent before client records are deleted.  Theoretically,
this means new records resulting from lock reclaim can be deleted.

This doesn't actually happen at the moment because any new "records"
resulting from lock reclaim are entered into the queue directory and
only dequeued to the database during a later monitor event.  Since a
monitor event can't collide with an ipreallocated event, no records
can be dequeeued into the database during the ipreallocated event, so
they can't be deleted by delete_records().

However, a subsequent commit will add direct writing of records into a
shared cluster filesystem directory.  This means that add-client
events will cause records to be added directly to that directory so,
without a fix, the race will be able to occur.

So, delete records before sending SM_NOTIFYs.  In theory, the script
could be killed before all SM_NOTIFYs are successfully sent, resulting
in loss of locks.  However, given the overall lack of error checking,
there are other, more likely problems.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
8 months agoctdb-scripts: Factor out some statd-callout functions
Martin Schwenke [Tue, 27 Jun 2023 03:37:56 +0000 (13:37 +1000)] 
ctdb-scripts: Factor out some statd-callout functions

This captures all of the persistent database (currently ctdb.tdb)
implementation-specific details in functions.  Alternate
implementations can now be easily added.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
8 months agoctdb-scripts: Improve update and listing code
Martin Schwenke [Wed, 2 Aug 2023 03:23:58 +0000 (13:23 +1000)] 
ctdb-scripts: Improve update and listing code

Drop the complexity associated with using awk to escape dots in IPv4
addresses to protect them from sed, and generate a grep -F filter
instead.

For listing, the pipeline is now longer, but the steps are now
clearer:

1. List DB records
2. Extract keys
3. Keep only keys machine hosted public IPs
4. Parse out server IP and client IP
5. Sort

Performance here isn't critical, so having clearer code is preferable.

Use temporary files to avoid command-line length limits.

Also, drop the cd to the queue directory during update.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>