[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Nov 1 00:15:03 UTC 2018


The branch, master has been updated
       via  1b2de44 vfs_fruit: let fruit_open_meta() with O_CREAT return a fake-fd
       via  d8c1bb5 vfs_fruit: don't check for delete-on-close on the FinderInfo stream
       via  480695c vfs_fruit: let fruit_pwrite_meta_stream also ftruncate empty FinderInfo
       via  6e13dbd vfs_fruit: pass stream size to delete_invalid_meta_stream()
       via  6fd256a vfs_fruit: let fruit handle all aio on the FinderInfo metadata stream
       via  80afafe vfs_fruit: do ino calculation
       via  d7d9271 vfs_fruit: prepare fruit_pread_meta() for reading on fake-fd
       via  4a5c9a9 vfs_fruit: prepare fruit_pwrite_meta() for on-demand opening and writing
       via  96320ec vfs_fruit: prepare struct fio for fake-fd and on-demand opening
       via  1e055a7 vfs_fruit: add fio->created
       via  a26032c vfs_fruit: remove resource fork special casing
       via  993c7c4 vfs_fruit: add some debugging of dev/ino
       via  9d8751d s4:torture/vfs/fruit: add test "empty_stream"
       via  aba502d s4:torture/vfs/fruit: add check_stream_list_handle()
       via  64b28e4 s4:torture/util: add torture_smb2_open()
       via  ebfcf75 vfs_fruit: filter empty streams
       via  046456f vfs_fruit: use check on global_fruit_config.nego_aapl for macOS specific behaviour
       via  7485007 s4:torture/vfs/fruit: enable AAPL extensions in a bunch of tests
       via  287082d vfs_fruit: don't unlink 0-byte size truncated streams
       via  3195ff9 s4:torture/vfs/fruit: write some data to a just created teststream
       via  b35d9e7 s4:torture/vfs/fruit: expand test "setinfo eof stream"
       via  055ca44 vfs_fruit: update handling of read-only creation of resource fork
       via  c3cf09a s4:torture/vfs/fruit: update test "creating rsrc with read-only access" for newer macOS versions
       via  6f42860 s4:torture/vfs/fruit: expand existing vfs_test "null afpinfo"
       via  0d9a80b s4:torture/vfs/fruit: expand existing test "setinfo delete-on-close AFP_AfpInfo" a little bit
       via  9cd9859 s4:torture/vfs/fruit: update test "read open rsrc after rename" to work with macOS
       via  f7551d8 s4:torture/vfs/fruit: ensure a directory handle is closed in all code paths
       via  1254988 s4:torture/vfs/fruit: update test "stream names" to work with macOS
       via  dba9a47 s4:torture/vfs/fruit: update test "SMB2/CREATE context AAPL" to work against macOS
       via  1d4e506 s4:torture/vfs/fruit: set share_access to NTCREATEX_SHARE_ACCESS_MASK in check_stream_list
       via  394d1fc s4:torture/vfs/fruit: fix a few error checks in "delete AFP_AfpInfo by writing all 0"
       via  242f42e s4:torture/vfs/fruit: skip a few tests when running against a macOS SMB server
       via  9f58997 vfs_streams_xattr: fix open implementation
       via  3649f1a vfs_fruit: optionally delete AppleDouble files without Resourcefork data
       via  e00e613 vfs_fruit: add option "delete_empty_adfiles"
       via  7be979f vfs_fruit: detect empty resource forks in ad_convert()
       via  2dbb2d2 vfs_fruit: add option "wipe_intentionally_left_blank_rfork"
       via  6f022e6 s4:torture: add test for AppleDouble ResourceFork conversion
       via  c3a1f3e s3:selftest: list vfs testssuites one per line
       via  2a9574b docs:vfs_fruit: add "delete_empty_adfiles" option
       via  f7a9809 docs:vfs_fruit: add "wipe_intentionally_left_blank_rfork" option
       via  9a4c188 s3:smbd: remove "0x" string prefix from dev/ino
       via  bda98b3 third_party: Update nss_wrapper to version 1.1.5
      from  0c91024 netcmd: Add 'samba-tool group stats' command

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1b2de44ea8114cf2025e8b8c843131e2f2dbed27
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 15:25:26 2018 +0200

    vfs_fruit: let fruit_open_meta() with O_CREAT return a fake-fd
    
    This is the final step in implementing the needed macOS semantics on the
    FinderInfo stream: as long as the client hasn't written a non-zero
    FinderInfo blob to the stream, there mustn't be a visible filesystem
    entry for other openers.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Nov  1 01:14:23 CET 2018 on sn-devel-144

commit d8c1bb52018289878b9397d513ebbae63933a05f
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 23:50:32 2018 +0200

    vfs_fruit: don't check for delete-on-close on the FinderInfo stream
    
    macOS SMB server doesn't filter out the FinderInfo stream if it has
    delete-on-close set.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 480695cd723cc4949e0b39ddb83560efac393412
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 23:40:14 2018 +0200

    vfs_fruit: let fruit_pwrite_meta_stream also ftruncate empty FinderInfo
    
    fruit_streaminfo currently filters out the FinderInfo stream is
    delete-on-close is set. We set it here internally, but the client may
    also set it over SMB. Turns out that the macOS SMB server does NOT
    filter out FinderInfo stream with delete-on-close set, so we must change
    the way filtering is done in fruit_streaminfo.
    
    Filtering is now done based on the FinderInfo stream being 0-bytes large which
    is why I'm adding the ftruncate here.
    
    No idea why the tests that check the filtering passed the commits
    leading up to this one, but if you revert this commit after applying the
    whole patchset, the "delete AFP_AfpInfo by writing all 0" test will fail.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6e13dbddaec9f8118e11309297f85c3cdfd22e43
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 23:46:43 2018 +0200

    vfs_fruit: pass stream size to delete_invalid_meta_stream()
    
    delete_invalid_meta_stream() is meant to guard against random data being
    present in the FinderInfo stream. If the stream size is 0, it's likely a
    freshly created stream where no data has been written to yet, so don't
    delete it.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6fd256afcd5fedc894036efbfba1fc6d2264fba9
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 17 16:51:34 2018 +0200

    vfs_fruit: let fruit handle all aio on the FinderInfo metadata stream
    
    This will be required to support using fake fds for the FinderInfo
    metadata stream.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 80afafe398566fd622f431966808d08ba9ec6473
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 16:49:23 2018 +0200

    vfs_fruit: do ino calculation
    
    As we'll start returning fake fds in open shortly, we can't rely on the
    next module to calculat correct inode numbers for streams and must take
    over that responsibility.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d7d92710711f6e555ed45c1dda528cd6a83e1bf5
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 15:22:08 2018 +0200

    vfs_fruit: prepare fruit_pread_meta() for reading on fake-fd
    
    If the read on the stream fails we may have hit a handle on a just
    created stream (fio->created=true) with no data written yet.
    
    If that's the case return an empty initialized FinderInfo blob.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4a5c9a9e73230f640eb045a3c47af75b5be9f1d6
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 15:21:08 2018 +0200

    vfs_fruit: prepare fruit_pwrite_meta() for on-demand opening and writing
    
    This avoid creating files or blobs in our streams backend when a client
    creates a stream but hasn't written anything yet. This is the only sane
    way to implement the following semantics:
    
    * client 1: create stream "file:foo"
    
    * client 2: open stream "file:foo"
    
    The second operation of client 2 must fail with NT_STATUS_NOT_FOUND.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 96320eccc9a63b793ff8d05842bce54f120286f9
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Aug 22 15:22:57 2018 +0200

    vfs_fruit: prepare struct fio for fake-fd and on-demand opening
    
    Not used for now, that comes in the subsequent commits.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1e055a79541eb69eb2deeae897dde3665c5ffee2
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 16:56:46 2018 +0200

    vfs_fruit: add fio->created
    
    fio->created tracks whether a create created a stream.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a26032c3f68028b01fb6a7d38851409db1858161
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 18:38:33 2018 +0200

    vfs_fruit: remove resource fork special casing
    
    Directly unlinking a file with open handles is not good, don't do it.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 993c7c4e711612225bd07b8fa5544c4bfef88a9e
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 17 19:07:11 2018 +0200

    vfs_fruit: add some debugging of dev/ino
    
    Aids in debugging dev/ino mismatch failures in open_file_ntcreate.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9d8751db64de75a0de442365b317c1b9ce194170
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 16:21:21 2018 +0200

    s4:torture/vfs/fruit: add test "empty_stream"
    
    One to rule them all: consistently test critical operations on all
    streams relevant to macOS clients: the FinderInfo stream, the Resource
    Fork stream and an arbitrary stream that macOS maps to xattrs when
    written to on a macOS SMB server.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit aba502d440ae3478543d3be5c5bbcea39fb0a463
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 11 17:14:50 2018 +0200

    s4:torture/vfs/fruit: add check_stream_list_handle()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 64b28e4a94365092f46052712a38e6fcfbb9f20c
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 10 18:45:56 2018 +0200

    s4:torture/util: add torture_smb2_open()
    
    This seems to be missing: a simple wrapper to just open a file without
    fancy options.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ebfcf75e993b1a792db76b94aa898532e1c81eeb
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 14:53:50 2018 +0200

    vfs_fruit: filter empty streams
    
    First step in achieving macOS compliant behaviour wrt to empty streams:
    - hide empty streams in streaminfo
    - prevent opens of empty streams
    
    This means that we may carry 0-byte sized streams in our streams
    backend, but this shouldn't really hurt.
    
    The previous attempt of deleting the streams when an SMB setinfo eof to
    0 request came in, turned out be a road into desaster.
    
    We could set delete-on-close on the stream, but that means we'd have to
    check for it for every write on a stream and checking the
    delete-on-close bits requires fetching the locking.tdb record, so this
    is expensive and I'd like to avoid that overhead.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 046456fca60b9fef38a0cdf5a116883fb1c7dffe
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 15:28:06 2018 +0200

    vfs_fruit: use check on global_fruit_config.nego_aapl for macOS specific behaviour
    
    Ensure any non MS compliant protocol behaviour targetted at supporting
    macOS clients are only effective if the client negotiated AAPL.
    
    Currently this only guards the resource fork which only macOS client are
    going to use, but subsequent commits add more this at this place.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7485007bb0a69dc8237c78be90f4bae06aad49b2
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 14:01:34 2018 +0200

    s4:torture/vfs/fruit: enable AAPL extensions in a bunch of tests
    
    These tests check for macOS SMB server specific behaviour. They work
    currently against Samba without enabling AAPL because in vfs_fruit we're
    currently don't check whether AAPL has been negotiated in one place. A
    subsequent commit will change that and this commit prepares for that
    change.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 287082d739362ad068df37076712927ccd7ca90c
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 14:54:48 2018 +0200

    vfs_fruit: don't unlink 0-byte size truncated streams
    
    This caused all sort of havoc with subsequent SMB request that acted on
    the handle of the then deleted backend storage (file or blob, depending
    on the used streams module).
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3195ff9547824dd129e3fbcbbb8823fb10a0a5d4
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 20 14:52:23 2018 +0200

    s4:torture/vfs/fruit: write some data to a just created teststream
    
    Doesn't currently make a difference, but this prepares for a later
    change in vfs_fruit that will filter out empty streams (which is the
    macOS behaviour).
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b35d9e74028727da24f349242cb0bc62403a9b09
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 12:43:16 2018 +0200

    s4:torture/vfs/fruit: expand test "setinfo eof stream"
    
    o Adds checks verifying that after setting eof to 0 on a stream, a
      subsequent open gets ENOENT, before and after closing the handle that
      had been used to set eof to 0.
    
    o Verify that a write to a handle succeeds after that handle has been
      used to set eof to 0 on a stream.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 055ca448f1a2bd995291af1810c9ec94f90f32dd
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 22 12:32:09 2018 +0200

    vfs_fruit: update handling of read-only creation of resource fork
    
    macOS SMB server versions supports this since 10.12, so we adapt our
    behaviour.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c3cf09a0791ed4dfb7ca18d175396ac1aca5d2ed
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 15:17:08 2018 +0200

    s4:torture/vfs/fruit: update test "creating rsrc with read-only access" for newer macOS versions
    
    While this operation failed against older macOS versions, it passes
    against versions 10.12 and newer. Update the test accordingly, a
    subsequent commit will then update our implementation.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6f428607e35055b9ce1a04a625d43740bf5c76b2
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 10 12:47:07 2018 +0200

    s4:torture/vfs/fruit: expand existing vfs_test "null afpinfo"
    
    This adds a check that a read on a seperate handle also sees the
    previously created AFP_AfpInfo stream.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0d9a80b6b2e3f51cad122ee0dc78c2f4dfdebcb5
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 9 18:48:08 2018 +0200

    s4:torture/vfs/fruit: expand existing test "setinfo delete-on-close AFP_AfpInfo" a little bit
    
    Add a check that verifies a create on a stream gets
    NT_STATUS_DELETE_PENDING after delete-on-close has been set.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9cd9859dc10d425d29774d221ec9ad697192b466
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 16:24:19 2018 +0200

    s4:torture/vfs/fruit: update test "read open rsrc after rename" to work with macOS
    
    macOS SMB server seems to return NT_STATUS_SHARING_VIOLATION in this
    case while Windows 2016 returns NT_STATUS_ACCESS_DENIED.
    
    Lets stick with the Windows error code for now in the Samba fileserver,
    but let the test pass against macOS.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f7551d8fb3599a6a71dd0570bad02bdc48324107
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 31 15:49:45 2018 +0100

    s4:torture/vfs/fruit: ensure a directory handle is closed in all code paths
    
    Otherwise we get a sharing violation when running against Samba and
    opening the directory a second time.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 125498861abeeed5bde727ff98d88d9ce4af6c75
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 15:39:12 2018 +0200

    s4:torture/vfs/fruit: update test "stream names" to work with macOS
    
    o create the basefile before trying to create a stream on it, otherwise
      this fails on macOS
    
    o write something to the stream, otherwise the stream is not listed as
      macOS hides 0-byte sized streams
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dba9a4743fc42b57f03b6ace24753ce8091f629f
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 15 15:31:21 2018 +0200

    s4:torture/vfs/fruit: update test "SMB2/CREATE context AAPL" to work against macOS
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1d4e50649b02c7c2314aa04e08f9946e21b6b37d
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 11 17:13:52 2018 +0200

    s4:torture/vfs/fruit: set share_access to NTCREATEX_SHARE_ACCESS_MASK in check_stream_list
    
    Avoid sharing conflicts with other opens on the basefile.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 394d1fc9ac8373ea7419ea9514750422bd6e504d
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 17 10:51:45 2018 +0200

    s4:torture/vfs/fruit: fix a few error checks in "delete AFP_AfpInfo by writing all 0"
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 242f42ef79e51e35ab33331e2f2d7c9feaac36f8
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 19 22:21:10 2018 +0200

    s4:torture/vfs/fruit: skip a few tests when running against a macOS SMB server
    
    These tests are designed to test specific vfs_fruit functionality.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9f58997d7a1ab0358963a45cb8bf291e7afa8068
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Aug 23 12:07:20 2018 +0200

    vfs_streams_xattr: fix open implementation
    
    Since a long time the modules's open function happily returned success
    when opening a non existent stream without O_CREAT.
    
    This change fixes it to return -1 and errno=ENOATTR if
    
    o get_ea_value() returns NT_STATUS_NOT_FOUND (eg mapped from
      getxattr() = -1, errno=ENOATTR) and
    
    o flags doesn't contain O_CREAT
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13646
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3649f1a41a299b14609318ef52b44e2d53cba4b5
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 9 14:54:31 2018 +0200

    vfs_fruit: optionally delete AppleDouble files without Resourcefork data
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e00e61345ccd88022cd24e62ac29e2c56a8f6117
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 3 12:01:00 2018 +0200

    vfs_fruit: add option "delete_empty_adfiles"
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7be979f958295474f0c0df6a4db0b5bca9a6676d
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 2 16:05:28 2018 +0200

    vfs_fruit: detect empty resource forks in ad_convert()
    
    For some reason the macOS client often writes AppleDouble files with a
    non-zero sized resource fork, but the resource fork data is just
    boilerplate data with the following string close to the start
    
      This resource fork intentionally left blank
    
    A dump with apple_dump looks like this:
    
    Entry ID   : 00000002 : Resource Fork
    Offset     : 00000052 : 82
    Length     : 0000011E : 286
    
    -RAW DUMP--:  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F : (ASCII)
    00000000   : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
    00000010   : 54 68 69 73 20 72 65 73 6F 75 72 63 65 20 66 6F : This resource fo
    00000020   : 72 6B 20 69 6E 74 65 6E 74 69 6F 6E 61 6C 6C 79 : rk intentionally
    00000030   : 20 6C 65 66 74 20 62 6C 61 6E 6B 20 20 20 00 00 :  left blank   ..
    00000040   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000050   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000060   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000070   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000080   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000090   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000A0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000B0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000C0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000D0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000E0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    000000F0   : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 : ................
    00000100   : 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 1E : ................
    00000110   : 00 00 00 00 00 00 00 00 00 1C 00 1E FF FF       : ..............
    
    We can safely discard this Resource Fork data.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2dbb2d287399e9c829a4fd4908a6dfba9fdfd7e8
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 3 12:01:00 2018 +0200

    vfs_fruit: add option "wipe_intentionally_left_blank_rfork"
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6f022e61597994bc032e61876f24150d7acb3fc2
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 4 14:28:15 2018 +0200

    s4:torture: add test for AppleDouble ResourceFork conversion
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c3a1f3ec9ba2402de2a876ca06086b2d53e122f0
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 4 13:47:20 2018 +0200

    s3:selftest: list vfs testssuites one per line
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2a9574b138f620e0a65cd61a957b99653c8dcd78
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 4 18:22:31 2018 +0200

    docs:vfs_fruit: add "delete_empty_adfiles" option
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f7a98094f05dd4b9abf5dc9704222aa5a07584d4
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 2 16:31:15 2018 +0200

    docs:vfs_fruit: add "wipe_intentionally_left_blank_rfork" option
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13642
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9a4c1888a9c2d3b5797902adcf519855204ebe24
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 31 15:16:18 2018 +0100

    s3:smbd: remove "0x" string prefix from dev/ino
    
    We used %llu as conversion specifier which results in a decimal number
    being printed, so remove the misleading "0x" prefix.
    
    While at it, I'll change %llu to the terse %ju.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit bda98b38464458a513148f0bf356d9f2150c1607
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Oct 31 08:44:08 2018 +0100

    third_party: Update nss_wrapper to version 1.1.5
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafsamba/samba_third_party.py |    2 +-
 docs-xml/manpages/vfs_fruit.8.xml        |   25 +
 selftest/target/Samba3.pm                |   18 +
 source3/modules/vfs_fruit.c              |  664 +++++++++++------
 source3/modules/vfs_streams_xattr.c      |   64 +-
 source3/selftest/tests.py                |   12 +-
 source3/smbd/open.c                      |   18 +-
 source4/torture/smb2/util.c              |   30 +
 source4/torture/vfs/fruit.c              | 1157 +++++++++++++++++++++++++++---
 source4/torture/vfs/vfs.c                |    1 +
 third_party/nss_wrapper/nss_wrapper.c    |  171 +++--
 third_party/nss_wrapper/wscript          |    2 +-
 12 files changed, 1754 insertions(+), 410 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_third_party.py b/buildtools/wafsamba/samba_third_party.py
index dbecf71..be73dbe 100644
--- a/buildtools/wafsamba/samba_third_party.py
+++ b/buildtools/wafsamba/samba_third_party.py
@@ -47,7 +47,7 @@ Build.BuildContext.CHECK_SOCKET_WRAPPER = CHECK_SOCKET_WRAPPER
 
 @conf
 def CHECK_NSS_WRAPPER(conf):
-    return conf.CHECK_BUNDLED_SYSTEM_PKG('nss_wrapper', minversion='1.1.3')
+    return conf.CHECK_BUNDLED_SYSTEM_PKG('nss_wrapper', minversion='1.1.5')
 Build.BuildContext.CHECK_NSS_WRAPPER = CHECK_NSS_WRAPPER
 
 @conf
diff --git a/docs-xml/manpages/vfs_fruit.8.xml b/docs-xml/manpages/vfs_fruit.8.xml
index 2583303..e4ca7bd 100644
--- a/docs-xml/manpages/vfs_fruit.8.xml
+++ b/docs-xml/manpages/vfs_fruit.8.xml
@@ -378,6 +378,31 @@
 	    </listitem>
 	  </varlistentry>
 
+	  <varlistentry>
+	    <term>fruit:wipe_intentionally_left_blank_rfork = yes | no</term>
+	    <listitem>
+	      <para>Whether to wipe Resource Fork data that matches the special
+	      286 bytes sized placeholder blob that macOS client create on
+	      occasion. The blob contains a string <quote>This resource fork
+	      intentionally left blank</quote>, the remaining bytes being mostly
+	      zero. There being no one use of this data, it is probably safe to
+	      discard it. When this option is enabled, this module truncates the
+	      Resource Fork stream to 0 bytes.</para>
+	      <para>The default is <emphasis>no</emphasis>.</para>
+	    </listitem>
+	  </varlistentry>
+
+	  <varlistentry>
+	    <term>fruit:delete_empty_adfiles = yes | no</term>
+	    <listitem>
+	      <para>Whether to delete empty AppleDouble files. Empty means that
+	      the resource fork entry in the AppleDouble files is of size 0, or
+	      the size is exactly 286 bytes and the content matches a special
+	      boilerplate resource fork created my macOS.</para>
+	      <para>The default is <emphasis>no</emphasis>.</para>
+	    </listitem>
+	  </varlistentry>
+
 	</variablelist>
 </refsect1>
 
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 356b4d3..f7957cf 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -2006,6 +2006,24 @@ sub provision($$$$$$$$$)
 	fruit:time machine = yes
 	fruit:time machine max size = 32K
 
+[vfs_fruit_wipe_intentionally_left_blank_rfork]
+	path = $shrdir
+	vfs objects = fruit streams_xattr acl_xattr xattr_tdb
+	fruit:resource = file
+	fruit:metadata = stream
+	fruit:wipe_intentionally_left_blank_rfork = true
+	fruit:delete_empty_adfiles = false
+	fruit:veto_appledouble = no
+
+[vfs_fruit_delete_empty_adfiles]
+	path = $shrdir
+	vfs objects = fruit streams_xattr acl_xattr xattr_tdb
+	fruit:resource = file
+	fruit:metadata = stream
+	fruit:wipe_intentionally_left_blank_rfork = true
+	fruit:delete_empty_adfiles = true
+	fruit:veto_appledouble = no
+
 [badname-tmp]
 	path = $badnames_shrdir
 	guest ok = yes
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index a3dabcd..efe88ef 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -142,6 +142,8 @@ struct fruit_config_data {
 	const char *model;
 	bool time_machine;
 	off_t time_machine_max_size;
+	bool wipe_intentionally_left_blank_rfork;
+	bool delete_empty_adfiles;
 
 	/*
 	 * Additional options, all enabled by default,
@@ -467,12 +469,65 @@ static const uint32_t set_eid[] = {
 	AD_DEV, AD_INO, AD_SYN, AD_ID
 };
 
+static char empty_resourcefork[] = {
+	0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E,
+	0x54, 0x68, 0x69, 0x73, 0x20, 0x72, 0x65, 0x73,
+	0x6F, 0x75, 0x72, 0x63, 0x65, 0x20, 0x66, 0x6F,
+	0x72, 0x6B, 0x20, 0x69, 0x6E, 0x74, 0x65, 0x6E,
+	0x74, 0x69, 0x6F, 0x6E, 0x61, 0x6C, 0x6C, 0x79,
+	0x20, 0x6C, 0x65, 0x66, 0x74, 0x20, 0x62, 0x6C,
+	0x61, 0x6E, 0x6B, 0x20, 0x20, 0x20, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E,
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0x1C, 0x00, 0x1E, 0xFF, 0xFF
+};
+
 struct fio {
 	/* tcon config handle */
 	struct fruit_config_data *config;
 
 	/* Denote stream type, meta or rsrc */
 	adouble_type_t type;
+
+	/* Whether the create created the stream */
+	bool created;
+
+	/*
+	 * AFP_AfpInfo stream created, but not written yet, thus still a fake
+	 * pipe fd. This is set to true in fruit_open_meta if there was no
+	 * exisiting stream but the caller requested O_CREAT. It is later set to
+	 * false when we get a write on the stream that then does open and
+	 * create the stream.
+	 */
+	bool fake_fd;
+	int flags;
+	int mode;
 };
 
 /*
@@ -1281,6 +1336,107 @@ static bool ad_convert_truncate(struct adouble *ad,
 	return true;
 }
 
+static bool ad_convert_blank_rfork(struct adouble *ad,
+				   bool *blank)
+{
+	struct fruit_config_data *config = NULL;
+	uint8_t *map = MAP_FAILED;
+	size_t maplen;
+	int cmp;
+	ssize_t len;
+	int rc;
+	bool ok;
+
+	*blank = false;
+
+	SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config,
+				struct fruit_config_data, return false);
+
+	if (!config->wipe_intentionally_left_blank_rfork) {
+		return true;
+	}
+
+	if (ad_getentrylen(ad, ADEID_RFORK) != sizeof(empty_resourcefork)) {
+		return true;
+	}
+
+	maplen = ad_getentryoff(ad, ADEID_RFORK) +
+		ad_getentrylen(ad, ADEID_RFORK);
+
+	/* FIXME: direct use of mmap(), vfs_aio_fork does it too */
+	map = mmap(NULL, maplen, PROT_READ|PROT_WRITE, MAP_SHARED,
+		   ad->ad_fd, 0);
+	if (map == MAP_FAILED) {
+		DBG_ERR("mmap AppleDouble: %s\n", strerror(errno));
+		return false;
+	}
+
+	cmp = memcmp(map + ADEDOFF_RFORK_DOT_UND,
+		     empty_resourcefork,
+		     sizeof(empty_resourcefork));
+	rc = munmap(map, maplen);
+	if (rc != 0) {
+		DBG_ERR("munmap failed: %s\n", strerror(errno));
+		return false;
+	}
+
+	if (cmp != 0) {
+		return true;
+	}
+
+	ad_setentrylen(ad, ADEID_RFORK, 0);
+
+	ok = ad_pack(ad);
+	if (!ok) {
+		return false;
+	}
+
+	len = sys_pwrite(ad->ad_fd, ad->ad_data, AD_DATASZ_DOT_UND, 0);
+	if (len != AD_DATASZ_DOT_UND) {
+		return false;
+	}
+
+	*blank = true;
+	return true;
+}
+
+static bool ad_convert_delete_adfile(struct adouble *ad,
+				     const struct smb_filename *smb_fname)
+{
+	struct fruit_config_data *config = NULL;
+	struct smb_filename *ad_name = NULL;
+	int rc;
+
+	if (ad_getentrylen(ad, ADEID_RFORK) > 0) {
+		return true;
+	}
+
+	SMB_VFS_HANDLE_GET_DATA(ad->ad_handle, config,
+				struct fruit_config_data, return false);
+
+	if (!config->delete_empty_adfiles) {
+		return true;
+	}
+
+	rc = adouble_path(talloc_tos(), smb_fname, &ad_name);
+	if (rc != 0) {
+		return false;
+	}
+
+	rc = SMB_VFS_NEXT_UNLINK(ad->ad_handle, ad_name);
+	if (rc != 0) {
+		DBG_ERR("Unlinking [%s] failed: %s\n",
+			smb_fname_str_dbg(ad_name), strerror(errno));
+		TALLOC_FREE(ad_name);
+		return false;
+	}
+
+	DBG_WARNING("Unlinked [%s] after conversion\n", smb_fname_str_dbg(ad_name));
+	TALLOC_FREE(ad_name);
+
+	return true;
+}
+
 /**
  * Convert from Apple's ._ file to Netatalk
  *
@@ -1295,13 +1451,19 @@ static int ad_convert(struct adouble *ad,
 {
 	bool ok;
 	bool converted_xattr = false;
+	bool blank;
 
 	ok = ad_convert_xattr(ad, smb_fname, &converted_xattr);
 	if (!ok) {
 		return -1;
 	}
 
-	if (converted_xattr) {
+	ok = ad_convert_blank_rfork(ad, &blank);
+	if (!ok) {
+		return -1;
+	}
+
+	if (converted_xattr || blank) {
 		ok = ad_convert_truncate(ad, smb_fname);
 		if (!ok) {
 			return -1;
@@ -1315,6 +1477,11 @@ static int ad_convert(struct adouble *ad,
 		return -1;
 	}
 
+	ok = ad_convert_delete_adfile(ad, smb_fname);
+	if (!ok) {
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -2094,6 +2261,14 @@ static int init_fruit_config(vfs_handle_struct *handle)
 		config->time_machine_max_size = conv_str_size(tm_size_str);
 	}
 
+	config->wipe_intentionally_left_blank_rfork = lp_parm_bool(
+		SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME,
+		"wipe_intentionally_left_blank_rfork", false);
+
+	config->delete_empty_adfiles = lp_parm_bool(
+		SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME,
+		"delete_empty_adfiles", false);
+
 	SMB_VFS_HANDLE_SET_DATA(handle, config,
 				NULL, struct fruit_config_data,
 				return -1);
@@ -2213,6 +2388,10 @@ static SMB_INO_T fruit_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
 	SMB_INO_T result;
 	char *upper_sname;
 
+	DBG_DEBUG("fruit_inode called for %ju/%ju [%s]\n",
+		  (uintmax_t)sbuf->st_ex_dev,
+		  (uintmax_t)sbuf->st_ex_ino, sname);
+
 	upper_sname = talloc_strdup_upper(talloc_tos(), sname);
 	SMB_ASSERT(upper_sname != NULL);
 
@@ -2230,8 +2409,8 @@ static SMB_INO_T fruit_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
 	/* Hopefully all the variation is in the lower 4 (or 8) bytes! */
 	memcpy(&result, hash, sizeof(result));
 
-	DEBUG(10, ("fruit_inode \"%s\": ino=0x%llu\n",
-		   sname, (unsigned long long)result));
+	DBG_DEBUG("fruit_inode \"%s\": ino=%ju\n",
+		  sname, (uintmax_t)result);
 
 	return result;
 }
@@ -3224,66 +3403,68 @@ static int fruit_connect(vfs_handle_struct *handle,
 	return rc;
 }
 
+static int fruit_fake_fd(void)
+{
+	int pipe_fds[2];
+	int fd;
+	int ret;
+
+	/*
+	 * Return a valid fd, but ensure any attempt to use it returns
+	 * an error (EPIPE). Once we get a write on the handle, we open
+	 * the real fd.
+	 */
+	ret = pipe(pipe_fds);
+	if (ret != 0) {
+		return -1;
+	}
+	fd = pipe_fds[0];
+	close(pipe_fds[1]);
+
+	return fd;
+}
+
 static int fruit_open_meta_stream(vfs_handle_struct *handle,
 				  struct smb_filename *smb_fname,
 				  files_struct *fsp,
 				  int flags,
 				  mode_t mode)
 {
-	AfpInfo *ai = NULL;
-	char afpinfo_buf[AFP_INFO_SIZE];
-	ssize_t len, written;
-	int hostfd = -1;
-	int rc = -1;
+	struct fruit_config_data *config = NULL;
+	struct fio *fio = NULL;
+	int open_flags = flags & ~O_CREAT;
+	int fd;
 
-	hostfd = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
-	if (hostfd == -1) {
-		return -1;
-	}
+	DBG_DEBUG("Path [%s]\n", smb_fname_str_dbg(smb_fname));
 
-	if (!(flags & (O_CREAT | O_TRUNC))) {
-		return hostfd;
-	}
+	SMB_VFS_HANDLE_GET_DATA(handle, config,
+				struct fruit_config_data, return -1);
 
-	ai = afpinfo_new(talloc_tos());
-	if (ai == NULL) {
-		rc = -1;
-		goto fail;
-	}
+	fio = VFS_ADD_FSP_EXTENSION(handle, fsp, struct fio, NULL);
+	fio->type = ADOUBLE_META;
+	fio->config = config;
 
-	len = afpinfo_pack(ai, afpinfo_buf);
-	if (len != AFP_INFO_SIZE) {
-		rc = -1;
-		goto fail;
+	fd = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, open_flags, mode);
+	if (fd != -1) {
+		return fd;
 	}
 
-	/* Set fd, needed in SMB_VFS_NEXT_PWRITE() */
-	fsp->fh->fd = hostfd;
-
-	written = SMB_VFS_NEXT_PWRITE(handle, fsp, afpinfo_buf,
-				      AFP_INFO_SIZE, 0);
-	fsp->fh->fd = -1;
-	if (written != AFP_INFO_SIZE) {
-		DBG_ERR("bad write [%zd/%d]\n", written, AFP_INFO_SIZE);
-		rc = -1;
-		goto fail;
+	if (!(flags & O_CREAT)) {
+		VFS_REMOVE_FSP_EXTENSION(handle, fsp);
+		return -1;
 	}
 
-	rc = 0;
+	fd = fruit_fake_fd();
+	if (fd == -1) {
+		VFS_REMOVE_FSP_EXTENSION(handle, fsp);
+		return -1;
+	}
 
-fail:
-	DBG_DEBUG("rc=%d, fd=%d\n", rc, hostfd);
+	fio->fake_fd = true;
+	fio->flags = flags;
+	fio->mode = mode;
 
-	if (rc != 0) {
-		int saved_errno = errno;
-		if (hostfd >= 0) {
-			fsp->fh->fd = hostfd;
-			SMB_VFS_NEXT_CLOSE(handle, fsp);
-		}
-		hostfd = -1;
-		errno = saved_errno;
-	}
-	return hostfd;
+	return fd;
 }
 
 static int fruit_open_meta_netatalk(vfs_handle_struct *handle,
@@ -3292,56 +3473,42 @@ static int fruit_open_meta_netatalk(vfs_handle_struct *handle,
 				    int flags,
 				    mode_t mode)
 {
-	int rc;
-	int fakefd = -1;
+	struct fruit_config_data *config = NULL;
+	struct fio *fio = NULL;
 	struct adouble *ad = NULL;
-	int fds[2];
+	bool meta_exists = false;
+	int fd;
 
 	DBG_DEBUG("Path [%s]\n", smb_fname_str_dbg(smb_fname));
 
-	/*
-	 * Return a valid fd, but ensure any attempt to use it returns an error
-	 * (EPIPE). All operations on the smb_fname or the fsp will use path
-	 * based syscalls.
-	 */
-	rc = pipe(fds);
-	if (rc != 0) {
-		goto exit;
+	ad = ad_get(talloc_tos(), handle, smb_fname, ADOUBLE_META);
+	if (ad != NULL) {
+		meta_exists = true;
 	}
-	fakefd = fds[0];
-	close(fds[1]);
-
-	if (flags & (O_CREAT | O_TRUNC)) {
-		/*
-		 * The attribute does not exist or needs to be truncated,
-		 * create an AppleDouble EA
-		 */
-		ad = ad_init(fsp, handle, ADOUBLE_META);
-		if (ad == NULL) {
-			rc = -1;
-			goto exit;
-		}
 
-		rc = ad_set(ad, fsp->fsp_name);
-		if (rc != 0) {
-			rc = -1;
-			goto exit;
-		}
+	TALLOC_FREE(ad);
 
-		TALLOC_FREE(ad);
+	if (!meta_exists && !(flags & O_CREAT)) {
+		errno = ENOENT;
+		return -1;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list