]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: vfs_snapper: Make unlink return errno = EROFS on a shadow copy path.
authorJeremy Allison <jra@samba.org>
Fri, 9 Aug 2019 17:07:04 +0000 (10:07 -0700)
committerDavid Disseldorp <ddiss@samba.org>
Mon, 12 Aug 2019 00:00:40 +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 d862eb3151d898fda297cde535dcd2d080483a0c..8fbaef694f2d6005f867a41cbf6c2416232082de 100644 (file)
@@ -2204,35 +2204,18 @@ static int snapper_gmt_open(vfs_handle_struct *handle,
 static int snapper_gmt_unlink(vfs_handle_struct *handle,
                              const struct smb_filename *smb_fname)
 {
-       time_t timestamp;
-       char *stripped;
-       int ret, saved_errno;
-       struct smb_filename *conv;
+       time_t timestamp = 0;
 
        if (!snapper_gmt_strip_snapshot(talloc_tos(), handle,
                                        smb_fname->base_name,
-                                       &timestamp, &stripped)) {
-               return -1;
-       }
-       if (timestamp == 0) {
-               return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
-       }
-       conv = cp_smb_filename(talloc_tos(), smb_fname);
-       if (conv == NULL) {
-               errno = ENOMEM;
+                                       &timestamp, NULL)) {
                return -1;
        }
-       conv->base_name = snapper_gmt_convert(conv, handle,
-                                             stripped, timestamp);
-       TALLOC_FREE(stripped);
-       if (conv->base_name == NULL) {
+       if (timestamp != 0) {
+               errno = EROFS;
                return -1;
        }
-       ret = SMB_VFS_NEXT_UNLINK(handle, conv);
-       saved_errno = errno;
-       TALLOC_FREE(conv);
-       errno = saved_errno;
-       return ret;
+       return SMB_VFS_NEXT_UNLINK(handle, smb_fname);
 }
 
 static int snapper_gmt_chmod(vfs_handle_struct *handle,