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 f8f98575f62e018e56111ccf39c353900fbb3668..74ffb672024a96f2e2afea721bf8e3d3130b063d 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 29a9785297429b458726f4262bb119a60dfd3653..e584d51465592b8b3d7369fd21308644e17928ce 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 1aa44ee14e1496aefc7b79ece4aadfa55c61c390..6a3f6c9c42efd9d23370ec2822e71576d41ba88a 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 0e8245e752d6e9d7be0c8081408730b6c441e258..4365f15b3d1f570c75503373df13cbaabedc6083 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 488ebc7795d91342182a9d57b5593c7dcb55f1aa..73106c4ac604fcda3e9bd116a0ad18358244894d 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 3336232e3d604bfcbd365d34a7cc1988fd8af77e..8a08aed83f8f2db8a31715cab23b7168e103bf98 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 e66ad9ebe434fb4c5faefc8c7f5d1c259c311662..215cb1f3934cfde5a9e57c2d22ed159134120e68 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 188463f6d51e5c85f6bdbaa0f0f90026f9557279..b6bc1682d1f6e3e00996e48d37f76f9b04cc6245 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 2977d7bdc3fa30ae7967712b46b17737c877a606..6a123092a5e0cc174112c1c3fa35667f61499875 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 905ad22fa6cd384c509b616132949d1802aae8aa..2f7c3d39dea8fee566c90f1b0ea006c56bc172f9 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 0eedf963f31ab54b537e75ac25425c64bfc8ffe2..3ccee36e6f1993d20a04c19a7aa4555145eaaba4 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 9bc02dafcfe1a042d163c3a368c1d64db557221a..8304ef18b185f74dbf0a9dd2159afddc81009edc 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,