From 0db5f559d0ef883c975177a705e82ae4d0951c72 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Tue, 23 May 2023 17:28:33 +0200 Subject: [PATCH] libadouble: allow FILE_SHARE_DELETE in ad_convert_xattr() Not specifying FILE_SHARE_DELETE wasn't done intentionally. Not setting the flag triggers the following problem: * client sends a CREATE with delete access * this triggers a call to open_streams_for_delete() where we check for conflicting opens on any of the streams of the file or directory * if the file (or directory) has a stream like ":com.apple.quarantine" the stream is opened with DELETE_ACCESS and kept open when the next step might: * if the file (or directory) has a Mac specific :AFP_AfpInfo stream, the ad_convert() routine in fruit_create_file() is triggered * ad_convert() checks if the file (or ...) has a sidecar ._ AppleDouble file, if it has: * in ad_convert_xattr() we unpack any set of xattrs encoded in the AppleDouble file and recreate them as streams with the VFS. Now, if any of these xattrs happens to be converted to a stream that we still have open in open_streams_for_delete() (see above) we get a NT_STATUS_SHARING_VIOLATION This error gets passed up the stack back to open_streams_for_delete() so the client CREATE request fails and the client is unhappy. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15378 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 55bd10456486628cad2bd085618e873598401c3b) --- .../samba3.vfs.fruit.delete_trigger_convert_sharing_violation | 4 ---- source3/lib/adouble.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 selftest/knownfail.d/samba3.vfs.fruit.delete_trigger_convert_sharing_violation diff --git a/selftest/knownfail.d/samba3.vfs.fruit.delete_trigger_convert_sharing_violation b/selftest/knownfail.d/samba3.vfs.fruit.delete_trigger_convert_sharing_violation deleted file mode 100644 index 7af35b0d4d5..00000000000 --- a/selftest/knownfail.d/samba3.vfs.fruit.delete_trigger_convert_sharing_violation +++ /dev/null @@ -1,4 +0,0 @@ -^samba3.vfs.fruit metadata_netatalk.delete_trigger_convert_sharing_violation\(nt4_dc\) -^samba3.vfs.fruit metadata_stream.delete_trigger_convert_sharing_violation\(nt4_dc\) -^samba3.vfs.fruit streams_depot.delete_trigger_convert_sharing_violation\(nt4_dc\) -^samba3.vfs.fruit fruit_delete_empty_adfiles.delete_trigger_convert_sharing_violation\(nt4_dc\) diff --git a/source3/lib/adouble.c b/source3/lib/adouble.c index 062c73ec758..15f8f0aa8a9 100644 --- a/source3/lib/adouble.c +++ b/source3/lib/adouble.c @@ -1222,7 +1222,7 @@ static bool ad_convert_xattr(vfs_handle_struct *handle, NULL, /* dirfsp */ stream_name, /* fname */ FILE_GENERIC_WRITE, /* access_mask */ - FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, /* share_access */ FILE_OPEN_IF, /* create_disposition */ 0, /* create_options */ 0, /* file_attributes */