From: Jeremy Allison Date: Thu, 1 Aug 2019 20:31:01 +0000 (-0700) Subject: s3: VFS: Make mknod return errno = EROFS on a shadow copy path. X-Git-Tag: tdb-1.4.2~257 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2e43661a1b907209a3ae165f1ec2b4bcb1c93ddf;p=thirdparty%2Fsamba.git s3: VFS: Make mknod 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 836898510c4..5256eed1011 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -1701,39 +1701,17 @@ static int shadow_copy2_mknod(vfs_handle_struct *handle, SMB_DEV_T dev) { time_t timestamp = 0; - char *stripped = NULL; - int saved_errno = 0; - int ret; - struct smb_filename *conv = NULL; if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, smb_fname->base_name, - ×tamp, &stripped)) { - return -1; - } - if (timestamp == 0) { - return SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev); - } - conv = cp_smb_filename(talloc_tos(), smb_fname); - if (conv == NULL) { - errno = ENOMEM; + ×tamp, NULL)) { return -1; } - conv->base_name = shadow_copy2_convert( - conv, handle, stripped, timestamp); - TALLOC_FREE(stripped); - if (conv->base_name == NULL) { + if (timestamp != 0) { + errno = EROFS; return -1; } - ret = SMB_VFS_NEXT_MKNOD(handle, conv, mode, dev); - if (ret == -1) { - saved_errno = errno; - } - TALLOC_FREE(conv); - if (saved_errno != 0) { - errno = saved_errno; - } - return ret; + return SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev); } static struct smb_filename *shadow_copy2_realpath(vfs_handle_struct *handle,