vfs: Add dirfsp to connectpath_fn()
authorVolker Lendecke <vl@samba.org>
Thu, 15 Sep 2022 03:18:33 +0000 (20:18 -0700)
committerJeremy Allison <jra@samba.org>
Sat, 17 Sep 2022 04:15:35 +0000 (04:15 +0000)
So far we only call CONNECTPATH on full paths. In the future, we'll
have a call that will not have converted a relative path to absolute
just for efficiency reasons. To give shadow_copy2 the chance to still
find the snapshot directory, pass the dirfsp down to it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
13 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_ceph.c
source3/modules/vfs_default.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_glusterfs.c
source3/modules/vfs_not_implemented.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_time_audit.c
source3/smbd/open.c
source3/smbd/vfs.c

index a72ba57e1a7550db07ee124cd5a6237bab49e6c3..98b090728f27c20d0006230072577cb25e87f794 100644 (file)
@@ -665,8 +665,10 @@ static NTSTATUS skel_get_real_filename_at(struct vfs_handle_struct *handle,
        return NT_STATUS_NOT_IMPLEMENTED;
 }
 
-static const char *skel_connectpath(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname)
+static const char *skel_connectpath(
+       struct vfs_handle_struct *handle,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *smb_fname)
 {
        errno = ENOSYS;
        return NULL;
index 8fb8644ad09fa869e2dd56e622738b6016ccd90a..b152f3596c5689f5b38cd556ac820ed71bc87107 100644 (file)
@@ -886,10 +886,12 @@ static NTSTATUS skel_get_real_filename_at(struct vfs_handle_struct *handle,
                handle, dirfsp, name, mem_ctx, found_name);
 }
 
-static const char *skel_connectpath(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname)
+static const char *skel_connectpath(
+       struct vfs_handle_struct *handle,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *smb_fname)
 {
-       return SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
+       return SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname);
 }
 
 static NTSTATUS skel_brl_lock_windows(struct vfs_handle_struct *handle,
index fc7afccfdb39248dcb3740797414a02b2798234e..20b6eb57900ffbd0b816e8ac4a36bd97b3d2aa24 100644 (file)
  * Version 47 - Add VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS for SMB_VFS_OPENAT()
  * Change to Version 48 - will ship with 4.18
  * Version 48 - Add cached_dos_attributes to struct stat_ex
+ * Version 48 - Add dirfsp to connectpath_fn()
  */
 
 #define SMB_VFS_INTERFACE_VERSION 48
@@ -1172,6 +1173,7 @@ struct vfs_fn_pointers {
                                            char **found_name);
 
        const char *(*connectpath_fn)(struct vfs_handle_struct *handle,
+                                     const struct files_struct *dirfsp,
                                      const struct smb_filename *smb_fname);
 
        NTSTATUS (*brl_lock_windows_fn)(struct vfs_handle_struct *handle,
@@ -1640,7 +1642,8 @@ NTSTATUS smb_vfs_call_get_real_filename_at(struct vfs_handle_struct *handle,
                                           TALLOC_CTX *mem_ctx,
                                           char **found_name);
 const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
-                                    const struct smb_filename *smb_fname);
+                                const struct files_struct *dirfsp,
+                                const struct smb_filename *smb_fname);
 NTSTATUS smb_vfs_call_brl_lock_windows(struct vfs_handle_struct *handle,
                                       struct byte_range_lock *br_lck,
                                       struct lock_struct *plock);
@@ -2112,8 +2115,10 @@ NTSTATUS vfs_not_implemented_get_real_filename_at(
        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);
+const char *vfs_not_implemented_connectpath(
+       struct vfs_handle_struct *handle,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *smb_fname);
 NTSTATUS vfs_not_implemented_brl_lock_windows(struct vfs_handle_struct *handle,
                                              struct byte_range_lock *br_lck,
                                              struct lock_struct *plock);
index c7089b62964b1297341bd60fbc5002ba9d31c3e0..f1a59e1d13abd2834fdf6474248d26212a46ec0b 100644 (file)
                (mem_ctx), \
                (found_name))
 
-#define SMB_VFS_CONNECTPATH(conn, smb_fname) \
-       smb_vfs_call_connectpath((conn)->vfs_handles, (smb_fname))
-#define SMB_VFS_NEXT_CONNECTPATH(conn, smb_fname) \
-       smb_vfs_call_connectpath((conn)->next, (smb_fname))
+#define SMB_VFS_CONNECTPATH(conn, dirfsp, smb_fname)                   \
+       smb_vfs_call_connectpath((conn)->vfs_handles, (dirfsp), (smb_fname))
+#define SMB_VFS_NEXT_CONNECTPATH(conn, dirfsp, smb_fname)      \
+       smb_vfs_call_connectpath((conn)->next, (dirfsp), (smb_fname))
 
 #define SMB_VFS_BRL_LOCK_WINDOWS(conn, br_lck, plock) \
        smb_vfs_call_brl_lock_windows((conn)->vfs_handles, (br_lck), (plock))
index 2186bfdb2ce6cb898a5a974ffe881717107d19be..b8190fa25e4ba677dbba36ed5af4af9e1ff671bf 100644 (file)
@@ -1292,8 +1292,10 @@ static NTSTATUS cephwrap_get_real_filename_at(
        return NT_STATUS_NOT_SUPPORTED;
 }
 
-static const char *cephwrap_connectpath(struct vfs_handle_struct *handle,
-                                      const struct smb_filename *smb_fname)
+static const char *cephwrap_connectpath(
+       struct vfs_handle_struct *handle,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *smb_fname)
 {
        return handle->conn->connectpath;
 }
index 9481c9f36d50f2405e7aef9edac47a83abde4a64..6cad87152efc1cc743b5d9fac568ebb4b986336a 100644 (file)
@@ -3453,6 +3453,7 @@ static NTSTATUS vfswrap_get_real_filename_at(
 }
 
 static const char *vfswrap_connectpath(struct vfs_handle_struct *handle,
+                                  const struct files_struct *dirfsp,
                                   const struct smb_filename *smb_fname)
 {
        return handle->conn->connectpath;
index 25fd0cad326f8a991e5e5a23b40ed21a9f28b9aa..011e483de2ffe630d5b369b55b5556ad1adecf37 100644 (file)
@@ -2115,12 +2115,14 @@ static NTSTATUS smb_full_audit_get_real_filename_at(
        return result;
 }
 
-static const char *smb_full_audit_connectpath(vfs_handle_struct *handle,
-                                       const struct smb_filename *smb_fname)
+static const char *smb_full_audit_connectpath(
+       vfs_handle_struct *handle,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *smb_fname)
 {
        const char *result;
 
-       result = SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
+       result = SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname);
 
        do_log(SMB_VFS_OP_CONNECTPATH,
               result != NULL,
index ffbe0f414ae677bf6eaecdf6125c83393b317fe0..33f941aaca987b74a167914cec6ea4d0dbe96751 100644 (file)
@@ -2348,8 +2348,10 @@ static NTSTATUS vfs_gluster_get_real_filename_at(
        return NT_STATUS_OK;
 }
 
-static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname)
+static const char *vfs_gluster_connectpath(
+       struct vfs_handle_struct *handle,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *smb_fname)
 {
        return handle->conn->connectpath;
 }
index 3c017c68bb8d7acdc6baec8cc07b44b089500acb..0d3294658cf9d861e035949c5cd20f16c9e7faed 100644 (file)
@@ -735,8 +735,10 @@ NTSTATUS vfs_not_implemented_get_real_filename_at(
 }
 
 _PUBLIC_
-const char *vfs_not_implemented_connectpath(struct vfs_handle_struct *handle,
-                                           const struct smb_filename *smb_fname)
+const char *vfs_not_implemented_connectpath(
+       struct vfs_handle_struct *handle,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *smb_fname)
 {
        errno = ENOSYS;
        return NULL;
index a3a6afbc3ace037292ce1f985aba629ab54c4e7f..b4ee00b71a0e7a722fb1f18a87d64ab9e0d2c590 100644 (file)
@@ -2625,8 +2625,10 @@ static NTSTATUS shadow_copy2_get_real_filename_at(
        return NT_STATUS_OK;
 }
 
-static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle,
-                                       const struct smb_filename *smb_fname_in)
+static const char *shadow_copy2_connectpath(
+       struct vfs_handle_struct *handle,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *smb_fname_in)
 {
        time_t timestamp = 0;
        char *stripped = NULL;
@@ -2656,7 +2658,7 @@ static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle,
                goto done;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname_in);
+               return SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname_in);
        }
 
        tmp = shadow_copy2_do_convert(talloc_tos(), handle, stripped, timestamp,
index e7633285607f0e72858edf94581f6637f21308eb..4942e4b84918fa133dd750923574c936150298ff 100644 (file)
@@ -1743,15 +1743,17 @@ static NTSTATUS smb_time_audit_get_real_filename_at(
        return result;
 }
 
-static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
-                                       const struct smb_filename *smb_fname)
+static const char *smb_time_audit_connectpath(
+       vfs_handle_struct *handle,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *smb_fname)
 {
        const char *result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
+       result = SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
index d443a0291f9c702e06ecad2f9240d2193785fb69..463f8809abcbeeb81608c2c0767272fdbb609b51 100644 (file)
@@ -532,7 +532,7 @@ static NTSTATUS process_symlink_open(const struct files_struct *dirfsp,
        struct smb_filename *full_fname = NULL;
        NTSTATUS status;
 
-       conn_rootdir = SMB_VFS_CONNECTPATH(conn, smb_fname);
+       conn_rootdir = SMB_VFS_CONNECTPATH(conn, NULL, smb_fname);
        if (conn_rootdir == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -705,7 +705,8 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
        SMB_ASSERT(!fsp_is_alternate_stream(fsp));
 
        if (smb_fname->base_name[0] == '/') {
-               const char *connpath = SMB_VFS_CONNECTPATH(conn, smb_fname);
+               const char *connpath = SMB_VFS_CONNECTPATH(
+                       conn, NULL, smb_fname);
                int cmp = strcmp(connpath, smb_fname->base_name);
 
                if (cmp == 0) {
index 5833d1b2ab284d948e9e06be3fe43faff0fbbf5d..13f5abaffec73fdb2c17ee549834b9de8462df43 100644 (file)
@@ -1224,7 +1224,7 @@ NTSTATUS check_reduced_name(connection_struct *conn,
        }
 
        /* Common widelinks and symlinks checks. */
-       conn_rootdir = SMB_VFS_CONNECTPATH(conn, smb_fname);
+       conn_rootdir = SMB_VFS_CONNECTPATH(conn, NULL, smb_fname);
        if (conn_rootdir == NULL) {
                DBG_NOTICE("Could not get conn_rootdir\n");
                TALLOC_FREE(resolved_fname);
@@ -2312,10 +2312,11 @@ NTSTATUS smb_vfs_call_get_real_filename_at(struct vfs_handle_struct *handle,
 }
 
 const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle,
+                                const struct files_struct *dirfsp,
                                 const struct smb_filename *smb_fname)
 {
        VFS_FIND(connectpath);
-       return handle->fns->connectpath_fn(handle, smb_fname);
+       return handle->fns->connectpath_fn(handle, dirfsp, smb_fname);
 }
 
 bool smb_vfs_call_strict_lock_check(struct vfs_handle_struct *handle,