summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_shadow_copy.c
AgeCommit message (Collapse)AuthorFilesLines
2025-11-10lib: Introduce cp_smb_basename() helper functionVolker Lendecke1-6/+2
I always had to look up the sequence of NULLs and 0s. Save lines. 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): Mon Nov 10 14:33:28 UTC 2025 on atb-devel-224
2025-11-10vfs: Fix trailing whitespaceVolker Lendecke1-8/+8
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org>
2025-09-06s3:shadow_copy: CID 1449539 talloc_realloc and error handlingShwetha K Acharya1-9/+14
- Replace TALLOC_REALLOC with talloc_realloc inorder to handle the integer overflow better. - Rename tlabels as tmp_labels for clarity. - Use shadow_copy_data->labels directly after successful reallocation instead of relying on a temporary variable. - Ensure that shadow_copy_data->num_volumes is set to 0 and shadow_copy_data->labels is freed on error paths inorder to address the potential resource leaks. Fixes: CID_1449539 Signed-off-by: Shwetha K Acharya <Shwetha.K.Acharya@ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org> Autobuild-User(master): Anoop C S <anoopcs@samba.org> Autobuild-Date(master): Sat Sep 6 10:34:27 UTC 2025 on atb-devel-224
2025-05-15lib: Save lines by avoiding explicit ZERO_STRUCTP callsVolker Lendecke1-3/+1
SMB_CALLOC_ARRAY(..., 1) does this. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-12-19smbd: Give source3/smbd/dir.c its own header fileVolker Lendecke1-0/+1
The prototypes were spread across 3 different files. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
2023-06-23vfs: Remove "sbuf" from readdir_fn()Volker Lendecke1-3/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Jun 23 18:29:40 UTC 2023 on atb-devel-224
2023-06-23smbd: Remove unused "sbuf" argument from ReadDirName()Volker Lendecke1-1/+1
Nobody used that anymore, most callers had passed in NULL anyway. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2023-06-14vfs: Remove vfs telldir/seekdir functionsVolker Lendecke1-17/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Jun 14 00:26:55 UTC 2023 on atb-devel-224
2023-06-13smbd: Remove the offset argument from ReadDirName()Volker Lendecke1-2/+1
Nobody does anything with this anymore, we just call ReadDirName() in sequence or do a RewindDir(). So we don't have to look at offsets as given by the file system anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2022-03-02s3: smbd: Rename OpenDir_ntstatus() -> OpenDir().Jeremy Allison1-6/+6
We now have a single OpenDir() function that returns an NTSTATUS. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Wed Mar 2 21:58:32 UTC 2022 on sn-devel-184
2022-03-02s3: VFS: shadow_copy: Move one more use of OpenDir() -> OpenDir_nstatus().Jeremy Allison1-2/+9
Eventually we can replace OpenDir() with OpenDir_ntatatus(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2020-12-16vfs: Add dirfsp arg to SMB_VFS_READDIR()Ralph Boehme1-3/+4
This allows for optimisations in VFS module: by passing the dirfsp as an additional arg, the function can check fsp->fsp_name->flags which may include eg SMB_FILENAME_POSIX_PATH to trigger POSIX pathname processing. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16smbd: use fsp_set_fd()Ralph Boehme1-2/+2
No change in behaviour. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-06-21vfs_shadow_copy: Fix a log messageAnoop C S1-2/+1
Signed-off-by: Anoop C S <anoopcs@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-05smbd: add twrp arg to synthetic_smb_fname()Ralph Boehme1-0/+1
Most places take twrp from a local struct smb_filename variable that the function is working on. Some don't for various reasons: o synthetic_smb_fname_split() is only called in very few places where we don't expect twrp paths o implementations of SMB_VFS_GETWD(), SMB_VFS_FS_CAPABILITIES() and SMB_VFS_REALPATH() return the systems view of cwd and realpath without twrp info o VFS modules implementing previous-versions support (vfs_ceph_snapshots, vfs_shadow_copy2, vfs_snapper) synthesize raw paths that are passed to VFS NEXT functions and therefor do not use twrp o vfs_fruit: macOS doesn't support VSS o vfs_recycle: in recycle_create_dir() we need a raw OS path to create a directory o vfs_virusfilter: a few places where we need raw OS paths o vfs_xattr_tdb: needs a raw OS path for SMB_VFS_NEXT_STAT() o printing and rpc server: don't support VSS o vfs_default_durable_reconnect: no Durable Handles on VSS handles, this might be enhances in the future. No idea if Windows supports this. o get_real_filename_full_scan: hm.... FIXME?? o get_original_lcomp: working on a raw path o msdfs: doesn't support VSS o vfs_get_ntquota: synthesizes an smb_filename from ".", so doesn't support VSS even though VFS modules implement it o fd_open: conn_rootdir_fname is a raw path o msg_file_was_renamed: obvious o open_np_file: pipes don't support VSS o Python bindings: get's a raw path from the caller o set_conn_connectpath: raw path o set_conn_connectpath: raw path o torture: gets raw paths from the caller Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-24vfs: remove SMB_VFS_OPENDIR()Ralph Boehme1-53/+0
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Mar 24 21:23:43 UTC 2020 on sn-devel-184
2020-03-24vfs_shadow_copy: use OpenDir() in shadow_copy_get_shadow_copy_data()Ralph Boehme1-20/+25
Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2017-12-18vfs: Use static_decl_vfs in all VFS modulesChristof Schmitt1-1/+1
Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Mon Dec 18 13:32:00 CET 2017 on sn-devel-144
2017-04-22lib: modules: Change XXX_init interface from XXX_init(void) to ↵Jeremy Allison1-2/+2
XXX_init(TALLOC_CTX *) Not currently used - no logic changes inside. This will make it possible to pass down a long-lived talloc context from the loading function for modules to use instead of having them internally all use talloc_autofree_context() which is a hidden global. Updated all known module interface numbers, and added a WHATSNEW. Signed-off-by: Jeremy Allison <jra@samba.org> Signed-off-by: Ralph Böhme <slow@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Apr 22 01:17:00 CEST 2017 on sn-devel-144
2017-02-10shadow_copy_get_shadow_copy_data: fix GCC snprintf warningDouglas Bagnall1-1/+10
GCC 7 warns about snprintf truncating a dirent d_name (potentially 255 bytes) to 25 bytes, even though we have checked that it is 25 long in shadow_copy_match_name(). Using strlcpy instead of snprintf lets us check it again, JUST TO BE SURE. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-03-24s3: Filenames: Add uint32_t flags parameter to synthetic_smb_fname().Jeremy Allison1-1/+2
Get it from parent/deriving smb_filename if present. Use 0 (as usually this a Windows-style lookup) if not. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
2016-03-01VFS: Modify opendir to take a const struct smb_filename * instead of const ↵Jeremy Allison1-4/+21
char * Preparing to reduce use of lp_posix_pathnames(). Uses the same techniques as commit 616d068f0cebb8e50a855b6e30f36fccb7f5a3c8 (synthetic_smb_fname()) to cope with modules that modify the incoming pathname. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2015-05-01Convert uint32/16/8 to _t for the last two include files in source3/include.Richard Sharpe1-2/+2
There are still many files to touch before we can remove the #define but this gets the last include files in source3/includes. Signed-off-by: Richard Sharpe <rsharpe@samba.org> Reviewed-by: Jeremy Allson <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri May 1 21:52:25 CEST 2015 on sn-devel-104
2012-04-05build: Remove SMB_STRUCT_DIR defineAndrew Bartlett1-12/+12
2012-04-05build: Remove SMB_STRUCT_DIRENT defineAndrew Bartlett1-7/+7
2011-12-12vfs: Make function pointer names consistent. They all end in _fnRichard Sharpe1-8/+8
Autobuild-User: Richard Sharpe <sharpe@samba.org> Autobuild-Date: Mon Dec 12 04:58:40 CET 2011 on sn-devel-104
2011-05-31struct make "struct shadow_copy_data" its own talloc contextVolker Lendecke1-1/+1
2011-05-31s3: Remove SHADOW_COPY_DATA typedefVolker Lendecke1-1/+4
2011-03-30s3: only include ntioctl.h where needed.Günther Deschner1-0/+1
Guenther
2011-03-30s3-vfs: include smbd/smbd.h in vfs modules.Günther Deschner1-0/+1
Guenther
2011-02-09Add fdopendir to the VFS. We will use this to reuse a directory fd already ↵Jeremy Allison1-0/+53
open by NtCreateX. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Wed Feb 9 00:55:22 CET 2011 on sn-devel-104
2009-07-24Make the smbd VFS typesafeVolker Lendecke1-15/+13
2009-02-09Add an optional SMB_STRUCT_SMB parameter to VFS_OP_READDIRSteven Danneman1-2/+2
* this allows VFS implementations that prefetch stat information on readdir to return it through one VFS call * backwards compatibility is maintained by passing in NULL * if the system readdir doesn't return stat info, the stat struct is set to invalid
2007-10-18RIP BOOL. Convert BOOL -> bool. I found a few interestingJeremy Allison1-2/+2
bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f)
2007-10-10r23801: The FSF has moved around a lot. This fixes their Mass Ave address.Andrew Tridgell1-2/+1
(This used to be commit 87c91e4362c51819032bfbebbb273c52e203b227)
2007-10-10r23779: Change from v2 or later to v3 or later.Jeremy Allison1-1/+1
Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3)
2007-10-10r20261: merge 20260 from samba_3_0_24Herb Lewis1-2/+3
clean up a bunch of no previous prototype warnings (This used to be commit c60687db112405262adf26dbf267804b04074e67)
2007-10-10r16945: Sync trunk -> 3.0 for 3.0.24 code. Still needJeremy Allison1-14/+14
to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8)
2007-10-10r13915: Fixed a very interesting class of realloc() bugs found by Coverity.Jeremy Allison1-5/+2
realloc can return NULL in one of two cases - (1) the realloc failed, (2) realloc succeeded but the new size requested was zero, in which case this is identical to a free() call. The error paths dealing with these two cases should be different, but mostly weren't. Secondly the standard idiom for dealing with realloc when you know the new size is non-zero is the following : tmp = realloc(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } However, there were *many* *many* places in Samba where we were using the old (broken) idiom of : p = realloc(p, size) if (!p) { return error; } which will leak the memory pointed to by p on realloc fail. This commit (hopefully) fixes all these cases by moving to a standard idiom of : p = SMB_REALLOC(p, size) if (!p) { return error; } Where if the realloc returns null due to the realloc failing or size == 0 we *guarentee* that the storage pointed to by p has been freed. This allows me to remove a lot of code that was dealing with the standard (more verbose) method that required a tmp pointer. This is almost always what you want. When a realloc fails you never usually want the old memory, you want to free it and get into your error processing asap. For the 11 remaining cases where we really do need to keep the old pointer I have invented the new macro SMB_REALLOC_KEEP_OLD_ON_ERROR, which can be used as follows : tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size); if (!tmp) { SAFE_FREE(p); return error; } else { p = tmp; } SMB_REALLOC_KEEP_OLD_ON_ERROR guarentees never to free the pointer p, even on size == 0 or realloc fail. All this is done by a hidden extra argument to Realloc(), BOOL free_old_on_error which is set appropriately by the SMB_REALLOC and SMB_REALLOC_KEEP_OLD_ON_ERROR macros (and their array counterparts). It remains to be seen what this will do to our Coverity bug count :-). Jeremy. (This used to be commit 1d710d06a214f3f1740e80e0bffd6aab44aac2b0)
2007-10-10r9483: Changed DIR to SMB_STRUCT_DIR because of the amazing stupidity of a ↵Jeremy Allison1-9/+9
UNIX vendor not understanding abstract data types :-(. Jeremy. (This used to be commit be5b4e2fa3ed30b0ff01b47d2354e5f782a12e25)
2007-10-10r7893: Add in the extra parameters to opendir() to fix the large ↵Jeremy Allison1-3/+3
directory/insane app problem. Rev vfs version. Doesn't change the normal codepath. Jeremy. (This used to be commit 0f03a6bdcdbdf60da81e0aeffa84ac6e48fc6a04)
2007-10-10r7541: Patch from core@road-star.jp for bug #2792. Ensure the shadow copyJeremy Allison1-0/+24
module hooks seekdir, telldir, rewinddir to match updated large directory code. Jeremy. (This used to be commit 0cdc62b60b6152cb67e517d70f4e4681dca8f4df)
2007-10-10r4738: Fix for bug #2238 - memory leak in shadow copy vfs.Jeremy Allison1-0/+1
Jeremy. (This used to be commit fb7f1aff7c96e4672641f80b74a058abf25d0d6d)
2007-10-10r4088: Get medieval on our ass about malloc.... :-). Take control of all our ↵Jeremy Allison1-3/+3
allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a)
2007-10-10r3671: More warning fixes from Rob Foehl <rwf@loonybin.net>.Jeremy Allison1-6/+6
Jeremy. (This used to be commit 3850f142c174034397451de8457564b9604113c5)
2007-10-10r329: add the shadow_copy vfs moduleStefan Metzmacher1-0/+227
I'll add documentation to the Samba-Howto-Collection metze (This used to be commit 2bef5d2741807fe3f38a95710533520700e253a4)