From: Jeremy Allison Date: Fri, 9 Aug 2019 17:24:11 +0000 (-0700) Subject: s3: VFS: vfs_snapper: Make chown return errno = EROFS on a shadow copy path. X-Git-Tag: tdb-1.4.2~170 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=872cd6fbda959936d6b0c3b3e403377837c3abba;p=thirdparty%2Fsamba.git s3: VFS: vfs_snapper: Make chown 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 --- diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index 451414447ef..b1ab2b9738c 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -2243,44 +2243,20 @@ static int snapper_gmt_chown(vfs_handle_struct *handle, uid_t uid, gid_t gid) { - time_t timestamp; - char *stripped = NULL; - int ret, saved_errno; - char *conv = NULL; - struct smb_filename *conv_smb_fname = NULL; + time_t timestamp = 0; if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, smb_fname->base_name, ×tamp, - &stripped)) { - return -1; - } - if (timestamp == 0) { - TALLOC_FREE(stripped); - return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid); - } - conv = snapper_gmt_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_CHOWN(handle, conv_smb_fname, uid, gid); - saved_errno = errno; - TALLOC_FREE(conv); - TALLOC_FREE(conv_smb_fname); - errno = saved_errno; - return ret; + return SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid); } static int snapper_gmt_chdir(vfs_handle_struct *handle,