s3: VFS: vfs_snapper: Make rmdir return errno = EROFS on a shadow copy path.
authorJeremy Allison <jra@samba.org>
Fri, 9 Aug 2019 17:29:23 +0000 (10:29 -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 d806b293b9561316d8cc47b2b826fea6826a223c..c3549d4aad90117b87b8c73b0d99997320d99aff 100644 (file)
@@ -2533,39 +2533,17 @@ static int snapper_gmt_mkdir(vfs_handle_struct *handle,
 static int snapper_gmt_rmdir(vfs_handle_struct *handle,
                                const struct smb_filename *fname)
 {
-       time_t timestamp;
-       char *stripped;
-       int ret, saved_errno;
-       char *conv;
-       struct smb_filename *smb_fname = NULL;
+       time_t timestamp = 0;
 
        if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname->base_name,
-                                       &timestamp, &stripped)) {
-               return -1;
-       }
-       if (timestamp == 0) {
-               return SMB_VFS_NEXT_RMDIR(handle, fname);
-       }
-       conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
-       TALLOC_FREE(stripped);
-       if (conv == NULL) {
+                                       &timestamp, NULL)) {
                return -1;
        }
-       smb_fname = synthetic_smb_fname(talloc_tos(),
-                                       conv,
-                                       NULL,
-                                       NULL,
-                                       fname->flags);
-       TALLOC_FREE(conv);
-       if (smb_fname == NULL) {
-               errno = ENOMEM;
+       if (timestamp != 0) {
+               errno = EROFS;
                return -1;
        }
-       ret = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
-       saved_errno = errno;
-       TALLOC_FREE(smb_fname);
-       errno = saved_errno;
-       return ret;
+       return SMB_VFS_NEXT_RMDIR(handle, fname);
 }
 
 static int snapper_gmt_chflags(vfs_handle_struct *handle,