Bug 15114 - Unable to delete AFP_Resource named stream
Summary: Unable to delete AFP_Resource named stream
Status: ASSIGNED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.13.4
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Jeremy Allison
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-01 21:41 UTC by suinn
Modified: 2022-09-15 16:44 UTC (History)
2 users (show)

See Also:


Attachments
SambaFailWindowsWorksPackets (48.79 KB, application/zip)
2022-07-01 21:41 UTC, suinn
no flags Details
"Raw" patch that fixes it for master. (785 bytes, patch)
2022-09-13 17:13 UTC, Jeremy Allison
no flags Details
Patch for vfs_fruit test to allow unique filename for delete on close AFP_Resource test. (660 bytes, patch)
2022-09-15 16:34 UTC, Jeremy Allison
no flags Details
pcap file of smbtorture vfs_fruit test running against MacOSX "Ventura" 10.13 server. (460.99 KB, application/octet-stream)
2022-09-15 16:39 UTC, Jeremy Allison
no flags Details
Text result (stdout) from smbtorture vfs_fruit run against MacOSX server (10.69 KB, text/plain)
2022-09-15 16:43 UTC, Jeremy Allison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description suinn 2022-07-01 21:41:34 UTC
Created attachment 17407 [details]
SambaFailWindowsWorksPackets

Configuration:
QNAP TVS-h1288X (QuTS hero)
Firmware: h5.0.0.1892
smbd (samba daemon) Version 4.13.14

Steps to Reproduce:
1. SMB Client logs into the server
2. testfile is created
3. Named stream of AFP_Resource is created in testfile
4. Data is written to the AFP_Resource resulting in a length of 63
5. AFP_Resource is closed
6. AFP_Resource is deleted
7. Create/QueryInfo(SMB2_FILE_STRAM_INFO)/Close is done on testfile

Expected Results:
The AFP_Resource named stream should be deleted

Actual Results:
Samba server return the QueryInfo showing that AFP_Resource is still present and still has a length of 63

I have attached a packet trace showing the incorrect behavior from Samba (QueryInfo at 185) and the correct behavior from Windows (QueryInfo at 407).
Comment 1 Jeremy Allison 2022-09-13 17:13:45 UTC
Created attachment 17514 [details]
"Raw" patch that fixes it for master.

Confirmed by Brad from Apple at SNIA SDC 2022.
Comment 2 Jeremy Allison 2022-09-13 18:23:32 UTC
Adding Ralph so he can see the problem.
Comment 3 Ralph Böhme 2022-09-13 19:35:53 UTC
Comment on attachment 17514 [details]
"Raw" patch that fixes it for master.

Does this pass

make test TESTS=vfs.fruit

?
Comment 4 Jeremy Allison 2022-09-13 19:41:59 UTC
Don't know. Haven't done a:

make test TESTS=vfs.fruit

yet. It fixes the problem for Brad with his Apple client code. It also seems to make the code match the comment :-).
Comment 5 Jeremy Allison 2022-09-14 00:35:36 UTC
make test TESTS=vfs.fruit fails:

checking whether create with delete-on-close is ignored for AFP_AfpResource
Opening not existing AFP_AfpResource
i[0] exp[::$DATA] got[::$DATA]
Trying to delete AFP_AfpResource via create with delete-on-close
Open stream vfs_fruit_dir\file:AFP_Resource
i[0] exp[::$DATA] got[::$DATA]
i[1] exp[:AFP_Resource:$DATA] got[:AFP_Resource:$DATA]
WARNING!: ../../source4/torture/vfs/fruit.c:3751: finfo.stream_info.out.num_streams was 1 (0x1), expected 2 (0x2): stream count
UNEXPECTED(failure): samba3.vfs.fruit metadata_netatalk.create delete-on-close AFP_AfpResource(nt4_dc)
REASON: Exception: Exception: ../../source4/torture/vfs/fruit.c:4599: Expression `ret == 1' failed: Bad streams
Trying to delete AFP_AfpResource via setinfo with delete-on-close
WARNING!: ../../source4/torture/vfs/fruit.c:3751: finfo.stream_info.out.num_streams was 1 (0x1), expected 2 (0x2): stream count
UNEXPECTED(failure): samba3.vfs.fruit metadata_netatalk.setinfo delete-on-close AFP_AfpResource(nt4_dc)
REASON: Exception: Exception: ../../source4/torture/vfs/fruit.c:4666: Expression `ret == 1' failed: Bad streams

which is this test: test_create_delete_on_close_resource().

Did you test this against a Mac SMB2 server ? If it passes against a Mac, then there's something different here I'm not seeing.
Comment 6 Jeremy Allison 2022-09-15 16:34:54 UTC
Created attachment 17517 [details]
Patch for vfs_fruit test to allow unique filename for delete on close AFP_Resource test.
Comment 7 Jeremy Allison 2022-09-15 16:39:25 UTC
Created attachment 17518 [details]
pcap file of smbtorture vfs_fruit test running against MacOSX "Ventura" 10.13 server.

Look at packet number 1449 - this is the open with DELETE_ON_CLOSE set for filename "vfs_fruit_dir\del_on_close_file:AFP_Resource" - and showing that the MacOSX server *does* delete this stream (of size 10 bytes).
Comment 8 Jeremy Allison 2022-09-15 16:43:12 UTC
Created attachment 17519 [details]
Text result (stdout) from smbtorture vfs_fruit run against MacOSX server

Relevant lines from file - showing MacOSX server will delete a 10 byte AFP_AfpResource stream:

130 test: create delete-on-close AFP_AfpResource
131 time: 2022-09-15 16:29:06.016219
132 Checking whether create with delete-on-close is ignored for AFP_AfpResource
133 Opening not existing AFP_AfpResource
134 i[0] exp[::$DATA] got[::$DATA]
135 Trying to delete AFP_AfpResource via create with delete-on-close
136 Open stream vfs_fruit_dir\del_on_close_file:AFP_Resource
137 i[0] exp[::$DATA] got[::$DATA]
138 i[1] exp[:AFP_Resource:$DATA] got[:AFP_Resource:$DATA]
139 WARNING!: ../../source4/torture/vfs/fruit.c:3751: finfo.stream_info.out.num_streams was 1 (0x1), expected 2 (0x2): stream count
140 time: 2022-09-15 16:29:06.183082
141 failure: create delete-on-close AFP_AfpResource [
142 ../../source4/torture/vfs/fruit.c:4599: Expression `ret == 1' failed: Bad streams
143 ]
Comment 9 Jeremy Allison 2022-09-15 16:44:22 UTC
Ralph, these last attachments show that MacOSX *will* delete a non-zero AFP_Resource stream. Our vfs_fruit tests are incorrect here.