diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index a72ba57e1a7..98b090728f2 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -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; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 8fb8644ad09..b152f3596c5 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -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, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index fc7afccfdb3..20b6eb57900 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -377,6 +377,7 @@ * 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); diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index c7089b62964..f1a59e1d13a 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -385,10 +385,10 @@ (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)) diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 2186bfdb2ce..b8190fa25e4 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -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; } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 9481c9f36d5..6cad87152ef 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -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; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 25fd0cad326..011e483de2f 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -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, diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index ffbe0f414ae..33f941aaca9 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -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; } diff --git a/source3/modules/vfs_not_implemented.c b/source3/modules/vfs_not_implemented.c index 3c017c68bb8..0d3294658cf 100644 --- a/source3/modules/vfs_not_implemented.c +++ b/source3/modules/vfs_not_implemented.c @@ -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; diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index a3a6afbc3ac..b4ee00b71a0 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -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, diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index e7633285607..4942e4b8491 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -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; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index d443a0291f9..463f8809abc 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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) { diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 5833d1b2ab2..13f5abaffec 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -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,