From 2e3f644f0aa78a255df41325ea6f3bee7f733208 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Aug 2019 13:18:42 -0700 Subject: [PATCH] s3: VFS: Make unlink return errno = EROFS on a shadow copy path. smbd has no business modifying a shadow copy filesystem, it should be read-only. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/modules/vfs_shadow_copy2.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index e5def9669f4..97c3b5d0de9 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -1480,39 +1480,17 @@ static int shadow_copy2_unlink(vfs_handle_struct *handle, const struct smb_filename *smb_fname) { time_t timestamp = 0; - char *stripped = NULL; - int saved_errno = 0; - int ret; - struct smb_filename *conv; if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, smb_fname->base_name, - ×tamp, &stripped)) { + ×tamp, NULL)) { 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; - return -1; - } - conv->base_name = shadow_copy2_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); - if (ret == -1) { - saved_errno = errno; - } - TALLOC_FREE(conv); - if (saved_errno != 0) { - errno = saved_errno; - } - return ret; + return SMB_VFS_NEXT_UNLINK(handle, smb_fname); } static int shadow_copy2_chmod(vfs_handle_struct *handle, -- 2.47.3