From 0b64e84c01a36302a2298c1d1af4c7f4c41ed6eb Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 Aug 2019 10:07:04 -0700 Subject: [PATCH] s3: VFS: vfs_snapper: 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: David Disseldorp --- source3/modules/vfs_snapper.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index d862eb3151d..8fbaef694f2 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -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, - ×tamp, &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; + ×tamp, 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, -- 2.47.3