From: Jeremy Allison Date: Fri, 9 Aug 2019 17:32:41 +0000 (-0700) Subject: s3: VFS: vfs_snapper: Make setxattr return errno = EROFS on a shadow copy path. X-Git-Tag: tdb-1.4.2~163 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e6b7d782020e86fc8e28438c969a2e9e1da288f1;p=thirdparty%2Fsamba.git s3: VFS: vfs_snapper: Make setxattr 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 Autobuild-User(master): David Disseldorp Autobuild-Date(master): Mon Aug 12 01:18:45 UTC 2019 on sn-devel-184 --- diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index cb1921cdd12..03bcf658ec6 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -2688,49 +2688,20 @@ static int snapper_gmt_setxattr(struct vfs_handle_struct *handle, size_t size, int flags) { time_t timestamp = 0; - char *stripped = NULL; - ssize_t ret; - int saved_errno = 0; - char *conv = NULL; - struct smb_filename *conv_smb_fname = NULL; if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, smb_fname->base_name, ×tamp, - &stripped)) { - return -1; - } - if (timestamp == 0) { - return SMB_VFS_NEXT_SETXATTR(handle, smb_fname, - aname, value, size, flags); - } - 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); - TALLOC_FREE(conv); - if (conv_smb_fname == NULL) { - errno = ENOMEM; + if (timestamp != 0) { + errno = EROFS; return -1; } - ret = SMB_VFS_NEXT_SETXATTR(handle, conv_smb_fname, + return SMB_VFS_NEXT_SETXATTR(handle, smb_fname, aname, value, size, flags); - if (ret == -1) { - saved_errno = errno; - } - TALLOC_FREE(conv_smb_fname); - TALLOC_FREE(conv); - if (saved_errno != 0) { - errno = saved_errno; - } - return ret; } static int snapper_gmt_get_real_filename(struct vfs_handle_struct *handle,