The branch, master has been updated
       via  721fbbf smbd: remove unused smbd_server_connection->ev_ctx
       via  894e500 smbd: add an effective {smb,smbd_smb2}_request->ev_ctx that 
holds the event context used for the request processing
       via  f2df8be smbd: add an effective connection_struct->user_ev_ctx that 
holds the event context used for the current user
       via  c835ffa smbd: use sconn->root_ev_ctx for 
smbd_sig_{term,hup}_handler()
       via  182991c smbd: use sconn->root_ev_ctx for brl_timeout_fn()
       via  1469382 smbd: add smbd_server_connection->{root,guest}_ev_ctx 
pointer
       via  f5f9b71 smbd: use raw_ev_ctx to clear the MSG_SMB_CONF_UPDATED 
registration
       via  dc517b2 smbd: explain that/why we use the raw tevent_context for 
linux_oplock_signal_handler()
       via  1d5210b smbd: explain that/why we use the raw tevent_context for 
do_break_to_none()
       via  e73eaa3 smbd: explain that/why we use the raw tevent_context for 
oplock_timeout_handler()
       via  52f098d smbd: explain that/why we use the raw tevent_context for 
lease_timeout_handler()
       via  7cfafaf smbd: explain that/why we use the raw tevent_context for 
update_write_time_handler()
       via  b0af571 vfs_glusterfs: explain that/why we use the raw 
tevent_context in init_gluster_aio()
       via  6114f95 smbd: add smbd_server_connection->raw_ev_ctx pointer
       via  c059f0a smbd: use req->xconn->client->raw_ev_ctx for 
schedule_deferred_open_message_smb()
       via  4d5d8d6 s3:smb2_server: use req->xconn->client->raw_ev_ctx for 
smbd_smb2_request_dispatch_immediate()
       via  051c321 s3:smb2_server: use req->xconn->client->raw_ev_ctx for 
smbd_smb2_request_pending_timer()
       via  934b375 smbd: remove unused tevent_context argument from notify_init
       via  d2adceb smbd: replace xconn->msg_ctx with xconn->client->msg_ctx
       via  d39f6ce smbd: replace xconn->ev_ctx with xconn->client->raw_ev_ctx
       via  19119a5 smbd: rename smbXsrv_client->ev_ctx into 
smbXsrv_client->raw_ev_ctx
       via  db83a8f vfs_default: maintain 
vfswrap_offload_write_state->{src_ev,dst_ev}
       via  506c9b3 vfs_default: make use of change_to_user_by_fsp() in order 
to switch between src and dst fsp
       via  2d75da9 vfs_btrfs: make use of become_user_by_fsp() in order to 
switch between src and dst fsp
       via  e4fb4c1 smbd: add {become,change_to}_user_by_fsp() helper functions
       via  4512b91 vfs_btrfs: don't keep state->subreq in 
btrfs_offload_write_send/recv()
       via  2317316 vfs_btrfs: update 
s/btrfs_cc_state/btrfs_offload_write_state/ s/cc_state/state/
       via  5ac91e4 vfs_btrfs: remove unused checks which are already caught by 
vfs_offload_token_check_handles()
       via  4af45b8 vfs_default: remove unused checks which are already caught 
by vfs_offload_token_check_handles()
       via  3194999 smbd: avoid calling set_current_user_info() twice with 
.need_tcon (SMB2)
       via  60dbaa4 smbd: avoid calling set_current_user_info() twice with 
AS_USER (SMB1)
       via  ff7efaf smbd: remove unused set_current_service()
       via  4a97448 smbd: let switch_message() only call 
chdir_current_service() for SMBtdis/SMBexit
       via  d1c8057 smbd: call chdir_current_service() in 
change_to_user_internal() and pop_conn_ctx()
       via  b27d885 smbd: remove set_current_service() from 
smbd_smb2_request_check_tcon()
       via  03f69e8 smbd: remove set_current_service() from defer_rename_done()
       via  58f4bbc smbd: call chdir_current_service() directly in 
smbXsrv_tcon_disconnect()
       via  1b86df9 smbd: remove useless set_current_service(NULL,0,True) from 
reload_services()
       via  a61d0aa smbd: use conn->lastused_count++ directly in 
process_blocking_lock_queue()
       via  f407a86 smbd: let create_conn_struct_as_root() fill in 
conn->origpath
       via  0e2786a smbd: make it possible to call vfs_ChDir(conn, 
conn->cwd_fname);
       via  ffe1918 smbd: call set_current_case_sensitive() before 
change_to_user() in switch_message()
       via  0186ff2 smbd: remember that the tcon completely setup 
connection_struct
       via  5472171 smbd: make it explicit that make_connection_snum() returns 
NT_STATUS_OK on success
       via  8cfe36e smbd: call set_current_user_info() in 
change_to_user_internal() and pop_conn_ctx()
       via  91a3796 smbd: move current_user caching to change_to_user_internal()
       via  35a12e7 smbd: simplify the logic in change_to_user()
       via  e469d6c smbd: let check_user_ok() construct ent->session_info in 
one coherent block
       via  0e7456d smbd: call set_current_case_sensitive() before 
chdir_current_service()
       via  8e81090 smbd: split out set_current_case_sensitive() and 
chdir_current_service() functions
       via  71d5809 smbd: remove xconn->client->last_session_id based 
set_current_user_info() caching
       via  df5e459 s3:lib: add caching to set_current_user_info()
      from  5d4f229 s4-dsdb: fix the build of audit_util.c

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


- Log -----------------------------------------------------------------
commit 721fbbfa7001b2788602106101f0407483894322
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: remove unused smbd_server_connection->ev_ctx
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>
    
    Autobuild-User(master): Stefan Metzmacher <[email protected]>
    Autobuild-Date(master): Mon Jun 18 11:46:36 CEST 2018 on sn-devel-144

commit 894e5001c747ce765dad5517778dda55d7d1f4d9
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: add an effective {smb,smbd_smb2}_request->ev_ctx that holds the event 
context used for the request processing
    
    In future this will an impersonation wrapper tevent_context based on the
    user session.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit f2df8be16be9dccd3d10ec060f1efbe5007a28c6
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: add an effective connection_struct->user_ev_ctx that holds the event 
context used for the current user
    
    This will be filled with an impersonation wrapper in the next commits.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit c835ffa72ddfd2431d22909148913b50f0d829d1
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: use sconn->root_ev_ctx for smbd_sig_{term,hup}_handler()
    
    They already call change_to_root_user(), which can be removed
    later.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 182991c26c8149c79b13a277b9822efc49fd1df0
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: use sconn->root_ev_ctx for brl_timeout_fn()
    
    This already calls change_to_root_user(), which can be removed
    later.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 146938217ed1ab9a7a9f38c055fec5513cbd5c4d
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: add smbd_server_connection->{root,guest}_ev_ctx pointer
    
    For now these are just the same as smbd_server_connection->ev_ctx,
    but this will change in future and we'll use impersonation wrappers.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit f5f9b719741465c7be3de20a6a69ec106ecc4568
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: use raw_ev_ctx to clear the MSG_SMB_CONF_UPDATED registration
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit dc517b20f60a156d73fdd551557eb1d4366dfdeb
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: explain that/why we use the raw tevent_context for 
linux_oplock_signal_handler()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 1d5210b615035e46b90758ac7aa4ceec9174bee5
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: explain that/why we use the raw tevent_context for do_break_to_none()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit e73eaa3c8004d3d8aff316cdb26b0bef85eceaca
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: explain that/why we use the raw tevent_context for 
oplock_timeout_handler()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 52f098d38da72d6eff3c4cac61487da897a8651c
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: explain that/why we use the raw tevent_context for 
lease_timeout_handler()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 7cfafaf190643eb28fc95d21a02a4e5e529e16d1
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: explain that/why we use the raw tevent_context for 
update_write_time_handler()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit b0af5715b0a7592a9728e0b76f653b9ab6228708
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    vfs_glusterfs: explain that/why we use the raw tevent_context in 
init_gluster_aio()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 6114f9545fa856717220658e87f2a60f6767b7f4
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: add smbd_server_connection->raw_ev_ctx pointer
    
    This will replace smbd_server_connection->ev_ctx in the next commits.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit c059f0ae729a47883362a1ba01b530b3d743bc45
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: use req->xconn->client->raw_ev_ctx for 
schedule_deferred_open_message_smb()
    
    process_smb() will redo the impersonation anyway.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 4d5d8d62e4454ceb22884a69f511ae60ac3af698
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    s3:smb2_server: use req->xconn->client->raw_ev_ctx for 
smbd_smb2_request_dispatch_immediate()
    
    smbd_smb2_request_dispatch() will redo the impersonation anyway,
    so we don't use req->ev_ctx.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 051c32167ce4a8395daa4ff1eb72eb805da9feab
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    s3:smb2_server: use req->xconn->client->raw_ev_ctx for 
smbd_smb2_request_pending_timer()
    
    There's no need to use req->ev_ctx here just to do some network io.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 934b375639c3c0ea17854e870c3458af619cc1da
Author: Stefan Metzmacher <[email protected]>
Date:   Thu May 24 07:18:10 2018 +0200

    smbd: remove unused tevent_context argument from notify_init
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit d2adcebda12943b7b4af1b8fca35a2c7aa1524e9
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: replace xconn->msg_ctx with xconn->client->msg_ctx
    
    This is the same pointer and we don't have a lot of callers,
    so we can just use one pointer.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit d39f6ce3b1ac9f70040e8140937280f445d2d861
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: replace xconn->ev_ctx with xconn->client->raw_ev_ctx
    
    This is the same pointer and we don't have a lot of callers,
    so we can just use one pointer.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 19119a55490bcfacbc7d4be340f650e9eaf212f2
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    smbd: rename smbXsrv_client->ev_ctx into smbXsrv_client->raw_ev_ctx
    
    That makes it clearer that no tevent_context wrapper is used here
    and the related code should really run without any (active) impersonation
    as before.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit db83a8f7c86946d478a55b611779b9666a47cabc
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Mar 22 10:54:41 2018 +0100

    vfs_default: maintain vfswrap_offload_write_state->{src_ev,dst_ev}
    
    These get filled with impersonation wrappers in the following commits.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 506c9b37df1de784fecc6e01cd30f2b3b693a9fd
Author: Stefan Metzmacher <[email protected]>
Date:   Wed May 23 12:03:02 2018 +0200

    vfs_default: make use of change_to_user_by_fsp() in order to switch between 
src and dst fsp
    
    This may matter if at least one share uses "force user".
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 2d75da9f61f16eac3c137e16f98e16f4022b79b0
Author: Stefan Metzmacher <[email protected]>
Date:   Wed May 23 12:03:02 2018 +0200

    vfs_btrfs: make use of become_user_by_fsp() in order to switch between src 
and dst fsp
    
    We can use become_user_by_fsp()/unbecome_user() as it spans only parts of
    the btrfs_offload_write_send() function and never goes async in between.
    
    This may matter if at least one share uses "force user".
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit e4fb4c1d0efe0f9f1c31eac4e57d60f4bcbc7149
Author: Stefan Metzmacher <[email protected]>
Date:   Wed May 23 11:54:58 2018 +0200

    smbd: add {become,change_to}_user_by_fsp() helper functions
    
    This can be used if a request operates on two fsp's,
    e.g. the offload_write_send/recv code.
    This is important if (at least) one of
    the shares uses "force user".
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 4512b91897fa1bba60005cc4378ffb5879be28f1
Author: Stefan Metzmacher <[email protected]>
Date:   Wed May 23 12:40:21 2018 +0200

    vfs_btrfs: don't keep state->subreq in btrfs_offload_write_send/recv()
    
    This can be a local variable as used in most of our tevent_req based
    code.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 231731623392cdcf117ed5febe178b5d7c1fb9c0
Author: Stefan Metzmacher <[email protected]>
Date:   Wed May 23 12:40:21 2018 +0200

    vfs_btrfs: update s/btrfs_cc_state/btrfs_offload_write_state/ 
s/cc_state/state/
    
    This matches our naming conventions used for tevent_req based functions.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 5ac91e487db935d508eb22cc81702c74029a5ad4
Author: Stefan Metzmacher <[email protected]>
Date:   Wed May 23 11:37:52 2018 +0200

    vfs_btrfs: remove unused checks which are already caught by 
vfs_offload_token_check_handles()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 4af45b8ff6c32bfdfb2eca07fe1b9f158d50fe87
Author: Stefan Metzmacher <[email protected]>
Date:   Wed May 23 11:37:52 2018 +0200

    vfs_default: remove unused checks which are already caught by 
vfs_offload_token_check_handles()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 3194999f0bf13d7d7c1f2b91bd8c1ec885158666
Author: Stefan Metzmacher <[email protected]>
Date:   Fri May 25 16:30:13 2018 +0200

    smbd: avoid calling set_current_user_info() twice with .need_tcon (SMB2)
    
    It's already called via change_to_user().
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 60dbaa490c2b11047f5d7043ed48363164804d6f
Author: Stefan Metzmacher <[email protected]>
Date:   Fri May 25 16:30:13 2018 +0200

    smbd: avoid calling set_current_user_info() twice with AS_USER (SMB1)
    
    It will be called via change_to_user().
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit ff7efafe73369ec27ab07307102807818ea48c39
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 11:22:31 2018 +0200

    smbd: remove unused set_current_service()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 4a97448cc9433a4a8e03f8efbe00a404d72c3616
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 11:18:13 2018 +0200

    smbd: let switch_message() only call chdir_current_service() for 
SMBtdis/SMBexit
    
    These are the two opcodes with DO_CHDIR, we don't want the
    set_current_case_sensitive() logic for them,
    so we don't need the full set_current_service() anymore.
    
    The AS_USER case is already handled before, set_current_case_sensitive()
    is called directly before change_to_user(), which already
    calls chdir_current_service().
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit d1c8057997f97c6cd537496611dfae4e8b4af520
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Jun 13 13:30:33 2018 +0200

    smbd: call chdir_current_service() in change_to_user_internal() and 
pop_conn_ctx()
    
    change_to_user() should be the one and only function for the whole
    impersonation processing. So we also need to stack the
    chdir_current_service() behaviour for become_user/unbecome_user,
    so we may need to call vfs_ChDir(ctx_p->conn, ctx_p->conn->cwd_fname);
    in pop_conn_ctx().
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit b27d885478245d8bd56ab4f5459908b6c574d15d
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 08:29:45 2018 +0200

    smbd: remove set_current_service() from smbd_smb2_request_check_tcon()
    
    The change_to_user() above already called chdir_current_service().
    And for smb2 we don't have per packet conn->case_sensitive anyway.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 03f69e82fc81f61d21def4465afa7f4a1b493c8b
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 08:29:45 2018 +0200

    smbd: remove set_current_service() from defer_rename_done()
    
    The change_to_user() above already called chdir_current_service().
    And for smb2 we don't have per packet conn->case_sensitive anyway.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 58f4bbc103a420a44234a7c12c8a9b11dea4d8d6
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 08:27:50 2018 +0200

    smbd: call chdir_current_service() directly in smbXsrv_tcon_disconnect()
    
    There's no need to worry about conn->case_sensitive here.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 1b86df90d27557fb8eefb182809c2f78cdb9f0fa
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 08:23:56 2018 +0200

    smbd: remove useless set_current_service(NULL,0,True) from reload_services()
    
    All this does is 'return false' as conn is NULL...
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit a61d0aa35b766f4df4d4f9e6891c3a7516e81100
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 08:21:21 2018 +0200

    smbd: use conn->lastused_count++ directly in process_blocking_lock_queue()
    
    This avoids using set_current_service(), which will be removed shortly.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit f407a86b743937d51192bc23917d4c819a9b722a
Author: Stefan Metzmacher <[email protected]>
Date:   Fri Jun 15 18:40:11 2018 +0200

    smbd: let create_conn_struct_as_root() fill in conn->origpath
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 0e2786a91fb9e3be2248d60b3c32d88fef2d0772
Author: Stefan Metzmacher <[email protected]>
Date:   Fri Jun 15 11:49:57 2018 +0200

    smbd: make it possible to call vfs_ChDir(conn, conn->cwd_fname);
    
    We should only TALLOC_FREE(old_cwd) at the successful end.
    This also avoids calling cp_smb_filename() on the old value.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit ffe1918e8153f5bf429e3d9ebed975c6127f1553
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 11:15:10 2018 +0200

    smbd: call set_current_case_sensitive() before change_to_user() in 
switch_message()
    
    change_to_user() will soon call chdir_current_service() and we should
    make sure conn->case_sensitive is prepared before calling vfs_ChDir().
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 0186ff23246cd5332729a80118d87d6a47488259
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 07:27:43 2018 +0200

    smbd: remember that the tcon completely setup connection_struct
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 5472171bdb46f1dcb0a4eae61b1d1b6af6373ee5
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Jun 14 07:26:14 2018 +0200

    smbd: make it explicit that make_connection_snum() returns NT_STATUS_OK on 
success
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 8cfe36eee92255509e61e591761db594de46cdb8
Author: Stefan Metzmacher <[email protected]>
Date:   Fri May 25 14:22:43 2018 +0200

    smbd: call set_current_user_info() in change_to_user_internal() and 
pop_conn_ctx()
    
    change_to_user() should be the one and only function for the whole
    impersonation processing. So we also need to stack the
    set_current_user_info() information for become_user/unbecome_user.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 91a37964814828020ec718bc6b802216f3425a70
Author: Stefan Metzmacher <[email protected]>
Date:   Tue Jun 12 15:39:51 2018 +0200

    smbd: move current_user caching to change_to_user_internal()
    
    Note that (current_user.vuid == vuid) also works with
    UID_FIELD_INVALID.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 35a12e7009d9f1e2eeab06c02ac8227f5b59c778
Author: Stefan Metzmacher <[email protected]>
Date:   Tue Jun 12 15:39:51 2018 +0200

    smbd: simplify the logic in change_to_user()
    
    We can return early if (vuser == NULL).
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit e469d6c73059d53dd10d590db7ab3118e66f731a
Author: Stefan Metzmacher <[email protected]>
Date:   Thu May 3 15:04:30 2018 +0200

    smbd: let check_user_ok() construct ent->session_info in one coherent block
    
    We should finish manipulating ent->session_info before filling
    conn->session_info. And conn->session_info should be not be changed.
    
    Use git show -U15.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 0e7456d28655fda118ad3d432e9baf8398206bbe
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Jun 13 11:23:42 2018 +0200

    smbd: call set_current_case_sensitive() before chdir_current_service()
    
    I guess we better setup conn->case_sensitive before doing the
    vfs_ChDir() calls, so we have a consistent result everytime.
    Otherwise vfs_Chdir() would get conn->case_sensitive from
    last request.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 8e81090789e4cc3ba9e5aa792d4e52971909c894
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Jun 13 11:03:01 2018 +0200

    smbd: split out set_current_case_sensitive() and chdir_current_service() 
functions
    
    We'll soon use them independend from set_current_service().
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit 71d5809188e416aeb3e9c67214eae32b4225c2d7
Author: Stefan Metzmacher <[email protected]>
Date:   Fri May 25 13:58:04 2018 +0200

    smbd: remove xconn->client->last_session_id based set_current_user_info() 
caching
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

commit df5e459299d1eb61879a4bdaf6f600acaab90b6a
Author: Stefan Metzmacher <[email protected]>
Date:   Fri May 25 13:40:12 2018 +0200

    s3:lib: add caching to set_current_user_info()
    
    Currently we do that in the caller, but we use global
    cache anyway, so we can simplify the callers.
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Ralph Boehme <[email protected]>

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

Summary of changes:
 source3/include/smb.h                |   2 +
 source3/include/vfs.h                |   5 ++
 source3/lib/substitute.c             |  15 ++++
 source3/librpc/idl/smbXsrv.idl       |   3 +-
 source3/modules/vfs_aio_pthread.c    |   2 +-
 source3/modules/vfs_btrfs.c          | 138 ++++++++++++++++++++++-------------
 source3/modules/vfs_default.c        |  65 +++++++++++++----
 source3/modules/vfs_glusterfs.c      |  11 ++-
 source3/modules/vfs_readonly.c       |   1 +
 source3/smbd/aio.c                   |   8 +-
 source3/smbd/blocking.c              |  15 ++--
 source3/smbd/conn.c                  |   7 ++
 source3/smbd/fileio.c                |  12 ++-
 source3/smbd/globals.h               |  14 ++--
 source3/smbd/ipc.c                   |   4 +-
 source3/smbd/msdfs.c                 |  16 +++-
 source3/smbd/notify.c                |   2 +-
 source3/smbd/notify_msg.c            |   1 -
 source3/smbd/open.c                  |   8 +-
 source3/smbd/oplock.c                |  44 ++++++++++-
 source3/smbd/oplock_linux.c          |  14 +++-
 source3/smbd/pipes.c                 |   8 +-
 source3/smbd/process.c               |  82 ++++++++++++++-------
 source3/smbd/proto.h                 |   6 +-
 source3/smbd/reply.c                 |   2 +-
 source3/smbd/server_reload.c         |   3 -
 source3/smbd/service.c               |  65 ++++++++++-------
 source3/smbd/smb2_break.c            |   4 +-
 source3/smbd/smb2_close.c            |   2 +-
 source3/smbd/smb2_create.c           |   6 +-
 source3/smbd/smb2_flush.c            |   2 +-
 source3/smbd/smb2_getinfo.c          |   2 +-
 source3/smbd/smb2_glue.c             |   1 +
 source3/smbd/smb2_ioctl.c            |   2 +-
 source3/smbd/smb2_ioctl_named_pipe.c |   2 +-
 source3/smbd/smb2_lock.c             |  10 ++-
 source3/smbd/smb2_notify.c           |   4 +-
 source3/smbd/smb2_query_directory.c  |   2 +-
 source3/smbd/smb2_read.c             |   2 +-
 source3/smbd/smb2_server.c           |  53 +++++++++-----
 source3/smbd/smb2_sesssetup.c        |   4 +-
 source3/smbd/smb2_setinfo.c          |   8 +-
 source3/smbd/smb2_tcon.c             |   4 +-
 source3/smbd/smb2_write.c            |   2 +-
 source3/smbd/smbXsrv_client.c        |  20 +++--
 source3/smbd/smbXsrv_open.c          |   4 +-
 source3/smbd/smbXsrv_session.c       |  14 ++--
 source3/smbd/smbXsrv_tcon.c          |   6 +-
 source3/smbd/uid.c                   | 119 ++++++++++++++++++++++--------
 source3/smbd/vfs.c                   |  27 ++-----
 source3/utils/status.c               |   1 -
 51 files changed, 572 insertions(+), 282 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/smb.h b/source3/include/smb.h
index 5e83ee9..9ec6543 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -156,6 +156,8 @@ struct sys_notify_context {
 struct current_user {
        struct connection_struct *conn;
        uint64_t vuid; /* SMB2 compat */
+       bool need_chdir;
+       bool done_chdir;
        struct security_unix_token ut;
        struct security_token *nt_user_token;
 };
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 81fb6c1..4e5b787 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -398,6 +398,7 @@ typedef struct files_struct {
 
 struct vuid_cache_entry {
        struct auth_session_info *session_info;
+       struct tevent_context *user_ev_ctx;
        uint64_t vuid; /* SMB2 compat */
        bool read_only;
        uint32_t share_access;
@@ -436,6 +437,7 @@ typedef struct connection_struct {
        char *connectpath;
        char *origpath;
        struct smb_filename *cwd_fname; /* Working directory. */
+       bool tcon_done;
 
        struct vfs_handle_struct *vfs_handles;          /* for the new plugins 
*/
 
@@ -444,6 +446,7 @@ typedef struct connection_struct {
         * on the vuid using this tid, this might change per SMB request.
         */
        struct auth_session_info *session_info;
+       struct tevent_context *user_ev_ctx;
 
        /*
         * If the "force group" parameter is set, this is the primary gid that
@@ -511,6 +514,8 @@ struct smb_request {
 
        size_t unread_bytes;
        bool encrypted;
+       /* the tevent_context (wrapper) the request operates on */
+       struct tevent_context *ev_ctx;
        connection_struct *conn;
        struct smbd_server_connection *sconn;
        struct smbXsrv_connection *xconn;
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 9fdc5ca..ea227c5 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -247,6 +247,17 @@ static const char *get_smb_user_name(void)
 void set_current_user_info(const char *smb_name, const char *unix_name,
                           const char *domain)
 {
+       static const void *last_smb_name;
+       static const void *last_unix_name;
+       static const void *last_domain;
+
+       if (likely(last_smb_name == smb_name &&
+           last_unix_name == unix_name &&
+           last_domain == domain))
+       {
+               return;
+       }
+
        fstrcpy(current_user_info.smb_name, smb_name);
        fstrcpy(current_user_info.unix_name, unix_name);
        fstrcpy(current_user_info.domain, domain);
@@ -255,6 +266,10 @@ void set_current_user_info(const char *smb_name, const 
char *unix_name,
         * has already been sanitised in register_existing_vuid. */
 
        sub_set_smb_name(current_user_info.smb_name);
+
+       last_smb_name = smb_name;
+       last_unix_name = unix_name;
+       last_domain = domain;
 }
 
 /*******************************************************************
diff --git a/source3/librpc/idl/smbXsrv.idl b/source3/librpc/idl/smbXsrv.idl
index d3f8d30..935c408 100644
--- a/source3/librpc/idl/smbXsrv.idl
+++ b/source3/librpc/idl/smbXsrv.idl
@@ -107,7 +107,7 @@ interface smbXsrv
 
        typedef [public] struct {
                [ignore] smbXsrv_client_table           *table;
-               [ignore] struct tevent_context          *ev_ctx;
+               [ignore] struct tevent_context          *raw_ev_ctx;
                [ignore] struct messaging_context       *msg_ctx;
 
                [ref] smbXsrv_client_global0            *global;
@@ -123,7 +123,6 @@ interface smbXsrv
                 * this session_table is used for SMB1 and SMB2,
                 */
                [ignore] struct smbXsrv_session_table   *session_table;
-               [ignore] hyper                          last_session_id;
                /*
                 * this tcon_table is only used for SMB1.
                 */
diff --git a/source3/modules/vfs_aio_pthread.c 
b/source3/modules/vfs_aio_pthread.c
index 88794bb..a9e2b09 100644
--- a/source3/modules/vfs_aio_pthread.c
+++ b/source3/modules/vfs_aio_pthread.c
@@ -276,7 +276,7 @@ static int open_async(const files_struct *fsp,
        }
 
        subreq = pthreadpool_tevent_job_send(opd,
-                                            fsp->conn->sconn->ev_ctx,
+                                            fsp->conn->user_ev_ctx,
                                             fsp->conn->sconn->pool,
                                             aio_open_worker, opd);
        if (subreq == NULL) {
diff --git a/source3/modules/vfs_btrfs.c b/source3/modules/vfs_btrfs.c
index 775e5f0..a11cb66 100644
--- a/source3/modules/vfs_btrfs.c
+++ b/source3/modules/vfs_btrfs.c
@@ -196,11 +196,29 @@ static NTSTATUS btrfs_offload_read_recv(struct tevent_req 
*req,
        return NT_STATUS_OK;
 }
 
-struct btrfs_cc_state {
+struct btrfs_offload_write_state {
        struct vfs_handle_struct *handle;
        off_t copied;
-       struct tevent_req *subreq;      /* non-null if passed to next VFS fn */
+       bool need_unbecome_user;
 };
+
+static void btrfs_offload_write_cleanup(struct tevent_req *req,
+                                       enum tevent_req_state req_state)
+{
+       struct btrfs_offload_write_state *state =
+               tevent_req_data(req,
+               struct btrfs_offload_write_state);
+       bool ok;
+
+       if (!state->need_unbecome_user) {
+               return;
+       }
+
+       ok = unbecome_user();
+       SMB_ASSERT(ok);
+       state->need_unbecome_user = false;
+}
+
 static void btrfs_offload_write_done(struct tevent_req *subreq);
 
 static struct tevent_req *btrfs_offload_write_send(struct vfs_handle_struct 
*handle,
@@ -213,8 +231,9 @@ static struct tevent_req *btrfs_offload_write_send(struct 
vfs_handle_struct *han
                                                off_t dest_off,
                                                off_t num)
 {
-       struct tevent_req *req;
-       struct btrfs_cc_state *cc_state;
+       struct tevent_req *req = NULL;
+       struct btrfs_offload_write_state *state = NULL;
+       struct tevent_req *subreq = NULL;
        struct btrfs_ioctl_clone_range_args cr_args;
        struct lock_struct src_lck;
        struct lock_struct dest_lck;
@@ -224,13 +243,17 @@ static struct tevent_req *btrfs_offload_write_send(struct 
vfs_handle_struct *han
        bool handle_offload_write = true;
        bool do_locking = false;
        NTSTATUS status;
+       bool ok;
 
-       req = tevent_req_create(mem_ctx, &cc_state, struct btrfs_cc_state);
+       req = tevent_req_create(mem_ctx, &state,
+                               struct btrfs_offload_write_state);
        if (req == NULL) {
                return NULL;
        }
 
-       cc_state->handle = handle;
+       state->handle = handle;
+
+       tevent_req_set_cleanup_fn(req, btrfs_offload_write_cleanup);
 
        status = vfs_offload_token_db_fetch_fsp(btrfs_offload_ctx,
                                                token, &src_fsp);
@@ -263,18 +286,19 @@ static struct tevent_req *btrfs_offload_write_send(struct 
vfs_handle_struct *han
        }
 
        if (!handle_offload_write) {
-               cc_state->subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle,
-                                                               cc_state, ev,
-                                                               fsctl,
-                                                               token,
-                                                               transfer_offset,
-                                                               dest_fsp,
-                                                               dest_off,
-                                                               num);
-               if (tevent_req_nomem(cc_state->subreq, req)) {
+               subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle,
+                                                        state,
+                                                        ev,
+                                                        fsctl,
+                                                        token,
+                                                        transfer_offset,
+                                                        dest_fsp,
+                                                        dest_off,
+                                                        num);
+               if (tevent_req_nomem(subreq, req)) {
                        return tevent_req_post(req, ev);
                }
-               tevent_req_set_callback(cc_state->subreq,
+               tevent_req_set_callback(subreq,
                                        btrfs_offload_write_done,
                                        req);
                return req;
@@ -287,6 +311,13 @@ static struct tevent_req *btrfs_offload_write_send(struct 
vfs_handle_struct *han
                return tevent_req_post(req, ev);
        }
 
+       ok = become_user_by_fsp(src_fsp);
+       if (!ok) {
+               tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
+               return tevent_req_post(req, ev);
+       }
+       state->need_unbecome_user = true;
+
        status = vfs_stat_fsp(src_fsp);
        if (tevent_req_nterror(req, status)) {
                return tevent_req_post(req, ev);
@@ -298,11 +329,6 @@ static struct tevent_req *btrfs_offload_write_send(struct 
vfs_handle_struct *han
                return tevent_req_post(req, ev);
        }
 
-       if (src_fsp->op == NULL || dest_fsp->op == NULL) {
-               tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
-               return tevent_req_post(req, ev);
-       }
-
        if (do_locking) {
                init_strict_lock_struct(src_fsp,
                                        src_fsp->op->global->open_persistent_id,
@@ -310,17 +336,24 @@ static struct tevent_req *btrfs_offload_write_send(struct 
vfs_handle_struct *han
                                        num,
                                        READ_LOCK,
                                        &src_lck);
+               if (!SMB_VFS_STRICT_LOCK_CHECK(src_fsp->conn, src_fsp, 
&src_lck)) {
+                       tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
+                       return tevent_req_post(req, ev);
+               }
+       }
+
+       ok = unbecome_user();
+       SMB_ASSERT(ok);
+       state->need_unbecome_user = false;
+
+       if (do_locking) {
                init_strict_lock_struct(dest_fsp,
-                                      dest_fsp->op->global->open_persistent_id,
+                                       
dest_fsp->op->global->open_persistent_id,
                                        dest_off,
                                        num,
                                        WRITE_LOCK,
                                        &dest_lck);
 
-               if (!SMB_VFS_STRICT_LOCK_CHECK(src_fsp->conn, src_fsp, 
&src_lck)) {
-                       tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
-                       return tevent_req_post(req, ev);
-               }
                if (!SMB_VFS_STRICT_LOCK_CHECK(dest_fsp->conn, dest_fsp, 
&dest_lck)) {
                        tevent_req_nterror(req, NT_STATUS_FILE_LOCK_CONFLICT);
                        return tevent_req_post(req, ev);
@@ -348,19 +381,20 @@ static struct tevent_req *btrfs_offload_write_send(struct 
vfs_handle_struct *han
                          (unsigned long long)cr_args.src_offset,
                          dest_fsp->fh->fd,
                          (unsigned long long)cr_args.dest_offset));
-               cc_state->subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle,
-                                                               cc_state, ev,
-                                                               fsctl,
-                                                               token,
-                                                               transfer_offset,
-                                                               dest_fsp,
-                                                               dest_off,
-                                                               num);
-               if (tevent_req_nomem(cc_state->subreq, req)) {
+               subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle,
+                                                        state,
+                                                        ev,
+                                                        fsctl,
+                                                        token,
+                                                        transfer_offset,
+                                                        dest_fsp,
+                                                        dest_off,
+                                                        num);
+               if (tevent_req_nomem(subreq, req)) {
                        return tevent_req_post(req, ev);
                }
                /* wait for subreq completion */
-               tevent_req_set_callback(cc_state->subreq,
+               tevent_req_set_callback(subreq,
                                        btrfs_offload_write_done,
                                        req);
                return req;
@@ -368,7 +402,7 @@ static struct tevent_req *btrfs_offload_write_send(struct 
vfs_handle_struct *han
 
        DEBUG(5, ("BTRFS_IOC_CLONE_RANGE returned %d\n", ret));
        /* BTRFS_IOC_CLONE_RANGE is all or nothing */
-       cc_state->copied = num;
+       state->copied = num;
        tevent_req_done(req);
        return tevent_req_post(req, ev);
 }
@@ -376,15 +410,18 @@ static struct tevent_req *btrfs_offload_write_send(struct 
vfs_handle_struct *han
 /* only used if the request is passed through to next VFS module */
 static void btrfs_offload_write_done(struct tevent_req *subreq)
 {
-       struct tevent_req *req = tevent_req_callback_data(
-               subreq, struct tevent_req);
-       struct btrfs_cc_state *cc_state = tevent_req_data(req,
-                                                       struct btrfs_cc_state);
+       struct tevent_req *req =
+               tevent_req_callback_data(subreq,
+               struct tevent_req);
+       struct btrfs_offload_write_state *state =
+               tevent_req_data(req,
+               struct btrfs_offload_write_state);
        NTSTATUS status;
 
-       status = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(cc_state->handle,
-                                             cc_state->subreq,
-                                             &cc_state->copied);
+       status = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(state->handle,
+                                                subreq,
+                                                &state->copied);
+       TALLOC_FREE(subreq);
        if (tevent_req_nterror(req, status)) {
                return;
        }
@@ -392,12 +429,13 @@ static void btrfs_offload_write_done(struct tevent_req 
*subreq)
 }
 
 static NTSTATUS btrfs_offload_write_recv(struct vfs_handle_struct *handle,
-                                     struct tevent_req *req,
-                                     off_t *copied)
+                                        struct tevent_req *req,
+                                        off_t *copied)
 {
+       struct btrfs_offload_write_state *state =
+               tevent_req_data(req,
+               struct btrfs_offload_write_state);
        NTSTATUS status;
-       struct btrfs_cc_state *cc_state = tevent_req_data(req,
-                                                       struct btrfs_cc_state);
 
        if (tevent_req_is_nterror(req, &status)) {
                DEBUG(4, ("server side copy chunk failed: %s\n",
@@ -407,8 +445,8 @@ static NTSTATUS btrfs_offload_write_recv(struct 
vfs_handle_struct *handle,
        }
 
        DEBUG(10, ("server side copy chunk copied %llu\n",
-                  (unsigned long long)cc_state->copied));
-       *copied = cc_state->copied;
+                  (unsigned long long)state->copied));
+       *copied = state->copied;
        tevent_req_received(req);
        return NT_STATUS_OK;
 }
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 82afb05..082b70f 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1584,13 +1584,14 @@ static NTSTATUS vfswrap_offload_read_recv(struct 
tevent_req *req,
 }
 
 struct vfswrap_offload_write_state {
-       struct tevent_context *ev;
        uint8_t *buf;
        bool read_lck_locked;
        bool write_lck_locked;
        DATA_BLOB *token;
+       struct tevent_context *src_ev;
        struct files_struct *src_fsp;
        off_t src_off;
+       struct tevent_context *dst_ev;
        struct files_struct *dst_fsp;
        off_t dst_off;
        off_t to_copy;
@@ -1598,6 +1599,22 @@ struct vfswrap_offload_write_state {
        size_t next_io_size;
 };
 
+static void vfswrap_offload_write_cleanup(struct tevent_req *req,
+                                         enum tevent_req_state req_state)
+{
+       struct vfswrap_offload_write_state *state = tevent_req_data(
+               req, struct vfswrap_offload_write_state);
+       bool ok;
+
+       if (state->dst_fsp == NULL) {
+               return;
+       }
+
+       ok = change_to_user_by_fsp(state->dst_fsp);
+       SMB_ASSERT(ok);
+       state->dst_fsp = NULL;
+}
+
 static NTSTATUS vfswrap_offload_write_loop(struct tevent_req *req);
 
 static struct tevent_req *vfswrap_offload_write_send(
@@ -1616,6 +1633,7 @@ static struct tevent_req *vfswrap_offload_write_send(
        size_t num = MIN(to_copy, COPYCHUNK_MAX_TOTAL_LEN);
        files_struct *src_fsp = NULL;
        NTSTATUS status;
+       bool ok;
 
        req = tevent_req_create(mem_ctx, &state,
                                struct vfswrap_offload_write_state);
@@ -1624,15 +1642,17 @@ static struct tevent_req *vfswrap_offload_write_send(
        }
 
        *state = (struct vfswrap_offload_write_state) {
-               .ev = ev,
                .token = token,
                .src_off = transfer_offset,
+               .dst_ev = ev,
                .dst_fsp = dest_fsp,
                .dst_off = dest_off,
                .to_copy = to_copy,
                .remaining = to_copy,
        };
 
+       tevent_req_set_cleanup_fn(req, vfswrap_offload_write_cleanup);
+
        switch (fsctl) {
        case FSCTL_SRV_COPYCHUNK:
        case FSCTL_SRV_COPYCHUNK_WRITE:
@@ -1666,7 +1686,6 @@ static struct tevent_req *vfswrap_offload_write_send(
        if (tevent_req_nterror(req, status)) {
                return tevent_req_post(req, ev);
        }
-       state->src_fsp = src_fsp;
 
        DBG_DEBUG("server side copy chunk of length %" PRIu64 "\n", to_copy);
 
@@ -1676,6 +1695,15 @@ static struct tevent_req *vfswrap_offload_write_send(
                return tevent_req_post(req, ev);
        }
 
+       ok = change_to_user_by_fsp(src_fsp);
+       if (!ok) {
+               tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
+               return tevent_req_post(req, ev);
+       }
+
+       state->src_ev = src_fsp->conn->user_ev_ctx;
+       state->src_fsp = src_fsp;
+
        state->buf = talloc_array(state, uint8_t, num);
        if (tevent_req_nomem(state->buf, req)) {
                return tevent_req_post(req, ev);
@@ -1700,16 +1728,6 @@ static struct tevent_req *vfswrap_offload_write_send(
                return tevent_req_post(req, ev);
        }
 
-       if (src_fsp->op == NULL) {
-               tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
-               return tevent_req_post(req, ev);
-       }
-
-       if (dest_fsp->op == NULL) {
-               tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
-               return tevent_req_post(req, ev);
-       }
-
        status = vfswrap_offload_write_loop(req);
        if (!NT_STATUS_IS_OK(status)) {
                tevent_req_nterror(req, status);
@@ -1729,6 +1747,10 @@ static NTSTATUS vfswrap_offload_write_loop(struct 
tevent_req *req)
        struct lock_struct read_lck;
        bool ok;
 
+       /*
+        * This is called under the context of state->src_fsp.
+        */
+
        state->next_io_size = MIN(state->remaining, 
talloc_array_length(state->buf));
 
        init_strict_lock_struct(state->src_fsp,
@@ -1746,7 +1768,7 @@ static NTSTATUS vfswrap_offload_write_loop(struct 
tevent_req *req)
        }
 
        subreq = SMB_VFS_PREAD_SEND(state,
-                                   state->src_fsp->conn->sconn->ev_ctx,
+                                   state->src_ev,
                                    state->src_fsp,
                                    state->buf,
                                    state->next_io_size,
@@ -1788,6 +1810,12 @@ static void vfswrap_offload_write_read_done(struct 
tevent_req *subreq)
 
        state->src_off += nread;


-- 
Samba Shared Repository

Reply via email to