]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: Make chflags return errno = EROFS on a shadow copy path.
authorJeremy Allison <jra@samba.org>
Thu, 1 Aug 2019 20:35:47 +0000 (13:35 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 7 Aug 2019 16:40:31 +0000 (16:40 +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: Ralph Boehme <slow@samba.org>
source3/modules/vfs_shadow_copy2.c

index 01e8ba4d445e151439b28631d758f7b9956f2dc4..c66fc233a9d7dd6419f288a140a415184214aa66 100644 (file)
@@ -2285,46 +2285,19 @@ static int shadow_copy2_chflags(vfs_handle_struct *handle,
                                unsigned int flags)
 {
        time_t timestamp = 0;
-       char *stripped = NULL;
-       int saved_errno = 0;
-       int ret;
-       char *conv;
-       struct smb_filename *conv_smb_fname = NULL;
 
        if (!shadow_copy2_strip_snapshot(talloc_tos(),
                                        handle,
                                        smb_fname->base_name,
                                        &timestamp,
-                                       &stripped)) {
-               return -1;
-       }
-       if (timestamp == 0) {
-               return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
-       }
-       conv = shadow_copy2_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);
-       if (conv_smb_fname == NULL) {
-               TALLOC_FREE(conv);
+       if (timestamp != 0) {
+               errno = EROFS;
                return -1;
        }
-       ret = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
-       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_CHFLAGS(handle, smb_fname, flags);
 }
 
 static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,