s3/modules: shadow_copy2: Add new fsetxattr_fn implementation
authorNoel Power <noel.power@suse.com>
Fri, 19 Feb 2021 15:03:01 +0000 (15:03 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 11 Mar 2021 17:50:30 +0000 (17:50 +0000)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_shadow_copy2.c

index f3d16b10e19b231e2e0e0cedee80e084de342006..4903f18c3689143ffb23fe6458f987c59195a58a 100644 (file)
@@ -2355,6 +2355,30 @@ static int shadow_copy2_setxattr(struct vfs_handle_struct *handle,
                                aname, value, size, flags);
 }
 
+static int shadow_copy2_fsetxattr(struct vfs_handle_struct *handle,
+                                struct files_struct *fsp,
+                                const char *aname, const void *value,
+                                size_t size, int flags)
+{
+       time_t timestamp = 0;
+       const struct smb_filename *smb_fname = NULL;
+
+       smb_fname = fsp->fsp_name;
+       if (!shadow_copy2_strip_snapshot(talloc_tos(),
+                               handle,
+                               smb_fname,
+                               &timestamp,
+                               NULL)) {
+               return -1;
+       }
+       if (timestamp != 0) {
+               errno = EROFS;
+               return -1;
+       }
+       return SMB_VFS_NEXT_FSETXATTR(handle, fsp,
+                               aname, value, size, flags);
+}
+
 static NTSTATUS shadow_copy2_create_dfs_pathat(struct vfs_handle_struct *handle,
                                struct files_struct *dirfsp,
                                const struct smb_filename *smb_fname,
@@ -3202,6 +3226,7 @@ static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
        .getxattrat_recv_fn = vfs_not_implemented_getxattrat_recv,
        .removexattr_fn = shadow_copy2_removexattr,
        .setxattr_fn = shadow_copy2_setxattr,
+       .fsetxattr_fn = shadow_copy2_fsetxattr,
        .chflags_fn = shadow_copy2_chflags,
        .get_real_filename_fn = shadow_copy2_get_real_filename,
        .pwrite_fn = shadow_copy2_pwrite,