s3: vfs: catia: compression get/set must act only on base file, and must cope with...
authorJeremy Allison <jra@samba.org>
Fri, 8 Sep 2017 22:28:39 +0000 (15:28 -0700)
committerRalph Boehme <slow@samba.org>
Tue, 12 Sep 2017 08:50:57 +0000 (10:50 +0200)
Correctly do filename conversion.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13003

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Sep 12 10:50:57 CEST 2017 on sn-devel-144

source3/modules/vfs_catia.c

index 5cf7476b4b2879361990f11621311da85bc55e8d..c47b64d8657c6e9b902517b7acf541615ca8b832 100644 (file)
@@ -2435,16 +2435,48 @@ static NTSTATUS catia_get_compression(vfs_handle_struct *handle,
        NTSTATUS result;
        struct catia_cache *cc = NULL;
        int ret;
+       struct smb_filename *mapped_smb_fname = NULL;
+       char *mapped_name = NULL;
 
-       ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc);
-       if (ret != 0) {
-               return map_nt_error_from_unix(errno);
+       if (fsp != NULL) {
+               ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc);
+               if (ret != 0) {
+                       return map_nt_error_from_unix(errno);
+               }
+               mapped_smb_fname = fsp->fsp_name;
+       } else {
+               result = catia_string_replace_allocate(handle->conn,
+                               smb_fname->base_name,
+                               &mapped_name,
+                               vfs_translate_to_unix);
+               if (!NT_STATUS_IS_OK(result)) {
+                       return result;
+               }
+
+               mapped_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                               mapped_name,
+                                               NULL,
+                                               NULL,
+                                               smb_fname->flags);
+               if (mapped_smb_fname == NULL) {
+                       TALLOC_FREE(mapped_name);
+                       return NT_STATUS_NO_MEMORY;
+               }
+
+               TALLOC_FREE(mapped_name);
        }
 
-       result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
-                                             _compression_fmt);
+       result = SMB_VFS_NEXT_GET_COMPRESSION(handle,
+                                       mem_ctx,
+                                       fsp,
+                                       mapped_smb_fname,
+                                       _compression_fmt);
 
-       CATIA_FETCH_FSP_POST_NEXT(&cc, fsp);
+       if (fsp != NULL) {
+               CATIA_FETCH_FSP_POST_NEXT(&cc, fsp);
+       } else {
+               TALLOC_FREE(mapped_smb_fname);
+       }
 
        return result;
 }