From: Jeremy Allison Date: Fri, 30 Jun 2017 20:37:03 +0000 (-0700) Subject: s3: VFS: Change SMB_VFS_CONNECTPATH to take const struct smb_filename * instead of... X-Git-Tag: tdb-1.3.14~6 X-Git-Url: http://git.samba.org/samba.git/?p=kai%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=51c1a2a45861c725f756f60ca05e6d1fa4ca34c6 s3: VFS: Change SMB_VFS_CONNECTPATH to take const struct smb_filename * instead of const char *. We need to migrate all pathname based VFS calls to use a struct to finish modernising the VFS with extra timestamp and flags parameters. Signed-off-by: Jeremy Allison Reviewed-by: Richard Sharpe Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Sat Jul 1 07:20:28 CEST 2017 on sn-devel-144 --- diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index f8f98575f62..74ffb672024 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -614,7 +614,7 @@ static int skel_get_real_filename(struct vfs_handle_struct *handle, } static const char *skel_connectpath(struct vfs_handle_struct *handle, - const char *filename) + 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 29a97852974..e584d514655 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -739,9 +739,9 @@ static int skel_get_real_filename(struct vfs_handle_struct *handle, } static const char *skel_connectpath(struct vfs_handle_struct *handle, - const char *filename) + const struct smb_filename *smb_fname) { - return SMB_VFS_NEXT_CONNECTPATH(handle, filename); + return SMB_VFS_NEXT_CONNECTPATH(handle, 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 1aa44ee14e1..6a3f6c9c42e 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -236,6 +236,8 @@ to struct smb_filename * */ /* Version 37 - Change realpath from char * to struct smb_filename * */ +/* Version 37 - Change connectpath from char * + to struct smb_filename * */ #define SMB_VFS_INTERFACE_VERSION 37 @@ -830,7 +832,7 @@ struct vfs_fn_pointers { char **found_name); const char *(*connectpath_fn)(struct vfs_handle_struct *handle, - const char *filename); + const struct smb_filename *smb_fname); NTSTATUS (*brl_lock_windows_fn)(struct vfs_handle_struct *handle, struct byte_range_lock *br_lck, @@ -1301,7 +1303,7 @@ int smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle, const char *path, const char *name, TALLOC_CTX *mem_ctx, char **found_name); const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle, - const char *filename); + 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, diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index 0e8245e752d..4365f15b3d1 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -356,10 +356,10 @@ #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_CONNECTPATH(conn, fname) \ - smb_vfs_call_connectpath((conn)->vfs_handles, (fname)) -#define SMB_VFS_NEXT_CONNECTPATH(conn, fname) \ - smb_vfs_call_connectpath((conn)->next, (fname)) +#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_BRL_LOCK_WINDOWS(conn, br_lck, plock, blocking_lock) \ smb_vfs_call_brl_lock_windows((conn)->vfs_handles, (br_lck), (plock), (blocking_lock)) diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 488ebc7795d..73106c4ac60 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -1252,7 +1252,7 @@ static int cephwrap_get_real_filename(struct vfs_handle_struct *handle, } static const char *cephwrap_connectpath(struct vfs_handle_struct *handle, - const char *fname) + 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 3336232e3d6..8a08aed83f8 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -2610,7 +2610,7 @@ static int vfswrap_get_real_filename(struct vfs_handle_struct *handle, } static const char *vfswrap_connectpath(struct vfs_handle_struct *handle, - const char *fname) + 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 e66ad9ebe43..215cb1f3934 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -1766,14 +1766,14 @@ static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle, } static const char *smb_full_audit_connectpath(vfs_handle_struct *handle, - const char *fname) + const struct smb_filename *smb_fname) { const char *result; - result = SMB_VFS_NEXT_CONNECTPATH(handle, fname); + result = SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname); do_log(SMB_VFS_OP_CONNECTPATH, result != NULL, handle, - "%s", fname); + "%s", smb_fname->base_name); return result; } diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 188463f6d51..b6bc1682d1f 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -1322,7 +1322,7 @@ static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle, } static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle, - const char *filename) + const struct smb_filename *smb_fname) { return handle->conn->connectpath; } diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 2977d7bdc3f..6a123092a5e 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -2700,11 +2700,12 @@ static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle, } static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle, - const char *fname) + const struct smb_filename *smb_fname_in) { time_t timestamp = 0; char *stripped = NULL; char *tmp = NULL; + const char *fname = smb_fname_in->base_name; struct smb_filename smb_fname = {0}; struct smb_filename *result_fname = NULL; char *result = NULL; @@ -2729,7 +2730,7 @@ static const char *shadow_copy2_connectpath(struct vfs_handle_struct *handle, goto done; } if (timestamp == 0) { - return SMB_VFS_NEXT_CONNECTPATH(handle, fname); + return SMB_VFS_NEXT_CONNECTPATH(handle, 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 905ad22fa6c..2f7c3d39dea 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -1624,19 +1624,20 @@ static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle, } static const char *smb_time_audit_connectpath(vfs_handle_struct *handle, - const char *fname) + 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, fname); + result = SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname); clock_gettime_mono(&ts2); timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log_fname("connectpath", timediff, fname); + smb_time_audit_log_fname("connectpath", timediff, + smb_fname->base_name); } return result; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 0eedf963f31..3ccee36e6f1 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -688,7 +688,7 @@ NTSTATUS fd_open(struct connection_struct *conn, if (!lp_widelinks(SNUM(conn))) { struct smb_filename *conn_rootdir_fname = NULL; const char *conn_rootdir = SMB_VFS_CONNECTPATH(conn, - smb_fname->base_name); + smb_fname); int saved_errno = 0; if (conn_rootdir == NULL) { diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 9bc02dafcfe..8304ef18b18 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1026,7 +1026,6 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn, char *dir_name = NULL; char *resolved_name = NULL; const char *last_component = NULL; - const char *fname = smb_fname->base_name; struct smb_filename *resolved_fname = NULL; struct smb_filename *saved_dir_fname = NULL; struct smb_filename *smb_fname_cwd = NULL; @@ -1034,7 +1033,7 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn, int ret; DEBUG(3,("check_reduced_name_with_privilege [%s] [%s]\n", - fname, + smb_fname->base_name, conn->connectpath)); @@ -1044,7 +1043,8 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn, goto err; } - if (!parent_dirname(ctx, fname, &dir_name, &last_component)) { + if (!parent_dirname(ctx, smb_fname->base_name, + &dir_name, &last_component)) { status = NT_STATUS_NO_MEMORY; goto err; } @@ -1117,7 +1117,7 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn, /* Ensure we're below the connect path. */ - conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname); + conn_rootdir = SMB_VFS_CONNECTPATH(conn, smb_fname); if (conn_rootdir == NULL) { DEBUG(2, ("check_reduced_name_with_privilege: Could not get " "conn_rootdir\n")); @@ -1302,7 +1302,7 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *conn_rootdir; size_t rootdir_len; - conn_rootdir = SMB_VFS_CONNECTPATH(conn, fname); + conn_rootdir = SMB_VFS_CONNECTPATH(conn, smb_fname); if (conn_rootdir == NULL) { DEBUG(2, ("check_reduced_name: Could not get " "conn_rootdir\n")); @@ -2268,10 +2268,10 @@ int smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle, } const char *smb_vfs_call_connectpath(struct vfs_handle_struct *handle, - const char *filename) + const struct smb_filename *smb_fname) { VFS_FIND(connectpath); - return handle->fns->connectpath_fn(handle, filename); + return handle->fns->connectpath_fn(handle, smb_fname); } bool smb_vfs_call_strict_lock(struct vfs_handle_struct *handle,