s3: VFS: vfs_snapper: Make removexattr return errno = EROFS on a shadow copy path.
authorJeremy Allison <jra@samba.org>
Fri, 9 Aug 2019 17:31:38 +0000 (10:31 -0700)
committerDavid Disseldorp <ddiss@samba.org>
Mon, 12 Aug 2019 00:00:41 +0000 (00:00 +0000)
smbd has no business modifying a shadow copy filesystem, it should be read-only.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
source3/modules/vfs_snapper.c

index 28edfd7a4d91cfe0fed23fb42b379b80741783f8..cb1921cdd121ddaaae7b81e49f714e1796b22de1 100644 (file)
@@ -2667,47 +2667,19 @@ static int snapper_gmt_removexattr(vfs_handle_struct *handle,
                                const char *aname)
 {
        time_t timestamp = 0;
-       char *stripped = NULL;
-       ssize_t ret;
-       int saved_errno = 0;
-       char *conv = NULL;
-       struct smb_filename *conv_smb_fname = NULL;
 
        if (!snapper_gmt_strip_snapshot(talloc_tos(),
                                        handle,
                                        smb_fname->base_name,
                                        &timestamp,
-                                       &stripped)) {
-               return -1;
-       }
-       if (timestamp == 0) {
-               return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, aname);
-       }
-       conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
-       TALLOC_FREE(stripped);
-       if (conv == NULL) {
+                                       NULL)) {
                return -1;
        }
-       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
-                                       conv,
-                                       NULL,
-                                       NULL,
-                                       smb_fname->flags);
-       TALLOC_FREE(conv);
-       if (conv_smb_fname == NULL) {
-               errno = ENOMEM;
+       if (timestamp != 0) {
+               errno = EROFS;
                return -1;
        }
-       ret = SMB_VFS_NEXT_REMOVEXATTR(handle, conv_smb_fname, aname);
-       if (ret == -1) {
-               saved_errno = errno;
-       }
-       TALLOC_FREE(conv_smb_fname);
-       TALLOC_FREE(conv);
-       if (saved_errno != 0) {
-               errno = saved_errno;
-       }
-       return ret;
+       return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, aname);
 }
 
 static int snapper_gmt_setxattr(struct vfs_handle_struct *handle,