smbd: convert SMB_VFS_GET_REAL_FILENAME() arg path to be a struct smb_filename
authorRalph Boehme <slow@samba.org>
Thu, 30 Apr 2020 14:40:28 +0000 (16:40 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 5 May 2020 19:18:41 +0000 (19:18 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
17 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/modules/vfs_ceph.c
source3/modules/vfs_ceph_snapshots.c
source3/modules/vfs_default.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_glusterfs.c
source3/modules/vfs_glusterfs_fuse.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_not_implemented.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_snapper.c
source3/modules/vfs_time_audit.c
source3/smbd/dir.c
source3/smbd/filename.c
source3/smbd/vfs.c

index ed9f108009e56c6707c58e13c66ec6f030345bd9..bab1d34469cd3cff689ee9aa1f0dc28246a2784f 100644 (file)
@@ -643,7 +643,7 @@ static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
 }
 
 static int skel_get_real_filename(struct vfs_handle_struct *handle,
-                                 const char *path,
+                                 const struct smb_filename *path,
                                  const char *name,
                                  TALLOC_CTX *mem_ctx, char **found_name)
 {
index 1dce543734f8db51b4d6fa2c9040fbe4f80d265f..92f9e8a8123e3bd5b091381012137d3feb77012c 100644 (file)
@@ -860,7 +860,7 @@ static NTSTATUS skel_streaminfo(struct vfs_handle_struct *handle,
 }
 
 static int skel_get_real_filename(struct vfs_handle_struct *handle,
-                                 const char *path,
+                                 const struct smb_filename *path,
                                  const char *name,
                                  TALLOC_CTX *mem_ctx, char **found_name)
 {
index c698920735671de156fbf11b36ee5dbf7924eba0..5e4190adc307ce8ebc506301f8977d67a2b392f0 100644 (file)
  *              bool closing
  *              bool lock_failure_seen
  *              changed to bitfields.
+ * Version 43 - convert SMB_VFS_GET_REAL_FILENAME() arg path
+ *              to be a struct smb_filename
  */
 
 #define SMB_VFS_INTERFACE_VERSION 43
@@ -927,7 +929,7 @@ struct vfs_fn_pointers {
                                  struct stream_struct **streams);
 
        int (*get_real_filename_fn)(struct vfs_handle_struct *handle,
-                                   const char *path,
+                                   const struct smb_filename *path,
                                    const char *name,
                                    TALLOC_CTX *mem_ctx,
                                    char **found_name);
@@ -1418,7 +1420,7 @@ NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
                                 unsigned int *num_streams,
                                 struct stream_struct **streams);
 int smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle,
-                                  const char *path,
+                                  const struct smb_filename *path,
                                   const char *name,
                                   TALLOC_CTX *mem_ctx,
                                   char **found_name);
@@ -1893,7 +1895,7 @@ NTSTATUS vfs_not_implemented_streaminfo(struct vfs_handle_struct *handle,
                                        unsigned int *num_streams,
                                        struct stream_struct **streams);
 int vfs_not_implemented_get_real_filename(struct vfs_handle_struct *handle,
-                                         const char *path,
+                                         const struct smb_filename *path,
                                          const char *name,
                                          TALLOC_CTX *mem_ctx,
                                          char **found_name);
index ed7baba5ba5f2fc8283e0d92aaecf16985079338..5bc8f37a87d76f0221204627788552a977dc8011 100644 (file)
@@ -1138,7 +1138,7 @@ static int cephwrap_chflags(struct vfs_handle_struct *handle,
 }
 
 static int cephwrap_get_real_filename(struct vfs_handle_struct *handle,
-                                    const char *path,
+                                    const struct smb_filename *path,
                                     const char *name,
                                     TALLOC_CTX *mem_ctx,
                                     char **found_name)
index 17f688353f90bd7b42d9668baede91cf90e6c4b2..4472f9717a1f22b8455cd386e23fc96d960318b2 100644 (file)
@@ -1395,7 +1395,7 @@ static int ceph_snap_gmt_setxattr(struct vfs_handle_struct *handle,
 }
 
 static int ceph_snap_gmt_get_real_filename(struct vfs_handle_struct *handle,
-                                        const char *path,
+                                        const struct smb_filename *path,
                                         const char *name,
                                         TALLOC_CTX *mem_ctx,
                                         char **found_name)
@@ -1403,9 +1403,10 @@ static int ceph_snap_gmt_get_real_filename(struct vfs_handle_struct *handle,
        time_t timestamp = 0;
        char stripped[PATH_MAX + 1];
        char conv[PATH_MAX + 1];
+       struct smb_filename conv_fname;
        int ret;
 
-       ret = ceph_snap_gmt_strip_snapshot(handle, path,
+       ret = ceph_snap_gmt_strip_snapshot(handle, path->base_name,
                                        &timestamp, stripped, sizeof(stripped));
        if (ret < 0) {
                errno = -ret;
@@ -1421,7 +1422,12 @@ static int ceph_snap_gmt_get_real_filename(struct vfs_handle_struct *handle,
                errno = -ret;
                return -1;
        }
-       ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, conv, name,
+
+       conv_fname = (struct smb_filename) {
+               .base_name = conv,
+       };
+
+       ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, &conv_fname, name,
                                             mem_ctx, found_name);
        return ret;
 }
index bfc84e1d20b5b717a41cda5ad89fce49860a9733..578eb34180ae59e4c230269f0a18256665ff5844 100644 (file)
@@ -3054,7 +3054,7 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
 }
 
 static int vfswrap_get_real_filename(struct vfs_handle_struct *handle,
-                                    const char *path,
+                                    const struct smb_filename *path,
                                     const char *name,
                                     TALLOC_CTX *mem_ctx,
                                     char **found_name)
index f8eef6eb1df0fbe22dbb8eb40358eea0103144cb..fad8a14e24535aae4273d2481d1071c8f25b7b64 100644 (file)
@@ -1968,7 +1968,7 @@ static NTSTATUS smb_full_audit_streaminfo(vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
-                                           const char *path,
+                                           const struct smb_filename *path,
                                            const char *name,
                                            TALLOC_CTX *mem_ctx,
                                            char **found_name)
@@ -1979,7 +1979,8 @@ static int smb_full_audit_get_real_filename(struct vfs_handle_struct *handle,
                                                found_name);
 
        do_log(SMB_VFS_OP_GET_REAL_FILENAME, (result == 0), handle,
-              "%s/%s->%s", path, name, (result == 0) ? *found_name : "");
+              "%s/%s->%s",
+              path->base_name, name, (result == 0) ? *found_name : "");
 
        return result;
 }
index 2c00a2f6489a5adcc4bccdeb898a9643ee60c8f0..d8f39bd9a969799173a7ce2d0fc46a30d67643b3 100644 (file)
@@ -1751,7 +1751,7 @@ static int vfs_gluster_chflags(struct vfs_handle_struct *handle,
 }
 
 static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle,
-                                        const char *path,
+                                        const struct smb_filename *path,
                                         const char *name,
                                         TALLOC_CTX *mem_ctx,
                                         char **found_name)
@@ -1768,7 +1768,7 @@ static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle,
        snprintf(key_buf, GLUSTER_NAME_MAX + 64,
                 "glusterfs.get_real_filename:%s", name);
 
-       ret = glfs_getxattr(handle->data, path, key_buf, val_buf,
+       ret = glfs_getxattr(handle->data, path->base_name, key_buf, val_buf,
                            GLUSTER_NAME_MAX + 1);
        if (ret == -1) {
                if (errno == ENOATTR) {
index c621f9abf8e460878d4d0b935605b5c9951218e3..1e07308e980513c8a73045e6811a2e0a46f13928 100644 (file)
@@ -24,7 +24,7 @@
 #define GLUSTER_NAME_MAX 255
 
 static int vfs_gluster_fuse_get_real_filename(struct vfs_handle_struct *handle,
-                                             const char *path,
+                                             const struct smb_filename *path,
                                              const char *name,
                                              TALLOC_CTX *mem_ctx,
                                              char **_found_name)
@@ -42,7 +42,7 @@ static int vfs_gluster_fuse_get_real_filename(struct vfs_handle_struct *handle,
        snprintf(key_buf, GLUSTER_NAME_MAX + 64,
                 "glusterfs.get_real_filename:%s", name);
 
-       ret = getxattr(path, key_buf, val_buf, GLUSTER_NAME_MAX + 1);
+       ret = getxattr(path->base_name, key_buf, val_buf, GLUSTER_NAME_MAX + 1);
        if (ret == -1) {
                if (errno == ENOATTR) {
                        errno = ENOENT;
index ae3ee40e147d5ad6600785ecae7fda094c33d03d..5e5351c3c86d90c950d885d3463182bf648f0d8f 100644 (file)
@@ -279,7 +279,7 @@ failure:
 }
 
 static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
-                                     const char *path,
+                                     const struct smb_filename *path,
                                      const char *name,
                                      TALLOC_CTX *mem_ctx,
                                      char **found_name)
@@ -308,7 +308,8 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
                                                      mem_ctx, found_name);
        }
 
-       full_path_len = full_path_tos(path, name, tmpbuf, sizeof(tmpbuf),
+       full_path_len = full_path_tos(path->base_name, name,
+                                     tmpbuf, sizeof(tmpbuf),
                                      &full_path, &to_free);
        if (full_path_len == -1) {
                errno = ENOMEM;
@@ -345,7 +346,7 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
        }
 
        DEBUG(10, ("smbd_gpfs_get_realfilename_path: %s/%s -> %s\n",
-                  path, name, real_pathname));
+                  path->base_name, name, real_pathname));
 
        name = strrchr_m(real_pathname, '/');
        if (name == NULL) {
index cb770790479c7cc3d7dc4f16fb9bf4acfa5eb831..f5cd002d897a0a3e3f09a32889390a3d77f4c9a2 100644 (file)
@@ -646,7 +646,7 @@ NTSTATUS vfs_not_implemented_streaminfo(struct vfs_handle_struct *handle,
 }
 
 int vfs_not_implemented_get_real_filename(struct vfs_handle_struct *handle,
-                                         const char *path,
+                                         const struct smb_filename *path,
                                          const char *name,
                                          TALLOC_CTX *mem_ctx,
                                          char **found_name)
index a8c904215eabbc0ad2bbb89dd05567e841777e8e..f405c8a80e203e1438bb68bda5a9301e6b30be12 100644 (file)
@@ -2470,16 +2470,18 @@ static NTSTATUS shadow_copy2_read_dfs_pathat(struct vfs_handle_struct *handle,
 }
 
 static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
-                                         const char *path,
+                                         const struct smb_filename *fname,
                                          const char *name,
                                          TALLOC_CTX *mem_ctx,
                                          char **found_name)
 {
+       char *path = fname->base_name;
        time_t timestamp = 0;
        char *stripped = NULL;
        ssize_t ret;
        int saved_errno = 0;
        char *conv;
+       struct smb_filename conv_fname;
 
        DEBUG(10, ("shadow_copy2_get_real_filename called for path=[%s], "
                   "name=[%s]\n", path, name));
@@ -2491,7 +2493,7 @@ static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
        }
        if (timestamp == 0) {
                DEBUG(10, ("timestamp == 0\n"));
-               return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
+               return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, fname, name,
                                                      mem_ctx, found_name);
        }
        conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
@@ -2500,9 +2502,14 @@ static int shadow_copy2_get_real_filename(struct vfs_handle_struct *handle,
                DEBUG(10, ("shadow_copy2_convert failed\n"));
                return -1;
        }
+
+       conv_fname = (struct smb_filename) {
+               .base_name = conv,
+       };
+
        DEBUG(10, ("Calling NEXT_GET_REAL_FILE_NAME for conv=[%s], "
                   "name=[%s]\n", conv, name));
-       ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, conv, name,
+       ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, &conv_fname, name,
                                             mem_ctx, found_name);
        DEBUG(10, ("NEXT_REAL_FILE_NAME returned %d\n", (int)ret));
        if (ret == -1) {
index 50ea19112ca3a60831c2cbde0216062e2cb2b005..b98289b90eb610315e038ef63a3d4aab8952bcc6 100644 (file)
@@ -2623,23 +2623,25 @@ static int snapper_gmt_setxattr(struct vfs_handle_struct *handle,
 }
 
 static int snapper_gmt_get_real_filename(struct vfs_handle_struct *handle,
-                                        const char *path,
+                                        const struct smb_filename *fpath,
                                         const char *name,
                                         TALLOC_CTX *mem_ctx,
                                         char **found_name)
 {
+       char *path = fpath->base_name;
        time_t timestamp;
        char *stripped;
        ssize_t ret;
        int saved_errno;
        char *conv;
+       struct smb_filename conv_fname;
 
        if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, path,
                                        &timestamp, &stripped)) {
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
+               return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, fpath, name,
                                                      mem_ctx, found_name);
        }
        if (stripped[0] == '\0') {
@@ -2655,7 +2657,12 @@ static int snapper_gmt_get_real_filename(struct vfs_handle_struct *handle,
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, conv, name,
+
+       conv_fname = (struct smb_filename) {
+               .base_name = conv,
+       };
+
+       ret = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, &conv_fname, name,
                                             mem_ctx, found_name);
        saved_errno = errno;
        TALLOC_FREE(conv);
index 626ccd63921f314cad9c2b8007e338764d1f8d27..8b7be9660c44cf2ac3a1b97be6f2549158751d8a 100644 (file)
@@ -1616,7 +1616,7 @@ static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
-                                           const char *path,
+                                           const struct smb_filename *path,
                                            const char *name,
                                            TALLOC_CTX *mem_ctx,
                                            char **found_name)
@@ -1632,7 +1632,8 @@ static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("get_real_filename", timediff, path);
+               smb_time_audit_log_fname("get_real_filename",
+                                        timediff, path->base_name);
        }
 
        return result;
index d6aa45b7997797a69603c087866031e790ff35e9..2cd659aab73c787f6a866e23018e8ec444db359e 100644 (file)
@@ -520,7 +520,7 @@ static char *dptr_ReadDirName(TALLOC_CTX *ctx,
         * scanning the whole directory.
         */
        ret = SMB_VFS_GET_REAL_FILENAME(dptr->conn,
-                                       dptr->smb_dname->base_name,
+                                       dptr->smb_dname,
                                        dptr->wcard,
                                        ctx,
                                        &found_name);
index 976aa9c4cd99fd83b95135950baba5e74440935c..0a3d8f390075b32c1ffc97af383c225e055f16e4 100644 (file)
@@ -1687,7 +1687,7 @@ int get_real_filename(connection_struct *conn,
 
        /* Try the vfs first to take advantage of case-insensitive stat. */
        ret = SMB_VFS_GET_REAL_FILENAME(conn,
-                                       path->base_name,
+                                       path,
                                        name,
                                        mem_ctx,
                                        found_name);
index fc43eebcadf335c37a4506a6209dc500a40efa14..89180e46e1e7d529cdc3edb5cc6264e225e24b2a 100644 (file)
@@ -2233,7 +2233,7 @@ NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle,
-                                  const char *path,
+                                  const struct smb_filename *path,
                                   const char *name,
                                   TALLOC_CTX *mem_ctx,
                                   char **found_name)