]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
12 months agoctdb-scripts: Track connections for all ports for public IPs
Martin Schwenke [Mon, 23 Oct 2023 03:17:36 +0000 (14:17 +1100)] 
ctdb-scripts: Track connections for all ports for public IPs

Currently TCP ports like NFS lock manager are not tracked.  It is
easier to track all connections than to add a configuration system to
try to track specified ports, so do that.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-scripts: Get connections after tickle list
Martin Schwenke [Mon, 30 Sep 2024 00:50:00 +0000 (10:50 +1000)] 
ctdb-scripts: Get connections after tickle list

Running ss to get current connections before running ctdb gettickles
means the ss output might be out of date when the 2 lists are
compared.  Some tickles might have been added after ss was run by some
other means (e.g. SMB tickles, added internally) and they would be
deleted according to the stale ss output.

This isn't currently a problem because update_tickles() is currently
only called with port 2049, so all tickles are managed by this code.
That will change in a subsequent commit.

Changing the order means the reverse problem can occur, where
update_tickles() attempts to delete an already deleted tickle.  That
may happen occasionally but is harmless because it doesn't result in
missing information.  It (currently) just causes a message to be
logged at DEBUG level.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-scripts: Move connection tracking to 10.interface
Martin Schwenke [Mon, 23 Oct 2023 03:05:21 +0000 (14:05 +1100)] 
ctdb-scripts: Move connection tracking to 10.interface

This should really be done for all connections to public IP addresses.
Leave the port number there for now - this is just the first step.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-server: Use ctdb_connection_same() to simplify
Martin Schwenke [Mon, 30 Sep 2024 02:21:59 +0000 (12:21 +1000)] 
ctdb-server: Use ctdb_connection_same() to simplify

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb: Don't leak a pointer on talloc_realloc failure
Volker Lendecke [Wed, 6 Nov 2024 10:51:04 +0000 (11:51 +0100)] 
ctdb: Don't leak a pointer on talloc_realloc failure

We should not directly overwrite the pointer we are realloc'ing

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
12 months agoctdb: Save a few lines with talloc_zero()
Volker Lendecke [Wed, 6 Nov 2024 10:49:36 +0000 (11:49 +0100)] 
ctdb: Save a few lines with talloc_zero()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
12 months agoctdb-server: Remove duplicate logic
Martin Schwenke [Mon, 30 Sep 2024 02:40:57 +0000 (12:40 +1000)] 
ctdb-server: Remove duplicate logic

Initialise the pointer to NULL and fall through to let
talloc_realloc() do the allocation.  talloc_realloc() does the right
thing with a NULL pointer...

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-server: Handle pre-existing connection first
Martin Schwenke [Mon, 30 Sep 2024 02:37:57 +0000 (12:37 +1000)] 
ctdb-server: Handle pre-existing connection first

This is cheap when tcparray is NULL and let's the code that now
follows be simplified.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-server: Drop an unnecessary variable
Martin Schwenke [Mon, 30 Sep 2024 02:34:18 +0000 (12:34 +1000)] 
ctdb-server: Drop an unnecessary variable

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-server: Drop a log message to DEBUG level
Martin Schwenke [Mon, 30 Sep 2024 02:30:13 +0000 (12:30 +1000)] 
ctdb-server: Drop a log message to DEBUG level

This is harmless, so it doesn't generally need to be logged.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-server: Clean up connection tracking functions
Martin Schwenke [Mon, 30 Sep 2024 02:22:46 +0000 (12:22 +1000)] 
ctdb-server: Clean up connection tracking functions

Apply README.Coding, modernise logging, pre-render connection as a
string for logging, switch terminology from "tickle" to "connection",
tidy up comments.

No changes in functionality.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-scripts: Use ss -H option to simplify
Martin Schwenke [Mon, 16 Sep 2024 02:26:53 +0000 (12:26 +1000)] 
ctdb-scripts: Use ss -H option to simplify

This option has been available since ~2018 and has been implemented in
the stub since then.  I guess we didn't use it because CentOS 7?

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-scripts: Remove superseded compatibility code
Martin Schwenke [Mon, 23 Oct 2023 03:23:45 +0000 (14:23 +1100)] 
ctdb-scripts: Remove superseded compatibility code

Since commit 224e99804efef960ef4ce2ff2f4f6dced1e74146, square brackets
have been parsed by daemon and tool code, so drop the compatibility
code from here.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-scripts: update_tickles() should use the public IPs cache
Martin Schwenke [Thu, 19 Sep 2024 04:32:46 +0000 (14:32 +1000)] 
ctdb-scripts: update_tickles() should use the public IPs cache

This avoids duplicating logic.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-scripts: Don't list connections when not hosting IPs
Martin Schwenke [Thu, 19 Sep 2024 03:52:48 +0000 (13:52 +1000)] 
ctdb-scripts: Don't list connections when not hosting IPs

With an empty IP filter, all incoming connections to port 2049 will be
listed, not just those to public IP addresses.  This causes error
messages like the following to be logged:

  ctdb-eventd[...]: 60.nfs: Failed to add 1 tickles

since the connection being added seems to be for a random NFS mount
that doesn't use a public IP addresses.

This has been a problem for a long time (probably since commit
04fe9e20749985c71fef1bce7f6e4c439fe11c81 in 2015).  It isn't currently
a huge deal because it only affects NFS connections.  However, this
code will soon be used to track connections to public IP addresses on
all ports.  This would result in a constant stream of log messages,
since there will always be some active connections.

The theory behind the fix is that if a node hosts no public IPs then
it should have no relevant connections and has no business changing
the list of registered tickles.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
Martin Schwenke [Fri, 13 Sep 2024 06:21:24 +0000 (16:21 +1000)] 
ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"

Massage a couple of lines manually so they're formatted sanely given
the new indentation.   Re-run shfmt to ensure no further changes.

Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-doc: Improve 10.interface documentation and comments
Martin Schwenke [Tue, 22 Aug 2023 02:12:50 +0000 (12:12 +1000)] 
ctdb-doc: Improve 10.interface documentation and comments

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-tests: Fix ss -a not supported
Martin Schwenke [Mon, 16 Sep 2024 02:32:02 +0000 (12:32 +1000)] 
ctdb-tests: Fix ss -a not supported

This is currently just a series of typos.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-tests: Drop unsupported long options from ss stub usage
Martin Schwenke [Mon, 16 Sep 2024 02:19:00 +0000 (12:19 +1000)] 
ctdb-tests: Drop unsupported long options from ss stub usage

These have not been supported since commit
896c77df1ce2645c6dd7898b59ea802e204dc7d9 in 2018.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agoctdb-tests: Ensure ss stub handles square brackets around addresses
Martin Schwenke [Fri, 27 Oct 2023 00:06:23 +0000 (11:06 +1100)] 
ctdb-tests: Ensure ss stub handles square brackets around addresses

It isn't unreasonable for unit test cases to use square brackets in
their input.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
12 months agolibndr: specialise ndr_token_find() for key pointer comparison
Douglas Bagnall [Thu, 17 Oct 2024 02:54:22 +0000 (15:54 +1300)] 
libndr: specialise ndr_token_find() for key pointer comparison

Usually we are doing a pointer comparison. Because we are doing it
in a tight loop, the cost of the comparison function call can be
noticeable.

There is a fuzz case that before f43ae1ab1a8803d8c5ad4e5f3dad63ccbe91aa54
took 3.957s, after that took 6.438s, and now again takes 3.960s.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Nov  6 12:06:04 UTC 2024 on atb-devel-224

12 months agoldb:test:lmdb_free_list: s/the the/to the/ in comment
Douglas Bagnall [Fri, 13 Sep 2024 02:31:54 +0000 (14:31 +1200)] 
ldb:test:lmdb_free_list: s/the the/to the/ in comment

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agos4:reg: s/the there/there/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:31:09 +0000 (14:31 +1200)] 
s4:reg: s/the there/there/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agos4: s/the the\b/the/ in miscellaneous comments
Douglas Bagnall [Fri, 13 Sep 2024 02:30:42 +0000 (14:30 +1200)] 
s4: s/the the\b/the/ in miscellaneous comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agos4:ldb_mods:group_audit: s/the the/the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:28:52 +0000 (14:28 +1200)] 
s4:ldb_mods:group_audit: s/the the/the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agos3:smbd:posix_acls: s/the the/that the/ in comment
Douglas Bagnall [Fri, 13 Sep 2024 02:27:57 +0000 (14:27 +1200)] 
s3:smbd:posix_acls: s/the the/that the/ in comment

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agos3:printing and spoolss: s/the the\b/the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:27:05 +0000 (14:27 +1200)] 
s3:printing and spoolss: s/the the\b/the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agos3:headers: s/the the\b/the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:26:35 +0000 (14:26 +1200)] 
s3:headers: s/the the\b/the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agos3:client:clitar: s/the the/to the/ in comment
Douglas Bagnall [Fri, 13 Sep 2024 02:25:36 +0000 (14:25 +1200)] 
s3:client:clitar: s/the the/to the/ in comment

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agopytest: s/the the\b/the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:24:55 +0000 (14:24 +1200)] 
pytest: s/the the\b/the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agosamba-tool:: s/the the\b/the/ in docstring
Douglas Bagnall [Fri, 13 Sep 2024 02:24:20 +0000 (14:24 +1200)] 
samba-tool:: s/the the\b/the/ in docstring

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agonsswitch:: s/the the\b/the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:23:47 +0000 (14:23 +1200)] 
nsswitch:: s/the the\b/the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agolibcli:auth:msrpc_parse: s/the the/is the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:22:30 +0000 (14:22 +1200)] 
libcli:auth:msrpc_parse: s/the the/is the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agoutil:charset: s/the the\b/the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:21:33 +0000 (14:21 +1200)] 
util:charset: s/the the\b/the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agotevent docs: s/the the\b/the/
Douglas Bagnall [Fri, 13 Sep 2024 02:21:12 +0000 (14:21 +1200)] 
tevent docs: s/the the\b/the/

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agopyldb: s/the the\b/the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:19:41 +0000 (14:19 +1200)] 
pyldb: s/the the\b/the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agoldb:pack: s/the the/in the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:19:23 +0000 (14:19 +1200)] 
ldb:pack: s/the the/in the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agolib/afs: s/the the\b/the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:18:00 +0000 (14:18 +1200)] 
lib/afs: s/the the\b/the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agoctdb:tests: s/the the\b/the/ in comments
Douglas Bagnall [Fri, 13 Sep 2024 02:17:30 +0000 (14:17 +1200)] 
ctdb:tests: s/the the\b/the/ in comments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
12 months agoWHATSNEW: SMB3 Directory Leases
Ralph Boehme [Thu, 24 Oct 2024 19:32:49 +0000 (21:32 +0200)] 
WHATSNEW: SMB3 Directory Leases

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Nov  5 15:51:27 UTC 2024 on atb-devel-224

12 months agosmbtorture: Directory Leases vs unlink
Ralph Boehme [Wed, 23 Oct 2024 18:11:59 +0000 (20:11 +0200)] 
smbtorture: Directory Leases vs unlink

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: Directory Leases vs hardlink
Ralph Boehme [Mon, 21 Oct 2024 10:33:08 +0000 (12:33 +0200)] 
smbtorture: Directory Leases vs hardlink

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: Directory Leases vs overwrite
Ralph Boehme [Fri, 18 Oct 2024 16:29:09 +0000 (18:29 +0200)] 
smbtorture: Directory Leases vs overwrite

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: Directory Leases vs renaming
Ralph Boehme [Mon, 9 Sep 2024 14:03:59 +0000 (16:03 +0200)] 
smbtorture: Directory Leases vs renaming

Note that we must use defines for the DLEASE* values, as declaring them as const
int triggers a CI failure on one of the runners (opensuse155-samba-o3) likely
due to a bug in its gcc version:

  ../../source4/torture/smb2/lease.c:6242:22: error: initializer element is not constant
     .srcdir_leasekey = DLEASE1,
                        ^~~~~~~

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: Directory Leases vs setting access date
Ralph Boehme [Mon, 9 Sep 2024 09:19:32 +0000 (11:19 +0200)] 
smbtorture: Directory Leases vs setting access date

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: Directory Leases vs setting inode change date
Ralph Boehme [Mon, 9 Sep 2024 08:37:19 +0000 (10:37 +0200)] 
smbtorture: Directory Leases vs setting inode change date

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: Directory Leases vs setting modification date
Ralph Boehme [Mon, 9 Sep 2024 08:35:09 +0000 (10:35 +0200)] 
smbtorture: Directory Leases vs setting modification date

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: Directory Leases vs setting creation date
Ralph Boehme [Fri, 18 Oct 2024 10:56:31 +0000 (12:56 +0200)] 
smbtorture: Directory Leases vs setting creation date

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: Directory Leases vs setting DOS attributes
Ralph Boehme [Fri, 18 Oct 2024 10:55:42 +0000 (12:55 +0200)] 
smbtorture: Directory Leases vs setting DOS attributes

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: Directory Leases vs setting EOF
Ralph Boehme [Fri, 18 Oct 2024 11:02:45 +0000 (13:02 +0200)] 
smbtorture: Directory Leases vs setting EOF

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agolibcli/smb: only copy the parent lease key if SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET...
Ralph Boehme [Thu, 24 Oct 2024 17:35:00 +0000 (19:35 +0200)] 
libcli/smb: only copy the parent lease key if SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET is set

MS-SMB2 3.3.5.9.11 Handling the SMB2_CREATE_REQUEST_LEASE_V2 Create Context:

  If the SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET bit is set in the Flags field of
  the request, Lease.ParentLeaseKey MUST be set to the ParentLeaseKey of the
  request.

Found by MS-SMB2-Prototocol-Testsuite test "Compare_Zero_LeaseFlag_ParentLeaseKey".

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: check parent leasekey is ignored unless SMB2_LEASE_FLAG_PARENT_LEASE_KEY_...
Ralph Boehme [Thu, 24 Oct 2024 10:00:40 +0000 (12:00 +0200)] 
smbtorture: check parent leasekey is ignored unless SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET is set

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agolibcli/smb: only allow SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET in lease_flag
Ralph Boehme [Tue, 22 Oct 2024 13:05:58 +0000 (15:05 +0200)] 
libcli/smb: only allow SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET in lease_flag

MS-SMB2 3.3.5.9.11 Handling the SMB2_CREATE_REQUEST_LEASE_V2 Create Context:

  The server MUST attempt to locate a Lease by performing a lookup in the
  LeaseTable.LeaseList using the LeaseKey ...

  If no lease is found, one MUST be allocated with the following values set:

  ...

  * Lease.Breaking is set to FALSE.

  ...

Ensures we ignore SMB2_LEASE_FLAG_BREAK_IN_PROGRESS. Found by
MS-SMB2-Prototocol-Testsuite "BreakReadLeaseV2TestCaseS0".

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: check SMB2_LEASE_FLAG_BREAK_IN_PROGRESS when client requests new lease
Ralph Boehme [Thu, 24 Oct 2024 09:52:19 +0000 (11:52 +0200)] 
smbtorture: check SMB2_LEASE_FLAG_BREAK_IN_PROGRESS when client requests new lease

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: expand Directory Leases test "v2_request
Ralph Boehme [Fri, 18 Oct 2024 15:25:56 +0000 (17:25 +0200)] 
smbtorture: expand Directory Leases test "v2_request

Add three subtests:

- trigger a sharing violation, ack break, create fails with STATUS_SHARING_VIOLATION
- trigger a sharing violation, close conflicting open, create succeeds
- write with valid parent lease key.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: simplify test_lease_v2_request()
Ralph Boehme [Fri, 6 Sep 2024 16:07:35 +0000 (18:07 +0200)] 
smbtorture: simplify test_lease_v2_request()

- Add and use test_rearm_dirlease().
- Rename variable "ls2" to "dirlease".
- Simplify lease epoch tracking by using dirlease.lease_epoch as a counter.
- Add comments.
- Zero out a handle after closing it.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: add test smb2.dirleases.leases
Ralph Boehme [Fri, 18 Oct 2024 15:19:34 +0000 (17:19 +0200)] 
smbtorture: add test smb2.dirleases.leases

Checks server accepts "RWH", "RH" and "R" lease request and grants at most
(lease_request & "RH"), so no "W", but "R" without "H" if requested.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agos4/torture: give smb2_generic_create_share() caller some flexibility
Ralph Boehme [Sun, 27 Feb 2022 17:48:49 +0000 (18:48 +0100)] 
s4/torture: give smb2_generic_create_share() caller some flexibility

This way callers can either create or open a directory.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agoselftest: add "smb2.dirlease" test suite
Ralph Boehme [Fri, 18 Oct 2024 12:51:09 +0000 (14:51 +0200)] 
selftest: add "smb2.dirlease" test suite

Move all existing Directory Leases tests to this test suite and require
SMB2_CAP_DIRECTORY_LEASING.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: grant Directory Lease if requested
Ralph Boehme [Tue, 3 Sep 2024 20:08:11 +0000 (22:08 +0200)] 
smbd: grant Directory Lease if requested

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: add option "smb3 directory leases"
Ralph Boehme [Wed, 12 May 2021 09:24:45 +0000 (11:24 +0200)] 
smbd: add option "smb3 directory leases"

By default enabled on non-clustered Samba, disabled on clustered Samba, the
reason being the expected additional load caused by forcing strict rename to be
enabled.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agodocs: fix indentation of "strict rename"
Ralph Boehme [Fri, 18 Oct 2024 14:17:08 +0000 (16:17 +0200)] 
docs: fix indentation of "strict rename"

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: allow directory leases in close_directory()
Ralph Boehme [Fri, 6 Sep 2024 10:28:46 +0000 (12:28 +0200)] 
smbd: allow directory leases in close_directory()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: use get_deferred_open_message_state() in open_directory()
Ralph Boehme [Fri, 6 Sep 2024 09:46:12 +0000 (11:46 +0200)] 
smbd: use get_deferred_open_message_state() in open_directory()

"deferred" will be used in the function by a later commit...

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agolibcli/smb: ignore lease_flags and lease_duration for leasev1 in smb2_lease_pull()
Ralph Boehme [Mon, 21 Oct 2024 10:51:20 +0000 (12:51 +0200)] 
libcli/smb: ignore lease_flags and lease_duration for leasev1 in smb2_lease_pull()

MS-SMB2 2.2.13.2.8 SMB2_CREATE_REQUEST_LEASE:

  LeaseFlags (4 bytes): This field MUST NOT be used and MUST be reserved.
  The client MUST set this to 0, and the server MUST ignore it on receipt.

  LeaseDuration (8 bytes): This field MUST NOT be used and MUST be reserved.
  The client MUST set this to 0, and the server MUST ignore it on receipt.

So let's really, really ignore it.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agolibcli/smb: rely on the caller zero-initializing "lease" in smb2_lease_pull()
Ralph Boehme [Mon, 21 Oct 2024 10:48:19 +0000 (12:48 +0200)] 
libcli/smb: rely on the caller zero-initializing "lease" in smb2_lease_pull()

Doing the zero initialization per struct member just feels like a way for bugs
to creep in, even when leasev1 is not going to change ever. The only caller has
already zero-initialized state->lease twice via 1) __tevent_req_create() and 2)
a struct initializer of "state".

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when creating hardlink
Ralph Boehme [Sun, 20 Oct 2024 19:37:41 +0000 (21:37 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when creating hardlink

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger change notification when creating hardlink
Ralph Boehme [Sun, 20 Oct 2024 19:36:59 +0000 (21:36 +0200)] 
smbd: trigger change notification when creating hardlink

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agovfs_tsmsm: trigger NOTIFY_ACTION_DIRLEASE_BREAK when changing offline attribute
Ralph Boehme [Wed, 19 May 2021 13:51:36 +0000 (15:51 +0200)] 
vfs_tsmsm: trigger NOTIFY_ACTION_DIRLEASE_BREAK when changing offline attribute

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agovfs_gpfs: trigger NOTIFY_ACTION_DIRLEASE_BREAK when changing offline attribute
Ralph Boehme [Wed, 19 May 2021 13:51:14 +0000 (15:51 +0200)] 
vfs_gpfs: trigger NOTIFY_ACTION_DIRLEASE_BREAK when changing offline attribute

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when changing timestamps
Ralph Boehme [Sat, 7 Sep 2024 13:52:04 +0000 (15:52 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when changing timestamps

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: in smb_set_file_time() rename "action" variable to "filter"
Ralph Boehme [Thu, 5 Sep 2024 17:00:32 +0000 (19:00 +0200)] 
smbd: in smb_set_file_time() rename "action" variable to "filter"

This matches the notify_fname() argument name and the next commit is going to
add an "action" variable.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when modifying DOS attributes
Ralph Boehme [Thu, 5 Sep 2024 17:29:23 +0000 (19:29 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when modifying DOS attributes

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when setting file EOF
Ralph Boehme [Wed, 19 May 2021 13:45:37 +0000 (15:45 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when setting file EOF

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK for renames
Ralph Boehme [Sat, 7 Sep 2024 14:02:23 +0000 (16:02 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK for renames

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: pass lck down to rename_internals_fsp()
Ralph Boehme [Mon, 30 Sep 2024 18:03:43 +0000 (20:03 +0200)] 
smbd: pass lck down to rename_internals_fsp()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when closing a modified file
Ralph Boehme [Wed, 12 May 2021 17:53:38 +0000 (19:53 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when closing a modified file

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when truncating files
Ralph Boehme [Sat, 19 Oct 2024 05:47:33 +0000 (07:47 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when truncating files

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when removing directories
Ralph Boehme [Sat, 7 Sep 2024 13:20:14 +0000 (15:20 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when removing directories

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when removing files
Ralph Boehme [Sat, 7 Sep 2024 14:21:41 +0000 (16:21 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when removing files

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agos3/locking: return parent_lease_key from get_delete_on_close_token()
Ralph Boehme [Wed, 23 Oct 2024 13:38:01 +0000 (15:38 +0200)] 
s3/locking: return parent_lease_key from get_delete_on_close_token()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agos3/locking: remember parent_lease_key that set delete-on-close
Ralph Boehme [Wed, 23 Oct 2024 12:10:46 +0000 (14:10 +0200)] 
s3/locking: remember parent_lease_key that set delete-on-close

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when creating files and directories
Ralph Boehme [Mon, 9 Sep 2024 19:55:36 +0000 (21:55 +0200)] 
smbd: trigger NOTIFY_ACTION_DIRLEASE_BREAK when creating files and directories

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: use contend_dirleases() in notify_fname()
Ralph Boehme [Wed, 19 May 2021 13:03:48 +0000 (15:03 +0200)] 
smbd: use contend_dirleases() in notify_fname()

Prepares for Directory Lease breaks.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: add flag NOTIFY_ACTION_DIRLEASE_BREAK for notify_fname()
Ralph Boehme [Wed, 19 May 2021 12:42:14 +0000 (14:42 +0200)] 
smbd: add flag NOTIFY_ACTION_DIRLEASE_BREAK for notify_fname()

Will be used to trigger Directory Lease breaks from notify_fname().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: add contend_dirleases()
Ralph Boehme [Wed, 4 Sep 2024 15:58:45 +0000 (17:58 +0200)] 
smbd: add contend_dirleases()

Checks for Directory Lease breaks on the parent directory of smb_fname. Gets a
sharemode lock on the locking.tdb record of the directory, hence it mustn't be
called if the caller still has another sharmode lock.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: pass lease, if any, to notify_fname()
Ralph Boehme [Mon, 4 Nov 2024 17:48:14 +0000 (18:48 +0100)] 
smbd: pass lease, if any, to notify_fname()

notify_fname() for NOTIFY_ACTION_DIRLEASE_BREAK will soon need the lease of the
current open and to implement "MS-FSA 2.1.4.12 Algorithm to Check for an Oplock
Break" with flags=PARENT_OBJECT.

No change in behaviour for now, all callers pass lease=NULL;

Also change path arg to struct smb_filename.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: pass lease and oplock_request to open_directory()
Ralph Boehme [Tue, 3 Sep 2024 18:24:22 +0000 (20:24 +0200)] 
smbd: pass lease and oplock_request to open_directory()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: pass fsp to notify_rename()
Ralph Boehme [Mon, 21 Oct 2024 13:52:29 +0000 (15:52 +0200)] 
smbd: pass fsp to notify_rename()

Not used for now, that comes soon.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: notify file truncation after dropping the sharemode lock
Ralph Boehme [Mon, 4 Nov 2024 17:44:08 +0000 (18:44 +0100)] 
smbd: notify file truncation after dropping the sharemode lock

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: move notify_fname() out of rmdir_internals() up to close_directory()
Ralph Boehme [Sat, 7 Sep 2024 14:24:01 +0000 (16:24 +0200)] 
smbd: move notify_fname() out of rmdir_internals() up to close_directory()

This way we've already dropped the sharemode lock.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: call notify_rename() after dropping the lck in rename_internals_fsp()
Ralph Boehme [Fri, 6 Sep 2024 10:40:43 +0000 (12:40 +0200)] 
smbd: call notify_rename() after dropping the lck in rename_internals_fsp()

Same here, cf the explanation in the previous commit.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: trigger notification for file and directory creation will be sent a wee bit...
Ralph Boehme [Mon, 9 Sep 2024 19:27:45 +0000 (21:27 +0200)] 
smbd: trigger notification for file and directory creation will be sent a wee bit later after dropping the sharemode lock

This will be a common pattern in the upcoming code dealing with Directory Lease
breaks: when checking for Directory Lease breaks on the parent directory, we
take the sharemode lock on the parent and hence by then must have dropped the
sharemode lock on the object that performs the Directory Lease break check. That
functionality will be later added to notify_fname().

This means the notification will be sent a wee bit later, but that's something
the change notification protocol has to live with anyway.

For Directory Leases the sequence to check for Directory Lease breaks is to call
MS-FSA 2.1.4.12 "Algorithm to Check for an Oplock Break" with
flags=PARENT_OBJECT at the end of each relevant operation, eg creating a file
asf, when processing of the operation that will call 2.1.4.12 is already
completed.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: add fsp_get_smb2_lease()
Ralph Boehme [Wed, 19 May 2021 14:58:21 +0000 (16:58 +0200)] 
smbd: add fsp_get_smb2_lease()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: ndrprint lease value in leases_db_set_fn()
Ralph Boehme [Wed, 12 May 2021 19:31:27 +0000 (21:31 +0200)] 
smbd: ndrprint lease value in leases_db_set_fn()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: check for handle lease break on destination when renaming
Ralph Boehme [Fri, 18 Oct 2024 06:02:21 +0000 (08:02 +0200)] 
smbd: check for handle lease break on destination when renaming

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: Split out smb2_parse_file_rename_information()
Ralph Boehme [Fri, 20 Sep 2024 03:14:12 +0000 (05:14 +0200)] 
smbd: Split out smb2_parse_file_rename_information()

No change in behaviour.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbtorture: expand test test_lease_v2_rename_target_overwrite()
Ralph Boehme [Mon, 14 Oct 2024 15:20:16 +0000 (17:20 +0200)] 
smbtorture: expand test test_lease_v2_rename_target_overwrite()

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: recursive delay_for_handle_lease_break_send()
Ralph Boehme [Thu, 17 Oct 2024 17:18:57 +0000 (19:18 +0200)] 
smbd: recursive delay_for_handle_lease_break_send()

Check for open files recursively when renaming a directory and wait for handle
lease breaks.

As delay_for_handle_lease_break_send() does the same check as
have_file_open_below(), remove have_file_open_below() from can_rename() so it is
not called twice for SMB2 renames, and add calls to have_file_open_below() to the
SMB1 entry rename entry points.

This is a bit ugly, but I don't see any other good way of doing this.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
12 months agosmbd: consolidate "have_file_open_below" logic in have_file_open_below()
Ralph Boehme [Sun, 13 Oct 2024 15:44:18 +0000 (17:44 +0200)] 
smbd: consolidate "have_file_open_below" logic in have_file_open_below()

Let have_file_open_below() be the single function to check if
"have_file_open_below" and let it check internally whether to just search the
fsp list in the process or traversing locking.tdb based on the setting of
"strict rename".

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>