From 2022338b7f9d6e44c43f3d8c4280cfcca346514c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 9 Aug 2019 10:29:23 -0700 Subject: [PATCH] s3: VFS: vfs_snapper: Make rmdir 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 | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index d806b293b95..c3549d4aad9 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -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, - ×tamp, &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) { + ×tamp, 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, -- 2.47.3