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

124230 Commits

Author SHA1 Message Date
Ralph Boehme
924e7a702f smbd: unconst smb_fname arg of all setfileinfo worker functions
This allows avoiding making copies of the smb_fname when it needs to be passed
to a function that takes a non-const smb_fname.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
83ecda17a2 smbd: use openat_pathref_fsp() in call_trans2findfirst()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Also drop pathref fsp from filename_convert() in call_trans2findfirst(), because
the call to filename_convert() is on the path from the client including the
search mask.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
aedaa97e69 smbd: un-const smb_fname in get_posix_fsp()
Avoids making a copy of smb_fname which allows using smb_fname->fsp if there is
one.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
9bdac4f812 smbd: use openat_pathref_fsp() in copy_file()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
492ca5819a smbd: use openat_pathref_fsp() rename_internals()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
36b03af0ea printing: use openat_pathref_fsp() in driver_unlink_internals()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

As the create_disposition is FILE_OPEN we just return the error if
openat_pathref_fsp() fails

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
14b0cc6b9a smbd: use openat_pathref_fsp() in reply_search()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

As the create_disposition is FILE_OPEN we just return the error if
openat_pathref_fsp() fails

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
0bdaba47f4 smbd: use openat_pathref_fsp() in open_streams_for_delete()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

As the create_disposition is FILE_OPEN we just return the error if
openat_pathref_fsp() fails

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
e5adfe64fc smbd: use openat_pathref_fsp() in get_file_handle_for_metadata()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

As the create_disposition is FILE_OPEN we just return the error if
openat_pathref_fsp() fails

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
a74f0af1a9 printing: use openat_pathref_fsp() in get_correct_cversion()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

As the create_disposition is FILE_OPEN we just return the error if
openat_pathref_fsp() fails

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
ef5e913bca printing: use openat_pathref_fsp() in file_version_is_newer()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

As the create_disposition is FILE_OPEN we just return the error if
openat_pathref_fsp() fails

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
cbe25e1777 printing: use openat_pathref_fsp() in file_version_is_newer()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

As the create_disposition is FILE_OPEN we just return the error if
openat_pathref_fsp() fails

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
e8a49d0ec9 s3/libadouble: use openat_pathref_fsp() in readdir_attr_meta_finderi_stream()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

As the create_disposition is FILE_OPEN we just return the error if
openat_pathref_fsp() fails

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
368b8158cb s3/libadouble: use openat_pathref_fsp() in ad_open_rsrc()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

As the create_disposition is FILE_OPEN we just return the error if
openat_pathref_fsp() fails

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
e4bb359a53 s3/libadouble: use openat_pathref_fsp() in ad_collect_one_stream()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
349c573773 s3/libadouble: use openat_pathref_fsp() in ad_unconvert_get_streams()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
e70c61874a s3/libadouble: use openat_pathref_fsp() in ad_unconvert_open_ad()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
be4a4b5116 s3/libadouble: use openat_pathref_fsp() in ad_convert_finderinfo()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
67a7354814 s3/libadouble: use openat_pathref_fsp() in ad_convert_xattr()
Ensures we have a pathref handle in the smb_fname we pass to
SMB_VFS_CREATE_FILE().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
9a5a1fe148 smbd: use open_pathref_fsp() in filename_convert_internal()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
4d29ab04d8 smbd: use common exit in filename_convert_internal()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
927c297bd6 smbd: add need_fsa arg and logic to file_find_di_(first|next)
All callers except rename_open_files() can ignore non FSA fsps.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:31 +00:00
Ralph Boehme
24dd647c1c smbd: ignore non FSA fsps in file_find_dif()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
05633454f8 smbd: reduce indentation in file_find_dif()
No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
cff6dff5c2 smbd: README.Coding fixes in file_find_dif()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
b2685e28d2 smbd: use move_smb_fname_fsp_link() in fsp_set_smb_fname()
This ensures that fsp->fsp_name->fsp is again set to the fsp and also preserves
the link fsp->fsp_name->fsp_link.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
d5edf302c9 smbd: maintain correct destructor order in fsp_free()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
994f88909d smbd: add move_smb_fname_fsp_link()
Function to move fsps from one smb_fname to another.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
d764c183eb smbd: add smb_fname_fsp_unlink()
Remove the link between an smb_fname and it's embedded smb_fname->fsp.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
7626bba6c1 smbd: add openat_pathref_fsp()
open_pathref_fsp() opens an "embedded" fsp inside smb_fname as
smb_fname->fsp. We call such an fsp a "pathref" fsp.

On system that support O_PATH the low level openat() is done with O_PATH. On
systems that lack support for O_PATH, we impersonate the root user as a
fallback.

Setting "is_pathref" in the fsp_flags before calling fd_openat() is what
triggers the special low-level behaviour inside the VFS.

The use of pathref fsps allows updating all callers of path based VFS functions
like

  dos_mode(smb_fname)
  -> SMB_VFS_GET_DOS_ATTRIBUTES(smb_fname)
     -> SMB_VFS_GETXATTR(smb_fname)

to use the handle based VFS function like

  fdos_mode(smb_fname->fsp)
  -> SMB_VFS_FGET_DOS_ATTRIBUTES(fsp)
     -> SMB_VFS_FGETXATTR(fsp)

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
c1c2dd6c19 smbd: remove SMB_VFS_FSTAT() from open_file()
This is now done in non_widelink_open().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
2b45b9a090 smbd: always fstat in non_widelink_open()
This way we can avoid stating twice: once here and possibly a second time in
the caller open_file().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
b6dfcae0cd smbd: convert non_widelink_open() and process_symlink_open() to return NTSTATUS
non_widelink_open() now also returns NT_STATUS_STOPPED_ON_SYMLINK in case an
attempt was made to either

1. open a symlink from a POSIX client, or

2. open a symlink from a Windows client but any of the symlink behaviour
   configuring options "follow symlink", "wide links" or "allow insecure wide
   links" prevents access to the symlink target

Caller open_file() has already been updated to map NT_STATUS_STOPPED_ON_SYMLINK
to NT_STATUS_NT_STATUS_OBJECT_PATH_NOT_FOUND.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
204c7b247b smbd: maps NT_STATUS_STOPPED_ON_SYMLINK to NT_STATUS_OBJECT_PATH_NOT_FOUND in open_file()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
241dd9d9a7 smbd: pass private_flags to open_file()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
12d75a83ea smbd: deal with real dirfsps in non_widelink_open()
If we get a real dirfsp, skip the parent-directory logic. Just pass the dirfsp
to SMB_VFS_OPENAT() which by now supports real dirfsps.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
65c4f61587 smbd: simplify setting and resetting fsp->fsp_name in non_widelink_open()
Instead of setting and resetting the name to the relative name every time we
call into the VFS, just set it once and reset it at the end and when recursing
via process_symlink_open().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
ade0af7881 smbd: use orig_fsp_name as variable name in non_widelink_open()
No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
d680e9aab1 smbd: remove unused cwdfsp from non_widelink_open()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
99f60a74e0 smbd: pass dirfsp down to non_widelink_open() and process_symlink_open()
Callers still all pass conn->cwd_fsp so no change in behaviour yet.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
abc00b959b smbd: pass a dirfsp to fd_open() and rename it to fd_openat()
For now no change in behaviour as all callers still pass conn->cwd_fsp. This
just prepared fd_openat() to deal with real dirfsp's pass by callers later on
when adding calls to fd_openat(dirfspm ...) in the directory enumeration loop.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
a272ca549f smbd: catch O_PATH opens of symlinks in in non_widelink_open()
Calling openat() with O_PATH|O_NOFOLLOW will open a handle on the symlink
itself. That would be a nice feature if it would be supported on more platforms,
but being a Linux only thing, we have to preserve the behaviour of failing to
open a handle on symlinks.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
abb7ab2c10 smbd: already set fsp fd in non_widelink_open()
A subsequent commit will add a consumer of the fd to non_widelink_open() (by
calling SMB_VFS_FSTAT()), so we need to set the fd already here. And it makes
more sense anyway. :)

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
eb6bbb4f01 smbd: check for pathref fd's in vfs_set_blocking()
Don't try to set pathref fd's to non-blocking, they're not used with IO.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
f898082130 vfs_shadow_copy2: deal with real dirfsps in shadow_copy2_openat()
Prepare shadow_copy2_openat() for real dirfsps flying by.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
a14db893c1 s3: add full_path_from_dirfsp_atname()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
7d1e6e83d8 vfs_glusterfs: implement pathref opens with become_root() fallback
Until glusterfs supports O_PATH, fallback to become_root().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
fd8825742f vfs_ceph: implement pathref opens in cephwrap_openat()
Ceph supports O_PATH since v0.93 from 2015:

https://ceph.io/geen-categorie/v0-93-hammer-release-candidate-released/

This seems to be old enough so we can hopefully use this without a runtime
version check.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
cf3c48cb08 vfs_default: implement pathref opens in vfswrap_openat()
If the system supports O_PATH we use that, otherwise we fallback to root opens.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00
Ralph Boehme
879d8a3be9 smbd/posix_acls: support pathref fd's in posix_sys_acl_blob_get_fd()
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-12-16 09:08:30 +00:00