1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

386 Commits

Author SHA1 Message Date
Ralph Boehme
a7fba3ff59 vfs_fruit: add missing calls to tevent_req_received()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15182

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
2022-10-06 22:03:35 +00:00
Jeremy Allison
35c637f2e6 s3: VFS: fruit. Implement fsync_send()/fsync_recv().
For type == ADOUBLE_META, fio->fake_fd is true so
writes are already synchronous, just call tevent_req_post().

For type == ADOUBLE_RSRC we know we are configured
with FRUIT_RSRC_ADFILE (because fruit_must_handle_aio_stream()
returned true), so we can just call SMB_VFS_NEXT_FSYNC_SEND()
after replacing fsp with fio->ad_fsp.

Remove knownfail.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15182

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
2022-10-06 22:03:35 +00:00
Volker Lendecke
7cd8715676 vfs: Add struct vfs_open_how.resolve
This prepares the later introduction of VFS_OPEN_HOW_RESOLVE_NO_SYMLINKS,
which will be used to make use of RESOLVE_NO_SYMLINKS on linux with openat2().

Right now all terminal VFS objects reject any resolve bits with ENOSYS.
So we only prepare the vfs layer for now without any real change.
But this will make backports to 4.17 much easier.

Pair-programmed-with: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Aug  6 02:39:11 UTC 2022 on sn-devel-184
2022-08-06 02:39:11 +00:00
Volker Lendecke
5fc016f268 vfs: change openat propotype to match linux openat2
The Linux prototype for openat2 looks like this:

       long openat2(int dirfd, const char *pathname,
                   struct open_how *how, size_t size);

where "struct open_how" is defined in "linux/openat2.h". It is
designed to be extensible with further flags.

The "size" parameter is required because there is no type checking
between userland and kernelspace, so the way for Linux to find which
version of open_how is being passed in is looking at the size:
"open_how" is expected to only every grow with additional fields,
should a change be necessary in the future.

Samba does not have this problem, we can typecheck the struct and
pointers, we expect all VFS modules to be compiled against the current
vfs.h.

For now this adds no functionality, but it will make further patches
much smaller.

Pair-programmed-with: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-08-06 01:43:50 +00:00
Volker Lendecke
c267c9839e VFS: NULL dirfsp for openat on stream opens
The main optimization is to avoid non_widelink_open() for streams
opens based on the fact that all streams opens are relative to
fsp->base_fsp, which is a pathref fsp already.

Neither streams_xattr nor streams_depot referenced dirfsp for the
streams case. Make this more obvious in the callers by passing NULL
and asserting this: non-streams opens and streams opens are just
different things, streams-opens can and do reference a base fsp and
don't need the non_widelink_open logic.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-07-25 12:04:33 +00:00
Volker Lendecke
a771f1d314 smbd: Simplify copy_file()
Pass in new_create_disposition directly. We can also remove the
if-case (ofun & OPENX_FILE_EXISTS_OPEN) in copy_file, the two callers
don't use it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-05-20 19:02:37 +00:00
Volker Lendecke
e7a60eb7c9 smbd: Simplify copy_file()
The only two callers did not use "count" and "target_is_directory".

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-05-20 19:02:37 +00:00
Volker Lendecke
6086a73f4e Revert "vfs: remove dirfsp arg from SMB_VFS_CREATE_FILE()"
This reverts commit 322574834f.

Not strictly a revert anymore, but for future work we do need "dirfsp"
in create_file_default() passed through the VFS.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2022-04-28 13:12:33 +00:00
Volker Lendecke
ef341e0f2d modules: Use conn->cwd_fsp in fruit_open_rsrc_adouble()
None of the adouble infrastructure is really prepared for a dirfsp
that is not conn->cwd_fsp, there are quite a few direct references to
it in adouble.c. This needs conversion, but at this point we need to
make fruit_openat() robust against a non-cwd_fsp dirfsp argument.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-04-07 16:33:28 +00:00
Volker Lendecke
702af7f85f vfs: Ensure we have a base fsp openat() for named streams
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-04-01 20:19:29 +00:00
Ralph Boehme
24f4bea5b8 vfs_fruit: change default for "fruit:zero_file_id" option to yes
After discussion with folks at Apple it should be safe these days to rely on the
Mac to generate its own File-Ids and let Samba return 0 File-Ids.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-03-31 23:01:37 +00:00
Jeremy Allison
0c113e652f s3: smbd: Rename OpenDir_ntstatus() -> OpenDir().
We now have a single OpenDir() function that returns an NTSTATUS.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Mar  2 21:58:32 UTC 2022 on sn-devel-184
2022-03-02 21:58:32 +00:00
Jeremy Allison
a1f4d74a1a s3: VFS: fruit: Move two more uses of OpenDir() -> OpenDir_nstatus().
Eventually we can replace OpenDir() with OpenDir_ntatatus().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
2022-03-02 21:04:34 +00:00
Volker Lendecke
40b7c862b4 vfs: Set errno in an error return
Don't leak an unrelated errno

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-03-01 20:09:29 +00:00
Volker Lendecke
2b6e557ec4 vfs: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-03-01 20:09:29 +00:00
Volker Lendecke
aacb3618c1 smbd: Use fsp_is_alternate_stream() where an fsp is available
Make it clear that being an alternate data stream handle is much more
a fsp property than a file name property.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-02-11 20:54:37 +00:00
Volker Lendecke
21b380ca13 smbd: Introduce fsp_is_alternate_stream()
To me this is more descriptive than "fsp->base_fsp != NULL". If this
turns out to be a performance problem, I would go and make this a
static inline in smbd/proto.h.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-02-11 20:54:37 +00:00
Volker Lendecke
f5bc73a2ad smbd: NULL out "fsp" in close_file()
Quite a few places already had this in the caller, but not all. Rename
close_file() to close_file_free() appropriately. We'll factor out
close_file_smb() doing only parts of close_file_free() later.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2022-02-10 18:16:36 +00:00
Pavel Filipenský
cebf26d062 s3:modules: Fix possible dereference of NULL for fio
We do not check consistently for fio being NULL in this file.

Found by covescan.

Pair-Programmed-With: Andreas Schneider <asn@samba.org>

Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jan 11 00:22:09 UTC 2022 on sn-devel-184
2022-01-11 00:22:09 +00:00
Ralph Boehme
8fa7848b4a vfs: Add flags and xferlen args to SMB_VFS_OFFLOAD_READ_RECV
We missed these values which follow from MS-FSCC 2.3.80 “FSCTL_OFFLOAD_READ
Reply”:

  Flags (4 bytes):

    A 32-bit unsigned integer that indicates which flags were returned for this
    operation. Possible values for the flags follow. All unused bits are reserved
    for future use, SHOULD be set to 0, and MUST be ignored.

    OFFLOAD_READ_FLAG_ALL_ZERO_BEYOND_CURRENT_RANGE (0x00000001)
    => The data beyond the current range is logically equivalent to zero.

  TransferLength (8 bytes):

    A 64-bit unsigned integer that contains the amount, in bytes, of data that the
    Token logically represents. This value indicates a contiguous region of the
    file from the beginning of the requested offset in the FileOffset field in the
    FSCTL_OFFLOAD_READ_INPUT data element (section 2.3.79). This value can be
    smaller than the CopyLength field specified in the FSCTL_OFFLOAD_READ_INPUT
    data element, which indicates that less data was logically
    represented (logically read) with the Token than was requested. The value of
    this field MUST be greater than 0x0000000000000000 and MUST be aligned to a
    logical sector boundary on the volume.

As we currently only implement COPY_CHUNK over the OFFLOAD VFS interface, the
VFS COPY_CHUNK backend in vfs_default just sets both values to 0 and they are
unused in the SMB frontend.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-10-08 19:28:32 +00:00
Jeremy Allison
03e36502f4 s3: VFS: fruit. In ad_get_meta_fsp(), we only need a handle on the base file, not the stream.
We'll be calling SMB_VFS_FGETXATTR() on the base fsp anyway.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14756

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-14 08:09:31 +00:00
Jeremy Allison
6a8d052f7c s3: VFS: fruit: In fruit_streaminfo_meta_netatalk(), ad_get() -> ad_get_meta_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-04 17:15:35 +00:00
Jeremy Allison
d05087d4b8 s3: VFS: fruit: In fruit_stat_meta_netatalk(), ad_get() -> ad_get_meta_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-04 17:15:35 +00:00
Jeremy Allison
99a2a1be15 s3: VFS: fruit: In readdir_attr_meta_finderi_netatalk(), ad_get() -> ad_get_meta_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-04 17:15:35 +00:00
Jeremy Allison
88f3ced4e0 s3: VFS: fruit: In update_btime(), ad_get() -> ad_get_meta_fsp().
Uncomment ad_get_meta_fsp() as we're now using it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-04 17:15:34 +00:00
Jeremy Allison
18b49ad251 s3: VFS: fruit: Add helper function ad_get_meta_fsp().
Not yet used. We will use this to replace calls
to ad_get(..., ADOUBLE_META). It uses openat_pathref_fsp()
to get a handle before calling into ad_get(..., ADOUBLE_META).

Uses the recursion guard to prevent recursion into openat_pathref_fsp()
from stat calls within.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-04 17:15:34 +00:00
Jeremy Allison
b2d6ed2906 s3: VFS: fruit: In the fruit handle->fruit_config_data, add a recursion guard we will set before calling openat_pathref_fsp().
Not yet used.

Same technique as used to prevent recursion in stat calls in vfs_fake_acls.c
This will go away once SMB_VFS_STATX() is added and we can select exactly
what fields we are calling stat() to get.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-04 17:15:34 +00:00
Jeremy Allison
342086d773 s3: VFS: fruit: In fruit_stat_meta_netatalk(), move the call to fruit_stat_base() before the ad_get() call.
Both must succeed for a valid return, and we're next going
to replace ad_get() with a wrapper that calls openat_pathref_fsp(),
which needs a VALID_STAT().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-04 17:15:34 +00:00
Jeremy Allison
6eaf027458 s3: VFS: fruit: Inside fruit_open_meta_netatalk() change to use fsp->base_fsp->fsp_name in ad_get() instead of smb_fname.
We know this will have a valid fsp within.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-04 17:15:34 +00:00
Jeremy Allison
4e97e33c3b s3: smbd: Code inside non_widelink_open() breaks an invarient inside the VFS. Demonstrate this.
vfs_fruit isn't the bad guy here. It's just a convenient
place to show that non_widelink_open() violates:

fsp->base_fsp->fsp_name->fsp == fsp->base_fsp invarient

Add selftest/knownfail.d/fruit_vfs_invariant to show
what this breaks. Next patch will fix the non_widelink_open()
code and remove the knownfail.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-07-04 17:15:34 +00:00
Jeremy Allison
492d105b44 s3: smbd: smbd_calculate_access_mask_fsp(). Add dirfsp parameter.
Pass this down into smbd_calculate_maximum_allowed_access_fsp().

Currently pass fsp->conn->cwd_fsp everywhere.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Jeremy Allison
3293cc8d75 s3: VFS: fruit: fruit_freaddir_attr(), smbd_calculate_access_mask() -> smbd_calculate_access_mask_fsp().
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-06-09 13:14:31 +00:00
Samuel Cabrero
1fa6d75b43 s3: VFS: fruit: Remove SMB_VFS_READDIR_ATTR()
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-05-14 20:04:28 +00:00
Samuel Cabrero
45578328a6 s3: VFS: fruit: Implement SMB_VFS_FREADDIR_ATTR()
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-05-14 20:04:28 +00:00
Noel Power
98c20b3aa3 s3/modules: VFS: fruit: Remove SMB_VFS_STREAMINFO
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-05-11 15:49:28 +00:00
Noel Power
4bca55aea1 s3/module: VFS: fruit: vfs_streaminfo -> vfs_fstreaminfo
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-05-11 15:49:28 +00:00
Noel Power
8e469af3cf s3: vfs: fruit: Implement SMB_VFS_FSTREAMINFO
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-05-11 15:49:28 +00:00
Samuel Cabrero
23c27b7f82 s3: VFS: fruit: Remove SMB_VFS_NTIMES()
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-04-19 12:28:30 +00:00
Samuel Cabrero
5d84ad711a s3: VFS: fruit: Implement SMB_VFS_FNTIMES()
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-04-19 12:28:30 +00:00
Noel Power
3df8106edc s3/modules: VFS: fruit: Remove fruit_chmod
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-04-11 22:27:34 +00:00
Noel Power
f54ec00eca s3/modules: VFS: fruit: Add new fchmod_fn implementation
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
2021-04-11 22:27:34 +00:00
Ralph Boehme
d2acd9629e s3/libadouble: remove dirfsp arg from ad_convert()
ad_convert() doesn't really need the dirfsp in most places. Only
ad_convert_delete_adfile() would use it, so instead open a dirfsp internally for
this function in a later commit.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-28 08:11:49 +00:00
Ralph Boehme
de85bccef2 vfs_fruit: support real dirfsps in fruit_unlinkat()
Now that all callees are updated, we can remove the assert.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-28 08:11:49 +00:00
Ralph Boehme
951fefeca8 vfs_fruit: support real dirfsps in fruit_unlink_rsrc_adouble()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-28 08:11:49 +00:00
Ralph Boehme
c231d88655 vfs_fruit: support real dirfsps in fruit_unlink_rsrc_stream()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-28 08:11:49 +00:00
Ralph Boehme
cb90a8dc79 vfs_fruit: use SMB_VFS_FREMOVEXATTR() in fruit_unlink_meta_netatalk()
Use the pathref fsp from the caller.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-28 08:11:49 +00:00
Ralph Boehme
7bc983f5d5 vfs_fruit: use synthetic_pathref() in delete_invalid_meta_stream()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-28 08:11:49 +00:00
Ralph Boehme
ffd6bcdf37 vfs_fruit: fix use after free in delete_invalid_meta_stream()
sname is used in the DBG_ERR message.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-28 08:11:49 +00:00
Ralph Boehme
1032bf08dd vfs_fruit: use synthetic_pathref() in readdir_attr_meta_finderi_stream()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2021-01-28 08:11:49 +00:00
Stefan Metzmacher
480516e3b8 vfs_fruit: make use of adouble_open_from_base_fsp(ADOUBLE_RSRC) in fruit_open_rsrc_adouble()
The key is that we return a fake_fd to the caller and only open
the '._' file in the background.

The next vfs backend should only see the fsp from
adouble_open_from_base_fsp, while the vfs backends above
should only see the fake_fd.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Jan 21 14:47:53 UTC 2021 on sn-devel-184
2021-01-21 14:47:53 +00:00