From 0ebb15a6e236bf920ee9ff901b81b264212c4c37 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 8 Aug 2019 15:56:59 -0700 Subject: [PATCH] s3: VFS: vfs_ceph_snapshots: Make chflags 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_ceph_snapshots.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c index 1eb94d5c15a..315472086c0 100644 --- a/source3/modules/vfs_ceph_snapshots.c +++ b/source3/modules/vfs_ceph_snapshots.c @@ -1324,40 +1324,20 @@ static int ceph_snap_gmt_chflags(vfs_handle_struct *handle, unsigned int flags) { time_t timestamp = 0; - char stripped[PATH_MAX + 1]; - char conv[PATH_MAX + 1]; int ret; - struct smb_filename *new_fname; - int saved_errno; ret = ceph_snap_gmt_strip_snapshot(handle, csmb_fname->base_name, - ×tamp, stripped, sizeof(stripped)); - if (ret < 0) { - errno = -ret; - return -1; - } - if (timestamp == 0) { - return SMB_VFS_NEXT_CHFLAGS(handle, csmb_fname, flags); - } - ret = ceph_snap_gmt_convert(handle, stripped, - timestamp, conv, sizeof(conv)); + ×tamp, NULL, 0); if (ret < 0) { errno = -ret; return -1; } - new_fname = cp_smb_filename(talloc_tos(), csmb_fname); - if (new_fname == NULL) { - errno = ENOMEM; + if (timestamp != 0) { + errno = EROFS; return -1; } - new_fname->base_name = conv; - - ret = SMB_VFS_NEXT_CHFLAGS(handle, new_fname, flags); - saved_errno = errno; - TALLOC_FREE(new_fname); - errno = saved_errno; - return ret; + return SMB_VFS_NEXT_CHFLAGS(handle, csmb_fname, flags); } static ssize_t ceph_snap_gmt_getxattr(vfs_handle_struct *handle, -- 2.47.3