The branch, master has been updated via 41204a4 vfs_fruit: enabling AAPL extensions must be a global switch via 708767d vfs_fruit: only veto AppleDouble files with fruit:resource=file via c7a79a9 s4/torture: vfs_fruit: add stream with illegal ntfs characters to copyile test via ffa727f vfs_fruit: use stat info from base_fsp via 8b7e88f s4/torture: vfs_fruit: test invalid AFPINFO_STREAM_NAME via a2afd61 vfs_fruit: ignore or delete invalid AFP_AfpInfo streams via bac79ea selftest: add shares without vfs_fruit for the vfs_fruit tests via 08dc5b4 s4/torture: change shares in used torture_suite_add_2ns_smb2_test() via b302444 docs/vfs_fruit: document known limitations with fruit:encoding=native via c8baf27 s4/torture: add test for AAPL find with name with illegal NTFS characters via 4972315 lib/torture: add torture_assert_mem_equal_goto via 8ae4539 s4/torture: add a vfs_fruit renaming test with open rsrc fork via f555c23 s4/torture: vfs_fruit: test deleting a file with resource fork via 3227b89 s4/torture: vfs_fruit: add test_null_afpinfo test via 9975c75 selftest: add description to vfs_fruit testsuites via f7b0982 selftest: also run vfs_fruit tests with streams_depot via d9ab40e selftest: run vfs_fruit tests against share with fruit:metadata=stream via cc88522 selftest: move vfs_fruit tests that require "fruit:metadata=netatalk" to vfs.fruit_netatalk via 51189bd selftest: reenable vfs_fruit tests via cc88132 vfs_fruit: refactor fruit_ftruncate and use new adouble API via b3c0f78 vfs_fruit: use fio in fruit_fallocate via ae6199c vfs_fruit: refactor fruit_fstat and use new adouble API via fcb9c84 vfs_fruit: refactor fruit_pread and fruit_pwrite and use new adouble API via 6537c56 vfs_fruit: refactor fruit_open and use new adouble API via 1d12035 vfs_fruit: rework struct adouble API via 8703b8e selftest: disable vfs_fruit tests via 41a2b2f vfs_fruit: fix fruit_check_access() via b122352 vfs_fruit: remove base_fsp name translation via 3e2a7f6 vfs_fruit: use SMB_VFS_NEXT_OPEN in two places via ad8a3b6 vfs_fruit: refactor readdir_attr_macmeta() resource fork size via a5b060f vfs_fruit: refactor fruit_ftruncate() and fix stream case via b0b785b vfs_fruit: fix fruit_ntimes() for the fruit:metadata!=netatalk case via ef2c81e vfs_fruit: refactor fruit_streaminfo() via 72325d9 vfs_fruit: add fruit_stat_rsrc_xattr() implementation via cbf87b4 vfs_fruit: add fruit_stat_rsrc_stream() implementation via 5037816 vfs_fruit: refactor fruit_stat_rsrc() via 22da6c8 vfs_fruit: refactor fruit_open_rsrc() via b95d204 vfs_fruit: in fruit_rmdir() check ._ files before deleting them via 1985407 vfs_fruit: fix fruit_rmdir() for the fruit:resource!=file case via 09c82a1 vfs_fruit: fix fruit_chown() for the fruit:resource!=file case via 22b509f vfs_fruit: fix fruit_chmod() for the fruit:resource!=file case via 6730e10 vfs_fruit: refactor fruit_unlink() via 8a9d0c5 vfs_fruit: fix fruit_rename() for the fruit:resource!=file case via 604bd6b vfs_fruit: correct readdir_attr_meta_finderi_stream() implementation via 5a46656 vfs_fruit: refactor readdir_attr_meta() via 79159f8 vfs_fruit: update_btime() is only needed for metadata=netatalk via cb1121e vfs_fruit: correct fruit_stat_meta_stream() implementation via aaf2ae1 vfs_fruit: refactor fruit_stat_meta() via a3be9e6 vfs_fruit: correct fruit_open_meta_stream() implementation via 5a072ca vfs_fruit: refactor fruit_open_meta() via 3d5bf4b vfs_fruit: replace unsafe ad_entry macro with a function via b121fff vfs_fruit: fix fruit_pwrite() with metadata=stream via 05d54dd vfs_fruit: rename empty_finderinfo() and make it more robust via 04feedb vfs_fruit: fix fruit_ftruncate with metadata=stream via d0eed8e vfs_fruit: fix fruit_pread with metadata=stream via 633aa1a vfs_catia: add catia_(g|s)et_dos_attributes via abe3572 vfs_catia: add catia_readdir_attr via af3b4ea vfs_catia: run translation on all handle based VFS functions via 4e2c7d0 vfs_streams_xattr: use SMB_VFS_NEXT_OPEN and CLOSE via 8035754 vfs_streams_xattr: call SMB_VFS_OPEN with smb_fname_base via 73a0768 s3/includes: add FinderInfo offset define to MacExtensions.h via 5e61235 selftest: don't run vfs_fruit tests against ad_dc env from 3d649a0 winbind: Fix a cut&paste debug typo
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 41204a4972ea62b7b656ad81e24bd052990f7e87 Author: Ralph Boehme <s...@samba.org> Date: Tue Feb 28 09:39:37 2017 +0100 vfs_fruit: enabling AAPL extensions must be a global switch Apple's SMB2 AAPL extension is enabled once per SMB2 connection. Unfortunately the (per se correct) fix for bug #12541 results in vfs_fruit checking a per tcon config state variable to determine whether AAPL has been negotiated. This variable will be false for all but the first tcon. We must make it a global variable. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12604 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> Autobuild-User(master): Uri Simchoni <u...@samba.org> Autobuild-Date(master): Thu Mar 2 04:34:10 CET 2017 on sn-devel-144 commit 708767da8c366c021d6d15a3ae71d009357c3320 Author: Ralph Boehme <s...@samba.org> Date: Thu Jan 19 09:30:45 2017 +0100 vfs_fruit: only veto AppleDouble files with fruit:resource=file vfs_fruit only creates AppleDouble files itself when "fruit:resource" is set to "file" (the default). It is only then the these AppleDouble files should be treated as an internal representation and should be inaccessible from clients. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12526> Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit c7a79a9b35225f41eeae961ab340882c7d49f0c4 Author: Ralph Boehme <s...@samba.org> Date: Fri Feb 17 16:35:44 2017 +0100 s4/torture: vfs_fruit: add stream with illegal ntfs characters to copyile test This ensures a stream with illegal NTFS characters mapped to the Unicode private range like :foo\xef\x80\xa2bar:$DATA that is stored as an xattr name user.DosStream.foo:bar:$DATA if "fruit:encoding = native" is set, is copied by the special fruit copy_chunk request. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit ffa727f33b06e71403303b53797a068f455b22f8 Author: Ralph Boehme <s...@samba.org> Date: Tue Feb 7 15:01:53 2017 +0100 vfs_fruit: use stat info from base_fsp This is also supposed to be valid in the VFS stack, so there's no need to re-stat here. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 8b7e88f368ce793699fc57272e74d0815219a250 Author: Ralph Boehme <s...@samba.org> Date: Sun Dec 11 19:11:09 2016 +0100 s4/torture: vfs_fruit: test invalid AFPINFO_STREAM_NAME BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit a2afd61906fbf36f75b2054abfd7384f220a14e3 Author: Ralph Boehme <s...@samba.org> Date: Sun Dec 11 19:10:05 2016 +0100 vfs_fruit: ignore or delete invalid AFP_AfpInfo streams BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit bac79eac093e042f22a77fa8e468f8c92bb3c113 Author: Ralph Boehme <s...@samba.org> Date: Sun Dec 11 19:06:46 2016 +0100 selftest: add shares without vfs_fruit for the vfs_fruit tests Not used for now, but the next commit will add a test that makes use of this. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 08dc5b4673a955f365095824275e67b2ea8fc31e Author: Ralph Boehme <s...@samba.org> Date: Sun Dec 11 19:02:37 2016 +0100 s4/torture: change shares in used torture_suite_add_2ns_smb2_test() torture_suite_add_2ns_smb2_test wan't used, change it to use the default share as share 1 and a second share taken from torture option "torture:share2". BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit b302444f5b0675f0cb0f26fa2ad53e298067f7ab Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 17:47:36 2016 +0100 docs/vfs_fruit: document known limitations with fruit:encoding=native BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit c8baf2760ad51a7739084a8e2617c58c287b651e Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 15:45:12 2016 +0100 s4/torture: add test for AAPL find with name with illegal NTFS characters BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 49723151b2107553559c397adadda90f7c4806f7 Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 15:44:37 2016 +0100 lib/torture: add torture_assert_mem_equal_goto BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 8ae4539e47bcaa37d5a052eaf443a95287d851e1 Author: Ralph Boehme <s...@samba.org> Date: Tue Dec 6 10:25:46 2016 +0100 s4/torture: add a vfs_fruit renaming test with open rsrc fork Verify IO on the resource fork works after a rename of the basefile. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit f555c2318eb06d1ceef32423dba9cd1a7c76f956 Author: Ralph Boehme <s...@samba.org> Date: Mon Dec 5 11:21:15 2016 +0100 s4/torture: vfs_fruit: test deleting a file with resource fork All the other tests ignore the return value of smb2_util_unlink(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 3227b891fcdd912b0c09398fed751fe8b53d01c9 Author: Ralph Boehme <s...@samba.org> Date: Tue Nov 29 16:21:08 2016 +0100 s4/torture: vfs_fruit: add test_null_afpinfo test BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 9975c7569cf5af74c25ac03985a7c409164ac2ce Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 17:41:14 2016 +0100 selftest: add description to vfs_fruit testsuites BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit f7b0982826b58cfcdaf8782e15c2440f31a45ba2 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 07:42:07 2016 +0100 selftest: also run vfs_fruit tests with streams_depot BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit d9ab40e0834c074ea26460347b035c52eb5eb0d7 Author: Ralph Boehme <s...@samba.org> Date: Tue Nov 15 15:25:14 2016 +0100 selftest: run vfs_fruit tests against share with fruit:metadata=stream BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit cc885223d79a7e8eb2177a351b745dceec0c9f5a Author: Ralph Boehme <s...@samba.org> Date: Tue Nov 15 22:31:20 2016 +0100 selftest: move vfs_fruit tests that require "fruit:metadata=netatalk" to vfs.fruit_netatalk BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 51189bd4758a140bad6abf3300c931302432a687 Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 20:43:21 2016 +0100 selftest: reenable vfs_fruit tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit cc88132854ed47510e056ed451ed376770ee301e Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 20:42:54 2016 +0100 vfs_fruit: refactor fruit_ftruncate and use new adouble API Use struct fio to denote a fsp handle is for a stream we care about. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit b3c0f785d753b26404f67acf8061be1cafde79a9 Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 20:41:55 2016 +0100 vfs_fruit: use fio in fruit_fallocate BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit ae6199c5ef9022518a709bb9aff20b8b2d83e456 Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 20:39:38 2016 +0100 vfs_fruit: refactor fruit_fstat and use new adouble API Use struct fio to denote a fsp handle is for a stream we care about. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit fcb9c840d7d082457c3136a44a23b489c98b0327 Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 20:38:17 2016 +0100 vfs_fruit: refactor fruit_pread and fruit_pwrite and use new adouble API Use struct fio to denote a fsp handle is for a stream we care about. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 6537c56de5dae8a1d193a949910296aea1cb6a4e Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 20:34:55 2016 +0100 vfs_fruit: refactor fruit_open and use new adouble API Use struct fio to denote a fsp handle is for a stream we care about. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 1d1203574328570288806fffefabb550ecc4e95d Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 19:12:32 2016 +0100 vfs_fruit: rework struct adouble API o factor out ad_open(), opens an fd to be used with IO on the metadata streams o rename ad_write() to ad_set() as this aligns nicely with the existing ad_get. This is the pathname based version used to solely set metadata on a file, there's also a handle based version: o add ad_fset(), a handle based version that can be used to set metadata and to update the AppleDouble header in a ._ AppleDouble file o remove fruit_fsp_recheck(), looking at it more closely, it is not needed This commit *compiles*, but all callers in the VFS ops must now be updated to use the new semantics, this comes next... BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 8703b8ef9d54c841d9da3f94b81195f247873dea Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 22:54:46 2016 +0100 selftest: disable vfs_fruit tests The next commits will completely change handle based VFS ops. This couldn't be done in a piecemeal fashion, I had to wipe the slate clean. Disabling tests in order to not break git bisects. Tests will be reenabled after a few commits that apply the larger change in a somewhat digestible fashion. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 41a2b2f5cdf751e17bde60e5cfbe395450e67485 Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 11:08:53 2016 +0100 vfs_fruit: fix fruit_check_access() Applying fcntl read locks requires an fd opened for reading. This means we have to check the open flags of an fd and if the fd is not opened for reading, we can't use it to set shared fctnl locks. Iow we won't be applying interop locks with Netatalk for files openend write-only. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit b1223520e3d35f59e0f77648e0afdf049e1c9de3 Author: Ralph Boehme <s...@samba.org> Date: Tue Dec 6 15:07:20 2016 +0100 vfs_fruit: remove base_fsp name translation This is now nicely done by vfs_catia for us. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 3e2a7f6227204e932a8337fe77cdda22d28f85f6 Author: Ralph Boehme <s...@samba.org> Date: Wed Feb 8 19:15:38 2017 +0100 vfs_fruit: use SMB_VFS_NEXT_OPEN in two places Using the SMB_VFS_OPEN leads to a logic recursion that is hard to follow and debug. It may be called twice for the same fsp with two different smb_fname's. Changing this here to use the NEXT function instead should have no change in behaviour otherwise, but it allows adding sane caching to vfs_catia to handle based VFS ops. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit ad8a3b6971945fbceeef8763613a9e5f5a475098 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 17:00:03 2016 +0100 vfs_fruit: refactor readdir_attr_macmeta() resource fork size Move resource fork size calculation to helper functions. Adds correct handling for the fruit:resource=stream case in readdir_attr_rfork_size_stream(), this wasn't done previously. Otherwise no change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit a5b060fcd2c1d26bd0abfceffcd7b2c43056c78e Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 16:20:46 2016 +0100 vfs_fruit: refactor fruit_ftruncate() and fix stream case The fruit:metadata=stream case wasn't handled previosly, this is now done in fruit_ftruncate_rsrc_stream(). The rest is just refactoring and no change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit b0b785b0d4b64810f6ee58b015929641246479d1 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 15:57:22 2016 +0100 vfs_fruit: fix fruit_ntimes() for the fruit:metadata!=netatalk case The following code must only be executed for the fruit:metadata=netatalk case. Otherwise no change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit ef2c81eb9fe5e12d5694af665be198994e02762d Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 15:49:03 2016 +0100 vfs_fruit: refactor fruit_streaminfo() Handle all settings of fruit:metadata and fruit:resource in helper functions. Resource fork streams of 0 bytes must be filtered out, this wasn't done previously for the fruit:resource=stream and xattr case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 72325d946aacc1beec0eb411f4c7209e06850e91 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 11:44:53 2016 +0100 vfs_fruit: add fruit_stat_rsrc_xattr() implementation This fixes fruit_stat_rsrc for the fruit:resource=xattr case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit cbf87b46c2ad7d0795616c517d3e39f24d827ef4 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 11:30:06 2016 +0100 vfs_fruit: add fruit_stat_rsrc_stream() implementation This fixes fruit_stat_rsrc for the fruit:resource=stream case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 5037816d28df6f1eed46abf910b0cd4c1a40ec77 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 11:26:22 2016 +0100 vfs_fruit: refactor fruit_stat_rsrc() Use helper functions for the fruit:resource cases. No change in behaveour. The next patch will add the proper helper functions for fruit:resource=xattr and fruit:resource=stream. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 22da6c82f08ed82cf7eddb3fdda2b6ab66264683 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 10:46:55 2016 +0100 vfs_fruit: refactor fruit_open_rsrc() This just splits up fruit_open_rsrc() to use helper functions for each config->rsrc setting. No change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit b95d2042e51ad4c2854e3b2465d55a063bc19f95 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 9 18:24:40 2016 +0100 vfs_fruit: in fruit_rmdir() check ._ files before deleting them This ensures we only delete valid AppleDouble files whose names begin with "._", not just *any* file that matches "^._*". Also use proper VFS functions instead of direclty calling the C library functions. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 19854072dbb7a9ba97d48f4012ea3a238721fc58 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 9 18:22:49 2016 +0100 vfs_fruit: fix fruit_rmdir() for the fruit:resource!=file case The following code must only be executed for the fruit:resource=file case. Otherwise no change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 09c82a1ce192112a7264d19f6d8888bad49f6a82 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 09:04:37 2016 +0100 vfs_fruit: fix fruit_chown() for the fruit:resource!=file case The following code must only be executed for the fruit:resource=file case. While at it, remove an unnecessary lstat, use the stat info from smb_fname. Otherwise no change in behaviour for the fruit:resource=file case (the default). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 22b509f52ed4de0856432327b3bf78fedcde141b Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 09:02:27 2016 +0100 vfs_fruit: fix fruit_chmod() for the fruit:resource!=file case The following code must only be executed for the fruit:resource=file case. While at it, remove an unnecessary lstat, use the stat info from smb_fname. Otherwise no change in behaviour for the fruit:resource=file case (the default). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 6730e1035ba740d0de413256a211937c3bd794e1 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 09:00:31 2016 +0100 vfs_fruit: refactor fruit_unlink() Refactor fruit_unlink() addin helper functions for all fruit:metadata and fruit:resource settings. No change in behaviour for fruit:metadata=netatalk and fruit:resource=file (both the default), but fixes behaviour for the other cases. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 8a9d0c541875d06254dc3a3039b20c8acac328ed Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 08:47:36 2016 +0100 vfs_fruit: fix fruit_rename() for the fruit:resource!=file case o fix the config check, we must only run following code for the fruit:resource=file o properly call SMB_VFS_NEXT_RENAME() instead diretly calling rename() o bail out if we get an invalid stat Otherwise, no change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 604bd6bf80285db2e52266708d55215f07503c73 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 9 17:24:18 2016 +0100 vfs_fruit: correct readdir_attr_meta_finderi_stream() implementation This gets correct behaviour in readdir_attr_meta_finderi for the metadata=stream case. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 5a466560b2811c78d731cc039c99c740ddee5ffc Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 1 17:04:35 2016 +0100 vfs_fruit: refactor readdir_attr_meta() Move the FinderInfo stuff to helper functions, no change in behaviour so far. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 79159f8dc95057187601ac167414cc49282bdabf Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 17:25:47 2016 +0100 vfs_fruit: update_btime() is only needed for metadata=netatalk BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit cb1121ec3268fecb7fa0f5fbb6d2dbffaea991b3 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 11:12:18 2016 +0100 vfs_fruit: correct fruit_stat_meta_stream() implementation BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit aaf2ae1b2b1a2822bff6140dfd7afde1569c2548 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 2 11:05:50 2016 +0100 vfs_fruit: refactor fruit_stat_meta() Handle config->meta in helper functions. No change in behaviour. The next step will add the correct implementation of fruit_stat_meta_stream(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit a3be9e69c3d3ff4980b47261dc0d043a0275a8c0 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 9 17:01:37 2016 +0100 vfs_fruit: correct fruit_open_meta_stream() implementation This needs to create and write a metadata blob when the stream is created. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 5a072ca91c642e61b36f1670105f6c8d1e64e25c Author: Ralph Boehme <s...@samba.org> Date: Tue Nov 29 16:56:00 2016 +0100 vfs_fruit: refactor fruit_open_meta() Just split out the fruit:metadata=stream case into a helper function, no change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 3d5bf4b85f3ca120206a12b3d102aef2ead33082 Author: Ralph Boehme <s...@samba.org> Date: Wed Nov 16 11:01:45 2016 +0100 vfs_fruit: replace unsafe ad_entry macro with a function BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit b121fff1568b0365ed27655bcd600a8d82cc3489 Author: Ralph Boehme <s...@samba.org> Date: Tue Nov 15 21:32:25 2016 +0100 vfs_fruit: fix fruit_pwrite() with metadata=stream This makes the test "delete AFP_AfpInfo by writing all 0" pass with fruit:metadata=stream. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 05d54dd71c9797e607c9fa3c5218c13755c7c652 Author: Ralph Boehme <s...@samba.org> Date: Fri Dec 9 16:25:38 2016 +0100 vfs_fruit: rename empty_finderinfo() and make it more robust No change in behaviour, but ad_entry(ad, ADEID_FINDERI) can in theory return NULL. The next commit will add the same function for a AfpInfo type, so rename this function that works on struct adouble to ad_empty_finderinfo(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 04feedb7f6e4519352fdd901356e6e53d97896d5 Author: Ralph Boehme <s...@samba.org> Date: Tue Nov 15 20:32:05 2016 +0100 vfs_fruit: fix fruit_ftruncate with metadata=stream With this the test "setinfo eof AFP_AfpInfo" passed with fruit:metadata=stream. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit d0eed8e73ff39acc6dca70a44f00f81d8ca564fd Author: Ralph Boehme <s...@samba.org> Date: Wed Nov 16 09:34:13 2016 +0100 vfs_fruit: fix fruit_pread with metadata=stream This make the test "fix offset and len handling for AFP_AfpInfo stream" pass with fruit:metadata=stream. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 633aa1ac10ba4e9d7a97fa026a407defb919ce1a Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 17:18:51 2016 +0100 vfs_catia: add catia_(g|s)et_dos_attributes BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit abe3572c59bec0f8da2a79e4ece9de43e8b5e16b Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 8 15:44:56 2016 +0100 vfs_catia: add catia_readdir_attr BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit af3b4ea4744ab2b67b4221cd6118b6cd2774660f Author: Ralph Boehme <s...@samba.org> Date: Tue Dec 6 15:00:58 2016 +0100 vfs_catia: run translation on all handle based VFS functions Also run translation of fsp->fsp_name and optionally fsp->base_fsp->fsp_name if set for all handle based VFS functions. This is necessary because some modules might use the path for something in the handle based VFS ops. An existing example is vfs_fruit. A later commit will remove the translation that was done there because catia didn't before this commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Pair-Programmed-With: Stefan Metzmacher <me...@samba.org> Signed-off-by: Ralph Boehme <s...@samba.org> Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 4e2c7d0ec45adf5992446e3e05c90dd40c2fd75b Author: Ralph Boehme <s...@samba.org> Date: Wed Feb 8 19:16:21 2017 +0100 vfs_streams_xattr: use SMB_VFS_NEXT_OPEN and CLOSE Using the SMB_VFS_OPEN leads to a recursion in the VFS that is hard to follow and debug. It's called twice for the same fsp with two different smb_fname's which makes it at least hard to debug, it may even be an invalid usage. Changing this here to use the NEXT function instead should have no change in behaviour otherwise. Bug: https://bugzilla.samba.org/show_bug.cgi?id=12565 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 8035754c28c1a469de4fac77247ef7e5a1d8b463 Author: Ralph Boehme <s...@samba.org> Date: Thu Dec 1 11:17:48 2016 +0100 vfs_streams_xattr: call SMB_VFS_OPEN with smb_fname_base In case an SMB_VFS_OPEN() on a stream basename fails with EISDIR, we retry the open as O_RDONLY. The retry should be done with the smb_fname_base as well. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 73a0768865a1f5e74d50e601641cbac5340f9e2d Author: Ralph Boehme <s...@samba.org> Date: Wed Nov 16 11:24:59 2016 +0100 s3/includes: add FinderInfo offset define to MacExtensions.h BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> commit 5e612352225e0296e3f91c8db2adcca4f098e514 Author: Ralph Boehme <s...@samba.org> Date: Tue Nov 15 13:07:12 2016 +0100 selftest: don't run vfs_fruit tests against ad_dc env This is just redundant and didn't add test coverage. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12427 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Uri Simchoni <u...@samba.org> ----------------------------------------------------------------------- Summary of changes: docs-xml/manpages/vfs_fruit.8.xml | 20 +- lib/torture/torture.h | 10 + selftest/target/Samba3.pm | 24 + source3/include/MacExtensions.h | 3 + source3/modules/vfs_catia.c | 1355 +++++++++++++- source3/modules/vfs_fruit.c | 3525 +++++++++++++++++++++++++---------- source3/modules/vfs_streams_xattr.c | 14 +- source3/selftest/tests.py | 7 +- source4/torture/vfs/fruit.c | 409 +++- source4/torture/vfs/vfs.c | 37 +- 10 files changed, 4310 insertions(+), 1094 deletions(-) Changeset truncated at 500 lines: diff --git a/docs-xml/manpages/vfs_fruit.8.xml b/docs-xml/manpages/vfs_fruit.8.xml index 6976d7d..d209a22 100644 --- a/docs-xml/manpages/vfs_fruit.8.xml +++ b/docs-xml/manpages/vfs_fruit.8.xml @@ -154,9 +154,13 @@ <para>Controls how the set of illegal NTFS ASCII character, commonly used by OS X clients, are stored in - the filesystem:</para> + the filesystem.</para> - <itemizedlist> + <para><emphasis>Important:</emphasis> this is known to not fully + work with <emphasis>fruit:metadata=stream</emphasis> or + <emphasis>fruit:resource=stream</emphasis>.</para> + + <itemizedlist> <listitem><para><command>private (default)</command> - store characters as encoded by the OS X client: mapped @@ -220,10 +224,14 @@ <varlistentry> <term>fruit:veto_appledouble = yes | no</term> <listitem> - <para>Whether ._ AppleDouble files are vetoed which - prevents the client from seing and accessing internal - AppleDouble files created by vfs_fruit itself for the - purpose of storing a Mac resource fork.</para> + <para><emphasis>Note:</emphasis> this option only applies when + <parameter>fruit:resource</parameter> is set to + <parameter>file</parameter> (the default).</para> + + <para>When <parameter>fruit:resource</parameter> is set to + <parameter>file</parameter>, vfs_fruit may create ._ AppleDouble + files. This options controls whether these ._ AppleDouble files + are vetoed which prevents the client from accessing them.</para> <para>Vetoing ._ files may break some applications, eg extracting Mac ZIP archives from Mac clients failes, because they contain ._ files. Setting this option to diff --git a/lib/torture/torture.h b/lib/torture/torture.h index 45332b2..b6d1301 100644 --- a/lib/torture/torture.h +++ b/lib/torture/torture.h @@ -357,6 +357,16 @@ void torture_result(struct torture_context *test, } \ } while(0) +#define torture_assert_mem_equal_goto(torture_ctx,got,expected,len,ret,label,cmt) \ + do { const void *__got = (got), *__expected = (expected); \ + if (memcmp(__got, __expected, len) != 0) { \ + torture_result(torture_ctx, TORTURE_FAIL, \ + __location__": "#got" of len %d did not match "#expected": %s", (int)len, cmt); \ + ret = false; \ + goto label; \ + } \ + } while(0) + static inline void torture_dump_data_str_cb(const char *buf, void *private_data) { char **dump = (char **)private_data; diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 0ec2917..aa50f07 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -1660,6 +1660,30 @@ sub provision($$$$$$$$) fruit:locking = netatalk fruit:encoding = native +[vfs_fruit_metadata_stream] + path = $shrdir + vfs objects = fruit streams_xattr acl_xattr + ea support = yes + fruit:resource = file + fruit:metadata = stream + +[vfs_fruit_stream_depot] + path = $shrdir + vfs objects = fruit streams_depot acl_xattr + ea support = yes + fruit:resource = stream + fruit:metadata = stream + +[vfs_wo_fruit] + path = $shrdir + vfs objects = streams_xattr acl_xattr + ea support = yes + +[vfs_wo_fruit_stream_depot] + path = $shrdir + vfs objects = streams_depot acl_xattr + ea support = yes + [badname-tmp] path = $badnames_shrdir guest ok = yes diff --git a/source3/include/MacExtensions.h b/source3/include/MacExtensions.h index 6cd3d41..981cb16 100644 --- a/source3/include/MacExtensions.h +++ b/source3/include/MacExtensions.h @@ -51,6 +51,9 @@ #define AFP_Version 0x00000100 #define AFP_BackupTime 0x80000000 #define AFP_FinderSize 32 + +#define AFP_OFF_FinderInfo 16 + /* ** Orginal AFP_AfpInfo stream used by NT ** We needed a way to store the create date so SAMBA diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index f4c77d9..0ee7c36 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -4,13 +4,13 @@ * Implement a fixed mapping of forbidden NT characters in filenames that are * used a lot by the CAD package Catia. * - * Yes, this a BAD BAD UGLY INCOMPLETE hack, but it helps quite some people - * out there. Catia V4 on AIX uses characters like "<*$ a *lot*, all forbidden - * under Windows... + * Catia V4 on AIX uses characters like "<*$ a *lot*, all forbidden under + * Windows... * * Copyright (C) Volker Lendecke, 2005 * Copyright (C) Aravind Srinivasan, 2009 * Copyright (C) Guenter Kukkukk, 2013 + * Copyright (C) Ralph Boehme, 2017 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +29,8 @@ #include "includes.h" #include "smbd/smbd.h" +#include "lib/util/tevent_unix.h" +#include "lib/util/tevent_ntstatus.h" static int vfs_catia_debug_level = DBGC_VFS; @@ -52,6 +54,15 @@ struct share_mapping_entry { struct char_mappings **mappings; }; +struct catia_cache { + bool is_fsp_ext; + const struct catia_cache * const *busy; + char *orig_fname; + char *fname; + char *orig_base_fname; + char *base_fname; +}; + struct share_mapping_entry *srt_head = NULL; static bool build_table(struct char_mappings **cmaps, int value) @@ -353,30 +364,305 @@ static NTSTATUS catia_translate_name(struct vfs_handle_struct *handle, return ret; } +#define CATIA_DEBUG_CC(lvl, cc, fsp) \ + catia_debug_cc((lvl), (cc), (fsp), __location__); + +static void catia_debug_cc(int lvl, + struct catia_cache *cc, + files_struct *fsp, + const char *location) +{ + DEBUG(lvl, ("%s: cc [0x%p] cc->busy [0x%p] " + "is_fsp_ext [%s] " + "fsp [0x%p] fsp name [%s] " + "orig_fname [%s] " + "fname [%s] " + "orig_base_fname [%s] " + "base_fname [%s]\n", + location, + cc, cc->busy, + cc->is_fsp_ext ? "yes" : "no", + fsp, fsp_str_dbg(fsp), + cc->orig_fname, cc->fname, + cc->orig_base_fname, cc->base_fname)); +} + +static void catia_free_cc(struct catia_cache **_cc, + vfs_handle_struct *handle, + files_struct *fsp) +{ + struct catia_cache *cc = *_cc; + + if (cc->is_fsp_ext) { + VFS_REMOVE_FSP_EXTENSION(handle, fsp); + cc = NULL; + } else { + TALLOC_FREE(cc); + } + + *_cc = NULL; +} + +static struct catia_cache *catia_validate_and_apply_cc( + vfs_handle_struct *handle, + files_struct *fsp, + const struct catia_cache * const *busy, + bool *make_tmp_cache) +{ + struct catia_cache *cc = NULL; + + *make_tmp_cache = false; + + cc = (struct catia_cache *)VFS_FETCH_FSP_EXTENSION(handle, fsp); + if (cc == NULL) { + return NULL; + } + + if (cc->busy != NULL) { + if (cc->busy == busy) { + /* This should never happen */ + CATIA_DEBUG_CC(0, cc, fsp); + smb_panic(__location__); + } + + /* + * Recursion. Validate names, the names in the fsp's should be + * the translated names we had set. + */ + + if ((cc->fname != fsp->fsp_name->base_name) + || + ((fsp->base_fsp != NULL) && + (cc->base_fname != fsp->base_fsp->fsp_name->base_name))) + { + CATIA_DEBUG_CC(10, cc, fsp); + + /* + * Names changed. Setting don't expose the cache on the + * fsp and ask the caller to create a temporary cache. + */ + *make_tmp_cache = true; + return NULL; + } + + /* + * Ok, a validated cache while in a recursion, just let the + * caller detect that cc->busy is != busy and there's + * nothing else to do. + */ + CATIA_DEBUG_CC(10, cc, fsp); + return cc; + } + + /* Not in a recursion */ + + if ((cc->orig_fname != fsp->fsp_name->base_name) + || + ((fsp->base_fsp != NULL) && + (cc->orig_base_fname != fsp->base_fsp->fsp_name->base_name))) + { + /* + * fsp names changed, this can happen in an rename op. + * Trigger recreation as a full fledged fsp extension. + */ + + CATIA_DEBUG_CC(10, cc, fsp); + catia_free_cc(&cc, handle, fsp); + return NULL; + } + + + /* + * Ok, we found a valid cache entry, no recursion. Just set translated + * names from the cache and mark the cc as busy. + */ + fsp->fsp_name->base_name = cc->fname; + if (fsp->base_fsp != NULL) { + fsp->base_fsp->fsp_name->base_name = cc->base_fname; + } + + cc->busy = busy; + CATIA_DEBUG_CC(10, cc, fsp); + return cc; +} + +#define CATIA_FETCH_FSP_PRE_NEXT(mem_ctx, handle, fsp, _cc) \ + catia_fetch_fsp_pre_next((mem_ctx), (handle), (fsp), (_cc), __func__); + +static int catia_fetch_fsp_pre_next(TALLOC_CTX *mem_ctx, + vfs_handle_struct *handle, + files_struct *fsp, + struct catia_cache **_cc, + const char *function) +{ + const struct catia_cache * const *busy = + (const struct catia_cache * const *)_cc; + struct catia_cache *cc = NULL; + NTSTATUS status; + bool make_tmp_cache = false; + + *_cc = NULL; + + DBG_DEBUG("Called from [%s]\n", function); + + cc = catia_validate_and_apply_cc(handle, + fsp, + busy, + &make_tmp_cache); + if (cc != NULL) { + if (cc->busy != busy) { + return 0; + } + *_cc = cc; + return 0; + } + + if (!make_tmp_cache) { + cc = (struct catia_cache *)VFS_ADD_FSP_EXTENSION( + handle, fsp, struct catia_cache, NULL); + if (cc == NULL) { + return -1; + } + *cc = (struct catia_cache) { + .is_fsp_ext = true, + }; + + mem_ctx = VFS_MEMCTX_FSP_EXTENSION(handle, fsp); + if (mem_ctx == NULL) { + DBG_ERR("VFS_MEMCTX_FSP_EXTENSION failed\n"); + catia_free_cc(&cc, handle, fsp); + return -1; + } + } else { + cc = talloc_zero(mem_ctx, struct catia_cache); + if (cc == NULL) { + return -1; + } + mem_ctx = cc; + } + + + status = catia_string_replace_allocate(handle->conn, + fsp->fsp_name->base_name, + &cc->fname, + vfs_translate_to_unix); + if (!NT_STATUS_IS_OK(status)) { + catia_free_cc(&cc, handle, fsp); + errno = map_errno_from_nt_status(status); + return -1; + } + talloc_steal(mem_ctx, cc->fname); + + if (fsp->base_fsp != NULL) { + status = catia_string_replace_allocate( + handle->conn, + fsp->base_fsp->fsp_name->base_name, + &cc->base_fname, + vfs_translate_to_unix); + if (!NT_STATUS_IS_OK(status)) { + catia_free_cc(&cc, handle, fsp); + errno = map_errno_from_nt_status(status); + return -1; + } + talloc_steal(mem_ctx, cc->base_fname); + } + + cc->orig_fname = fsp->fsp_name->base_name; + fsp->fsp_name->base_name = cc->fname; + + if (fsp->base_fsp != NULL) { + cc->orig_base_fname = fsp->base_fsp->fsp_name->base_name; + fsp->base_fsp->fsp_name->base_name = cc->base_fname; + } + + cc->busy = busy; + CATIA_DEBUG_CC(10, cc, fsp); + + *_cc = cc; + + return 0; +} + +#define CATIA_FETCH_FSP_POST_NEXT(_cc, fsp) do { \ + int saved_errno = errno; \ + catia_fetch_fsp_post_next((_cc), (fsp), __func__); \ + errno = saved_errno; \ +} while(0) + +static void catia_fetch_fsp_post_next(struct catia_cache **_cc, + files_struct *fsp, + const char *function) +{ + const struct catia_cache * const *busy = + (const struct catia_cache * const *)_cc; + struct catia_cache *cc = *_cc; + + DBG_DEBUG("Called from [%s]\n", function); + + if (cc == NULL) { + /* + * This can happen when recursing in the VFS on the fsp when the + * pre_next func noticed the recursion and set out cc pointer to + * NULL. + */ + return; + } + + if (cc->busy != busy) { + CATIA_DEBUG_CC(0, cc, fsp); + smb_panic(__location__); + return; + } + + cc->busy = NULL; + *_cc = NULL; + + fsp->fsp_name->base_name = cc->orig_fname; + if (fsp->base_fsp != NULL) { + fsp->base_fsp->fsp_name->base_name = cc->orig_base_fname; + } + + CATIA_DEBUG_CC(10, cc, fsp); + + if (!cc->is_fsp_ext) { + TALLOC_FREE(cc); + } + + return; +} + static int catia_open(vfs_handle_struct *handle, struct smb_filename *smb_fname, files_struct *fsp, int flags, mode_t mode) { - char *name_mapped = NULL; - char *tmp_base_name; - int ret; + struct catia_cache *cc = NULL; + char *orig_smb_fname = smb_fname->base_name; + char *mapped_smb_fname = NULL; NTSTATUS status; + int ret; - tmp_base_name = smb_fname->base_name; status = catia_string_replace_allocate(handle->conn, - smb_fname->base_name, - &name_mapped, vfs_translate_to_unix); + smb_fname->base_name, + &mapped_smb_fname, + vfs_translate_to_unix); if (!NT_STATUS_IS_OK(status)) { - errno = map_errno_from_nt_status(status); return -1; } - smb_fname->base_name = name_mapped; + ret = CATIA_FETCH_FSP_PRE_NEXT(talloc_tos(), handle, fsp, &cc); + if (ret != 0) { + TALLOC_FREE(mapped_smb_fname); + return ret; + } + + smb_fname->base_name = mapped_smb_fname; ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); - smb_fname->base_name = tmp_base_name; - TALLOC_FREE(name_mapped); + smb_fname->base_name = orig_smb_fname; + + TALLOC_FREE(mapped_smb_fname); + CATIA_FETCH_FSP_POST_NEXT(&cc, fsp); return ret; } @@ -1114,33 +1400,1030 @@ catia_setxattr(vfs_handle_struct *handle, const char *path, return ret; } -static struct vfs_fn_pointers vfs_catia_fns = { - .mkdir_fn = catia_mkdir, - .rmdir_fn = catia_rmdir, - .opendir_fn = catia_opendir, - .open_fn = catia_open, - .rename_fn = catia_rename, - .stat_fn = catia_stat, - .lstat_fn = catia_lstat, - .unlink_fn = catia_unlink, - .chown_fn = catia_chown, - .lchown_fn = catia_lchown, - .chmod_fn = catia_chmod, - .chdir_fn = catia_chdir, - .ntimes_fn = catia_ntimes, - .realpath_fn = catia_realpath, - .chflags_fn = catia_chflags, - .streaminfo_fn = catia_streaminfo, - .translate_name_fn = catia_translate_name, - .get_nt_acl_fn = catia_get_nt_acl, - .chmod_acl_fn = catia_chmod_acl, - .sys_acl_get_file_fn = catia_sys_acl_get_file, - .sys_acl_set_file_fn = catia_sys_acl_set_file, - .sys_acl_delete_def_file_fn = catia_sys_acl_delete_def_file, +static int catia_fstat(vfs_handle_struct *handle, + files_struct *fsp, -- Samba Shared Repository