[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Wed Dec 16 10:16:01 UTC 2020


The branch, master has been updated
       via  874c5fcf6da smbd: Remove the smb_fname parameter from set_ea().
       via  898c537a431 smbd: set_ea() must have an fsp, so remove uses of the smb_fname parameter.
       via  0049a34b27f smbd: smb_info_set_ea() can only get fsp==NULL in POSIX mode accessing a symlink.
       via  a55a2bfb914 vfs: SMB_VFS_GET_COMPRESSION() -> SMB_VFS_FGET_COMPRESSION()
       via  3db25c1c9b3 smbd: remove unused get_ea_dos_attribute()
       via  04b4dc8649c vfs: RIP SMB_VFS_GET_DOS_ATTRIBUTES()
       via  d466ba6d613 vfs: add and use fget_ea_dos_attribute()
       via  0f5a28d6c1c smbd: use SMB_VFS_FGET_DOS_ATTRIBUTES() in open_file_ntcreate()
       via  2317583b5e1 smbd: RIP dos_mode()
       via  22d9c31a821 smbd: use fdos_mode() in tsmsm_fset_dos_attributes()
       via  2a1bb23288a smbd: use fdos_mode() in tsmsm_set_dos_attributes()
       via  e7a90fd7a17 smbd: use fdos_mode() in dos_mode_at_vfs_get_dosmode_done()
       via  62d82326a44 smbd: use fdos_mode() in smb_set_file_disposition_info()
       via  8eb561688e1 smbd: use fdos_mode() in smb_set_file_dosmode()
       via  24d75b92d08 smbd: pass fsp to smb_set_file_dosmode()
       via  72d19c89285 smbd: use fdos_mode() in smbd_do_qfilepathinfo()
       via  ccb68c56198 smbd: use fdos_mode() in call_trans2open()
       via  05b31b47b1b smbd: use fdos_mode() in smbd_smb2_create_after_exec()
       via  608085af10d smbd: use fdos_mode() in setup_close_full_information()
       via  0977f13795e smbd: use fdos_mode() in reply_getattrE()
       via  96a882655b8 smbd: use fdos_mode() in copy_file()
       via  812e59c6998 smbd: use fdos_mode() in rename_internals_fsp()
       via  58e103a7916 smbd: README.Coding fixes in rename_internals_fsp()
       via  f19b01a1cbd smbd: use SMB_VFS_FSTAT() in rename_internals_fsp()
       via  8dbac0d5c7a smbd: call rename_open_files() a bit earlier in rename_internals_fsp()
       via  988a838a352 smbd: use fdos_mode() in do_unlink()
       via  7d0c60ffd56 smbd: use fdos_mode() in can_rename()
       via  b3e5feb9ce7 smbd: use fdos_mode() in reply_open_and_X()
       via  594bfdea81b smbd: use fdos_mode() in reply_open()
       via  8bdf3f30fd1 smbd: use fdos_mode() in reply_getatr()
       via  933577585c3 smbd: use fdos_mode() in open_file_ntcreate()
       via  6e5128356ba smbd: use fdos_mode() in check_base_file_access()
       via  7386dc737c0 smbd: use fdos_mode() in copy_internals()
       via  f432bc56801 smbd: use fdos_mode() in call_nt_transact_create()
       via  ec9afe04d81 smbd: use fdos_mode() in reply_ntcreate_and_X()
       via  a649ebed44a smbd: use fdos_mode() in mark_file_modified()
       via  bde16030a29 smbd: use fdos_mode() in vfs_default_durable_reconnect()
       via  147c3f2ef55 smbd: use fdos_mode() in set_create_timespec_ea()
       via  8e9887c24f7 smbd: drop pathref from smb_fname_dst_in in rename_internals_fsp()
       via  ea2def330b1 smbd: un-const smb_fname_dst_in arg of rename_internals_fsp()
       via  c83516f307a vfstest: use filename_convert() in cmd_utime()
       via  54b4321f619 smbd: use fdos_mode() in file_set_sparse()
       via  180e0a7d928 smbd: use fdos_mode() in smbd_dirptr_8_3_mode_fn()
       via  06906b1d1f6 smbd: use fdos_mode() in smbd_dirptr_lanman2_mode_fn()
       via  ccd3352b171 smbd: add fdos_mode()
       via  da93d88e30f vfs_gpfs: fix bogus compiler warning
       via  4ac20da4b91 smbd: use fsp in smb_set_file_time()
       via  ef9afe38d08 smbd: always use check_access_fsp() in smb_set_info_standard()
       via  752bc3881cf smbd: always use check_access_fsp() in smb_set_file_basic_info()
       via  cc0e740ae0f smbd: in reply_setatr() pass pathref fsp to smb_set_file_time()
       via  5bec96219b6 smbd: use check_access_fsp() in set_ea()
       via  a716c5569c7 smbd: use pathref fsp in call_trans2setfilepathinfo()
       via  2bcb268b183 smbd: use pathref fsp in call_trans2qfilepathinfo()
       via  d9e9f063dda smbd: use SMB_VFS_CREATE_FILE() in call_trans2mkdir()
       via  3d8237a8701 smbd: check for non FSA fsps in smb_file_rename_information()
       via  192897b49bb smbd: deal with non FSA fsps in check_access_fsp()
       via  3da8af16146 smbd: unconst fsp arg of check_access_fsp()
       via  9535af3646a smbd: check for valid FSA fsp in smb_set_posix_acl()
       via  1bc943ddf34 smbd: check for valid FSA fsp in smb_query_posix_acl()
       via  435c0f88286 smbd: adjust allocation size check across handles in smbd_do_qfilepathinfo()
       via  2aac91003ee smbd: add smbd_check_access_rights_fsp()
       via  8e3798dd222 smbd: factor out smbd_check_access_rights_sd() from smbd_check_access_rights()
       via  c98d1113f8d smbd: call open_pathref_fsp() in smbd_dirptr_get_entry()
       via  86edc662548 smbd: use get_dosmode in smbd_dirptr_8_3_mode_fn()
       via  36d72d8a81b vfs_default: return stat info for symlinks in POSIX context
       via  dd368479289 vfs_default: simplify vfswrap_readdir()
       via  dba8593c6f8 vfs: Add dirfsp arg to SMB_VFS_READDIR()
       via  985c1be5ccf smbd: use vfs_stat() in more places
       via  37e6783f417 smbd: use vfs_stat() in dptr_ReadDirName()
       via  9d075d80722 smbd: add vfs_stat()
       via  a63a3972948 s3/torture: add POSIX-STAT test
       via  562ae8eb236 s3/torture: add POSIX-READLINK test
       via  c8a2530b8db s3/torture: add POSIX-LS-SINGLE test
       via  0ccd24b41c5 s3/torture: add POSIX-LS-WILDCARD test
       via  626b4e5724e s3/torture: add torture_conn_set_sockopt() wrapper
       via  5770cdd7635 smbd: optimisation using pathref fd to open real fd if possible
       via  37003ec7090 vfs_fruit: disable fd reopening optimisations for the two special macOS streams
       via  4bcb3d7a03d vfs_xattr_tdb: don't leak the fd into the caller
       via  d00d09fdcf7 smbd: reuse smb_fname->fsp in create_file_default()
       via  c21890d128d smbd: replace a stat() with an fstat() in create_file_unixpath()
       via  945bdc7c235 smbd: we DO NEED the low level fd
       via  94dea7a26c2 smbd: call open_pathref_fsp() in unlink_internals() in wildcard matching loop
       via  dab50f39532 smbd: prevent non-POSIX stat-opens of symlinks in open_file()
       via  e6650c47cf0 net: use openat_pathref_fsp() in net_vfs_get_ntacl()
       via  bf4b1b9b12e smbd: avoid a smb_fname copy in smb_set_file_size()
       via  924e7a702f2 smbd: unconst smb_fname arg of all setfileinfo worker functions
       via  83ecda17a20 smbd: use openat_pathref_fsp() in call_trans2findfirst()
       via  aedaa97e694 smbd: un-const smb_fname in get_posix_fsp()
       via  9bdac4f8124 smbd: use openat_pathref_fsp() in copy_file()
       via  492ca5819a4 smbd: use openat_pathref_fsp() rename_internals()
       via  36b03af0ea2 printing: use openat_pathref_fsp() in driver_unlink_internals()
       via  14b0cc6b9a1 smbd: use openat_pathref_fsp() in reply_search()
       via  0bdaba47f4a smbd: use openat_pathref_fsp() in open_streams_for_delete()
       via  e5adfe64fc1 smbd: use openat_pathref_fsp() in get_file_handle_for_metadata()
       via  a74f0af1a91 printing: use openat_pathref_fsp() in get_correct_cversion()
       via  ef5e913bca5 printing: use openat_pathref_fsp() in file_version_is_newer()
       via  cbe25e1777d printing: use openat_pathref_fsp() in file_version_is_newer()
       via  e8a49d0ec9e s3/libadouble: use openat_pathref_fsp() in readdir_attr_meta_finderi_stream()
       via  368b8158cb7 s3/libadouble: use openat_pathref_fsp() in ad_open_rsrc()
       via  e4bb359a53c s3/libadouble: use openat_pathref_fsp() in ad_collect_one_stream()
       via  349c5737734 s3/libadouble: use openat_pathref_fsp() in ad_unconvert_get_streams()
       via  e70c61874af s3/libadouble: use openat_pathref_fsp() in ad_unconvert_open_ad()
       via  be4a4b51169 s3/libadouble: use openat_pathref_fsp() in ad_convert_finderinfo()
       via  67a73548140 s3/libadouble: use openat_pathref_fsp() in ad_convert_xattr()
       via  9a5a1fe148c smbd: use open_pathref_fsp() in filename_convert_internal()
       via  4d29ab04d81 smbd: use common exit in filename_convert_internal()
       via  927c297bd6a smbd: add need_fsa arg and logic to file_find_di_(first|next)
       via  24dd647c1c3 smbd: ignore non FSA fsps in file_find_dif()
       via  05633454f8b smbd: reduce indentation in file_find_dif()
       via  cff6dff5c2a smbd: README.Coding fixes in file_find_dif()
       via  b2685e28d2a smbd: use move_smb_fname_fsp_link() in fsp_set_smb_fname()
       via  d5edf302c9c smbd: maintain correct destructor order in fsp_free()
       via  994f88909df smbd: add move_smb_fname_fsp_link()
       via  d764c183eb5 smbd: add smb_fname_fsp_unlink()
       via  7626bba6c1e smbd: add openat_pathref_fsp()
       via  c1c2dd6c19f smbd: remove SMB_VFS_FSTAT() from open_file()
       via  2b45b9a0900 smbd: always fstat in non_widelink_open()
       via  b6dfcae0cd0 smbd: convert non_widelink_open() and process_symlink_open() to return NTSTATUS
       via  204c7b247b0 smbd: maps NT_STATUS_STOPPED_ON_SYMLINK to NT_STATUS_OBJECT_PATH_NOT_FOUND in open_file()
       via  241dd9d9a74 smbd: pass private_flags to open_file()
       via  12d75a83ea8 smbd: deal with real dirfsps in non_widelink_open()
       via  65c4f615879 smbd: simplify setting and resetting fsp->fsp_name in non_widelink_open()
       via  ade0af78816 smbd: use orig_fsp_name as variable name in non_widelink_open()
       via  d680e9aab16 smbd: remove unused cwdfsp from non_widelink_open()
       via  99f60a74e05 smbd: pass dirfsp down to non_widelink_open() and process_symlink_open()
       via  abc00b959be smbd: pass a dirfsp to fd_open() and rename it to fd_openat()
       via  a272ca549fc smbd: catch O_PATH opens of symlinks in in non_widelink_open()
       via  abb7ab2c10e smbd: already set fsp fd in non_widelink_open()
       via  eb6bbb4f016 smbd: check for pathref fd's in vfs_set_blocking()
       via  f8980821301 vfs_shadow_copy2: deal with real dirfsps in shadow_copy2_openat()
       via  a14db893c19 s3: add full_path_from_dirfsp_atname()
       via  7d1e6e83d8a vfs_glusterfs: implement pathref opens with become_root() fallback
       via  fd8825742f7 vfs_ceph: implement pathref opens in cephwrap_openat()
       via  cf3c48cb088 vfs_default: implement pathref opens in vfswrap_openat()
       via  879d8a3be9f smbd/posix_acls: support pathref fd's in posix_sys_acl_blob_get_fd()
       via  c9889c194aa vfs_posixacl: support pathref fd's in posixacl_sys_acl_set_fd()
       via  b2e6d7b00bc vfs_posixacl: support pathref fd's in posixacl_sys_acl_get_fd()
       via  011252c6111 vfs_fruit: skip Netatalk locking checks for path-ref fd's
       via  9b3c80f8c1c vfs_default: support pathref fd's in vfswrap_fsetxattr()
       via  a46f987ce57 vfs_default: support pathref fd's in vfswrap_fremovexattr()
       via  0f353bca64a vfs_default: support pathref fd's in vfswrap_flistxattr()
       via  3105e53f624 vfs_default: support pathref fd's in vfswrap_fgetxattr()
       via  6d16e580905 vfs_default: initialize conn->have_proc_fds
       via  11e2a8562f8 vfs_default: fix indentation
       via  2af46c7fda6 vfs: add fsp flag "have_proc_fds"
       via  1f94c3ee7be vfs: add struct connection_struct flag "have_proc_fds"
       via  1d35fc7f545 vfs_error_inject: ignore path_ref_fd's
       via  c39940d81b0 s3/lib: add proc fds infrastructure
       via  b56f554ff00 vfs: make struct fd_handle private
       via  dd8fe0cfc26 smbd: remove redundant initialisation of the fsp fd
       via  140df3218a5 smbd: use fd_handle_create()
       via  fdb91631185 smbd: use fh_[get|set]_refcount()
       via  da786ccd1d2 smbd: use fh_[get|set]_private_options()
       via  059dee953d6 smbd: use fh_[get|set]_gen_id()
       via  0d9afd7ab88 smbd: use fh_[get|set]_pos() and fh_[get|set]_position_information()
       via  61628adef65 smbd: use fsp_get_pathref_fd() for logical fd comparisons
       via  450d7f134c7 smbd: use fsp_get_pathref_fd() for fstat() calls
       via  5648662b2f2 smbd: use fsp_get_pathref_fd() for "internal" xattr functions
       via  bc908ea3f2e smbd: use fsp_get_pathref_fd() for *at related directory handles
       via  0208ca6946d smbd: use fsp_get_pathref_fd() when close()ing fds
       via  f5632b43337 smbd: use fsp_get_pathref_fd() as part of DEBUG and syslog messages
       via  9db3ff25732 smbd: use fsp_get_io_fd() when accessing a file or it's associated metadata
       via  50ce980902c smbd: use fsp_set_fd()
       via  28f43fdadc8 smbd: add fd_handle.[c|h]
       via  c6c65d1fc18 vfs: add "is_fsa" flag to struct files_struct
       via  bf7ab87877a vfs: add "is_pathref" to struct files_struct
       via  703c1898034 CI: skip kernel-oplocks tests on older kernels
       via  436903afe2a CI: add samba-no-opath
      from  7a077f152aa s3:smbd:trans2.c - add twrp to tmp smb_fname in smbd_do_qfsinfo

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


- Log -----------------------------------------------------------------
commit 874c5fcf6daaa88eddd374f7c8d5162590b046c8
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Dec 14 12:15:48 2020 -0800

    smbd: Remove the smb_fname parameter from set_ea().
    
    We know we must have a valid fsp.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Wed Dec 16 10:15:11 UTC 2020 on sn-devel-184

commit 898c537a4319c1ff657394424475fdaaf2b97ad1
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Dec 14 10:14:46 2020 -0800

    smbd: set_ea() must have an fsp, so remove uses of the smb_fname parameter.
    
    Next we can remove it.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 0049a34b27f385ef18d4c84c993d1364d4dbbb0f
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Dec 14 12:07:48 2020 -0800

    smbd: smb_info_set_ea() can only get fsp==NULL in POSIX mode accessing a symlink.
    
    Ensure this is the case and force-return NT_STATUS_ACCESS_DENIED here.
    Remove any race condition if anyone modifies the symlink whilst the
    operation is in process.
    
    This now allows us to require a valid fsp for operations on EAs.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit a55a2bfb9143002161ef119298891725c6d3c075
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 13 12:02:34 2020 +0200

    vfs: SMB_VFS_GET_COMPRESSION() -> SMB_VFS_FGET_COMPRESSION()
    
    Now that handle based fdos_mode() is used everywhere we can be sure that we're
    also always getting a handle in SMB_VFS_GET_COMPRESSION() so we can now safely
    remove the path parameter. :)
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3db25c1c9b3f0d5ec91905b068a0da3daa581e02
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 3 07:57:37 2020 +0100

    smbd: remove unused get_ea_dos_attribute()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 04b4dc8649cecd1699921c9a98f93b64d7c333dc
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 21:48:32 2020 +0200

    vfs: RIP SMB_VFS_GET_DOS_ATTRIBUTES()
    
                    (\  _  /)
                    ( \ O / )
                     (// \\)
                        X
                       / \
                      /___\
               _____/      \\_____
              |         +         ||
              |                   ||
              |   SMB_VFS_GET_    ||
              | DOS_ATTRIBUTES()  ||
              |                   ||
              |                   ||
              |                   ||
              |  _     ___   _    ||
              | | \     |   | \   ||
              | |  |    |   |  |  ||
              | |_/     |   |_/   ||
              | | \     |   |     ||
              | |  \    |   |     ||
              | |   \. _|_. | .   ||
              |                   ||
      *     * | *   **    * **    |**     **
       \)),.,\(/.,(//,,..,,\||(,,.,\\,.((//
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d466ba6d61365f72618dd3093706b8706b8f7c93
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 3 07:57:03 2020 +0100

    vfs: add and use fget_ea_dos_attribute()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0f5a28d6c1cb564653092c085d51c846ba852183
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 21:36:33 2020 +0200

    smbd: use SMB_VFS_FGET_DOS_ATTRIBUTES() in open_file_ntcreate()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2317583b5e15a0f355f0a04502edf8791a23e8aa
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 21:14:41 2020 +0200

    smbd: RIP dos_mode()
    
              .--. .-,       .-..-.__
            .'(`.-` \_.-'-./`  |\_( "\__
         __.>\ ';  _;---,._|   / __/`'--)
        /.--.  : |/' _.--.<|  /  | |
    _..-'    `\     /' /`  /_/ _/_/
     >_.-``-. `Y  /' _;---.`|/))))
    '` .-''. \|:  .'   __, .-'"`
     .'--._ `-:  \/:  /'  '.\             _|_
         /.'`\ :;   /'      `-           `-|-`
        -`    |     |                      |
              :.; : |                  .-'~^~`-.
              |:    |                .' _     _ `.
              |:.   |                | |_) | |_) |
              :. :  |                | | \ | |   |
              : ;   |                |           |
              : ;   |                |           |
              : ;   |                | dos_mode()|
            .:| . : ;                |           |
    -."-/\\\/:::.    `\."-._'."-"_\\-|           |///."-
    " -."-.\\"-."//.-".`-."_\\-.".-\\`=.........=`//-".
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 22d9c31a8210e37e62299f06c2c17df24d615daa
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 21:11:51 2020 +0200

    smbd: use fdos_mode() in tsmsm_fset_dos_attributes()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2a1bb23288a62097d656e7c273e0164fa8bec261
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 21:11:19 2020 +0200

    smbd: use fdos_mode() in tsmsm_set_dos_attributes()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e7a90fd7a173d8e3cd5a2bb163df61758b2b973f
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 21:10:40 2020 +0200

    smbd: use fdos_mode() in dos_mode_at_vfs_get_dosmode_done()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 62d82326a442bff55af330acd6917545e307e037
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 21:09:00 2020 +0200

    smbd: use fdos_mode() in smb_set_file_disposition_info()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8eb561688e1ec62a809dc695c0a22179b3c7defd
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 21:08:29 2020 +0200

    smbd: use fdos_mode() in smb_set_file_dosmode()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 24d75b92d0839626cd11797e4458494b7a9d6fb2
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 30 22:00:17 2020 +0100

    smbd: pass fsp to smb_set_file_dosmode()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 72d19c89285f27dbfdfc29f3f5e281243156448b
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 21:07:35 2020 +0200

    smbd: use fdos_mode() in smbd_do_qfilepathinfo()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ccb68c56198ce1b135201537565a906a09247a2f
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:59:35 2020 +0200

    smbd: use fdos_mode() in call_trans2open()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 05b31b47b1b68f3237143b37520d128fda3e2688
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:59:09 2020 +0200

    smbd: use fdos_mode() in smbd_smb2_create_after_exec()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 608085af10d96547d22ff6b997a5dfdb94d4a830
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:53:48 2020 +0200

    smbd: use fdos_mode() in setup_close_full_information()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0977f13795e17a584f64c32f4c4a79f6f00cdcf5
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:49:02 2020 +0200

    smbd: use fdos_mode() in reply_getattrE()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 96a882655b8e76285f3461ada931fd5a94f2e4a4
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:48:43 2020 +0200

    smbd: use fdos_mode() in copy_file()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 812e59c6998cd1c6d877087d1feff8b2aebc0f29
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 30 16:08:03 2020 +0100

    smbd: use fdos_mode() in rename_internals_fsp()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 58e103a79161aa4320e6ce64528dbd2669f5ac3b
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 30 16:06:38 2020 +0100

    smbd: README.Coding fixes in rename_internals_fsp()
    
    No change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f19b01a1cbdb1e2047f4c91647e9c82ed6da6acf
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 30 16:03:19 2020 +0100

    smbd: use SMB_VFS_FSTAT() in rename_internals_fsp()
    
    While at it, use the open handle on the renamed file to call fstat() instead of
    stat().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8dbac0d5c7ae3ec3905e0a14069d1c541a230f8e
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 30 15:38:22 2020 +0100

    smbd: call rename_open_files() a bit earlier in rename_internals_fsp()
    
    This prepares for using handle based SMB_VFS_FSTAT() and fdos_mode() a few lines
    below. As some VFS modules will use the fsp->fsp_name we have to make sure to
    rename it first.
    
    Fwiw, notify_rename() is moved as well as it needs to original name in
    fsp->fsp_name.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 988a838a352fe7a47e3b754020ee6887d3ad27be
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:43:21 2020 +0200

    smbd: use fdos_mode() in do_unlink()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7d0c60ffd56d80a986c84dabf1b30cb869f8a269
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:42:41 2020 +0200

    smbd: use fdos_mode() in can_rename()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b3e5feb9ce73dfce498228a248e4f0dd82b44514
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:42:03 2020 +0200

    smbd: use fdos_mode() in reply_open_and_X()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 594bfdea81bbf64da0b3eb2dd9aa85c250f1d1f7
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:41:43 2020 +0200

    smbd: use fdos_mode() in reply_open()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8bdf3f30fd12b261dc15b101baf1b6350f5c8328
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:41:18 2020 +0200

    smbd: use fdos_mode() in reply_getatr()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 933577585c3dd48dd17c780babd326dc8160a02b
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:40:51 2020 +0200

    smbd: use fdos_mode() in open_file_ntcreate()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6e5128356ba2d7ba325791931448c9c8453a7604
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:39:37 2020 +0200

    smbd: use fdos_mode() in check_base_file_access()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7386dc737c047a7a8ee63b42d708d557e14ac08d
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:38:27 2020 +0200

    smbd: use fdos_mode() in copy_internals()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f432bc56801f8fd8a3f3f944739550bbd1eb98ee
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:37:24 2020 +0200

    smbd: use fdos_mode() in call_nt_transact_create()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ec9afe04d81dc088922dc32b8355e36e28ec5ccf
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:36:19 2020 +0200

    smbd: use fdos_mode() in reply_ntcreate_and_X()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a649ebed44a40822b04620fed34e041978628c05
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:32:49 2020 +0200

    smbd: use fdos_mode() in mark_file_modified()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit bde16030a297e87c81c6b0e5be7b1d93cdd0dd60
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:32:05 2020 +0200

    smbd: use fdos_mode() in vfs_default_durable_reconnect()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 147c3f2ef55ba8d54539de5c6c5a9c6fb80efd92
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:31:15 2020 +0200

    smbd: use fdos_mode() in set_create_timespec_ea()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8e9887c24f7a0706f0e4db5078f5f62845d25fe7
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 29 18:36:08 2020 +0100

    smbd: drop pathref from smb_fname_dst_in in rename_internals_fsp()
    
    The pathref is not needed anymore below this point and it conflicts with the
    code that checks for open handles on the destination just below.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ea2def330b18d8bfc28f52c80a530a95ba7bd89d
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 29 18:30:19 2020 +0100

    smbd: un-const smb_fname_dst_in arg of rename_internals_fsp()
    
    A subsequent commit is going to modify smb_fname_dst_in.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c83516f307a9cbcd1663520f772dd1b81119e988
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 28 11:31:46 2020 +0100

    vfstest: use filename_convert() in cmd_utime()
    
    Ensures we have a pathref fsp when calling SMB_VFS_NTIMES().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 54b4321f6197a82fb0d1fe0263ae950ae9e4379f
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 20:29:28 2020 +0200

    smbd: use fdos_mode() in file_set_sparse()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 180e0a7d9282826e56b1b496a6c1cb68e00ed248
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 25 16:35:11 2020 +0100

    smbd: use fdos_mode() in smbd_dirptr_8_3_mode_fn()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 06906b1d1f6b9c98008ac0480f7fb55befc09929
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 16:40:18 2020 +0200

    smbd: use fdos_mode() in smbd_dirptr_lanman2_mode_fn()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ccd3352b171ad4bbe2e4ac1d8030c9dfdd2dac48
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 15:44:29 2020 +0200

    smbd: add fdos_mode()
    
    Note that this continues using the braindead dual path/handle based API mistake,
    but only in order to reuse the util functions and because this is an
    intermediate step to support transitioning to an all handle based flow.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit da93d88e30f58d9dfa919982b0625da37c682a27
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 20 21:59:35 2020 +0200

    vfs_gpfs: fix bogus compiler warning
    
    The next commit adds the first call inside Samba to the VFS function
    SMB_VFS_FGET_DOS_ATTRIBUTES() and therefor also to
    vfs_gpfs_fget_dos_attributes().  No idea why gcc is generating this warning:
    
    [4127/4716] Compiling source3/modules/vfs_aio_fork.c
    ../../source3/modules/vfs_gpfs.c: In function ‘vfs_gpfs_fget_dos_attributes’:
    ../../source3/modules/vfs_gpfs.c:1728:2: error: ‘file_id’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     1728 |  update_stat_ex_file_id(&fsp->fsp_name->st, file_id);
          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated due to -Wfatal-errors.
    cc1: all warnings being treated as errors
    
    This change fixes the error.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4ac20da4b9104fbfb63de09745a89a234441320b
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 28 12:24:14 2020 +0100

    smbd: use fsp in smb_set_file_time()
    
    Ensure we have a valid fsp whos name we pass to file_ntimes(). Remember,
    file_ntimes() by default ends up calling SMB_VFS_GET_DOS_ATTRIBUTES() under the
    hood in order to get/set the creation date.
    
    As any fsp->fsp_name contains a backpointer to the fsp ie
    
      fsp->fsp_name->fsp == fsp
    
    passing set_fsp->fsp_name to file_ntimes() allows replacing the path based
    SMB_VFS_GET_DOS_ATTRIBUTES() with SMB_VFS_FGET_DOS_ATTRIBUTES() under the hoods.
    
    Also use the base_fsp->fsp_name for the base name in case of setting the
    timestamps on a stream.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ef9afe38d08ab8edddd2f7af3a241dce82cc07a1
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 27 21:13:36 2020 +0100

    smbd: always use check_access_fsp() in smb_set_info_standard()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 752bc3881cfe31b85e38c04564e384a90a354b94
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 27 21:13:12 2020 +0100

    smbd: always use check_access_fsp() in smb_set_file_basic_info()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cc0e740ae0f739968478161b41379d1f12fb25e2
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 4 10:09:34 2020 +0100

    smbd: in reply_setatr() pass pathref fsp to smb_set_file_time()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5bec96219b64009fcdd79294c5395cf0cdd79d2d
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 27 21:12:22 2020 +0100

    smbd: use check_access_fsp() in set_ea()
    
    We now always have a fsp.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a716c5569c76d771d07d1e8172fa31be5fa15b39
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 17 12:14:19 2020 +0100

    smbd: use pathref fsp in call_trans2setfilepathinfo()
    
    This means we're now passing a valid fsp to all setinfo functions. The only
    special case being when dealing with a symlink in POSIX context.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2bcb268b1837371c9b8a384ca310ac6e54a812d6
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 17 07:54:42 2020 +0100

    smbd: use pathref fsp in call_trans2qfilepathinfo()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d9e9f063ddaa5465c97d52e8edf25d957b1bddee
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 28 10:35:59 2020 +0100

    smbd: use SMB_VFS_CREATE_FILE() in call_trans2mkdir()
    
    Use SMB_VFS_CREATE_FILE() instead of the create_directory() in order to have a
    fsp that we can pass to set_ea().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3d8237a87011ff0ab680fc4c609d7455cf843a0f
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 17 12:11:13 2020 +0100

    smbd: check for non FSA fsps in smb_file_rename_information()
    
    If the fsp is a non FSA fsp created by openat_pathref_fsp(), we can't pass it to
    rename_internals_fsp(). We have to go via rename_internals() which internally
    uses SMB_VFS_CREATE_FILE() to open an fsp which ensure we go through the lease
    checking code.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 192897b49bbaaf3dfb3db00f8c0b16c721d669f8
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 17 12:09:05 2020 +0100

    smbd: deal with non FSA fsps in check_access_fsp()
    
    For fsps coming out of openat_pathref_fsp() and not SMB_VFS_CREATE_FILE(),
    fsp->access_mask will be 0 and we check the requested rights against the
    permissions of the object opened by the fsp.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3da8af16146b8fb5f73de37013288f947148ed9a
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 17 12:08:48 2020 +0100

    smbd: unconst fsp arg of check_access_fsp()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9535af3646a3faae48da7dc6cd0e266894b12369
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 16 18:37:42 2020 +0100

    smbd: check for valid FSA fsp in smb_set_posix_acl()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1bc943ddf34f59af23ab43890e3672cb944491ad
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 16 18:37:11 2020 +0100

    smbd: check for valid FSA fsp in smb_query_posix_acl()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 435c0f88286cffafffd77469b29adcd06abea4e4
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 17 07:59:13 2020 +0100

    smbd: adjust allocation size check across handles in smbd_do_qfilepathinfo()
    
    Check all open files if either we don't have an fsp or if the fsp is not a full
    FSA fsp, ie not one which was created by SMB_VFS_CREATE_FILE() but by
    openat_pathref_fsp().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2aac91003ee2212eb25feab6f14d44c7f2759586
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 27 11:24:03 2020 +0100

    smbd: add smbd_check_access_rights_fsp()
    
    Handle based version of smbd_check_access_rights().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8e3798dd22276bc1ac8e96004d0e5e974240a7b9
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 27 11:23:03 2020 +0100

    smbd: factor out smbd_check_access_rights_sd() from smbd_check_access_rights()
    
    No change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c98d1113f8d2cfd52cbe7592574bbe5425a09471
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 10:00:57 2020 +0100

    smbd: call open_pathref_fsp() in smbd_dirptr_get_entry()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 86edc662548661761abbe381d35426ba67bd0576
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 25 13:21:25 2020 +0100

    smbd: use get_dosmode in smbd_dirptr_8_3_mode_fn()
    
    Caller currently always passes true, but this will change soonish with a change
    to smbd_dirptr_get_entry().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 36d72d8a81b9436e067a553d39056de9dc84deec
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 16 15:47:50 2020 +0200

    vfs_default: return stat info for symlinks in POSIX context
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dd36847928992ee5dc39f09e12992ab65c138923
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 16 15:40:56 2020 +0200

    vfs_default: simplify vfswrap_readdir()
    
    No change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dba8593c6f8c11d18ddc01e54f90c50c44070257
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Nov 22 13:57:27 2020 +0100

    vfs: Add dirfsp arg to SMB_VFS_READDIR()
    
    This allows for optimisations in VFS module: by passing the dirfsp as an
    additional arg, the function can check fsp->fsp_name->flags which may include eg
    SMB_FILENAME_POSIX_PATH to trigger POSIX pathname processing.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 985c1be5ccf40d0f5c85f42bc0d9bd0a15a86b59
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 25 12:29:40 2020 +0100

    smbd: use vfs_stat() in more places
    
    This replaces the code in a bunch of places where we choose between stat() and
    lstat() based on req->posix_pathname. The new code inside vfs_stat() is based on
    checking the smb_fname flag SMB_FILENAME_POSIX_PATH.
    
    req->posix_pathname is inherited from the global POSIX pathnames state and the
    smb_fname flags is also inherited from that indirectly via the UCF flags.
    
    Tl;dr: no change in behaviour. :)
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 37e6783f417a176b264ef6506174c0bbfe74f405
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 14 15:48:07 2020 +0200

    smbd: use vfs_stat() in dptr_ReadDirName()
    
    This is subtle: we inherit the smb_fname flags from the directory to its
    directory entries while listing a directory. This means if were listing a
    directory in POSIX context, we now treat all entries as POSIX paths and
    correctly call lstat() on the entries instead of stat().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9d075d8072210a9806141021c7758575a411ffcf
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 16 14:35:10 2020 +0200

    smbd: add vfs_stat()
    
    Deals with POSIX paths and either calls lstat() for POSIX or stat().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a63a39729489be073e0fe882a1f470f82dddfce6
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 15 15:36:42 2020 +0200

    s3/torture: add POSIX-STAT test
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 562ae8eb2369741e96c85fd22a5b65eb8c1863a4
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 15 15:32:34 2020 +0200

    s3/torture: add POSIX-READLINK test
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c8a2530b8db0e5c9b204577430fe8399bb8ff694
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 15 15:24:11 2020 +0200

    s3/torture: add POSIX-LS-SINGLE test
    
    Note that uses SMB2 for the "Windows client" (aka non-POSIX) connection as SMB1
    directory listing code translates a directory listing with a search mask that
    matches an existing file to a CREATE which won't cut it for our test as we're
    targetting the directory listing code.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0ccd24b41c5c474435031d6d7bc8abbffb898050
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 15 15:11:20 2020 +0200

    s3/torture: add POSIX-LS-WILDCARD test
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 626b4e5724efe6bde49c112dc31a171854edd180
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 15 12:32:53 2020 +0200

    s3/torture: add torture_conn_set_sockopt() wrapper
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5770cdd7635a018817418f58bd37268aedebd6a9
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 12 15:28:08 2020 +0200

    smbd: optimisation using pathref fd to open real fd if possible
    
    This is an optimisation that avoids going through the expensive
    non_widelink_open() logic a second time. It depends on a usable /proc/%d/fd/%d
    filesystem and this is checked and set as "can_reopen" flag by the VFS in the
    openat() function in the fsp.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 37003ec709041d523bec56ee17034cc6f3d26a09
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 24 18:02:26 2020 +0100

    vfs_fruit: disable fd reopening optimisations for the two special macOS streams
    
    I couldn't figure out why the reopen fails a few vfs.fruit tests, so for now
    disable the optimisations. It only affects the two special Mac streams, so it's
    not *that* bad, but definitely something we would want to improve on in the near
    future.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4bcb3d7a03db4c3346bcb4cb62752aa9930cd3b4
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 24 16:16:10 2020 +0100

    vfs_xattr_tdb: don't leak the fd into the caller
    
    This is subtle: generally fsp_set_fd(fd) is called in the caller of
    SMB_VFS_OPENAT() in non_widelink_open().
    
    fsp_set_fd() has a check that asserts certain combindations of the existing
    fsp->fh->fd and the new fd. Both being valid fds is not allowed.
    
    Therefor inside the VFS we must reset fsp->fh->fd if we've set it.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d00d09fdcf73a5839ae4f82cf8e953bb761bfbfb
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 2 17:40:41 2020 +0200

    smbd: reuse smb_fname->fsp in create_file_default()
    
    This is the big bang for the internal pathref fsps: up to this point the pathref
    fsps were lingering around unused inside smb_fname->fsp.
    
    With this change, the internal fsp will be the one that is going to be returned
    from SMB_VFS_CREATE_FILE() if the client requested access mask matches the
    criteria in open_file():
    
    	uint32_t need_fd_mask =
    		FILE_READ_DATA |
    		FILE_WRITE_DATA |
    		FILE_APPEND_DATA |
    		FILE_EXECUTE |
    		WRITE_DAC_ACCESS |
    		WRITE_OWNER_ACCESS |
    		SEC_FLAG_SYSTEM_SECURITY |
    		READ_CONTROL_ACCESS;
    
    As long as the client doesn't request any of the access rights listed above, we
    reuse the smb_fname->fsp, otherwise we close the smb_fname->fsp and call
    fd_open() to open a new fsp.
    
    In the future we can remove the four non-IO related access rights from the list:
    
    		WRITE_DAC_ACCESS |
    		WRITE_OWNER_ACCESS |
    		SEC_FLAG_SYSTEM_SECURITY |
    		READ_CONTROL_ACCESS
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c21890d128d43f6f739051aff61436c9119ba5ab
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 23 07:46:42 2020 +0100

    smbd: replace a stat() with an fstat() in create_file_unixpath()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 945bdc7c2350ba2edc6fd40bfcf2d5ac3f451b5c
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 27 19:21:48 2020 +0100

    smbd: we DO NEED the low level fd
    
    In order to make everything handle based, we will need the basefile handle when
    eg the client requests setting any of the filemetadata that is common across all
    streams, eg the file's timestamps.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 94dea7a26c2f4cd4e7ca0a6913cbcbb4b0e6e881
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 17 19:35:50 2020 +0200

    smbd: call open_pathref_fsp() in unlink_internals() in wildcard matching loop
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dab50f3953259635ba14d166472c3dbe920f1311
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 1 14:40:33 2020 +0200

    smbd: prevent non-POSIX stat-opens of symlinks in open_file()
    
    Also adjust the test that checks for this.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e6650c47cf08dc9c95668cd321cc66267318125a
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 16:54:28 2020 +0100

    net: use openat_pathref_fsp() in net_vfs_get_ntacl()
    
    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit bf4b1b9b12ec82a0d5b20586e961f8fe6ecf89b2
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 16:51:26 2020 +0100

    smbd: avoid a smb_fname copy in smb_set_file_size()
    
    Now that we get a non-const smb_fname we can use that for the call to
    SMB_VFS_CREATE_FILE().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 924e7a702f2b9dae563b10969864a2085418be2b
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 16:28:41 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 83ecda17a20cf25696698cb7693cea509a642575
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 15:51:59 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit aedaa97e6942bc76af53fb4535183a574a0e4cac
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 15:48:15 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9bdac4f81242d69fc75705614dbe69cddc7667c4
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 15:46:57 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 492ca5819a40f06d59d670d39c98271b223a5a55
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 15:44:08 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 36b03af0ea25ca5f390fcc597ff258e1662d1536
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 14:57:45 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 14b0cc6b9a1027b4d6d95be58d05f72e375d9f56
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 14:52:31 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0bdaba47f4a6cfef6740fda84f983bf316562ed2
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:56:56 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e5adfe64fc116defaba0aea376f81a31b70e1e4d
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:51:04 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a74f0af1a91fe0bbc68e4d41d65f43ec383ae8bf
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:47:19 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ef5e913bca584f0232d5bfff14df4ccba2dda35c
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:39:29 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cbe25e1777d0c43c21e8acc2cea79fd03fdaf2ea
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:38:43 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e8a49d0ec9e4fc31e1b2a8f93a3d36b2a3caed50
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:37:52 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 368b8158cb737089fb471019de4bfadf5c0d57e2
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:34:21 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e4bb359a53c64bf2622def547dfc3520d1b5cd67
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:32:02 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 349c5737734788b4d2725387405b7b4ffd8a6d9a
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:31:13 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e70c61874aff29176712274ebf1e721b0d339910
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:30:18 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit be4a4b511693c75165e7ead599f8652e70ec0155
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:28:30 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 67a73548140b5134a0389e47ad169805ea970641
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 12 12:25:56 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9a5a1fe148cd82cd00d2ee913ec1ae90b9fb24e0
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Jun 13 19:16:39 2020 +0200

    smbd: use open_pathref_fsp() in filename_convert_internal()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4d29ab04d810fa05140b347928872185ae54fff6
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 23 06:40:16 2020 +0100

    smbd: use common exit in filename_convert_internal()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 927c297bd6af116758cfb5081523859e0156834d
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 19 11:35:23 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 24dd647c1c34dc5b09f55f03aef4725c06a185ab
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 19 11:21:42 2020 +0100

    smbd: ignore non FSA fsps in file_find_dif()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 05633454f8babf74ee615bd015805ce1e2d96997
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 19 11:10:35 2020 +0100

    smbd: reduce indentation in file_find_dif()
    
    No change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cff6dff5c2a730bfb4915aa1182c0421e5db680f
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Nov 19 11:09:05 2020 +0100

    smbd: README.Coding fixes in file_find_dif()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b2685e28d2ab6b7b68db2bd1f615a848663d5eb5
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 23 06:23:12 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d5edf302c9ca1a48927c8a6db780b8e193edfd05
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jun 10 15:21:35 2020 +0200

    smbd: maintain correct destructor order in fsp_free()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 994f88909dfb7bde4381d547d37f4422ed3d77e2
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 23 06:00:40 2020 +0100

    smbd: add move_smb_fname_fsp_link()
    
    Function to move fsps from one smb_fname to another.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d764c183eb5704064fdcbeb2903fba06a1481d37
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 23 05:59:02 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7626bba6c1efaeb457d43e8821572f45f6b344ab
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Sep 29 10:14:47 2020 +0200

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c1c2dd6c19f0d96648bfb16a2fa4433e7129f9fe
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 17 16:05:11 2020 +0100

    smbd: remove SMB_VFS_FSTAT() from open_file()
    
    This is now done in non_widelink_open().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2b45b9a09008b63c3aa0ea062ed3b2c0eafc960b
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Nov 16 13:54:49 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b6dfcae0cd0ef8481a2dd00c60ed77021d724cd4
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 24 12:30:58 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 204c7b247b0a256113f873c3e785eada7a550b37
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 23 12:16:38 2020 +0200

    smbd: maps NT_STATUS_STOPPED_ON_SYMLINK to NT_STATUS_OBJECT_PATH_NOT_FOUND in open_file()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 241dd9d9a74970180b60a3521579c2f09ad06b3a
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 26 12:31:10 2020 +0100

    smbd: pass private_flags to open_file()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 12d75a83ea85f9b971c03549f2069c6324dde5a5
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 24 12:30:28 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 65c4f6158799374bd125647cd3216ed8fe6523ff
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 10:19:28 2020 +0200

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ade0af788162d96cdc2e79aae8c79fca7a170315
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 19 10:16:06 2020 +0200

    smbd: use orig_fsp_name as variable name in non_widelink_open()
    
    No change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d680e9aab169cf83b7966df814f33d6a5532c2ab
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 13 16:47:51 2020 +0200

    smbd: remove unused cwdfsp from non_widelink_open()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 99f60a74e05d3336dbacadfd7ab3fa64f0a166da
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 13 16:38:18 2020 +0200

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit abc00b959be9ba5e6ca7535405866d771e76bfb3
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Oct 13 14:38:28 2020 +0200

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a272ca549fc7d2e935c3d3a103f3bd3f65b1960e
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Sep 29 10:00:21 2020 +0200

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit abb7ab2c10eef05b54669c7bc947804d34470ee0
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 12 13:21:07 2020 +0200

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit eb6bbb4f0163ce7805b3691236abfb87757ed997
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 26 14:39:02 2020 +0100

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f89808213015b36b22fbcba8cb26e14f33f8c9cb
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 16 12:28:39 2020 +0200

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a14db893c19734f02d89f3b78f0ea75b79abbd72
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Apr 14 17:44:37 2020 +0200

    s3: add full_path_from_dirfsp_atname()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7d1e6e83d8a5565f84d3ab72df21d9beb83c081d
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 1 15:44:15 2020 +0200

    vfs_glusterfs: implement pathref opens with become_root() fallback
    
    Until glusterfs supports O_PATH, fallback to become_root().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fd8825742f7cc4acb705fdaec41ddb91967e37c5
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 1 15:44:15 2020 +0200

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cf3c48cb08811e45b6d88a4c27b873485321beb0
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 9 14:24:43 2020 +0200

    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 879d8a3be9f660384f49657b8214168c4b62aee5
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 1 15:22:18 2020 +0200

    smbd/posix_acls: support pathref fd's in posix_sys_acl_blob_get_fd()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c9889c194aa61c20ff91baa14ef4f2d37d292e86
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 1 15:21:45 2020 +0200

    vfs_posixacl: support pathref fd's in posixacl_sys_acl_set_fd()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b2e6d7b00bc01523631ebbcebaa7f8dbbd626bd0
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Oct 1 15:20:56 2020 +0200

    vfs_posixacl: support pathref fd's in posixacl_sys_acl_get_fd()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 011252c6111871e7376450caf7cf7d6f2ff80cde
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Aug 1 16:19:20 2020 +0200

    vfs_fruit: skip Netatalk locking checks for path-ref fd's
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9b3c80f8c1cfef77b9e376682065796690cd8e3d
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Sep 29 11:11:53 2020 +0200

    vfs_default: support pathref fd's in vfswrap_fsetxattr()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a46f987ce57ee2e50c80431a53fc3573bc7c22aa
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Sep 29 11:10:51 2020 +0200

    vfs_default: support pathref fd's in vfswrap_fremovexattr()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0f353bca64a7e64c951ca2c5ba04bdda4333a0d6
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Sep 29 10:56:19 2020 +0200

    vfs_default: support pathref fd's in vfswrap_flistxattr()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3105e53f62481624650dd4f5d37920b1a778591a
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Sep 29 10:55:52 2020 +0200

    vfs_default: support pathref fd's in vfswrap_fgetxattr()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6d16e580905296a8ae9f2dcd499ed63a587485df
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 25 07:05:20 2020 +0100

    vfs_default: initialize conn->have_proc_fds
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 11e2a8562f8e15c2c24e54cf108bb7beb98852fd
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 25 07:04:31 2020 +0100

    vfs_default: fix indentation
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2af46c7fda60780e85a37ff0872a3a8c5b1631ff
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Nov 24 12:20:23 2020 +0100

    vfs: add fsp flag "have_proc_fds"
    
    This flag is used by the VFS layer to tell the FSA layer that it is allowed to
    reopen an fsp by using an exisiting pathref fd with /proc/PID/fd/FD to open a
    full fd.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1f94c3ee7be39433a5518cefa95ecc1392341675
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Nov 25 05:32:19 2020 +0100

    vfs: add struct connection_struct flag "have_proc_fds"
    
    Allows the VFS layer to tell the higher layers if fds opened by the openat() VFS
    implementation are visible objects inside a /proc/PID/fd/FD filesystem.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 1d35fc7f5456c91325745d2914d539cd70763ae4
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Jun 15 11:33:39 2020 +0200

    vfs_error_inject: ignore path_ref_fd's
    
    This avoids failing opens triggered by filename_convert() ->
    openat_pathref_fsp().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c39940d81b000a721d70ab9c19787f5bf5716b55
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Sep 30 14:45:34 2020 +0200

    s3/lib: add proc fds infrastructure
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b56f554ff00437993ae7fa37dcaebf9a080bf3e9
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Sep 27 19:39:37 2020 +0200

    vfs: make struct fd_handle private
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dd8fe0cfc2627dcdcec140a85eb96b9da5a6dba4
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 2 17:40:51 2020 +0200

    smbd: remove redundant initialisation of the fsp fd
    
    This is already set to -1 by fd_handle_create().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 140df3218a547f70354064f7def68d9d2d12b63d
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Sep 27 21:16:03 2020 +0200

    smbd: use fd_handle_create()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit fdb91631185978664eaac0b79e3c6ab9ddff9079
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Sep 28 10:37:36 2020 +0200

    smbd: use fh_[get|set]_refcount()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit da786ccd1d2bf834b75f9a9c067f6ae4911dd5a2
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Oct 23 17:47:46 2020 +0200

    smbd: use fh_[get|set]_private_options()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 059dee953d6cc443eb2cd81d9d92cdeedc9390ea
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Sep 28 10:35:32 2020 +0200

    smbd: use fh_[get|set]_gen_id()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0d9afd7ab887d57c110a22c6a15241bf03ac0a59
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Sep 28 10:32:29 2020 +0200

    smbd: use fh_[get|set]_pos() and fh_[get|set]_position_information()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 61628adef65eefe21efc358f886af28f68e8c0ce
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 5 07:51:50 2020 +0200

    smbd: use fsp_get_pathref_fd() for logical fd comparisons
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 450d7f134c7c1e6d88f00a58e83d962be0b0bb09
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Oct 5 07:50:16 2020 +0200

    smbd: use fsp_get_pathref_fd() for fstat() calls
    
    If we can access the path to a file, by default we have FILE_READ_ATTRIBUTES
    from the containing directory. See the section: "Algorithm to Check Access to an
    Existing File" in MS-FSA.pdf.
    
    So it's also safe to use a root opened pathref fd, as the root open is done on
    the final component after a chdir() to the parent directory was done while still
    impersonating the use. Qed.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5648662b2f2b91133d3ec8ece69a32955348fa23
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 4 14:48:48 2020 +0200

    smbd: use fsp_get_pathref_fd() for "internal" xattr functions
    
    We're using xattr data storage for internal reasons in these places, so in all
    places it's safe to use a possibly root opened fd.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit bc908ea3f2eb2284b625bc257264235cad0a7951
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 17 17:01:47 2020 +0200

    smbd: use fsp_get_pathref_fd() for *at related directory handles
    
    Obviously correct to use fsp_get_pathref_fd() here.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0208ca6946db7f800977d20cdda0ae7df03ae635
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 3 21:24:29 2020 +0200

    smbd: use fsp_get_pathref_fd() when close()ing fds
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f5632b43337c04e4c51c952326324fb475646ec3
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Oct 3 17:41:17 2020 +0200

    smbd: use fsp_get_pathref_fd() as part of DEBUG and syslog messages
    
    Nothing really dangerous is done with the fds here, so we can safely use
    fsp_get_pathref_fd() in these cases.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9db3ff257322a8dd0602cdbf6d3ac4f4f8cfa0e0
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Sep 26 21:52:52 2020 +0200

    smbd: use fsp_get_io_fd() when accessing a file or it's associated metadata
    
    In all places where we access or modify a file or it's associated metadata, we
    use fsp_get_io_fd() to fetch the low-level fd from the fsp. This ensures we
    don't accidentally use a pathref fsp where the fd would be opened as root on
    systems lacking O_PATH.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 50ce980902c9bd76bb4e800fb7d142013605e737
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Sep 26 21:46:51 2020 +0200

    smbd: use fsp_set_fd()
    
    No change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 28f43fdadc89bdc2e3041fe077df2389acd0ceaa
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Sep 27 13:14:30 2020 +0200

    smbd: add fd_handle.[c|h]
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c6c65d1fc180e4070f6d3ec031b8dac66f3ab276
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Nov 22 13:54:51 2020 +0100

    vfs: add "is_fsa" flag to struct files_struct
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit bf7ab87877a4572ad2da442c59d1ec9be26ab96f
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Jul 14 10:10:19 2020 +0200

    vfs: add "is_pathref" to struct files_struct
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 703c18980348add3414f7bb27f3b9c770f5bed6e
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Dec 15 07:20:55 2020 +0100

    CI: skip kernel-oplocks tests on older kernels
    
    The kernel of the gitlab shared runners container host has a bug in the
    interaction between kernel oplocks and O_PATH opens which was fixed by
    387e3746d01c34457d6a73688acd90428725070b in 5.3.1:
    
    <https://kernel.googlesource.com/pub/scm/linux/kernel/git/jlayton/linux/+/refs/tags/locks-v5.3-1%5E%21/>
    
    Don't actually start the OPLOCK5 test is kernel oplocks are not available,
    instead of relying on the #ifdef HAVE_KERNEL_OPLOCKS_LINUX magic in torture.c.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 436903afe2aaf6e3afe794c9ebe22081a55b9bb3
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Jun 22 13:32:45 2020 +0200

    CI: add samba-no-opath
    
    Add a job that builds with O_PATH undefined.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 .gitlab-ci.yml                                     |   3 +
 docs-xml/manpages/vfs_full_audit.8.xml             |   2 +-
 examples/VFS/skel_opaque.c                         |  17 +-
 examples/VFS/skel_transparent.c                    |  23 +-
 lib/replace/system/filesys.h                       |   4 +
 script/autobuild.py                                |  21 +
 selftest/skip.opath-required                       |   9 +
 selftest/wscript                                   |   3 +
 source3/include/proto.h                            |   7 +
 source3/include/smb_macros.h                       |  12 +-
 source3/include/vfs.h                              | 227 +++++-
 source3/include/vfs_macros.h                       |  20 +-
 source3/lib/adouble.c                              |  40 +-
 source3/lib/system.c                               |  56 ++
 source3/locking/posix.c                            |  18 +-
 source3/locking/share_mode_lock.c                  |  15 +-
 source3/modules/vfs_acl_common.c                   |   4 +-
 source3/modules/vfs_acl_tdb.c                      |   7 +-
 source3/modules/vfs_acl_xattr.c                    |   4 +-
 source3/modules/vfs_afsacl.c                       |   2 +-
 source3/modules/vfs_aio_fork.c                     |  18 +-
 source3/modules/vfs_aio_pthread.c                  |  10 +-
 source3/modules/vfs_aixacl.c                       |   8 +-
 source3/modules/vfs_aixacl2.c                      |   2 +-
 source3/modules/vfs_audit.c                        |   2 +-
 source3/modules/vfs_btrfs.c                        |  91 ++-
 source3/modules/vfs_cacheprime.c                   |   2 +-
 source3/modules/vfs_cap.c                          |   7 +-
 source3/modules/vfs_catia.c                        |  86 +--
 source3/modules/vfs_ceph.c                         |  61 +-
 source3/modules/vfs_commit.c                       |  12 +-
 source3/modules/vfs_default.c                      | 309 +++++---
 source3/modules/vfs_dirsort.c                      |  17 +-
 source3/modules/vfs_error_inject.c                 |   3 +-
 source3/modules/vfs_extd_audit.c                   |   4 +-
 source3/modules/vfs_fruit.c                        |  34 +-
 source3/modules/vfs_full_audit.c                   |  45 +-
 source3/modules/vfs_glusterfs.c                    |  24 +-
 source3/modules/vfs_gpfs.c                         | 123 +--
 source3/modules/vfs_io_uring.c                     |   6 +-
 source3/modules/vfs_media_harmony.c                |   9 +-
 source3/modules/vfs_nfs4acl_xattr.c                |   6 +-
 source3/modules/vfs_not_implemented.c              |  17 +-
 source3/modules/vfs_offline.c                      |   9 -
 source3/modules/vfs_posix_eadb.c                   |   8 +-
 source3/modules/vfs_posixacl.c                     |  45 +-
 source3/modules/vfs_prealloc.c                     |   2 +-
 source3/modules/vfs_readahead.c                    |  16 +-
 source3/modules/vfs_shadow_copy.c                  |  11 +-
 source3/modules/vfs_shadow_copy2.c                 |  37 +-
 source3/modules/vfs_solarisacl.c                   |   6 +-
 source3/modules/vfs_streams_depot.c                |   4 +-
 source3/modules/vfs_streams_xattr.c                |  12 +-
 source3/modules/vfs_syncops.c                      |   2 +-
 source3/modules/vfs_time_audit.c                   |  48 +-
 source3/modules/vfs_tru64acl.c                     |   4 +-
 source3/modules/vfs_tsmsm.c                        |  19 +-
 source3/modules/vfs_unityed_media.c                |   5 +-
 source3/modules/vfs_virusfilter.c                  |   2 +-
 source3/modules/vfs_vxfs.c                         |  14 +-
 source3/modules/vfs_widelinks.c                    |  10 +-
 source3/modules/vfs_xattr_tdb.c                    |  23 +-
 source3/printing/nt_printing.c                     |  25 +-
 source3/printing/printspoolss.c                    |  13 +-
 source3/selftest/tests.py                          |  25 +-
 source3/smbd/aio.c                                 |  12 +-
 source3/smbd/close.c                               |   6 +-
 source3/smbd/conn.c                                |   4 +-
 source3/smbd/dir.c                                 | 156 +++-
 source3/smbd/dosmode.c                             | 110 ++-
 source3/smbd/durable.c                             |  16 +-
 source3/smbd/fake_file.c                           |   4 +-
 source3/smbd/fd_handle.c                           | 124 +++
 source3/smbd/fd_handle.h                           |  48 ++
 .../util_macstreams.h => smbd/fd_handle_private.h} |  28 +-
 source3/smbd/fileio.c                              |  17 +-
 source3/smbd/filename.c                            | 117 ++-
 source3/smbd/files.c                               | 441 ++++++++++-
 source3/smbd/nttrans.c                             |   6 +-
 source3/smbd/open.c                                | 849 ++++++++++++++-------
 source3/smbd/oplock.c                              |   6 +-
 source3/smbd/oplock_linux.c                        |  10 +-
 source3/smbd/pipes.c                               |   2 +-
 source3/smbd/posix_acls.c                          |  53 +-
 source3/smbd/proto.h                               |  45 +-
 source3/smbd/pysmbd.c                              |  18 +-
 source3/smbd/reply.c                               | 187 +++--
 source3/smbd/smb1_utils.c                          |  15 +-
 source3/smbd/smb2_close.c                          |  12 +-
 source3/smbd/smb2_create.c                         |   3 +-
 source3/smbd/smb2_flush.c                          |   2 +-
 source3/smbd/smb2_getinfo.c                        |   2 +-
 source3/smbd/smb2_ioctl_filesys.c                  |   3 +-
 source3/smbd/smb2_query_directory.c                |   2 +-
 source3/smbd/smb2_setinfo.c                        |  38 +-
 source3/smbd/smbd.h                                |   1 +
 source3/smbd/trans2.c                              | 345 +++++----
 source3/smbd/vfs.c                                 |  60 +-
 source3/torture/cmd_vfs.c                          |  71 +-
 source3/torture/proto.h                            |   5 +
 source3/torture/test_posix.c                       | 722 ++++++++++++++++++
 source3/torture/torture.c                          |  55 +-
 source3/utils/net_vfs.c                            |  10 +
 source3/wscript_build                              |   6 +
 104 files changed, 3800 insertions(+), 1541 deletions(-)
 create mode 100644 selftest/skip.opath-required
 create mode 100644 source3/smbd/fd_handle.c
 create mode 100644 source3/smbd/fd_handle.h
 copy source3/{lib/util_macstreams.h => smbd/fd_handle_private.h} (57%)
 create mode 100644 source3/torture/test_posix.c


Changeset truncated at 500 lines:

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7a7582cb6db..eafd454d445 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -226,6 +226,9 @@ samba-schemaupgrade:
 samba-ad-dc-1-mitkrb5:
   extends: .private_template
 
+samba-no-opath:
+  extends: .private_template
+
 # 'pages' is a special job which can publish artifacts in `public` dir to gitlab pages
 pages:
   image: ${SAMBA_CI_CONTAINER_REGISTRY}/samba-ci-${SAMBA_CI_CONTAINER_IMAGE}:${SAMBA_CI_CONTAINER_TAG}
diff --git a/docs-xml/manpages/vfs_full_audit.8.xml b/docs-xml/manpages/vfs_full_audit.8.xml
index 674b032017d..d4fbdb4f02e 100644
--- a/docs-xml/manpages/vfs_full_audit.8.xml
+++ b/docs-xml/manpages/vfs_full_audit.8.xml
@@ -60,6 +60,7 @@
         <member>fchmod</member>
         <member>fchown</member>
         <member>fdopendir</member>
+        <member>fget_compression</member>
         <member>fget_dos_attributes</member>
         <member>fget_nt_acl_at</member>
         <member>fgetxattr</member>
@@ -78,7 +79,6 @@
         <member>fsync_send</member>
         <member>ftruncate</member>
         <member>get_alloc_size</member>
-        <member>get_compression</member>
         <member>get_dfs_referrals</member>
         <member>get_dos_attributes</member>
         <member>get_dos_attributes_recv</member>
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 2a3a7301bdb..881a7fdaf1c 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -156,7 +156,9 @@ static DIR *skel_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 static struct dirent *skel_readdir(vfs_handle_struct *handle,
-				   DIR *dirp, SMB_STRUCT_STAT *sbuf)
+				   struct files_struct *dirfsp,
+				   DIR *dirp,
+				   SMB_STRUCT_STAT *sbuf)
 {
 	return NULL;
 }
@@ -618,10 +620,9 @@ static NTSTATUS skel_offload_write_recv(struct vfs_handle_struct *handle,
 	return NT_STATUS_OK;
 }
 
-static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
+static NTSTATUS skel_fget_compression(struct vfs_handle_struct *handle,
 				     TALLOC_CTX *mem_ctx,
 				     struct files_struct *fsp,
-				     struct smb_filename *smb_fname,
 				     uint16_t *_compression_fmt)
 {
 	return NT_STATUS_INVALID_DEVICE_REQUEST;
@@ -713,13 +714,6 @@ static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
 	return NT_STATUS_NOT_IMPLEMENTED;
 }
 
-static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
-				struct smb_filename *smb_fname,
-				uint32_t *dosmode)
-{
-	return NT_STATUS_NOT_IMPLEMENTED;
-}
-
 struct skel_get_dos_attributes_state {
 	struct vfs_aio_state aio_state;
 	uint32_t dosmode;
@@ -1111,7 +1105,7 @@ static struct vfs_fn_pointers skel_opaque_fns = {
 	.offload_read_recv_fn = skel_offload_read_recv,
 	.offload_write_send_fn = skel_offload_write_send,
 	.offload_write_recv_fn = skel_offload_write_recv,
-	.get_compression_fn = skel_get_compression,
+	.fget_compression_fn = skel_fget_compression,
 	.set_compression_fn = skel_set_compression,
 
 	.streaminfo_fn = skel_streaminfo,
@@ -1126,7 +1120,6 @@ static struct vfs_fn_pointers skel_opaque_fns = {
 	.audit_file_fn = skel_audit_file,
 
 	/* DOS attributes. */
-	.get_dos_attributes_fn = skel_get_dos_attributes,
 	.get_dos_attributes_send_fn = skel_get_dos_attributes_send,
 	.get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
 	.fget_dos_attributes_fn = skel_fget_dos_attributes,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index a86b3e7cd19..2680b4f3285 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -164,9 +164,11 @@ static DIR *skel_fdopendir(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 static struct dirent *skel_readdir(vfs_handle_struct *handle,
-				   DIR *dirp, SMB_STRUCT_STAT *sbuf)
+				   struct files_struct *dirfsp,
+				   DIR *dirp,
+				   SMB_STRUCT_STAT *sbuf)
 {
-	return SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
+	return SMB_VFS_NEXT_READDIR(handle, dirfsp, dirp, sbuf);
 }
 
 static void skel_seekdir(vfs_handle_struct *handle, DIR *dirp, long offset)
@@ -827,13 +829,12 @@ static NTSTATUS skel_offload_write_recv(struct vfs_handle_struct *handle,
 	return NT_STATUS_OK;
 }
 
-static NTSTATUS skel_get_compression(struct vfs_handle_struct *handle,
+static NTSTATUS skel_fget_compression(struct vfs_handle_struct *handle,
 				     TALLOC_CTX *mem_ctx,
 				     struct files_struct *fsp,
-				     struct smb_filename *smb_fname,
 				     uint16_t *_compression_fmt)
 {
-	return SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
+	return SMB_VFS_NEXT_FGET_COMPRESSION(handle, mem_ctx, fsp,
 					    _compression_fmt);
 }
 
@@ -933,15 +934,6 @@ static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
 }
 
-static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
-				struct smb_filename *smb_fname,
-				uint32_t *dosmode)
-{
-	return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
-				smb_fname,
-				dosmode);
-}
-
 struct skel_get_dos_attributes_state {
 	struct vfs_aio_state aio_state;
 	uint32_t dosmode;
@@ -1418,7 +1410,7 @@ static struct vfs_fn_pointers skel_transparent_fns = {
 	.offload_read_recv_fn = skel_offload_read_recv,
 	.offload_write_send_fn = skel_offload_write_send,
 	.offload_write_recv_fn = skel_offload_write_recv,
-	.get_compression_fn = skel_get_compression,
+	.fget_compression_fn = skel_fget_compression,
 	.set_compression_fn = skel_set_compression,
 
 	.streaminfo_fn = skel_streaminfo,
@@ -1433,7 +1425,6 @@ static struct vfs_fn_pointers skel_transparent_fns = {
 	.audit_file_fn = skel_audit_file,
 
 	/* DOS attributes. */
-	.get_dos_attributes_fn = skel_get_dos_attributes,
 	.get_dos_attributes_send_fn = skel_get_dos_attributes_send,
 	.get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
 	.fget_dos_attributes_fn = skel_fget_dos_attributes,
diff --git a/lib/replace/system/filesys.h b/lib/replace/system/filesys.h
index 976b2aeec5e..034e5d5886c 100644
--- a/lib/replace/system/filesys.h
+++ b/lib/replace/system/filesys.h
@@ -199,6 +199,10 @@
 #define mkdir(d,m) _mkdir(d)
 #endif
 
+#ifdef DISABLE_OPATH
+#undef O_PATH
+#endif
+
 /*
    this allows us to use a uniform error handling for our xattr
    wrappers
diff --git a/script/autobuild.py b/script/autobuild.py
index a76309df8a2..00ba8d727b0 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -375,6 +375,27 @@ tasks = {
         ("check-clean-tree", "script/clean-source-tree.sh"),
         ],
 
+    "samba-no-opath": [
+        ("random-sleep", random_sleep(300, 900)),
+        ("configure", "ADDITIONAL_CFLAGS='-DDISABLE_OPATH=1' ./configure.developer --without-ad-dc --with-selftest-prefix=./bin/ab" + samba_configure_params),
+        ("make", "make -j"),
+        ("test", make_test(
+            cmd="make test DISABLE_OPATH=1",
+            include_envs=[
+            "nt4_dc",
+            "nt4_dc_smb1",
+            "nt4_dc_smb1_done",
+            "nt4_dc_schannel",
+            "nt4_member",
+            "simpleserver",
+            "fileserver",
+            "fileserver_smb1",
+            "fileserver_smb1_done",
+            ])),
+        ("lcov", LCOV_CMD),
+        ("check-clean-tree", "script/clean-source-tree.sh"),
+        ],
+
     "samba-ad-dc-1": [
         ("random-sleep", random_sleep(1, 1)),
         ("configure", "./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params),
diff --git a/selftest/skip.opath-required b/selftest/skip.opath-required
new file mode 100644
index 00000000000..0faf0c4bd6c
--- /dev/null
+++ b/selftest/skip.opath-required
@@ -0,0 +1,9 @@
+# Opening O_RDONLY screws kernel oplocks which is not a problem
+# as only Linux has kernel oplocks and as Linux has O_PATH, we
+# don't need O_RDONLY in the first place.
+^samba3.smb2.kernel-oplocks.*
+^samba3.smbtorture_s3.plain.OPLOCK5.*
+#
+# These fail because become_root() doesn't work in make test
+^samba3.blackbox.dropbox.*
+^samba3.raw.samba3hide.*
diff --git a/selftest/wscript b/selftest/wscript
index b057702b756..60297045078 100644
--- a/selftest/wscript
+++ b/selftest/wscript
@@ -271,6 +271,9 @@ def cmd_testonly(opt):
         # GSS_KRB5_CRED_NO_CI_FLAGS_X
         env.OPTIONS += " --exclude=${srcdir}/selftest/skip.no-GSS_KRB5_CRED_NO_CI_FLAGS_X"
 
+    if os.environ.get('DISABLE_OPATH'):
+        env.OPTIONS += " --exclude=${srcdir}/selftest/skip.opath-required"
+
     if env.ADDRESS_SANITIZER:
         # We try to find the correct libasan automatically
         libasan = Utils.cmd_output(
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9f74287f967..6e14ac42777 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -237,6 +237,9 @@ char *sys_realpath(const char *path);
 int sys_get_number_of_cores(void);
 #endif
 
+bool sys_have_proc_fds(void);
+const char *sys_proc_fd_path(int fd, char *buf, int bufsize);
+
 struct stat;
 void init_stat_ex_from_stat (struct stat_ex *dst,
 			    const struct stat *src,
@@ -785,6 +788,10 @@ struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx,
 					 const SMB_STRUCT_STAT *psbuf,
 					 NTTIME twrp,
 					 uint32_t flags);
+struct smb_filename *full_path_from_dirfsp_atname(
+	TALLOC_CTX *mem_ctx,
+	const struct files_struct *dirfsp,
+	const struct smb_filename *atname);
 struct smb_filename *synthetic_smb_fname_split(TALLOC_CTX *ctx,
 						const char *fname,
 						bool posix_path);
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 1513696f766..d9583945c55 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -45,7 +45,8 @@
 #define IS_PRINT(conn)       ((conn) && (conn)->printer)
 
 #define CHECK_READ(fsp,req) \
-	(((fsp)->fh->fd != -1) && \
+	((!(fsp)->fsp_flags.is_pathref) &&  \
+	 (fsp_get_io_fd(fsp) != -1) && \
 	 (((fsp)->fsp_flags.can_read) || \
 	  ((req->flags2 & FLAGS2_READ_PERMIT_EXECUTE) && \
 	   (fsp->access_mask & FILE_EXECUTE))))
@@ -63,7 +64,8 @@
  * test).
  */
 #define CHECK_READ_SMB2(fsp) \
-	(((fsp)->fh->fd != -1) && \
+	((!(fsp)->fsp_flags.is_pathref) &&  \
+	 (fsp_get_io_fd(fsp) != -1) && \
 	 (((fsp)->fsp_flags.can_read) || \
 	  (fsp->access_mask & FILE_EXECUTE)))
 
@@ -74,12 +76,14 @@
  * the "if execute is granted then also grant read" arrangement.
  */
 #define CHECK_READ_IOCTL(fsp) \
-	(((fsp)->fh->fd != -1) && \
+	((!(fsp)->fsp_flags.is_pathref) &&  \
+	 (fsp_get_io_fd(fsp) != -1) && \
 	 (((fsp)->fsp_flags.can_read)))
 
 #define CHECK_WRITE(fsp) \
 	((fsp)->fsp_flags.can_write && \
-	 ((fsp)->fh->fd != -1))
+	(!(fsp)->fsp_flags.is_pathref) && \
+	 (fsp_get_io_fd(fsp) != -1))
 
 #define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \
 				NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) )
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 91151df6e06..1a5d71e8401 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -333,6 +333,13 @@
  * Version 44 - Make dirfsp arg to SMB_VFS_READLINKAT() const
  * Version 44 - Add a flag 'encryption_required' to files_struct that that
  *              prevents that encrypted connections can be downgraded.
+ * Version 44 - Add a flag 'is_pathref' to struct files_struct.
+ * Version 44 - Add 'is_fsa' flag to struct files_struct.
+ * Version 44 - Add 'have_proc_fds' flag to struct connection_struct.
+ * Version 44 - Add 'have_proc_fds' flag to struct files_struct.
+ * Version 44 - Add dirfsp arg to SMB_VFS_READDIR()
+ * Version 44 - Remove SMB_VFS_GET_DOS_ATTRIBUTES()
+ * Version 44 - Replace SMB_VFS_GET_COMPRESSION() with SMB_VFS_FGET_COMPRESSION()
  */
 
 #define SMB_VFS_INTERFACE_VERSION 44
@@ -361,21 +368,7 @@ typedef union unid_t {
 	gid_t gid;
 } unid_t;
 
-struct fd_handle {
-	size_t ref_count;
-	int fd;
-	uint64_t position_information;
-	off_t pos;
-	uint32_t private_options;	/* NT Create options, but we only look at
-				 * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and
-				 * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB and
-				 * NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE
-				 * for print files *only*, where
-				 * DELETE_ON_CLOSE is not stored in the share
-				 * mode database.
-				 */
-	uint64_t gen_id;
-};
+struct fd_handle;
 
 struct fsp_lease {
 	size_t ref_count;
@@ -398,6 +391,9 @@ typedef struct files_struct {
 	struct timeval open_time;
 	uint32_t access_mask;		/* NTCreateX access bits (FILE_READ_DATA etc.) */
 	struct {
+		bool is_pathref : 1; /* See below */
+		bool is_fsa : 1;     /* See below */
+		bool have_proc_fds : 1;
 		bool kernel_share_modes_taken : 1;
 		bool update_write_time_triggered : 1;
 		bool update_write_time_on_close : 1;
@@ -490,6 +486,159 @@ typedef struct files_struct {
 	uint64_t lock_failure_offset;
 } files_struct;
 
+/*
+ * The fsp flags "is_pathref" and "is_fsa"
+ * =======================================
+ *
+ * Summary
+ * -------
+ *
+ * The flag "is_pathref" is a property of the low-level VFS-layer file
+ * handle. If "is_pathref" is true, only a subset of VFS calls are allowed
+ * on the handle and on systems that support it, the low-level fd is open
+ * with O_PATH. If "is_pathref" is false, the low-level fd is a "normal"
+ * file descriptor that can be used with all VFS calls.
+ *
+ * The flag "is_fsa" is a property of the FSA layer in Samba. The term FSA
+ * layer refers to the parts of smbs that implement Windows NTFS semantics
+ * on-top of a POSIX filesystem. If "is_fsa" is true, the fsp was
+ * processed by the SMB_VFS_CREATE_FILE() VFS call, otherwise the fsp was
+ * created by openat_pathref_fsp() which only connected the low-level
+ * handle by calling into VFS SMB_VFS_OPENAT(), but the whole FSA layer
+ * logic is skipped.
+ *
+ * Note that only three possible combinations of "is_pathref" and "is_fsa"
+ * are possible:
+ *
+ * | is_fsa \ is_pathref | + | - |
+ * |---------------------+---+---|
+ * | +                   | + | + |
+ * | -                   | + | - |
+ *
+ * So a fsp can't be a full low-level fd (is_pathref=false) and not be
+ * processed by the FSA layer.
+ *
+ * Details
+ * -------
+ *
+ * On Linux the O_PATH flag to open() can be used to open a filehandle on
+ * a file or directory with interesting properties:
+ *
+ * - the file-handle indicates a location in the filesystem tree,
+ * - no permission checks are done by the kernel and
+ * - only operations that act purely at the file descriptor level are
+ *   allowed.
+ *
+ * The file itself is not opened, and other file operations (e.g.,
+ * read(2), write(2), fchmod(2), fchown(2), fgetxattr(2), ioctl(2),
+ * mmap(2)) fail with the error EBADF.
+ *
+ * The following subset of operations that is relevant to Samba is allowed:
+ *
+ * - close(2),
+ * - fchdir(2), if the file descriptor refers to a directory,
+ * - fstat(2),
+ * - fstatfs(2) and
+ * - passing the file descriptor as the dirfd argument of openat() and the
+ *   other "*at()" system calls. This includes linkat(2) with
+ *   AT_EMPTY_PATH (or via procfs using AT_SYMLINK_FOLLOW) even if the
+ *   file is not a directory.
+ *
+ * Opening a file or directory with the O_PATH flag requires no
+ * permissions on the object itself (but does require execute permission
+ * on the directories in the path prefix). By contrast, obtaining a
+ * reference to a filesystem object by opening it with the O_RDONLY flag
+ * requires that the caller have read permission on the object, even when
+ * the subsequent operation (e.g., fchdir(2), fstat(2)) does not require
+ * read permis‐ sion on the object. [1]
+ *
+ * If for example Samba receives an SMB request to open a file requesting
+ * SEC_FILE_READ_ATTRIBUTE access rights because the client wants to read
+ * the file's metadata from the handle, Samba will have to call POSIX
+ * open() with at least O_RDONLY access rights.
+ *
+ * Usecase for O_PATH in Samba
+ * ---------------------------
+ *
+ * By leveraging this Linux specific flags we can avoid permission
+ * mismatches as described above. Additionally O_PATH allows basing all
+ * filesystem accesses done by the fileserver on handle based syscalls by
+ * opening all client pathnames with O_PATH and consistently using for
+ * example fstat() instead of stat() throughout the codebase.
+ *
+ * Subsequently we will refer to Samba file-handles (fsp's) opened with
+ * O_PATH "path referencing fsp's" or "pathref" fsp's for short.
+ *
+ * Currently Samba bases the decision whether to call POSIX open() on a
+ * client pathname or whether to leave the low-level handle at -1, what we
+ * call a stat-open, in the function open_file() and it is based on the
+ * client requested SMB acccess mask.
+ *
+ * The set of rights that trigger an open() include READ_CONTROL_ACCESS,
+ * resulting in a call to open() with at least O_RDONLY. If the filesystem
+ * supports NT style ACLs natively (like GPFS or ZFS), the filesystem may
+ * grant the user requested right READ_CONTROL_ACCESS, but it may not
+ * grant READ_DATA (O_RDONLY), resulting in a permission denied error.
+ *
+ * Historically the set of access rights that triggered opening a file was:
+ *
+ *   FILE_READ_DATA
+ *   FILE_WRITE_DATA
+ *   FILE_APPEND_DATA
+ *   FILE_EXECUTE
+ *   WRITE_DAC_ACCESS
+ *   WRITE_OWNER_ACCESS
+ *   SEC_FLAG_SYSTEM_SECURITY
+ *   READ_CONTROL_ACCESS
+ *
+ * By using O_PATH this can be trimmed down to
+ *
+ *   FILE_READ_DATA
+ *   FILE_WRITE_DATA
+ *   FILE_APPEND_DATA
+ *   FILE_EXECUTE
+ *
+ * Fallback on systems without O_PATH support
+ * ------------------------------------------
+ *
+ * A fallback is needed that allows opening a file-handle with the same
+ * higher level semantics even if the system doesn't support O_PATH. This
+ * is implemented by qimpersonating the root user for the open()
+ * syscall. To avoid bypassing restrictive permissions on intermediate
+ * directories components of a path, the root user is only impersonated
+ * after changing directory to the parent directory of the client
+ * requested pathname.
+ *
+ * In order to avoid privilege escalation security issues with these root
+ * opened file-handles we must carefully control their usage throughout
+ * the codebase. Therefor we
+ *
+ * - tag the pathref fsp's with the flag "is_pathref" and
+ *
+ * - control access to the file-handle by making the structure private and only
+ *   allowing access with accessor functions.
+ *
+ * Two functions are used to fetch the low-level system file-handle from an fsp
+ *
+ * - fsp_get_io_fd(fsp): enforces fsp is NOT a pathref file-handle and
+ *
+ * - fsp_get_pathref_fd(fsp): allows fsp to be either a pathref file-handle or a
+ *   traditional POSIX file-handle opened with O_RDONLY or any other POSIX open
+ *   flag.
+ *
+ * The general guideline when to use which function is:
+ *
+ * - if you do something like fstat(fd), use fsp_get_pathref_fd(fsp),
+ * - if you do something like *at(dirfd, ...), use fsp_get_pathref_fd(fsp),


-- 
Samba Shared Repository



More information about the samba-cvs mailing list