From: Jeremy Allison Date: Thu, 1 Aug 2019 20:23:48 +0000 (-0700) Subject: s3: VFS: Make chmod return errno = EROFS on a shadow copy path. X-Git-Tag: tdb-1.4.2~260 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e8e1b00aef923c701b122cdcc6de16a05b9915ca;p=thirdparty%2Fsamba.git s3: VFS: Make chmod 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 --- diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 97c3b5d0de9..6f21c8e0232 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -1498,49 +1498,19 @@ static int shadow_copy2_chmod(vfs_handle_struct *handle, mode_t mode) { time_t timestamp = 0; - char *stripped = NULL; - int saved_errno = 0; - int ret; - char *conv = NULL; - struct smb_filename *conv_smb_fname; if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, smb_fname->base_name, ×tamp, - &stripped)) { - return -1; - } - if (timestamp == 0) { - TALLOC_FREE(stripped); - return SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode); - } - conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp); - TALLOC_FREE(stripped); - if (conv == NULL) { + NULL)) { return -1; } - conv_smb_fname = synthetic_smb_fname(talloc_tos(), - conv, - NULL, - NULL, - smb_fname->flags); - if (conv_smb_fname == NULL) { - TALLOC_FREE(conv); - errno = ENOMEM; + if (timestamp != 0) { + errno = EROFS; return -1; } - - ret = SMB_VFS_NEXT_CHMOD(handle, conv_smb_fname, mode); - if (ret == -1) { - saved_errno = errno; - } - TALLOC_FREE(conv); - TALLOC_FREE(conv_smb_fname); - if (saved_errno != 0) { - errno = saved_errno; - } - return ret; + return SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode); } static int shadow_copy2_chown(vfs_handle_struct *handle,