Current Samba master incorrectly returns STATUS_INVALID_HANDLE on copy_chunk
Ralph Boehme
slow at samba.org
Sat Nov 9 21:34:40 UTC 2024
On 11/9/24 4:26 PM, Ralph Boehme via samba-technical wrote:
> On 10/9/24 9:43 PM, Jeremy Allison wrote:
>> Can we just map (access_mask (FILE_APPEND_DATA|SYNCHRONIZE)) ==
>> (FILE_APPEND_DATA|SYNCHRONIZE))
>> to O_APPEND, regardless of POSIX mode ?
>
> thinking about this a bit more, this seems doable, albeit only for POSIX
> mode. For non-POSIX mode we could potentially break WIndows application
> that open only with FILE_APPEND_DATA: I checked with a torture test that
> Windows doesn't enforce append behaviour for FILE_APPEND_DATA|SYNCHRONIZE.
>
> For POSIX opens we should also allow combinations like
> FILE_READ_ATTRIBUTES|FILE_APPEND_DATA to map to O_APPEND, so clients can
> write in append mode to the handle and still are able to fstat() it.
>
> https://gitlab.com/samba-team/samba/-/merge_requests/3863
in addition, I guess for SMB3 POSIX we might want to require that the
client sets offset=-2 in SMB2-WRITES on a handle opened with append
semantics, reusing the logic from MS-FSA.
This avoids bringing in the ambiguity of POSIX vs Linux pwrite()
O_APPEND behaviour into the protocol by clearly specifying: if a handle
is opened in append mode, all writes are using write() with O_APPEND
semantics which are clearly specified.
Looking at possible server implementations, it seems both Linux and
FreeBSD note in man pwrite() under BUGS, that a pwrite() on a handle
opened with O_APPEND ignores the offset, so we in Samba we can continue
to use pwrite() in SMB_VFS_PWRITE() default backend.
To avoid relying on BUGS, we can check for and use pwritev2() with
flags=RWF_APPEND, at least on Linux.
-slow
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20241109/47142f31/OpenPGP_signature.sig>
More information about the samba-technical
mailing list