]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
66 min agosmbd: implement POSIX-FSA 2.1.4.8.1 FileDispositionInformation master
Ralph Boehme [Mon, 2 Mar 2026 13:26:22 +0000 (14:26 +0100)] 
smbd: implement POSIX-FSA 2.1.4.8.1 FileDispositionInformation

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Jul 17 18:26:27 UTC 2026 on atb-devel-224

2 hours agopython/tests: add Smb3UnixTests.test_delete_read_only_attr
Ralph Boehme [Mon, 2 Mar 2026 13:51:34 +0000 (14:51 +0100)] 
python/tests: add Smb3UnixTests.test_delete_read_only_attr

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 hours agopython/tests: enhance LibsmbTests.clean_file to work with READ-ONLY attributes
Ralph Boehme [Mon, 2 Mar 2026 15:51:34 +0000 (16:51 +0100)] 
python/tests: enhance LibsmbTests.clean_file to work with READ-ONLY attributes

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 hours agopylibsmb: add "sfileinfo" method
Ralph Boehme [Mon, 2 Mar 2026 15:57:30 +0000 (16:57 +0100)] 
pylibsmb: add "sfileinfo" method

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2 hours agopylibsmb: add MS-SMB2 SET_INFO InfoTypes
Ralph Boehme [Mon, 2 Mar 2026 15:53:44 +0000 (16:53 +0100)] 
pylibsmb: add MS-SMB2 SET_INFO InfoTypes

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
8 hours agoWHATSNEW: SMB3 Persistent Handles gitlab/master
Ralph Boehme [Fri, 17 Jul 2026 09:24:08 +0000 (11:24 +0200)] 
WHATSNEW: SMB3 Persistent Handles

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Jul 17 11:21:41 UTC 2026 on atb-devel-224

9 hours agoCI: skip samba3.clustered.smb2.persistent-open.reconnect-contended
Ralph Boehme [Tue, 14 Jul 2026 17:48:01 +0000 (19:48 +0200)] 
CI: skip samba3.clustered.smb2.persistent-open.reconnect-contended

It's likely a real bug that needs to be investigated, but we're
running out of time for the 4.25 merge windows, so let's pave over it
and fix it later.

Marking as flapping is not sufficient as the test leaves ctdb
non-functional when failing.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.deleteonclose-twice"
Ralph Boehme [Tue, 2 Dec 2025 15:09:32 +0000 (16:09 +0100)] 
smbtorture: add test "smb2.persistent-open.deleteonclose-twice"

Verifies cleanup of stale delete-on-close token. This only works against Samba
where we have to implement DoC token expiration instead of fully deleting the
file (and the token).

 1. Open file with PH an handle-timeout of 1s
 2. Open file a second time with PH an handle-timeout of 10s
 3. Set Doc on handle from (1)
 4. Set Doc on handle from (2)
 5. Disconnect
 6. Sleep 2s, handle from (1) should expire, scavenger should not
    cleanup DoC token as that is from (3)
 7. Reconnect session and handle from (3)
 8. Close file, should now get removed as Doc should still be set
 9. Verify file is gone

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add testsuite "smb2.persistent-open-failover"
Ralph Boehme [Fri, 12 Dec 2025 15:49:51 +0000 (16:49 +0100)] 
smbtorture: add testsuite "smb2.persistent-open-failover"

This uses the same basic test as smb2.persistent-open.reconnect-contended, but
instead of doing a simple TCP disconnect from TALLOC_FREE()ing the smb2_tree, we
use the ctdb failover hooks.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add tests "smb2.persistent-open.deleteonclose-[reconnect|expire]"
Ralph Boehme [Mon, 1 Dec 2025 15:41:02 +0000 (16:41 +0100)] 
smbtorture: add tests "smb2.persistent-open.deleteonclose-[reconnect|expire]"

smb2.persistent-open.deleteonclose-reconnect verifies reconnecting or expiring a
Persistent Handle with delete-on-close pending:

1a. SMB2-CREATE + PH + initial-delete-on-close, or

1b. SMB2-CREATE + PH + SMB2-SETINFO(delete-on-close), then

2. Disconnect TCP
3. Reconnect TCP and handle
4. SMB2-CLOSE -> should delete the file
5. Try to open -> should fail with NT_STATUS_OBJECT_NAME_NOT_FOUND

The test smb2.persistent-open.deleteonclose-expire fails against Samba, but
works againt Windows. The reason is current lack of support for accessing our
VFS from the scavenger. Note that the same problem applies to Durable Handles,
not just Persistent Handles.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.directory-disconnect"
Ralph Boehme [Sun, 28 Sep 2025 10:39:10 +0000 (12:39 +0200)] 
smbtorture: add test "smb2.persistent-open.directory-disconnect"

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.directory-leaselevels"
Ralph Boehme [Sat, 27 Sep 2025 14:29:35 +0000 (16:29 +0200)] 
smbtorture: add test "smb2.persistent-open.directory-leaselevels"

Test Persistent Handles and various lease levels on directories.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.replay-multi"
Ralph Boehme [Mon, 30 Jun 2025 15:04:30 +0000 (17:04 +0200)] 
smbtorture: add test "smb2.persistent-open.replay-multi"

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.replay-reconnect"
Ralph Boehme [Tue, 26 Aug 2025 03:53:27 +0000 (05:53 +0200)] 
smbtorture: add test "smb2.persistent-open.replay-reconnect"

A simple replay test on a Persistent Handle:

- get a persistent handle
- disconnect
- reconnect
- replay
- use reconnected handle by writing to it

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.rename-dir-open-files"
Ralph Boehme [Mon, 25 Aug 2025 16:03:45 +0000 (18:03 +0200)] 
smbtorture: add test "smb2.persistent-open.rename-dir-open-files"

Verifies rename a directory containing a disconnected Persistent Handle
fails.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.timeout_5"
Ralph Boehme [Mon, 25 Aug 2025 09:56:48 +0000 (11:56 +0200)] 
smbtorture: add test "smb2.persistent-open.timeout_5"

Verify that a disconnected Persistent Handle with a timeout of 5 seconds is
reaped by the scavenger after the timeout expires, so another client can then
open the file.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.reconnect-contended-replay"
Ralph Boehme [Mon, 25 Aug 2025 09:38:47 +0000 (11:38 +0200)] 
smbtorture: add test "smb2.persistent-open.reconnect-contended-replay"

This tests verifies, that a

* contending open on a disconnected persisten open that triggers a lease
  break is blocked,

* a replay if the create that caused the lease break fails with
  NT_STATUS_FILE_NOT_AVAILABLE as long the the persistent open is still
  disconnected,

* after the persistent open is reconnected the second replay of the
  contending open succeeds

* the client with the persistent open receives a lease break

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.reconnect-contended-oplock"
Ralph Boehme [Thu, 25 Sep 2025 14:59:54 +0000 (16:59 +0200)] 
smbtorture: add test "smb2.persistent-open.reconnect-contended-oplock"

Persistent Handles together with oplocks are broken on Windows: eg oplocks are
"silently" downgraded from B to S when reconnecting a PH, instead of sending an
oplock break with the downgraded oplock level (cf --option=torture:subtest=7).

Samba doesn't grant Persistent Handles with oplocks at all, only with
leases or without an oplock or lease.

Skip these tests altogether, they're merely kept for historical
reference and in case this subject needs furthter exploration in the
future.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.reconnect-contended-two"
Ralph Boehme [Thu, 25 Sep 2025 14:49:22 +0000 (16:49 +0200)] 
smbtorture: add test "smb2.persistent-open.reconnect-contended-two"

Same as smb2.persistent-open.reconnect-contended, but with two Persistent
Handles sharing the same lease key.

Note that some tests are failing against Windows as Windows is strangely failing
to reconnect the second handle. This is being discussed with Microsoft:

PR: https://lists.samba.org/archive/cifs-protocol/2025-September/004583.html

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add test "smb2.persistent-open.reconnect-contended"
Ralph Boehme [Sun, 24 Aug 2025 19:56:38 +0000 (21:56 +0200)] 
smbtorture: add test "smb2.persistent-open.reconnect-contended"

This tests trying to open a file with a disconnected persistent handle
with various different lease levels, sharemodes and create disposition
combinations.

The client then disconnects and we try to open (contend) the now disconnected
Persistent Handle from the first client. This will either fail with
NT_STATUS_FILE_NOT_AVAILABLE or trigger a lease break which gets dispatched once
the first client reconnects.

The client must always be able to reconnect the disconnected open and the server
guarantees that any operations which break W or H leases are blocked.

The bottom line being:

* incompatible opens without H-lease are blocked with
  NT_STATUS_FILE_NOT_AVAILABLE

* incompatible opens with a H lease trigger a lease break and are deferred until
  the first client reconnects the handle

* in addition to that, if the file has byterange locks the lease must include
  W, otherwise contending opens are also blocked with NT_STATUS_FILE_NOT_AVAILABLE

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: start of a smb2.persistent-open testsuite
Ralph Boehme [Sun, 26 Oct 2025 11:01:11 +0000 (12:01 +0100)] 
smbtorture: start of a smb2.persistent-open testsuite

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoselftest: add share argument to planclusteredmembertestsuite()
Ralph Boehme [Fri, 12 Dec 2025 14:32:45 +0000 (15:32 +0100)] 
selftest: add share argument to planclusteredmembertestsuite()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos4/torture: add torture_smb2_connection_share_ext()
Ralph Boehme [Sat, 29 Nov 2025 15:02:26 +0000 (16:02 +0100)] 
s4/torture: add torture_smb2_connection_share_ext()

Takes an additional share paramter compared to torture_smb2_connection_ext().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoselftest: add clusteredmember env ctdb management hooks
Ralph Boehme [Sun, 26 Oct 2025 11:00:33 +0000 (12:00 +0100)] 
selftest: add clusteredmember env ctdb management hooks

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbtorture: add utility functions to stop and restart the serving ctdb node
Ralph Boehme [Sun, 26 Oct 2025 10:53:44 +0000 (11:53 +0100)] 
smbtorture: add utility functions to stop and restart the serving ctdb node

Add arbitrary sleep for five seconds, so far this seem to have worked well on
gitlab CI.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: add FSCTL_SMBTORTURE_[GET_CTDB_PNN|STOP_CTDB_NODE|START_CTDB_NODE]
Ralph Boehme [Sun, 26 Oct 2025 08:59:28 +0000 (09:59 +0100)] 
smbd: add FSCTL_SMBTORTURE_[GET_CTDB_PNN|STOP_CTDB_NODE|START_CTDB_NODE]

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: bypass child cleanup when child exits with a magic exit code
Ralph Boehme [Sun, 26 Oct 2025 08:56:09 +0000 (09:56 +0100)] 
smbd: bypass child cleanup when child exits with a magic exit code

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbstatus: print persistent handles
Ralph Boehme [Sat, 26 Jul 2025 16:12:03 +0000 (18:12 +0200)] 
smbstatus: print persistent handles

While at it, add all other share_mode_entry flags to the json output.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: SMB layer processing of Persistent Handle requests
Ralph Boehme [Sat, 23 Aug 2025 19:28:56 +0000 (21:28 +0200)] 
smbd: SMB layer processing of Persistent Handle requests

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: fail replay operation on handle that has been used
Ralph Boehme [Mon, 25 Aug 2025 16:48:20 +0000 (18:48 +0200)] 
smbd: fail replay operation on handle that has been used

Using a handle, eg processing an SMB2_WRITE operation, removes the replay cache
record associated with open.

If the handle is a Persistent Handle, the replay must fail with
NT_STATUS_FILE_NOT_AVAILABLE in this case, whereas for a Durable Handle without
persistency, the replay would be handled as a new create.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: pass replay_operation and persistent_requested to smb2srv_open_lookup_replay_ca...
Ralph Boehme [Mon, 25 Aug 2025 16:47:43 +0000 (18:47 +0200)] 
smbd: pass replay_operation and persistent_requested to smb2srv_open_lookup_replay_cache()

Not yet used, that comes next.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: prepare checks before SMB_VFS_DURABLE_COOKIE() for PHs
Ralph Boehme [Sat, 27 Sep 2025 08:41:07 +0000 (10:41 +0200)] 
smbd: prepare checks before SMB_VFS_DURABLE_COOKIE() for PHs

No change in behaviour. Prepares for adding an additional condition for
requesting a cookie.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: open smbXsrv_open_global.tdb db with per-record persistency support
Ralph Boehme [Wed, 19 Sep 2018 22:21:43 +0000 (15:21 -0700)] 
smbd: open smbXsrv_open_global.tdb db with per-record persistency support

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: use DBWRAP_STORE_PERSISTENT in smbXsrv_open_global_store()
Ralph Boehme [Wed, 26 Feb 2025 17:03:15 +0000 (18:03 +0100)] 
smbd: use DBWRAP_STORE_PERSISTENT in smbXsrv_open_global_store()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: check for Persistent Handles in smbXsrv_open_global_verify_record()
Ralph Boehme [Wed, 26 Feb 2025 16:55:57 +0000 (17:55 +0100)] 
smbd: check for Persistent Handles in smbXsrv_open_global_verify_record()

Return NT_STATUS_REMOTE_DISCONNECT for a Persistent Handle if the process
doesn't exist, same error response as for a Durable Handle where the server_id
is found to be set to the special disconnected id a few lines above.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: advertize CAP_CONTINUOUS_AVAILABILITY if "continuous availability" is enabled
Ralph Boehme [Tue, 18 Mar 2025 10:37:11 +0000 (11:37 +0100)] 
smbd: advertize CAP_CONTINUOUS_AVAILABILITY if "continuous availability" is enabled

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: advertize SMB2_CAP_PERSISTENT_HANDLES global capability
Ralph Boehme [Fri, 28 Jul 2017 12:03:14 +0000 (14:03 +0200)] 
smbd: advertize SMB2_CAP_PERSISTENT_HANDLES global capability

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agonet/serverid: implement "--persistent" for "net serverid wipedbs"
Ralph Boehme [Tue, 25 Nov 2025 15:25:16 +0000 (16:25 +0100)] 
net/serverid: implement "--persistent" for "net serverid wipedbs"

Wipe the per-record backup databases.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agonet/serverid: also remove stale record from locking.tdb
Ralph Boehme [Tue, 25 Nov 2025 15:27:28 +0000 (16:27 +0100)] 
net/serverid: also remove stale record from locking.tdb

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: make smbXsrv_open_global_parse_record() public
Ralph Boehme [Sun, 7 Dec 2025 07:44:04 +0000 (08:44 +0100)] 
smbd: make smbXsrv_open_global_parse_record() public

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoscavenger: make share_mode_cleanup_disconnected() public
Ralph Boehme [Tue, 25 Nov 2025 15:25:16 +0000 (16:25 +0100)] 
scavenger: make share_mode_cleanup_disconnected() public

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoscavenger: add missing field seperator in debug output
Ralph Boehme [Tue, 25 Nov 2025 15:25:16 +0000 (16:25 +0100)] 
scavenger: add missing field seperator in debug output

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoscavenger: clean up stale delete-on-close tokens in the scavenger
Ralph Boehme [Mon, 1 Dec 2025 16:48:24 +0000 (17:48 +0100)] 
scavenger: clean up stale delete-on-close tokens in the scavenger

Currently we discard Durable Handles when processing a client disconnect that
have delete-on-close set, which will then also clean up the delete-on-close
token.

This is going to change for Persistent Handles, so we have to prepare for
cleaning up delete-on-close tokens in the scavenger.

Windows takes it one step further and the file gets actually deleted: on Windows
delete-on-close in set at the FSA layer so when the scavenger closes the handle,
the filesystem will just follow standard delete-on-close processing and delete
the file.

For Samba this is hard to implement in the scavenger, as it would need to be
extended to be able talk to the Samba VFS to delete the file, so we merely
remove the stale delete-token and without deleting the file.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: add reset_delete_on_close_lck_open_id()
Ralph Boehme [Tue, 2 Dec 2025 14:12:18 +0000 (15:12 +0100)] 
s3/locking: add reset_delete_on_close_lck_open_id()

Factor out reset_delete_on_close_lck_internal() and then make the
existing reset_delete_on_close_lck() a wrapper around it.

No change in behaviour for reset_delete_on_close_lck().

reset_delete_on_close_lck_open_id() receives the open_persistent_id from the
smbXsrv_open_global.tdb as an additional parameter

A later commit will use reset_delete_on_close_lck_open_id() in the open
scavenging code to ensure the delete token is only removed if the open-id
matches.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoscavenger: ignore failures to remove lease
Ralph Boehme [Mon, 27 Oct 2025 15:15:30 +0000 (16:15 +0100)] 
scavenger: ignore failures to remove lease

Allows to add more cleanup code after the lease cleanup.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: add brlock_wipe()
Ralph Boehme [Wed, 29 Oct 2025 13:37:38 +0000 (14:37 +0100)] 
s3/locking: add brlock_wipe()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: add locking_wipe()
Ralph Boehme [Wed, 29 Oct 2025 13:33:57 +0000 (14:33 +0100)] 
s3/locking: add locking_wipe()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/lib: add g_lock_wipe()
Ralph Boehme [Wed, 29 Oct 2025 13:34:08 +0000 (14:34 +0100)] 
s3/lib: add g_lock_wipe()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: add smbXsrv_open_global_wipe()
Ralph Boehme [Wed, 29 Oct 2025 13:19:15 +0000 (14:19 +0100)] 
smbd: add smbXsrv_open_global_wipe()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agocleanupd: Persistent Handle cleanup
Ralph Boehme [Wed, 18 Sep 2019 00:13:20 +0000 (17:13 -0700)] 
cleanupd: Persistent Handle cleanup

This adds the logic to trigger scavending Persistent Handles from a few places:

- when we got the cluster exclusive ph-cleanup glock after starting
- when the current glock holder node died
- after an unclean process exit

This traverses the node local persistent smbXsrv_open_global_persistent.tdb
which is expected to be leightweight and fast.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: setup cleanupd *after* the scavenger
Ralph Boehme [Sun, 20 May 2018 16:47:37 +0000 (18:47 +0200)] 
smbd: setup cleanupd *after* the scavenger

This ensure the private scavenger state is initialized in the cleanupd
child which is used in scavegenger_schedule_disconnected().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: add smbXsrv_open_global_traverse_per_rec_persistent_read()
Ralph Boehme [Sun, 6 May 2018 06:49:33 +0000 (08:49 +0200)] 
smbd: add smbXsrv_open_global_traverse_per_rec_persistent_read()

This can be used to traverse persistent handles.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: notify scavenger of disconnected persistent handles in delay_for_oplock_fn()
Ralph Boehme [Sat, 30 Aug 2025 13:23:39 +0000 (15:23 +0200)] 
smbd: notify scavenger of disconnected persistent handles in delay_for_oplock_fn()

Adds an additional mechanism to trigger cleanup of possibly stale Persistent
Handle state.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: pass fsp to open_mode_check()
Ralph Boehme [Fri, 21 Mar 2025 14:28:58 +0000 (15:28 +0100)] 
smbd: pass fsp to open_mode_check()

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoscavenger: update cleanup_disconnected_share_mode_entry_fn() for Persistent Handles
Ralph Boehme [Thu, 20 Feb 2025 17:20:18 +0000 (18:20 +0100)] 
scavenger: update cleanup_disconnected_share_mode_entry_fn() for Persistent Handles

Also don't panic if the disconnected check fails, just log it.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoscavenger: update scavenger_add_timer() for Persistent Handles
Ralph Boehme [Tue, 25 Nov 2025 14:58:27 +0000 (15:58 +0100)] 
scavenger: update scavenger_add_timer() for Persistent Handles

With Persistent Handles global->disconnect_time might be 0 if a process or node
crashed and global->server_id won't be set to the special disconnected id.

Due to a race there might the open record might already be gone, so handle that
as well to still allow cleanup of locking.tdb and brlock.tdb records.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/brlock: update brlock cleanup for Persistent Handles
Ralph Boehme [Fri, 29 Aug 2025 13:44:16 +0000 (15:44 +0200)] 
s3/brlock: update brlock cleanup for Persistent Handles

Durable Handles don't allow byte-range locks from other opens on a file, but
Persistent Handles do allow this. Adapt brl_cleanup_disconnected() to
deal with locks from different handles.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/brlock: add brl_get_locks_for_cleanup()
Ralph Boehme [Tue, 17 Sep 2019 18:43:08 +0000 (11:43 -0700)] 
s3/brlock: add brl_get_locks_for_cleanup()

Takes the file_id to locate the brl record instead of an fsp. Prepares for being
called from the scavenger where we don't have fsps.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/brlock: add support for opening brlock.tdb with DBWRAP_FLAG_PER_REC_PERSISTENT
Ralph Boehme [Fri, 19 Jun 2026 13:15:14 +0000 (15:15 +0200)] 
s3/brlock: add support for opening brlock.tdb with DBWRAP_FLAG_PER_REC_PERSISTENT

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/brlock: implement reconnecting persistent byterange locks
Ralph Boehme [Sat, 6 Dec 2025 16:01:29 +0000 (17:01 +0100)] 
s3/brlock: implement reconnecting persistent byterange locks

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/brlock: handle persistent byterange locks in byte_range_lock_flush()
Ralph Boehme [Thu, 17 Jul 2025 10:52:22 +0000 (12:52 +0200)] 
s3/brlock: handle persistent byterange locks in byte_range_lock_flush()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: pass persistent to brl_lock() and add it to struct lock_struct
Ralph Boehme [Sat, 6 Dec 2025 15:58:24 +0000 (16:58 +0100)] 
s3/locking: pass persistent to brl_lock() and add it to struct lock_struct

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/brlock: avoid an else branch
Ralph Boehme [Thu, 19 Sep 2019 19:19:24 +0000 (12:19 -0700)] 
s3/brlock: avoid an else branch

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: adjust get_lease_type() for Persistent Handles
Ralph Boehme [Thu, 6 Nov 2025 13:40:41 +0000 (14:40 +0100)] 
smbd: adjust get_lease_type() for Persistent Handles

If the lease record was lost due to a node outage, just return
SMB2_LEASE_NONE. Note that e->protect will only be set to true for Persistent
Handles and if the handle is currently disconnected.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: use SMB2_LEASE_NONE in get_lease_type()
Ralph Boehme [Mon, 8 Dec 2025 15:49:14 +0000 (16:49 +0100)] 
smbd: use SMB2_LEASE_NONE in get_lease_type()

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: deal with Persistent Handles in close_directory()
Ralph Boehme [Wed, 1 Oct 2025 08:59:52 +0000 (10:59 +0200)] 
smbd: deal with Persistent Handles in close_directory()

Basically copying the logic from close_normal_file().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: pass private_flags to open_directory()
Ralph Boehme [Wed, 1 Oct 2025 08:33:47 +0000 (10:33 +0200)] 
smbd: pass private_flags to open_directory()

For now selectively filter NTCREATEX_FLAG_PERSISTENT_OPEN.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: factor out close_durable()
Ralph Boehme [Mon, 1 Dec 2025 17:27:29 +0000 (18:27 +0100)] 
smbd: factor out close_durable()

No change in behaviour. Will be used from close_directory() next.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: set persistent state to false in file_close_conn()
Ralph Boehme [Wed, 26 Feb 2025 16:58:00 +0000 (17:58 +0100)] 
smbd: set persistent state to false in file_close_conn()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: set persistent to false in close_normal_file()
Ralph Boehme [Mon, 31 Jul 2017 19:55:54 +0000 (21:55 +0200)] 
smbd: set persistent to false in close_normal_file()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoscavenger: pass individual args not fsp to scavenger_schedule_disconnected()
Ralph Boehme [Mon, 1 Dec 2025 17:03:46 +0000 (18:03 +0100)] 
scavenger: pass individual args not fsp to scavenger_schedule_disconnected()

In preperation of calling scavenger_schedule_disconnected() from a
function where we don't have an fsp.

Not having an fsp also means not having access to the open record via
fsp->op->global to fetch the timeout values. Hence in the scavenger in
scavenger_add_timer() we use smbXsrv_open_global_lookup() to fetch the open
record with the timeout values.

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: make smbXsrv_open_global_lookup() public
Ralph Boehme [Tue, 5 Aug 2025 17:06:39 +0000 (19:06 +0200)] 
smbd: make smbXsrv_open_global_lookup() public

The scavenger needs this to fetch the record from smbXsrv_open_global.tdb.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agoscavenger: prepare cleaning up stale delete-on-close tokens in the scavenger
Ralph Boehme [Sat, 6 Dec 2025 16:37:35 +0000 (17:37 +0100)] 
scavenger: prepare cleaning up stale delete-on-close tokens in the scavenger

Pass the fsp->name_hash to the scavenger and down to
share_mode_cleanup_disconnected().

Not yet used.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: restrict pure R leases on directories on CA shares
Ralph Boehme [Fri, 28 Nov 2025 11:12:52 +0000 (12:12 +0100)] 
smbd: restrict pure R leases on directories on CA shares

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: apply leases restriction from tcon->smb_max_lease_mask
Ralph Boehme [Wed, 18 Sep 2019 19:11:36 +0000 (12:11 -0700)] 
smbd: apply leases restriction from tcon->smb_max_lease_mask

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: restrict leases on CA and SO shares when filling tcon->smb_max_lease_mask
Ralph Boehme [Sun, 30 Nov 2025 14:31:10 +0000 (15:31 +0100)] 
smbd: restrict leases on CA and SO shares when filling tcon->smb_max_lease_mask

This adds the following paremetric options

  smb3 ca:max lease mask = RWH (default:R, set to RWH in selftest on testshare)

  smb3 ca so:max lease mask = RWH (default:R)

For now keep them as "internal" undocumented parametric options. If we learn
about real world usecases in the future, we can then look into turning them into
documented options.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: checking for disconnected Persistent Handles
Ralph Boehme [Sat, 6 Dec 2025 15:26:17 +0000 (16:26 +0100)] 
smbd: checking for disconnected Persistent Handles

The core of blocking access to disconnect Persistent Handles:

  MS-SMB2 3.3.5.9 Receiving an SMB2 CREATE Request:

  If Connection.Dialect belongs to the SMB 3.x dialect family and the request
  does not contain SMB2_CREATE_DURABLE_HANDLE_RECONNECT Create Context or
  SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 Create Context, the server MUST look
  up an existing open in the GlobalOpenTable where Open.FileName matches the
  file name in the Buffer field of the request. If an Open entry is found, and
  if all the following conditions are satisfied, the server SHOULD<300> fail the
  request with STATUS_FILE_NOT_AVAILABLE:

  - Open.IsPersistent is TRUE
  - Open.Connection is NULL

If the disconnected handle has an H lease (or WH lease in case the file has
byterange locks), and the contending open triggers a lease break, we have to
"save" the lease break until the handle is reconnected.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: reorder send_break_message() in delay_for_oplock_fn()
Ralph Boehme [Tue, 28 Oct 2025 18:11:33 +0000 (19:11 +0100)] 
smbd: reorder send_break_message() in delay_for_oplock_fn()

No change in behaviour, reduces the diff of the subsequent commit.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: tweak process_oplock_break_message() to support saved lease breaks
Ralph Boehme [Sun, 31 Aug 2025 11:40:27 +0000 (13:40 +0200)] 
smbd: tweak process_oplock_break_message() to support saved lease breaks

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: add and fill CreateGuid in struct smbd_smb2_request
Ralph Boehme [Mon, 19 May 2025 10:59:24 +0000 (12:59 +0200)] 
smbd: add and fill CreateGuid in struct smbd_smb2_request

This will get stored in the share_mode_entry and is used as part of Persistent
Handle reconnect.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: add support for opening locking.tdb with DBWRAP_FLAG_PER_REC_PERSISTENT
Ralph Boehme [Sat, 18 Nov 2017 14:50:53 +0000 (15:50 +0100)] 
s3/locking: add support for opening locking.tdb with DBWRAP_FLAG_PER_REC_PERSISTENT

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: get rid of fsp arg to reset_delete_on_close_lck()
Ralph Boehme [Mon, 1 Dec 2025 16:41:16 +0000 (17:41 +0100)] 
smbd: get rid of fsp arg to reset_delete_on_close_lck()

We need reset_delete_on_close_lck() to be callable from the scavenger who
doesn't have any fsp's.

No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: deal with Persistent Handles in share_mode_forall_entries()
Ralph Boehme [Sun, 3 Aug 2025 10:54:59 +0000 (12:54 +0200)] 
s3/locking: deal with Persistent Handles in share_mode_forall_entries()

Handle deleting a Persistent Handle.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: use DBWRAP_STORE_PERSISTENT in share_mode_data_ltdb_store()
Ralph Boehme [Tue, 17 Sep 2019 02:53:43 +0000 (19:53 -0700)] 
s3/locking: use DBWRAP_STORE_PERSISTENT in share_mode_data_ltdb_store()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: prepare set_share_mode() for Persistent Handles
Ralph Boehme [Thu, 20 Feb 2025 15:21:55 +0000 (16:21 +0100)] 
s3/locking: prepare set_share_mode() for Persistent Handles

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: prepare del_share_mode_open_id() for Persistent Handles
Ralph Boehme [Fri, 14 Mar 2025 18:59:46 +0000 (19:59 +0100)] 
s3/locking: prepare del_share_mode_open_id() for Persistent Handles

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: add flags to locking_tdb_data_store()
Ralph Boehme [Tue, 17 Sep 2019 02:53:43 +0000 (19:53 -0700)] 
s3/locking: add flags to locking_tdb_data_store()

Needed to pass DBWRAP_[STORE|DROP]_PERSISTENT through the layers.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: add flags to share_mode_g_lock_writev()
Ralph Boehme [Wed, 19 Feb 2025 16:18:22 +0000 (17:18 +0100)] 
s3/locking: add flags to share_mode_g_lock_writev()

Needed to pass DBWRAP_[STORE|DROP]_PERSISTENT through the layers.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: update share_entry_stale_pid() check for Persistent Handles
Ralph Boehme [Tue, 17 Sep 2019 16:47:52 +0000 (09:47 -0700)] 
s3/locking: update share_entry_stale_pid() check for Persistent Handles

Disconnected Persistent Handles are NOT "stale" and must be preserved. But while
we're at it to check if the handle is connected or not, remember this
information so we can check this later in the open code.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agos3/locking: map between fsp->op->global->persistent and SHARE_ENTRY_FLAG_PERSISTENT_OPEN
Ralph Boehme [Tue, 7 Oct 2025 16:41:26 +0000 (18:41 +0200)] 
s3/locking: map between fsp->op->global->persistent and SHARE_ENTRY_FLAG_PERSISTENT_OPEN

This marks a share_mode_entry as a Persistent Handle.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agosmbd: add and use NTCREATEX_FLAG_PERSISTENT_OPEN
Ralph Boehme [Tue, 7 Oct 2025 16:40:32 +0000 (18:40 +0200)] 
smbd: add and use NTCREATEX_FLAG_PERSISTENT_OPEN

This will be used by the SMB2-CREATE code to request a Persistent Handle from
SMB_VFS_CREATE_FILE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agovfs_default: update vfs_default_durable_reconnect_lease() for PHs
Ralph Boehme [Wed, 3 Dec 2025 06:47:37 +0000 (07:47 +0100)] 
vfs_default: update vfs_default_durable_reconnect_lease() for PHs

Heavily commented the code hence keeping the commit message short. :)

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agovfs_default: check for missing lease create context
Ralph Boehme [Fri, 19 Jun 2026 12:01:01 +0000 (14:01 +0200)] 
vfs_default: check for missing lease create context

MS-SMB2: 3.3.5.9.7 Handling the SMB2_CREATE_DURABLE_HANDLE_RECONNECT Create
Context tells us:

...

If any of the following conditions is TRUE, the server MUST fail the request
with STATUS_OBJECT_NAME_NOT_FOUND:

- Open.Lease is not NULL and the SMB2_CREATE_REQUEST_LEASE_V2 or the
  SMB2_CREATE_REQUEST_LEASE create context is not present.

...

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agovfs_default: factor out vfs_default_durable_reconnect_lease()
Ralph Boehme [Tue, 2 Dec 2025 19:09:03 +0000 (20:09 +0100)] 
vfs_default: factor out vfs_default_durable_reconnect_lease()

Also call vfs_default_durable_reconnect_lease() after updating the
share_mode_entry. No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agovfs_default: ensure e.pid is current in vfs_default_durable_reconnect_fn()
Ralph Boehme [Tue, 2 Dec 2025 19:14:20 +0000 (20:14 +0100)] 
vfs_default: ensure e.pid is current in vfs_default_durable_reconnect_fn()

We need the uptodate value in e.pid when we make use of e later.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agovfs_default: initialize lease in the vfs_default_durable_reconnect_state
Ralph Boehme [Tue, 2 Dec 2025 19:00:32 +0000 (20:00 +0100)] 
vfs_default: initialize lease in the vfs_default_durable_reconnect_state

vfs_default_durable_reconnect_fn() needs it.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agovfs_default: remove redundant checks
Ralph Boehme [Tue, 2 Dec 2025 18:58:41 +0000 (19:58 +0100)] 
vfs_default: remove redundant checks

This stuff has already been checked by share_mode_entry_durable_reconnect_fn().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agovfs_default: adapt share_mode_entry_durable_reconnect_fn() for Persistent Handles
Ralph Boehme [Tue, 2 Dec 2025 18:49:01 +0000 (19:49 +0100)] 
vfs_default: adapt share_mode_entry_durable_reconnect_fn() for Persistent Handles

Additionally check the create_guid. We could also do this for Durable Handles
v2 if we wanted to.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agovfs_default: rename durable_reconnect_fn() to share_mode_entry_durable_reconnect_cb()
Ralph Boehme [Tue, 2 Jun 2026 06:06:46 +0000 (08:06 +0200)] 
vfs_default: rename durable_reconnect_fn() to share_mode_entry_durable_reconnect_cb()

Currently we have

  vfs_default_durable_reconnect_fn()

and

  durable_reconnect_fn

which can be a bit confusing when reading the code for the first time (or even
multiple times...).

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
9 hours agovfs_default: skip checking stat info from the cookie for Persistent Handles
Ralph Boehme [Tue, 2 Dec 2025 18:47:17 +0000 (19:47 +0100)] 
vfs_default: skip checking stat info from the cookie for Persistent Handles

As we can't reliably update the stat info in the cookie in the disconnect
handler, we have to skip these checks for Persistent Handles.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>