From: Jeremy Allison Date: Fri, 16 Aug 2019 22:59:27 +0000 (-0700) Subject: s3: VFS: vfs_shadow_copy2. Implement linkat(). X-Git-Tag: tevent-0.10.1~302 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c55b43ba13a162d07befc27361632cdf2ef8aeb2;p=thirdparty%2Fsamba.git s3: VFS: vfs_shadow_copy2. Implement linkat(). Currently identical to link(). Signed-off-by: Jeremy Allison Reviewed-by: Ralph Böhme --- diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 5d57b9c0229..84fe49bdcb9 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -1267,6 +1267,55 @@ static int shadow_copy2_link(vfs_handle_struct *handle, return SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname); } +static int shadow_copy2_linkat(vfs_handle_struct *handle, + files_struct *srcfsp, + const struct smb_filename *old_smb_fname, + files_struct *dstfsp, + const struct smb_filename *new_smb_fname, + int flags) +{ + time_t timestamp_old = 0; + time_t timestamp_new = 0; + char *snappath_old = NULL; + char *snappath_new = NULL; + + if (!shadow_copy2_strip_snapshot_internal(talloc_tos(), + handle, + old_smb_fname->base_name, + ×tamp_old, + NULL, + &snappath_old, + NULL)) { + return -1; + } + if (!shadow_copy2_strip_snapshot_internal(talloc_tos(), + handle, + new_smb_fname->base_name, + ×tamp_new, + NULL, + &snappath_new, + NULL)) { + return -1; + } + if ((timestamp_old != 0) || (timestamp_new != 0)) { + errno = EROFS; + return -1; + } + /* + * Don't allow links on already converted paths. + */ + if ((snappath_old != NULL) || (snappath_new != NULL)) { + errno = EROFS; + return -1; + } + return SMB_VFS_NEXT_LINKAT(handle, + srcfsp, + old_smb_fname, + dstfsp, + new_smb_fname, + flags); +} + static int shadow_copy2_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname) { @@ -3131,6 +3180,7 @@ static struct vfs_fn_pointers vfs_shadow_copy2_fns = { .get_quota_fn = shadow_copy2_get_quota, .renameat_fn = shadow_copy2_renameat, .link_fn = shadow_copy2_link, + .linkat_fn = shadow_copy2_linkat, .symlink_fn = shadow_copy2_symlink, .stat_fn = shadow_copy2_stat, .lstat_fn = shadow_copy2_lstat,