s3: VFS: Change SMB_VFS_CONNECTPATH to take const struct smb_filename * instead of...
authorJeremy Allison <jra@samba.org>
Fri, 30 Jun 2017 20:37:03 +0000 (13:37 -0700)
committerJeremy Allison <jra@samba.org>
Sat, 1 Jul 2017 05:20:28 +0000 (07:20 +0200)
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 <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Jul  1 07:20:28 CEST 2017 on sn-devel-144

12 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_shadow_copy2.c
source3/modules/vfs_time_audit.c
source3/smbd/open.c
source3/smbd/vfs.c

index f8f9857..74ffb67 100644 (file)
@@ -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;
index 29a9785..e584d51 100644 (file)
@@ -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,
index 1aa44ee..6a3f6c9 100644 (file)
                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,
index 0e8245e..4365f15 100644 (file)
 #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))
index 488ebc7..73106c4 100644 (file)
@@ -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;
 }
index 3336232..8a08aed 100644 (file)
@@ -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;
 }
index e66ad9e..215cb1f 100644 (file)
@@ -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;
 }
index 188463f..b6bc168 100644 (file)
@@ -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;
 }
index 2977d7b..6a12309 100644 (file)
@@ -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,
index 905ad22..2f7c3d3 100644 (file)
@@ -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;
index 0eedf96..3ccee36 100644 (file)
@@ -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) {
index 9bc02da..8304ef1 100644 (file)
@@ -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,