s3: VFS: vfs_ceph_snapshots: Make unlink return errno = EROFS on a shadow copy path.
authorJeremy Allison <jra@samba.org>
Thu, 8 Aug 2019 22:45:10 +0000 (15:45 -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 4d935a55a1a36ece378854297cbcdaf688f3ae09..8db03191094cf1ff6121a14545961d1a9b651478 100644 (file)
@@ -958,41 +958,20 @@ static int ceph_snap_gmt_unlink(vfs_handle_struct *handle,
                              const struct smb_filename *csmb_fname)
 {
        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_UNLINK(handle, csmb_fname);
-       }
-
-       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_UNLINK(handle, new_fname);
-       saved_errno = errno;
-       TALLOC_FREE(new_fname);
-       errno = saved_errno;
-       return ret;
+       return SMB_VFS_NEXT_UNLINK(handle, csmb_fname);
 }
 
 static int ceph_snap_gmt_chmod(vfs_handle_struct *handle,