s3: VFS: vfs_ceph_snapshots: Make chmod return errno = EROFS on a shadow copy path.
authorJeremy Allison <jra@samba.org>
Thu, 8 Aug 2019 22:47:44 +0000 (15:47 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 9 Aug 2019 16:48:36 +0000 (16:48 +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_ceph_snapshots.c

index 8db03191094cf1ff6121a14545961d1a9b651478..3076fa54c3aecb7fcefaf3e5aa4760dfccbea25f 100644 (file)
@@ -979,41 +979,20 @@ static int ceph_snap_gmt_chmod(vfs_handle_struct *handle,
                        mode_t mode)
 {
        time_t timestamp = 0;
-       char stripped[PATH_MAX + 1];
-       char conv[PATH_MAX + 1];
        int ret;
-       struct smb_filename *new_fname;
-       int saved_errno;
 
        ret = ceph_snap_gmt_strip_snapshot(handle,
                                        csmb_fname->base_name,
-                                       &timestamp, stripped, sizeof(stripped));
-       if (ret < 0) {
-               errno = -ret;
-               return -1;
-       }
-       if (timestamp == 0) {
-               return SMB_VFS_NEXT_CHMOD(handle, csmb_fname, mode);
-       }
-
-       ret = ceph_snap_gmt_convert(handle, stripped,
-                                       timestamp, conv, sizeof(conv));
+                                       &timestamp, NULL, 0);
        if (ret < 0) {
                errno = -ret;
                return -1;
        }
-       new_fname = cp_smb_filename(talloc_tos(), csmb_fname);
-       if (new_fname == NULL) {
-               errno = ENOMEM;
+       if (timestamp != 0) {
+               errno = EROFS;
                return -1;
        }
-       new_fname->base_name = conv;
-
-       ret = SMB_VFS_NEXT_CHMOD(handle, new_fname, mode);
-       saved_errno = errno;
-       TALLOC_FREE(new_fname);
-       errno = saved_errno;
-       return ret;
+       return SMB_VFS_NEXT_CHMOD(handle, csmb_fname, mode);
 }
 
 static int ceph_snap_gmt_chown(vfs_handle_struct *handle,