[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Thu Apr 28 14:03:01 UTC 2022


The branch, master has been updated
       via  922261d77ae smbd: Use filename_convert_dirfsp() in smbd_smb2_create_send()
       via  5efa2ddde32 smbd: Use filename_convert_dirfsp() in reply_ntcreate_and_X()
       via  fde4363f589 smbd: Add filename_convert_dirfsp()
       via  29fa2f51c36 smbd: Only create an artificial dirfsp when necessary
       via  c1a3104a2ab smbd: Pass dirfsp to create_file_unixpath()
       via  eb3c47ac330 CI: use native Python functions to detect system and release
       via  6086a73f4e5 Revert "vfs: remove dirfsp arg from SMB_VFS_CREATE_FILE()"
       via  de9986fb9b7 vfs: Remove name-based SMB_VFS_GET_REAL_FILENAME()
       via  89bffa149dd smbd: Use SMB_VFS_GET_REAL_FILENAME_AT() in dptr_ReadDirName()
       via  2c05ebe9736 vfs: Implement snapper_gmt_get_real_filename_at()
       via  2e1d2083f54 vfs: Implement shadow_copy2_get_real_filename_at()
       via  b21cd4c8d21 vfs: Implement vfs_gpfs_get_real_filename_at()
       via  5aca0056abf vfs: Implement vfs_gluster_get_real_filename_at()
       via  ba6f7cfe805 vfs: Implement vfs_gluster_fuse_get_real_filename_at()
       via  cf60c51dc0d vfs: Implement ceph_snap_gmt_get_real_filename_at()
       via  c4d4fa68d61 smbd: Add get_real_filename_at()
       via  dcdc2585095 smbd: Introduce get_real_filename_full_scan_at()
       via  973212e8c11 smbd: Add OpenDir_from_pathref
       via  df29512b72f smbd: Add openat_internal_dir_from_pathref()
       via  02f6130c907 vfs: Add SMB_VFS_GET_REAL_FILENAME_AT
       via  804a19ca5d6 smbd: Pass up stat-info from openat_pathref_fsp() on error
      from  03d0dd2651c vfs_gpfs: Ignore pathref fds for gpfs:recalls check

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 922261d77ae9190aada81e97ce8a41c5306acd9c
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 8 13:27:39 2022 +0200

    smbd: Use filename_convert_dirfsp() in smbd_smb2_create_send()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Thu Apr 28 14:02:53 UTC 2022 on sn-devel-184

commit 5efa2ddde3231b389111b57e99b0ccff338ac609
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 8 13:27:20 2022 +0200

    smbd: Use filename_convert_dirfsp() in reply_ntcreate_and_X()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit fde4363f589d5ac47aba5ad63e964d42006565d5
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Dec 8 07:08:10 2021 +0100

    smbd: Add filename_convert_dirfsp()
    
    As part of the filename_convert() process, keep a pathref dirfsp of
    the containing directory for later use. This avoids having to do
    another non_widelink_open() on every SMB2_CREATE and ntcreate&x in
    later patches.
    
    Future work will be to go through other filename_convert() calls and
    make them use filename_convert_dirfsp(). If we manage to convert all
    of them except the one in filename_convert_dirfsp() itself, we can
    simplify filename_convert() and unix_convert() significantly.
    
    Too large a patch, but I don't know how to split this up into smaller
    logic pieces.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 29fa2f51c367bce871262e4b53617567d2fe67fb
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 8 13:10:15 2022 +0200

    smbd: Only create an artificial dirfsp when necessary
    
    parent_pathref() is expensive, and we should avoid it if possible.
    
    Not effective at this point, we always pass in NULL, but will be used
    soon.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit c1a3104a2ab2ea29059b1aa5b4515d1f39e276ad
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Apr 7 11:50:52 2022 +0200

    smbd: Pass dirfsp to create_file_unixpath()
    
    Will be used soon.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit eb3c47ac3301ef533086e41e980d7f0b15cf530c
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 2 16:10:28 2022 +0100

    CI: use native Python functions to detect system and release
    
    This ensures we detect the runtime system and release, not the ones
    when Samba was build. It's necessary to detect the correct kernel
    version we're running on because for kernels before 5.3.1 O_PATH opens
    unnecessarily broke kernel oplocks, which breaks our tests. And in
    gitlab it can happen that we build on kernels after 5.3.1 and later
    run on older kernels. In this situation we can't run kernel oplock
    tests.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 6086a73f4e50fc12db1155e52f026a4ca0f8fc40
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Nov 23 12:29:17 2021 +0100

    Revert "vfs: remove dirfsp arg from SMB_VFS_CREATE_FILE()"
    
    This reverts commit 322574834f1e71bc01f21be9059ca4d386517c84.
    
    Not strictly a revert anymore, but for future work we do need "dirfsp"
    in create_file_default() passed through the VFS.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit de9986fb9b7a408f767eccc64a0941a1d28f8e74
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 16 10:14:14 2022 +0100

    vfs: Remove name-based SMB_VFS_GET_REAL_FILENAME()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 89bffa149dd290a130e3fbd357b4a643508c484e
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 15 12:45:48 2022 +0100

    smbd: Use SMB_VFS_GET_REAL_FILENAME_AT() in dptr_ReadDirName()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 2c05ebe9736084ec84d9c2c5692afe3514f91f40
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 16 10:01:40 2022 +0100

    vfs: Implement snapper_gmt_get_real_filename_at()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 2e1d2083f54bbefee8bc1ba7eba37a3809e5183d
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Mar 16 08:57:16 2022 +0100

    vfs: Implement shadow_copy2_get_real_filename_at()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit b21cd4c8d212473c5dd03b521c19e2748d092558
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 15 12:40:14 2022 +0100

    vfs: Implement vfs_gpfs_get_real_filename_at()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 5aca0056abf14777ca77afec36526f6932138816
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 15 12:39:14 2022 +0100

    vfs: Implement vfs_gluster_get_real_filename_at()
    
    gluster seems not to implement O_PATH, so it should be possible to do
    a glfs_fgetxattr() on the pathref dirfsp.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit ba6f7cfe8059f31529c754b5db61c8ca52b6b9b6
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 15 12:13:23 2022 +0100

    vfs: Implement vfs_gluster_fuse_get_real_filename_at()
    
    Needs testing in a real gluster environment
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit cf60c51dc0d761565e7e4de05a2e0b4561f693a6
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 15 12:06:08 2022 +0100

    vfs: Implement ceph_snap_gmt_get_real_filename_at()
    
    Copy the logic from ceph_snap_gmt_get_real_filename(). This is
    untested in autobuild, but as ceph is broken anyway due to
    812cb602e3be, we need to talk to the ceph developers before 4.17.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit c4d4fa68d61dcc037e5cdfc67bd6b98a93929a83
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 13 16:31:20 2022 +0100

    smbd: Add get_real_filename_at()
    
    Make get_real_filename() a wrapper.
    
    Right now shadow_copy2 does a fallback to do get_real_filename() on
    the twrp=0 tree in case of snapdirseverywhere because snapdirs can be
    somewhere deep in the tree, and doing that correctly would be a
    full-tree walk. I'd say that snapdirseverywhere is impossible to
    implement if you want symlink safety, i.e. careful top-down tree
    traversal together with snapdirseverywhere. If you have
    snapdirseverywhere you need to pass down the full path very deep down,
    which contradicts our fd-based approach we want to take.
    
    Also, I believe that our test does not 100% correctly reflect what
    actually is there: My understanding is that if you activate
    snapdirseverywhere for example in GPFS, you see all snapshots at every
    level (this would need to be verified). Our test does something more
    nasty: It creates and tests a specific snapshot only at one place deep
    in the directory hierarchy, which makes it impossible to find without
    the full path.
    
    This is all a big mess, but for now we need to deal with it. This adds
    the twrp=0 fallback to core smbd, but I don't see any other way to do
    that properly. And I do want a fd-based getrealfilename....
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit dcdc258509539fdb9f875f16acd2b0c156218782
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 13 15:55:25 2022 +0100

    smbd: Introduce get_real_filename_full_scan_at()
    
    Make get_real_filename_full_scan() a wrapper.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 973212e8c11b29f5aa78c43dba476501d26a3835
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 13 15:42:31 2022 +0100

    smbd: Add OpenDir_from_pathref
    
    Like OpenDir() starting from a directory pathref fsp
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit df29512b72f652728afd6ce161e4eec50c2400a8
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 13 10:48:12 2022 +0100

    smbd: Add openat_internal_dir_from_pathref()
    
    If we have a directory pathref fsp, do an openat(dirfd, ".", O_RDONLY)
    to cheaply get a real directory handle.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 02f6130c907e7e3aef89a9b84c72f1deb649e5ff
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 13 12:15:59 2022 +0100

    vfs: Add SMB_VFS_GET_REAL_FILENAME_AT
    
    In a patchset that I'm working on right now there's the need to call
    getrealfilename while the code does have a pathref fsp already
    around. Doing the name-based call including non_widelink_open is not
    necessary in this case. Start by adding the _at based call to the VFS.
    
    For now, fall back to the name-based call. glusterfs-fuse will in a
    future patch be converted to fgetxattr.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 804a19ca5d6c8155f7b35304ce457203453ccd60
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 14 22:52:11 2022 +0100

    smbd: Pass up stat-info from openat_pathref_fsp() on error
    
    If openat_pathref_fsp() fails, callers might want to inspect the stat
    info. If we really failed on STOPPED_ON_SYMLINK, the caller might need
    to know this, although openat_pathref_fsp() masked this error.
    
    As there is no smb_fname->fsp returned from openat_pathref_fsp() on
    error, we need to pass this up in smb_fname itself.
    
    This essentially reverts de439cd03047, which does basically the same
    thing but is too specific. We need to cover the general !O_PATH case
    more broadly.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 examples/VFS/skel_opaque.c                |  13 +-
 examples/VFS/skel_transparent.c           |  18 +-
 lib/util/memcache.h                       |   1 +
 source3/include/proto.h                   |   8 +
 source3/include/vfs.h                     |  32 +-
 source3/include/vfs_macros.h              |  27 +-
 source3/lib/adouble.c                     |   5 +
 source3/modules/vfs_ceph.c                |   6 +-
 source3/modules/vfs_ceph_snapshots.c      |  40 +-
 source3/modules/vfs_default.c             |  16 +-
 source3/modules/vfs_fruit.c               |   5 +-
 source3/modules/vfs_full_audit.c          |  18 +-
 source3/modules/vfs_glusterfs.c           |  10 +-
 source3/modules/vfs_glusterfs_fuse.c      |  20 +-
 source3/modules/vfs_gpfs.c                |  32 +-
 source3/modules/vfs_media_harmony.c       |   3 +
 source3/modules/vfs_not_implemented.c     |   7 +-
 source3/modules/vfs_shadow_copy2.c        |  76 ++-
 source3/modules/vfs_snapper.c             |  34 +-
 source3/modules/vfs_time_audit.c          |  17 +-
 source3/modules/vfs_unityed_media.c       |   3 +
 source3/modules/vfs_worm.c                |   3 +-
 source3/printing/nt_printing.c            |   3 +
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c |   2 +
 source3/selftest/tests.py                 |   6 +-
 source3/smbd/dir.c                        |  41 +-
 source3/smbd/filename.c                   | 780 ++++++++++++++++++++++++++++--
 source3/smbd/files.c                      | 153 ++++++
 source3/smbd/open.c                       |  64 ++-
 source3/smbd/proto.h                      |  19 +
 source3/smbd/smb1_nttrans.c               |  12 +-
 source3/smbd/smb1_reply.c                 |   6 +
 source3/smbd/smb1_trans2.c                |   3 +
 source3/smbd/smb2_create.c                |  17 +-
 source3/smbd/smb2_nttrans.c               |   2 +
 source3/smbd/smb2_reply.c                 |   4 +
 source3/smbd/smb2_trans2.c                |   6 +
 source3/smbd/vfs.c                        |  19 +-
 source3/torture/cmd_vfs.c                 |   1 +
 source3/utils/net_vfs.c                   |   1 +
 40 files changed, 1277 insertions(+), 256 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 4719a45e7bb..23614b660d9 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -206,6 +206,7 @@ static int skel_openat(struct vfs_handle_struct *handle,
 
 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
 				 struct smb_request *req,
+				 struct files_struct *dirfsp,
 				 struct smb_filename *smb_fname,
 				 uint32_t access_mask,
 				 uint32_t share_access,
@@ -651,11 +652,11 @@ static NTSTATUS skel_fstreaminfo(struct vfs_handle_struct *handle,
 	return NT_STATUS_NOT_IMPLEMENTED;
 }
 
-static NTSTATUS skel_get_real_filename(struct vfs_handle_struct *handle,
-				       const struct smb_filename *path,
-				       const char *name,
-				       TALLOC_CTX *mem_ctx,
-				       char **found_name)
+static NTSTATUS skel_get_real_filename_at(struct vfs_handle_struct *handle,
+					  struct files_struct *dirfsp,
+					  const char *name,
+					  TALLOC_CTX *mem_ctx,
+					  char **found_name)
 {
 	return NT_STATUS_NOT_IMPLEMENTED;
 }
@@ -1044,7 +1045,7 @@ static struct vfs_fn_pointers skel_opaque_fns = {
 	.set_compression_fn = skel_set_compression,
 
 	.fstreaminfo_fn = skel_fstreaminfo,
-	.get_real_filename_fn = skel_get_real_filename,
+	.get_real_filename_at_fn = skel_get_real_filename_at,
 	.connectpath_fn = skel_connectpath,
 	.brl_lock_windows_fn = skel_brl_lock_windows,
 	.brl_unlock_windows_fn = skel_brl_unlock_windows,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index ecd3c282240..9fc211c5e2e 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -214,6 +214,7 @@ static int skel_openat(struct vfs_handle_struct *handle,
 
 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
 				 struct smb_request *req,
+				 struct files_struct *dirfsp,
 				 struct smb_filename *smb_fname,
 				 uint32_t access_mask,
 				 uint32_t share_access,
@@ -232,6 +233,7 @@ static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
 {
 	return SMB_VFS_NEXT_CREATE_FILE(handle,
 					req,
+					dirfsp,
 					smb_fname,
 					access_mask,
 					share_access,
@@ -875,14 +877,14 @@ static NTSTATUS skel_fstreaminfo(struct vfs_handle_struct *handle,
 				streams);
 }
 
-static NTSTATUS skel_get_real_filename(struct vfs_handle_struct *handle,
-				       const struct smb_filename *path,
-				       const char *name,
-				       TALLOC_CTX *mem_ctx,
-				       char **found_name)
+static NTSTATUS skel_get_real_filename_at(struct vfs_handle_struct *handle,
+					  struct files_struct *dirfsp,
+					  const char *name,
+					  TALLOC_CTX *mem_ctx,
+					  char **found_name)
 {
-	return SMB_VFS_NEXT_GET_REAL_FILENAME(handle,
-					      path, name, mem_ctx, found_name);
+	return SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
+		handle, dirfsp, name, mem_ctx, found_name);
 }
 
 static const char *skel_connectpath(struct vfs_handle_struct *handle,
@@ -1359,7 +1361,7 @@ static struct vfs_fn_pointers skel_transparent_fns = {
 	.set_compression_fn = skel_set_compression,
 
 	.fstreaminfo_fn = skel_fstreaminfo,
-	.get_real_filename_fn = skel_get_real_filename,
+	.get_real_filename_at_fn = skel_get_real_filename_at,
 	.connectpath_fn = skel_connectpath,
 	.brl_lock_windows_fn = skel_brl_lock_windows,
 	.brl_unlock_windows_fn = skel_brl_unlock_windows,
diff --git a/lib/util/memcache.h b/lib/util/memcache.h
index 1ba4d5ac2f8..1e13e334191 100644
--- a/lib/util/memcache.h
+++ b/lib/util/memcache.h
@@ -36,6 +36,7 @@ struct memcache;
 
 enum memcache_number {
 	STAT_CACHE,
+	GETREALFILENAME_CACHE,
 	GETWD_CACHE,
 	GETPWNAM_CACHE,		/* talloc */
 	MANGLE_HASH2_CACHE,
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 2f96a35c531..aebbd7f9c47 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -723,6 +723,14 @@ struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx,
 					 const SMB_STRUCT_STAT *psbuf,
 					 NTTIME twrp,
 					 uint32_t flags);
+NTSTATUS filename_convert_dirfsp(
+	TALLOC_CTX *ctx,
+	connection_struct *conn,
+	const char *name_in,
+	uint32_t ucf_flags,
+	NTTIME twrp,
+	struct files_struct **pdirfsp,
+	struct smb_filename **psmb_name_rel);
 struct smb_filename *full_path_from_dirfsp_atname(
 	TALLOC_CTX *mem_ctx,
 	const struct files_struct *dirfsp,
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index e3d7fee90ff..841a930d309 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -369,6 +369,9 @@
  * Version 47 - remove st_ex_itime from struct stat_ex
  * Version 47 - remove (unused) struct lock_struct last_lock_failure
 		from files_struct.
+ * Version 47 - Add SMB_VFS_GET_REAL_FILENAME_AT
+ * Version 47 - Replace SMB_VFS_GET_REAL_FILENAME with SMB_VFS_GET_REAL_FILENAME_AT
+ * Version 47 - Re-add dirfsp to CREATE_FILE
  */
 
 #define SMB_VFS_INTERFACE_VERSION 47
@@ -973,6 +976,7 @@ struct vfs_fn_pointers {
 			 mode_t mode);
 	NTSTATUS (*create_file_fn)(struct vfs_handle_struct *handle,
 				   struct smb_request *req,
+				   struct files_struct *dirfsp,
 				   struct smb_filename *smb_fname,
 				   uint32_t access_mask,
 				   uint32_t share_access,
@@ -1147,11 +1151,11 @@ struct vfs_fn_pointers {
 				   unsigned int *num_streams,
 				   struct stream_struct **streams);
 
-	NTSTATUS (*get_real_filename_fn)(struct vfs_handle_struct *handle,
-					 const struct smb_filename *path,
-					 const char *name,
-					 TALLOC_CTX *mem_ctx,
-					 char **found_name);
+	NTSTATUS (*get_real_filename_at_fn)(struct vfs_handle_struct *handle,
+					    struct files_struct *dirfsp,
+					    const char *name,
+					    TALLOC_CTX *mem_ctx,
+					    char **found_name);
 
 	const char *(*connectpath_fn)(struct vfs_handle_struct *handle,
 				      const struct smb_filename *smb_fname);
@@ -1458,6 +1462,7 @@ int smb_vfs_call_openat(struct vfs_handle_struct *handle,
 			mode_t mode);
 NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
 				  struct smb_request *req,
+				  struct files_struct *dirfsp,
 				  struct smb_filename *smb_fname,
 				  uint32_t access_mask,
 				  uint32_t share_access,
@@ -1616,11 +1621,11 @@ NTSTATUS smb_vfs_call_fstreaminfo(struct vfs_handle_struct *handle,
 				  TALLOC_CTX *mem_ctx,
 				  unsigned int *num_streams,
 				  struct stream_struct **streams);
-NTSTATUS smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle,
-					const struct smb_filename *path,
-					const char *name,
-					TALLOC_CTX *mem_ctx,
-					char **found_name);
+NTSTATUS smb_vfs_call_get_real_filename_at(struct vfs_handle_struct *handle,
+					   struct files_struct *dirfsp,
+					   const char *name,
+					   TALLOC_CTX *mem_ctx,
+					   char **found_name);
 const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
 				     const struct smb_filename *smb_fname);
 NTSTATUS smb_vfs_call_brl_lock_windows(struct vfs_handle_struct *handle,
@@ -1902,6 +1907,7 @@ int vfs_not_implemented_openat(vfs_handle_struct *handle,
 			       mode_t mode);
 NTSTATUS vfs_not_implemented_create_file(struct vfs_handle_struct *handle,
 				struct smb_request *req,
+				struct files_struct *dirfsp,
 				struct smb_filename *smb_fname,
 				uint32_t access_mask,
 				uint32_t share_access,
@@ -2088,6 +2094,12 @@ NTSTATUS vfs_not_implemented_get_real_filename(
 	const char *name,
 	TALLOC_CTX *mem_ctx,
 	char **found_name);
+NTSTATUS vfs_not_implemented_get_real_filename_at(
+	struct vfs_handle_struct *handle,
+	struct files_struct *dirfsp,
+	const char *name,
+	TALLOC_CTX *mem_ctx,
+	char **found_name);
 const char *vfs_not_implemented_connectpath(struct vfs_handle_struct *handle,
 					    const struct smb_filename *smb_fname);
 NTSTATUS vfs_not_implemented_brl_lock_windows(struct vfs_handle_struct *handle,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 99619320df4..840e77cf1b0 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -147,14 +147,14 @@
 #define SMB_VFS_NEXT_OPENAT(handle, dirfsp, smb_fname, fsp, flags, mode) \
 	smb_vfs_call_openat((handle)->next, (dirfsp), (smb_fname), (fsp), (flags), (mode))
 
-#define SMB_VFS_CREATE_FILE(conn, req, smb_fname, access_mask, share_access, create_disposition, \
+#define SMB_VFS_CREATE_FILE(conn, req, dirfsp, smb_fname, access_mask, share_access, create_disposition, \
         create_options, file_attributes, oplock_request, lease, allocation_size, private_flags, sd, ea_list, result, pinfo, in_context_blobs, out_context_blobs) \
-        smb_vfs_call_create_file((conn)->vfs_handles, (req), (smb_fname), (access_mask), (share_access), (create_disposition), \
+        smb_vfs_call_create_file((conn)->vfs_handles, (req), (dirfsp), (smb_fname), (access_mask), (share_access), (create_disposition), \
         (create_options), (file_attributes), (oplock_request), (lease), (allocation_size), (private_flags), (sd), (ea_list), (result), (pinfo), \
 	(in_context_blobs), (out_context_blobs))
-#define SMB_VFS_NEXT_CREATE_FILE(handle, req, smb_fname, access_mask, share_access, create_disposition, \
+#define SMB_VFS_NEXT_CREATE_FILE(handle, req, dirfsp, smb_fname, access_mask, share_access, create_disposition, \
 	create_options, file_attributes, oplock_request, lease, allocation_size, private_flags, sd, ea_list, result, pinfo, in_context_blobs, out_context_blobs) \
-	smb_vfs_call_create_file((handle)->next, (req), (smb_fname), (access_mask), (share_access), (create_disposition), \
+	smb_vfs_call_create_file((handle)->next, (req), (dirfsp), (smb_fname), (access_mask), (share_access), (create_disposition), \
         (create_options), (file_attributes), (oplock_request), (lease), (allocation_size), (private_flags), (sd), (ea_list), (result), (pinfo), \
 	(in_context_blobs), (out_context_blobs))
 
@@ -367,10 +367,21 @@
 #define SMB_VFS_NEXT_FSTREAMINFO(handle, fsp, mem_ctx, num_streams, streams) \
 	smb_vfs_call_fstreaminfo(handle->next, (fsp), (mem_ctx), (num_streams), (streams))
 
-#define SMB_VFS_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) \
-	smb_vfs_call_get_real_filename((conn)->vfs_handles, (path), (name), (mem_ctx), (found_name))
-#define SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx, found_name) \
-	smb_vfs_call_get_real_filename((handle)->next, (path), (name), (mem_ctx), (found_name))
+#define SMB_VFS_GET_REAL_FILENAME_AT(conn, dirfsp, name, mem_ctx, found_name) \
+	smb_vfs_call_get_real_filename_at( \
+		(conn)->vfs_handles, \
+		(dirfsp), \
+		(name), \
+		(mem_ctx), \
+		(found_name))
+#define SMB_VFS_NEXT_GET_REAL_FILENAME_AT( \
+	handle, dirfsp, name, mem_ctx, found_name) \
+	smb_vfs_call_get_real_filename_at( \
+		(handle)->next, \
+		(dirfsp), \
+		(name), \
+		(mem_ctx), \
+		(found_name))
 
 #define SMB_VFS_CONNECTPATH(conn, smb_fname) \
 	smb_vfs_call_connectpath((conn)->vfs_handles, (smb_fname))
diff --git a/source3/lib/adouble.c b/source3/lib/adouble.c
index ddc43fab0f4..b831464f5a9 100644
--- a/source3/lib/adouble.c
+++ b/source3/lib/adouble.c
@@ -1219,6 +1219,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle,
 		status = SMB_VFS_CREATE_FILE(
 			handle->conn,			/* conn */
 			NULL,				/* req */
+			NULL,				/* dirfsp */
 			stream_name,			/* fname */
 			FILE_GENERIC_WRITE,		/* access_mask */
 			FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */
@@ -1355,6 +1356,7 @@ static bool ad_convert_finderinfo(vfs_handle_struct *handle,
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,			/* conn */
 		NULL,				/* req */
+		NULL,				/* dirfsp */
 		stream_name,			/* fname */
 		FILE_GENERIC_WRITE,		/* access_mask */
 		FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */
@@ -1604,6 +1606,7 @@ static bool ad_unconvert_open_ad(TALLOC_CTX *mem_ctx,
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,
 		NULL,				/* req */
+		NULL,				/* dirfsp */
 		adpath,
 		FILE_READ_DATA|FILE_WRITE_DATA,
 		FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
@@ -1660,6 +1663,7 @@ static bool ad_unconvert_get_streams(struct vfs_handle_struct *handle,
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,				/* conn */
 		NULL,					/* req */
+		NULL,					/* dirfsp */
 		smb_fname,				/* fname */
 		FILE_READ_ATTRIBUTES,			/* access_mask */
 		(FILE_SHARE_READ | FILE_SHARE_WRITE |	/* share_access */
@@ -1755,6 +1759,7 @@ static bool ad_collect_one_stream(struct vfs_handle_struct *handle,
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,
 		NULL,				/* req */
+		NULL,				/* dirfsp */
 		sname,
 		FILE_READ_DATA|DELETE_ACCESS,
 		FILE_SHARE_READ,
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 44c9cf3053a..8132f5ba8b1 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -1272,9 +1272,9 @@ static int cephwrap_fchflags(struct vfs_handle_struct *handle,
 	return -1;
 }
 
-static NTSTATUS cephwrap_get_real_filename(
+static NTSTATUS cephwrap_get_real_filename_at(
 	struct vfs_handle_struct *handle,
-	const struct smb_filename *path,
+	struct files_struct *dirfsp,
 	const char *name,
 	TALLOC_CTX *mem_ctx,
 	char **found_name)
@@ -1634,7 +1634,7 @@ static struct vfs_fn_pointers ceph_fns = {
 	.mknodat_fn = cephwrap_mknodat,
 	.realpath_fn = cephwrap_realpath,
 	.fchflags_fn = cephwrap_fchflags,
-	.get_real_filename_fn = cephwrap_get_real_filename,
+	.get_real_filename_at_fn = cephwrap_get_real_filename_at,
 	.connectpath_fn = cephwrap_connectpath,
 
 	/* EA operations. */
diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c
index ad4c8f1dd94..06ef5538450 100644
--- a/source3/modules/vfs_ceph_snapshots.c
+++ b/source3/modules/vfs_ceph_snapshots.c
@@ -1313,9 +1313,9 @@ static int ceph_snap_gmt_fsetxattr(struct vfs_handle_struct *handle,
 				aname, value, size, flags);
 }
 
-static NTSTATUS ceph_snap_gmt_get_real_filename(
+static NTSTATUS ceph_snap_gmt_get_real_filename_at(
 	struct vfs_handle_struct *handle,
-	const struct smb_filename *path,
+	struct files_struct *dirfsp,
 	const char *name,
 	TALLOC_CTX *mem_ctx,
 	char **found_name)
@@ -1323,18 +1323,22 @@ static NTSTATUS ceph_snap_gmt_get_real_filename(
 	time_t timestamp = 0;
 	char stripped[PATH_MAX + 1];
 	char conv[PATH_MAX + 1];
-	struct smb_filename conv_fname;
+	struct smb_filename *conv_fname = NULL;
 	int ret;
 	NTSTATUS status;
 
-	ret = ceph_snap_gmt_strip_snapshot(handle, path,
-					&timestamp, stripped, sizeof(stripped));
+	ret = ceph_snap_gmt_strip_snapshot(
+		handle,
+		dirfsp->fsp_name,
+		&timestamp,
+		stripped,
+		sizeof(stripped));
 	if (ret < 0) {
 		return map_nt_error_from_unix(-ret);
 	}
 	if (timestamp == 0) {
-		return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
-						      mem_ctx, found_name);
+		return SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
+			handle, dirfsp, name, mem_ctx, found_name);
 	}
 	ret = ceph_snap_gmt_convert_dir(handle, stripped,
 					timestamp, conv, sizeof(conv));
@@ -1342,12 +1346,22 @@ static NTSTATUS ceph_snap_gmt_get_real_filename(
 		return map_nt_error_from_unix(-ret);
 	}
 
-	conv_fname = (struct smb_filename) {
-		.base_name = conv,
-	};
+	status = synthetic_pathref(
+		talloc_tos(),
+		dirfsp->conn->cwd_fsp,
+		conv,
+		NULL,
+		NULL,
+		0,
+		0,
+		&conv_fname);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
 
-	status = SMB_VFS_NEXT_GET_REAL_FILENAME(
-		handle, &conv_fname, name, mem_ctx, found_name);
+	status = SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
+		handle, conv_fname->fsp, name, mem_ctx, found_name);
+	TALLOC_FREE(conv_fname);
 	return status;
 }
 
@@ -1461,7 +1475,7 @@ static struct vfs_fn_pointers ceph_snap_fns = {
 	.getxattrat_recv_fn = vfs_not_implemented_getxattrat_recv,
 	.fsetxattr_fn = ceph_snap_gmt_fsetxattr,
 	.fchflags_fn = ceph_snap_gmt_fchflags,
-	.get_real_filename_fn = ceph_snap_gmt_get_real_filename,
+	.get_real_filename_at_fn = ceph_snap_gmt_get_real_filename_at,
 };
 
 static_decl_vfs;
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 7108402a407..d67a9fe4325 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -735,6 +735,7 @@ out:
 }
 static NTSTATUS vfswrap_create_file(vfs_handle_struct *handle,
 				    struct smb_request *req,
+				    struct files_struct *dirfsp,
 				    struct smb_filename *smb_fname,
 				    uint32_t access_mask,
 				    uint32_t share_access,
@@ -752,7 +753,7 @@ static NTSTATUS vfswrap_create_file(vfs_handle_struct *handle,
 				    const struct smb2_create_blobs *in_context_blobs,
 				    struct smb2_create_blobs *out_context_blobs)
 {
-	return create_file_default(handle->conn, req, smb_fname,
+	return create_file_default(handle->conn, req, dirfsp, smb_fname,
 				   access_mask, share_access,
 				   create_disposition, create_options,
 				   file_attributes, oplock_request, lease,
@@ -3358,11 +3359,12 @@ static NTSTATUS vfswrap_fstreaminfo(vfs_handle_struct *handle,
 	return NT_STATUS_OK;
 }
 
-static NTSTATUS vfswrap_get_real_filename(struct vfs_handle_struct *handle,
-					  const struct smb_filename *path,
-					  const char *name,
-					  TALLOC_CTX *mem_ctx,
-					  char **found_name)
+static NTSTATUS vfswrap_get_real_filename_at(
+	struct vfs_handle_struct *handle,
+	struct files_struct *dirfsp,
+	const char *name,
+	TALLOC_CTX *mem_ctx,
+	char **found_name)
 {
 	/*
 	 * Don't fall back to get_real_filename so callers can differentiate
@@ -4015,7 +4017,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
 	.file_id_create_fn = vfswrap_file_id_create,
 	.fs_file_id_fn = vfswrap_fs_file_id,
 	.fstreaminfo_fn = vfswrap_fstreaminfo,
-	.get_real_filename_fn = vfswrap_get_real_filename,
+	.get_real_filename_at_fn = vfswrap_get_real_filename_at,
 	.connectpath_fn = vfswrap_connectpath,
 	.brl_lock_windows_fn = vfswrap_brl_lock_windows,
 	.brl_unlock_windows_fn = vfswrap_brl_unlock_windows,
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 81bc0cf4cc2..183c4e02371 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -964,6 +964,7 @@ static bool readdir_attr_meta_finderi_stream(
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,                           /* conn */
 		NULL,                                   /* req */
+		NULL,					/* dirfsp */
 		stream_name,				/* fname */
 		FILE_READ_DATA,                         /* access_mask */
 		(FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
@@ -4136,6 +4137,7 @@ static int fruit_ftruncate(struct vfs_handle_struct *handle,
 
 static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
 				  struct smb_request *req,
+				  struct files_struct *dirfsp,
 				  struct smb_filename *smb_fname,
 				  uint32_t access_mask,
 				  uint32_t share_access,
@@ -4188,7 +4190,7 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
 	}
 
 	status = SMB_VFS_NEXT_CREATE_FILE(
-		handle, req, smb_fname,
+		handle, req, dirfsp, smb_fname,
 		access_mask, share_access,
 		create_disposition, create_options,
 		file_attributes, oplock_request,
@@ -4957,6 +4959,7 @@ static bool fruit_get_bandsize(vfs_handle_struct *handle,
 	status = SMB_VFS_NEXT_CREATE_FILE(
 		handle,				/* conn */
 		NULL,				/* req */
+		NULL,				/* dirfsp */
 		smb_fname,			/* fname */
 		FILE_GENERIC_READ,		/* access_mask */
 		FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index a905971c1b9..af37cf19335 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -167,6 +167,7 @@ typedef enum _vfs_op_type {
 	SMB_VFS_OP_FS_FILE_ID,
 	SMB_VFS_OP_FSTREAMINFO,
 	SMB_VFS_OP_GET_REAL_FILENAME,
+	SMB_VFS_OP_GET_REAL_FILENAME_AT,
 	SMB_VFS_OP_CONNECTPATH,
 	SMB_VFS_OP_BRL_LOCK_WINDOWS,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list