summaryrefslogtreecommitdiff
path: root/source3/smbd
AgeCommit message (Collapse)AuthorFilesLines
2026-04-20smbdotconf: Add "automount fs types" to smb.confPavel Filipenský1-0/+31
This adds a new global parameter "automount fs types" that allows administrators to configure additional filesystem types that should trigger automounting, beyond the always-supported autofs filesystem. To enable 'samba unaware FS' automounting, add: automount fs types = 0x12345678 This allows e.g. ZFS snapshots in <dataset root>/.zfs/snapshot to be mounted. To find out the magic number that is not listed in /usr/include/linux/magic.h, run: stat -f -c '0x%t' /path/to/mountpoint BUG: https://bugzilla.samba.org/show_bug.cgi?id=15991 Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Samuel Cabrero <scabrero@samba.org> Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org> Autobuild-Date(master): Mon Apr 20 19:57:42 UTC 2026 on atb-devel-224
2026-04-16smbd: handle synthetic_smb_fname failure properly in delete_all_streamsShachar Sharon1-1/+1
When 'synthetic_smb_fname' fails due to memory error, it returns NULL. Fix this error-case logic in 'delete_all_streams'. Signed-off-by: Shachar Sharon <ssharon@redhat.com> Reviewed-by: Anoop C S <anoopcs@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Anoop C S <anoopcs@samba.org> Autobuild-Date(master): Thu Apr 16 13:48:23 UTC 2026 on atb-devel-224
2026-04-14s3:smbd: guard lp_killservice() in delete_and_reload_printers() with ↵Jeremy Allison1-1/+2
connections_snum_used check delete_and_reload_printers() unconditionally calls lp_killservice() to destroy autoloaded printer services that are no longer in the printer list. If any active connection is still using the printer service number, the destroyed service can cause a NULL pointer dereference on subsequent requests. Guard the call with connections_snum_used() so the service is only freed when no connections are using it. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14978 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Mulder <dmulder@samba.org>
2026-04-14s3:loadparm: add lp_register_snum_in_use_fn() callback registrationJeremy Allison1-0/+1
Add a mechanism for smbd to register a callback that checks whether a service number is currently in use by any active connection. This will be used by subsequent commits to guard free_service_byindex() calls in lp_servicenumber() and other sites that currently destroy services without checking if they are in use, which can leave active connections holding stale service numbers that lead to NULL pointer dereferences. The callback is registered by smbd during smbd_process() startup via connections_snum_used. Non-smbd programs (testparm, net, etc.) leave the callback as NULL, meaning no connections exist and it is always safe to free services. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14978 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Mulder <dmulder@samba.org>
2026-04-08s3:smb2_server: failing lease/oplock breaks should call ↵Stefan Metzmacher1-1/+36
smbd_server_connection_terminate() If there's a problem sending a lease break we need to call smbd_server_connection_terminate(xconn). Currently we only called smbXsrv_connection_disconnect_transport(), which only closes the low level socket, but it doesn't cleanup smbXsrv_connection and in case of the last connection for the smbXsrv_client, so we leave the stale structures and the stale process behind. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15995 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2026-03-10smbd: update declaration in smb2_sesssetup, smb2_tconShwetha Acharya2-8/+4
Signed-off-by: Shwetha K Acharya <Shwetha.K.Acharya@ibm.com> Reviewed-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Shweta Sodani <ssodani@redhat.com> Reviewed-by: Xavi Hernandez <xhernandez@redhat.com> Reviewed-by: Guenther Deschner <gd@samba.org> Autobuild-User(master): Günther Deschner <gd@samba.org> Autobuild-Date(master): Tue Mar 10 13:01:10 UTC 2026 on atb-devel-224
2026-03-10smbd: Log client ip when rejecting nonencrypted tconsVolker Lendecke1-3/+13
Used for better diagnosis Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Shweta Sodani <ssodani@redhat.com> Reviewed-by: Xavi Hernandez <xhernandez@redhat.com> Reviewed-by: Guenther Deschner <gd@samba.org>
2026-03-10smbd: Log client ip when rejecting nonencrypted sesssetupsVolker Lendecke1-3/+12
Used for better diagnosis Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Shweta Sodani <ssodani@redhat.com> Reviewed-by: Xavi Hernandez <xhernandez@redhat.com> Reviewed-by: Guenther Deschner <gd@samba.org>
2026-03-04smbd: Fix getting fs capabilitiesVolker Lendecke1-18/+12
The change from statvfs to fstatvfs has a bug: When this is called in make_connection_snum, conn->cwd_fsp is not fully set up yet. So the "This happens in create_conn_struct_as_root()" comment applies everywhere. We need to look at the share rootdir, so open a pathref fsp on it. This is called only once per tcon, so it's not in our hot code path. Found by a user who has "/" mounted readonly, and MacOS denied writing. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Mar 4 10:01:41 UTC 2026 on atb-devel-224
2026-03-01vfs: Remove unused SMB_VFS_GETWD()Volker Lendecke1-7/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Sun Mar 1 21:22:24 UTC 2026 on atb-devel-224
2026-03-01vfs: Remove callers of SMB_VFS_GETWD()Volker Lendecke2-13/+2
We don't chdir() arbitrarily. We can reference conn->connectpath instead. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01vfs: Significantly simplify vfs_ChDir_shareroot()Volker Lendecke8-193/+15
Now that we are sure we don't chdir to arbitrary paths, and nobody except vfs_ChDir_shareroot() calls vfs_GetWd() anymore, we can get rid of the getwd cache and replace the LastDir-check with a simple if (conn == chdir_lastconn_cache) { return 0; } The places where we reset LastDir to NULL, forcing a real chdir, are replaced by a call to reset_chdir_lastconn_cache(). Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01vfs: A connectpath is never "."Volker Lendecke1-29/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01vfs: Inline vfs_ChDir() into vfs_ChDir_shareroot()Volker Lendecke1-17/+10
vfs_ChDir_shareroot() was the only caller of vfs_ChDir() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Make vfs_GetWd() static to vfs.cVolker Lendecke2-2/+4
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Inline print_impersonation_info()Volker Lendecke1-22/+7
With the fact that we only chdir() to the share root, we can directly print conn->connectpath and avoid a call to vfs_GetWd() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Make vfs_ChDir() staticVolker Lendecke2-3/+2
This makes it clear that we only ever chdir() to the root of a share. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Avoid the VFS' chdir() call in close_cnum()Volker Lendecke1-3/+2
The purpose of this call here is to make a file system unmountable. For shares backed by a local file system, a direct chdir(2) syscall to "/" will achieve the same, and shares like cephfs backed by libraries without a local mount will not be affected anyway. For them, a VFS level chdir("/") relative to a connection does not make much sense anyway. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Remove unused create_conn_struct_tos()Volker Lendecke2-57/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Remove unused create_conn_struct_tos_cwd()Volker Lendecke2-68/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Call create_conn_struct_chdir() in get_referred_path()Volker Lendecke1-7/+8
create_conn_struct_tos_cwd() provides an attempt to chdir() back to where we came from. This is flawed, because SMB_VFS_CHDIR() is always relative to a connection, and conn_struct_tos_destructor() calls vfs_ChDir() on the fake connection, not the one we came from. Remove the flawed attempt to chdir() back in get_referred_path(). The one caller in vfswrap_get_dfs_referrals() changes back to the "real" connection that issued the dfs call from SMB, and the RPC server callers don't care. They rely on the chdir("/") in conn_wrap_destructor(). This adds one chdir("/") in smbd's "get referral" calls, but those should be rare enough not to cause performance problems. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01pysmbd: Use create_conn_struct_chdir()Volker Lendecke1-26/+46
pysmbd is the one user of fake connection_structs that depends on not changing to "/" after the connection has been torn down. Add special handling here. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Remove unused create_conn_struct_cwd()Volker Lendecke2-33/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Add create_conn_struct_chdir()Volker Lendecke2-0/+75
This is supposed to replace create_conn_struct_tos() in the next patches. Stay tuned... Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Leave sconn->ev_ctx as NULL for internal fake connectionsVolker Lendecke2-31/+15
These connection_structs are only there to access files like msdfs symlinks or printer driver files. They will never participate in async processing like sending out events or getting delayed for oplocks. Any such use is a bug, because if you look at create_conn_struct_tos() we create an event context that we will never poll on, so events posted there will never finish. Leave the ev_ctx NULL so that we get an early crash instead of running into problems later. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Remove a pointless TALLOC_FREE()Volker Lendecke1-1/+0
This hangs off "c" anyway Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01smbd: Add vfs_ChDir_shareroot() wrapperVolker Lendecke4-11/+15
Clarify where we just change to the root of the export. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01rpc_server: Move dfs helper routines to srv_dfs_nt.cVolker Lendecke2-537/+13
This makes it clear that these callers of create_conn_struct_tos_cwd() don't really need to chdir() back to whatever cwd the process was in before. RPC servers don't really have a concept of "implicit" current working directory that is assumed to be the root dir of the current share. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-03-01s3/smbd: Convert smbd_do_qfsinfo() to use PUSH_LE_U64Anoop C S1-26/+28
Signed-off-by: Anoop C S <anoopcs@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2026-02-25smbd: Avoid a pointless if-statementVolker Lendecke1-3/+1
All you can read in optimizing guides is that branches are expensive... Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2026-02-25smbd: Introduce helper vars in SMB_QUERY_POSIX_WHOAMIVolker Lendecke1-34/+31
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
2026-02-15smbd: Modernize a DEBUGVolker Lendecke1-2/+5
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: Simplify smbd_do_qfsinfo()Volker Lendecke4-25/+3
We can rely on fsp now, avoid passing and using fname Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: smbd_do_qfsinfo() can rely on an fsp now, use fsp's stat infoVolker Lendecke1-1/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15vfs: Add "fsp" to SMB_VFS_SET_QUOTAVolker Lendecke2-3/+5
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15vfs: Change SMB_VFS_GET_QUOTA to take a fsp instead of a nameVolker Lendecke3-21/+22
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: Make disk_quotas() take a fspVolker Lendecke3-9/+23
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15vfs: Remove SMB_VFS_STATVFSVolker Lendecke1-7/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: Call FSTATVFS instead of STATVFSVolker Lendecke2-11/+21
To get the fs capabilities we do an openat_pathref_fsp_dot(), which also avoids a call to SMB_VFS_STAT there. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15vfs: Add SMB_VFS_FSTATVFSVolker Lendecke1-0/+8
To replace SMB_VFS_STATVFS next Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15lib: Move statvfs.[ch] to lib/utilVolker Lendecke4-317/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: Give statvfs.c its own header fileVolker Lendecke5-7/+63
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: Add sys_fstatvfs()Volker Lendecke2-0/+50
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: Factor out initializing vfs_statvfs_struct from system infoVolker Lendecke1-50/+70
Patch is a bit confusing due to all the #ifdefs, but it's just some code shuffling to prepare for the next patch. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15vfs: Change SMB_VFS_DISK_FREE to take a fspVolker Lendecke2-6/+4
The modules that change the pathname need a synthetic_pathref now for the SMB_VFS_NEXT_DISK_FREE() call. I think this is the right thing to do anyway, as this goes through all the path scrutiny and does not depend on direct multi-component paths anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: Make sys_disk_free() take a fspVolker Lendecke1-4/+5
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: Make get_dfree_info() take a fspVolker Lendecke5-13/+15
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd: Use fsp->fsp_name in smbd_do_qfsinfo()Volker Lendecke1-6/+6
Both callers pass an fsp now, use that for get_dfree_info() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd/smb1: Open a pathref's fsp_name to get_dfree_info()Volker Lendecke1-8/+11
Preparation for converting get_dfree_info() to directly take a fsp. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2026-02-15smbd/smb1: send pathref fsp of share root to smbd_do_qfsinfoVolker Lendecke2-6/+21
The other caller of this already passes one. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>