The branch, master has been updated via e6f3631 s3/smbd: update some more DEBUG macros in smbd_smb2_create_send via 18a7ea8 s3/smbd: use early returns in smbd_smb2_create_send via e55949c s3/smbd: factor out smbd_smb2_create_after_exec from smbd_smb2_create_send via 6478a2b s3/smbd: factor out smbd_smb2_create_before_exec from smbd_smb2_create_send via 403f024 s3/smbd: remove all stack variables of smbd_smb2_create_send into smbd_smb2_create_state via cadf4d5 s3/smbd: move create ctx extraction and validation to a helper func via 8229473 s3/smbd: move create contexts into smbd_smb2_create_state via 4cbd2f1 s3/smbd: remove unneeded args from smbd_smb2_create_finish via 4bb7acf s3/smbd: move info into smbd_smb2_create_state via b0ee889 s3/smbd: add in_create_disposition to smbd_smb2_create_state via 127715c s3/smbd: add in_oplock_level to smbd_smb2_create_state via dafb1ad s3/smbd: move requested_oplock_level into smbd_smb2_create_state via 0a8263a s3/smbd: move replay_operation into smbd_smb2_create_state via 29d654a s3/smbd: move result into smbd_smb2_create_state via bb072ba s3/smbd: leverage early return added in the previous commit via b11ce87 s3/smbd: factor out smbd_smb2_create_finish from smbd_smb2_create_send via ef7cabb s3/smbd: modernize a DEBUG statement via 4179a3e s3/smbd: move some setup code in smbd_smb2_create_send a few lines up via 7c5d996 s3/smbd: add tevent context to smbd_smb2_create_state via 718fa0e s3/smbd: use struct initializer for smbd_smb2_create_state from 629fc066 lib: Remove fncall.c
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit e6f3631eba863e6dda007b4e2d9a3b7ef3d49f35 Author: Ralph Boehme <s...@samba.org> Date: Sat Jul 22 19:34:25 2017 +0200 s3/smbd: update some more DEBUG macros in smbd_smb2_create_send Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> Autobuild-User(master): Ralph Böhme <s...@samba.org> Autobuild-Date(master): Sat Oct 21 18:08:46 CEST 2017 on sn-devel-144 commit 18a7ea8c0f76fa9c969e6e8563d1f8ad8c65a9c2 Author: Ralph Boehme <s...@samba.org> Date: Fri Jul 21 18:59:55 2017 +0200 s3/smbd: use early returns in smbd_smb2_create_send Now that we have the nice smbd_smb2_create_after_exec() and smbd_smb2_create_finish() functions, use early returns for the create replay and durable handle reconnect case. No change in behaviour, best viewed with $ git show -w COMMIT Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit e55949c415b5acbeadb463f5eae1ad5782531748 Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 20 16:14:31 2017 +0200 s3/smbd: factor out smbd_smb2_create_after_exec from smbd_smb2_create_send No change in behaviour. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 6478a2b1fd983888f322facd454dd6601dd61bf2 Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 20 16:14:31 2017 +0200 s3/smbd: factor out smbd_smb2_create_before_exec from smbd_smb2_create_send No change in behaviour, best viewed with: $ git show --diff-algorithm=histogram COMMIT Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 403f024de138b30fd9702c20dc2359255f31f64d Author: Ralph Boehme <s...@samba.org> Date: Fri Jul 21 18:02:05 2017 +0200 s3/smbd: remove all stack variables of smbd_smb2_create_send into smbd_smb2_create_state This allows factoring out smbd_smb2_create_after|before_exec() in the next steps. Moving all variable in one big fell swoop instead of one per commit, because if I'd miss to adjust a variable access the commit wouldn't compile. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit cadf4d56eef527316565b5b9f1f1bd8bf3750b5b Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 20 12:51:37 2017 +0200 s3/smbd: move create ctx extraction and validation to a helper func No change in behaviour. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 8229473347818f9865094c2000b788d51c23909b Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 20 12:15:19 2017 +0200 s3/smbd: move create contexts into smbd_smb2_create_state Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 4cbd2f13bad8cf2bb96073b36238792f17a24db1 Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 20 11:29:46 2017 +0200 s3/smbd: remove unneeded args from smbd_smb2_create_finish The previous commits moved all arguments into smbd_smb2_create_state. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 4bb7acfe658ffce089b8265ca02e1c711c63c5f6 Author: Ralph Boehme <s...@samba.org> Date: Sat Jul 22 18:49:50 2017 +0200 s3/smbd: move info into smbd_smb2_create_state Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit b0ee889a0a6f97ff3c804655ec67a4aa2f863591 Author: Ralph Boehme <s...@samba.org> Date: Sat Jul 22 18:47:17 2017 +0200 s3/smbd: add in_create_disposition to smbd_smb2_create_state Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 127715c6658cde99d31d9256be0c93d662ee50fd Author: Ralph Boehme <s...@samba.org> Date: Sat Jul 22 18:43:33 2017 +0200 s3/smbd: add in_oplock_level to smbd_smb2_create_state Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit dafb1ad4b65de92470711b876838a2d73e9203c8 Author: Ralph Boehme <s...@samba.org> Date: Sat Jul 22 18:40:16 2017 +0200 s3/smbd: move requested_oplock_level into smbd_smb2_create_state Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 0a8263a9d6a9187703c7e76a5c960e87a32deadc Author: Ralph Boehme <s...@samba.org> Date: Sat Jul 22 18:32:50 2017 +0200 s3/smbd: move replay_operation into smbd_smb2_create_state Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 29d654a19ed2f88a2ea3d6a3742b688bc3019d6b Author: Ralph Boehme <s...@samba.org> Date: Sat Jul 22 15:31:05 2017 +0200 s3/smbd: move result into smbd_smb2_create_state Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit bb072ba474b0d4526066cc881c63c0c839de20f2 Author: Ralph Boehme <s...@samba.org> Date: Wed Jul 19 19:07:55 2017 +0200 s3/smbd: leverage early return added in the previous commit Now that the other cases handled in the if/else blocks do early returns, we can move the logic handling file opens out of the final else block. No change in behaviour, best viewed with $ git show -w COMMIT Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit b11ce878574d3edf82f4002e60d905b1c79df3c9 Author: Ralph Boehme <s...@samba.org> Date: Wed Jul 19 19:04:46 2017 +0200 s3/smbd: factor out smbd_smb2_create_finish from smbd_smb2_create_send No change in behaviour. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit ef7cabb4185cfca7da398cd1af5c8c25c9977d62 Author: Ralph Boehme <s...@samba.org> Date: Fri Jul 21 15:34:02 2017 +0200 s3/smbd: modernize a DEBUG statement Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 4179a3e67d390232d794d7a073b9b3110963c266 Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 20 06:03:34 2017 +0200 s3/smbd: move some setup code in smbd_smb2_create_send a few lines up This is just one of the last steps before splitting out large code parts into _before() and _after() functions. No change in behaviour. Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 7c5d996e7107e082e78eb94932f7e710ed7a93c9 Author: Ralph Boehme <s...@samba.org> Date: Fri Jul 21 16:23:53 2017 +0200 s3/smbd: add tevent context to smbd_smb2_create_state ...and use it in everywhere in smbd_smb2_create_send(). Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> commit 718fa0e6e50852a6b9b50db28a770302fdacd911 Author: Ralph Boehme <s...@samba.org> Date: Thu Jul 20 06:49:46 2017 +0200 s3/smbd: use struct initializer for smbd_smb2_create_state Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/smbd/smb2_create.c | 1552 +++++++++++++++++++++++--------------------- 1 file changed, 828 insertions(+), 724 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c index c4fe247..d34a5f7 100644 --- a/source3/smbd/smb2_create.c +++ b/source3/smbd/smb2_create.c @@ -428,6 +428,7 @@ static NTSTATUS smbd_smb2_create_durable_lease_check(struct smb_request *smb1req } struct smbd_smb2_create_state { + struct tevent_context *ev; struct smbd_smb2_request *smb2req; struct smb_request *smb1req; bool open_was_deferred; @@ -435,6 +436,43 @@ struct smbd_smb2_create_state { struct timeval request_time; struct file_id id; struct deferred_open_record *open_rec; + files_struct *result; + bool replay_operation; + uint8_t in_oplock_level; + uint32_t in_create_disposition; + int requested_oplock_level; + int info; + char *fname; + struct ea_list *ea_list; + NTTIME max_access_time; + struct security_descriptor *sec_desc; + uint64_t allocation_size; + struct GUID _create_guid; + struct GUID *create_guid; + bool update_open; + bool durable_requested; + uint32_t durable_timeout_msec; + bool do_durable_reconnect; + uint64_t persistent_id; + struct smb2_lease lease; + struct smb2_lease *lease_ptr; + ssize_t lease_len; + bool need_replay_cache; + struct smbXsrv_open *op; + + struct smb2_create_blob *dhnc; + struct smb2_create_blob *dh2c; + struct smb2_create_blob *dhnq; + struct smb2_create_blob *dh2q; + struct smb2_create_blob *rqls; + struct smb2_create_blob *exta; + struct smb2_create_blob *mxac; + struct smb2_create_blob *secd; + struct smb2_create_blob *alsi; + struct smb2_create_blob *twrp; + struct smb2_create_blob *qfid; + struct smb2_create_blob *svhdx; + uint8_t out_oplock_level; uint32_t out_create_action; struct timespec out_creation_ts; @@ -449,103 +487,40 @@ struct smbd_smb2_create_state { struct smb2_create_blobs *out_context_blobs; }; -static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct smbd_smb2_request *smb2req, - uint8_t in_oplock_level, - uint32_t in_impersonation_level, - uint32_t in_desired_access, - uint32_t in_file_attributes, - uint32_t in_share_access, - uint32_t in_create_disposition, - uint32_t in_create_options, - const char *in_name, - struct smb2_create_blobs in_context_blobs) +static NTSTATUS smbd_smb2_create_fetch_create_ctx( + struct tevent_req *req, + struct smb2_create_blobs *in_context_blobs) { - struct tevent_req *req = NULL; - struct smbd_smb2_create_state *state = NULL; - NTSTATUS status; - struct smb_request *smb1req = NULL; - files_struct *result = NULL; - int info; - int requested_oplock_level; - struct smb2_create_blob *dhnc = NULL; - struct smb2_create_blob *dh2c = NULL; - struct smb2_create_blob *dhnq = NULL; - struct smb2_create_blob *dh2q = NULL; - struct smb2_create_blob *rqls = NULL; - bool replay_operation = false; - - if(lp_fake_oplocks(SNUM(smb2req->tcon->compat))) { - requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE; - } else { - requested_oplock_level = in_oplock_level; - } - - req = tevent_req_create(mem_ctx, &state, - struct smbd_smb2_create_state); - if (req == NULL) { - return NULL; - } - state->smb2req = smb2req; - - smb1req = smbd_smb2_fake_smb_request(smb2req); - if (tevent_req_nomem(smb1req, req)) { - return tevent_req_post(req, ev); - } - state->smb1req = smb1req; - - if (smb2req->subreq == NULL) { - DEBUG(10,("smbd_smb2_create: name[%s]\n", - in_name)); - } else { - struct smbd_smb2_create_state *old_state = tevent_req_data( - smb2req->subreq, struct smbd_smb2_create_state); - - DEBUG(10,("smbd_smb2_create_send: reentrant for file %s\n", - in_name )); - - state->id = old_state->id; - state->request_time = old_state->request_time; - state->open_rec = talloc_move(state, &old_state->open_rec); - state->open_was_deferred = old_state->open_was_deferred; - } - - TALLOC_FREE(smb2req->subreq); - smb2req->subreq = req; - - state->out_context_blobs = talloc_zero(state, struct smb2_create_blobs); - if (tevent_req_nomem(state->out_context_blobs, req)) { - return tevent_req_post(req, ev); - } - - dhnq = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_DHNQ); - dhnc = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_DHNC); - dh2q = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_DH2Q); - dh2c = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_DH2C); - if (smb2req->xconn->smb2.server.capabilities & SMB2_CAP_LEASING) { - rqls = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_RQLS); - } - - if ((dhnc && dh2c) || (dhnc && dh2q) || (dh2c && dhnq) || - (dh2q && dh2c)) + struct smbd_smb2_create_state *state = tevent_req_data( + req, struct smbd_smb2_create_state); + + state->dhnq = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_DHNQ); + state->dhnc = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_DHNC); + state->dh2q = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_DH2Q); + state->dh2c = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_DH2C); + if (state->smb2req->xconn->smb2.server.capabilities & SMB2_CAP_LEASING) { + state->rqls = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_RQLS); + } + + if (((state->dhnc != NULL) && (state->dh2c != NULL)) || + ((state->dhnc != NULL) && (state->dh2q != NULL)) || + ((state->dh2c != NULL) && (state->dhnq != NULL)) || + ((state->dh2q != NULL) && (state->dh2c != NULL))) { /* not both are allowed at the same time */ - tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); - return tevent_req_post(req, ev); + return NT_STATUS_INVALID_PARAMETER; } - if (dhnc) { + if (state->dhnc != NULL) { uint32_t num_blobs_allowed; - if (dhnc->data.length != 16) { - tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); - return tevent_req_post(req, ev); + if (state->dhnc->data.length != 16) { + return NT_STATUS_INVALID_PARAMETER; } /* @@ -560,28 +535,26 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx, * above.) */ - if (dhnq) { + if (state->dhnq != NULL) { num_blobs_allowed = 2; } else { num_blobs_allowed = 1; } - if (rqls != NULL) { + if (state->rqls != NULL) { num_blobs_allowed += 1; } - if (in_context_blobs.num_blobs != num_blobs_allowed) { - tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND); - return tevent_req_post(req, ev); + if (in_context_blobs->num_blobs != num_blobs_allowed) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; } } - if (dh2c) { + if (state->dh2c!= NULL) { uint32_t num_blobs_allowed; - if (dh2c->data.length != 36) { - tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER); - return tevent_req_post(req, ev); + if (state->dh2c->data.length != 36) { + return NT_STATUS_INVALID_PARAMETER; } /* @@ -598,776 +571,907 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx, num_blobs_allowed = 1; - if (rqls != NULL) { + if (state->rqls != NULL) { num_blobs_allowed += 1; } - if (in_context_blobs.num_blobs != num_blobs_allowed) { - tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND); - return tevent_req_post(req, ev); + if (in_context_blobs->num_blobs != num_blobs_allowed) { + return NT_STATUS_OBJECT_NAME_NOT_FOUND; } } + state->exta = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_EXTA); + state->mxac = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_MXAC); + state->secd = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_SECD); + state->alsi = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_ALSI); + state->twrp = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_TWRP); + state->qfid = smb2_create_blob_find(in_context_blobs, + SMB2_CREATE_TAG_QFID); + if (state->smb2req->xconn->protocol >= PROTOCOL_SMB3_02) { + /* + * This was introduced with SMB3_02 + */ + state->svhdx = smb2_create_blob_find( + in_context_blobs, SVHDX_OPEN_DEVICE_CONTEXT); + } + + return NT_STATUS_OK; +} + +static void smbd_smb2_create_before_exec(struct tevent_req *req); +static void smbd_smb2_create_after_exec(struct tevent_req *req); +static void smbd_smb2_create_finish(struct tevent_req *req); + +static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct smbd_smb2_request *smb2req, + uint8_t in_oplock_level, + uint32_t in_impersonation_level, + uint32_t in_desired_access, + uint32_t in_file_attributes, + uint32_t in_share_access, + uint32_t in_create_disposition, + uint32_t in_create_options, + const char *in_name, + struct smb2_create_blobs in_context_blobs) +{ + struct tevent_req *req = NULL; + struct smbd_smb2_create_state *state = NULL; + NTSTATUS status; + struct smb_request *smb1req = NULL; + struct smb_filename *smb_fname = NULL; + uint32_t ucf_flags; + + req = tevent_req_create(mem_ctx, &state, + struct smbd_smb2_create_state); + if (req == NULL) { + return NULL; + } + *state = (struct smbd_smb2_create_state) { + .ev = ev, + .smb2req = smb2req, + .in_oplock_level = in_oplock_level, + .in_create_disposition = in_create_disposition, + }; + + smb1req = smbd_smb2_fake_smb_request(smb2req); + if (tevent_req_nomem(smb1req, req)) { + return tevent_req_post(req, state->ev); + } + state->smb1req = smb1req; + + if (smb2req->subreq == NULL) { + DBG_DEBUG("name [%s]\n", in_name); + } else { + struct smbd_smb2_create_state *old_state = tevent_req_data( + smb2req->subreq, struct smbd_smb2_create_state); + + DBG_DEBUG("reentrant for file %s\n", in_name); + + state->id = old_state->id; + state->request_time = old_state->request_time; + state->open_rec = talloc_move(state, &old_state->open_rec); + state->open_was_deferred = old_state->open_was_deferred; + } + + TALLOC_FREE(smb2req->subreq); + smb2req->subreq = req; + + if (lp_fake_oplocks(SNUM(smb2req->tcon->compat))) { + state->requested_oplock_level = SMB2_OPLOCK_LEVEL_NONE; + } else { + state->requested_oplock_level = state->in_oplock_level; + } + + /* these are ignored for SMB2 */ + in_create_options &= ~(0x10);/* NTCREATEX_OPTIONS_SYNC_ALERT */ + in_create_options &= ~(0x20);/* NTCREATEX_OPTIONS_ASYNC_ALERT */ + + in_file_attributes &= ~FILE_FLAG_POSIX_SEMANTICS; + + state->fname = talloc_strdup(state, in_name); + if (tevent_req_nomem(state->fname, req)) { + return tevent_req_post(req, state->ev); + } + + state->out_context_blobs = talloc_zero(state, struct smb2_create_blobs); + if (tevent_req_nomem(state->out_context_blobs, req)) { + return tevent_req_post(req, state->ev); + } + + status = smbd_smb2_create_fetch_create_ctx(req, &in_context_blobs); + if (tevent_req_nterror(req, status)) { + return tevent_req_post(req, state->ev); + } + if (IS_IPC(smb1req->conn)) { const char *pipe_name = in_name; - if (dhnc || dh2c) { + if (state->dhnc != NULL || state->dh2c != NULL) { /* durable handles are not supported on IPC$ */ tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND); - return tevent_req_post(req, ev); + return tevent_req_post(req, state->ev); } if (!lp_nt_pipe_support()) { tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED); - return tevent_req_post(req, ev); + return tevent_req_post(req, state->ev); } - status = open_np_file(smb1req, pipe_name, &result); + status = open_np_file(smb1req, pipe_name, &state->result); if (!NT_STATUS_IS_OK(status)) { tevent_req_nterror(req, status); - return tevent_req_post(req, ev); + return tevent_req_post(req, state->ev); } - info = FILE_WAS_OPENED; + state->info = FILE_WAS_OPENED; + + smbd_smb2_create_finish(req); + return req; + } else if (CAN_PRINT(smb1req->conn)) { - if (dhnc || dh2c) { + if (state->dhnc != NULL || state->dh2c != NULL) { /* durable handles are not supported on printers */ tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND); - return tevent_req_post(req, ev); + return tevent_req_post(req, state->ev); } - status = file_new(smb1req, smb1req->conn, &result); + status = file_new(smb1req, smb1req->conn, &state->result); if(!NT_STATUS_IS_OK(status)) { tevent_req_nterror(req, status); - return tevent_req_post(req, ev); + return tevent_req_post(req, state->ev); } - status = print_spool_open(result, in_name, + status = print_spool_open(state->result, in_name, smb1req->vuid); if (!NT_STATUS_IS_OK(status)) { - file_free(smb1req, result); + file_free(smb1req, state->result); tevent_req_nterror(req, status); - return tevent_req_post(req, ev); + return tevent_req_post(req, state->ev); } - info = FILE_WAS_CREATED; - } else { - char *fname; - struct smb2_create_blob *exta = NULL; - struct ea_list *ea_list = NULL; - struct smb2_create_blob *mxac = NULL; - NTTIME max_access_time = 0; - struct smb2_create_blob *secd = NULL; - struct security_descriptor *sec_desc = NULL; - struct smb2_create_blob *alsi = NULL; - uint64_t allocation_size = 0; - struct smb2_create_blob *twrp = NULL; - struct smb2_create_blob *qfid = NULL; - struct GUID _create_guid = GUID_zero(); - struct GUID *create_guid = NULL; - bool update_open = false; - bool durable_requested = false; - uint32_t durable_timeout_msec = 0; - bool do_durable_reconnect = false; - uint64_t persistent_id = 0; - struct smb2_lease lease; - struct smb2_lease *lease_ptr = NULL; - ssize_t lease_len = -1; - bool need_replay_cache = false; - struct smbXsrv_open *op = NULL; -#if 0 - struct smb2_create_blob *svhdx = NULL; -#endif - - exta = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_EXTA); - mxac = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_MXAC); - secd = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_SECD); - alsi = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_ALSI); - twrp = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_TWRP); - qfid = smb2_create_blob_find(&in_context_blobs, - SMB2_CREATE_TAG_QFID); -#if 0 - if (smb2req->xconn->protocol >= PROTOCOL_SMB3_02) { - /* - * This was introduced with SMB3_02 - */ - svhdx = smb2_create_blob_find(&in_context_blobs, - SVHDX_OPEN_DEVICE_CONTEXT); + state->info = FILE_WAS_CREATED; + + smbd_smb2_create_finish(req); + return req; + } + + smbd_smb2_create_before_exec(req); + if (!tevent_req_is_in_progress(req)) { + return tevent_req_post(req, state->ev); + } + + DBG_DEBUG("open execution phase\n"); + + /* + * For the backend file open procedure, there are + * three possible modes: replay operation (in which case + * there is nothing else to do), durable_reconnect or + * new open. + */ + if (state->replay_operation) { + state->result = state->op->compat; + state->result->op = state->op; + state->update_open = false; + state->info = state->op->create_action; + + smbd_smb2_create_after_exec(req); + if (!tevent_req_is_in_progress(req)) { + return req; } -#endif - fname = talloc_strdup(state, in_name); - if (tevent_req_nomem(fname, req)) { - return tevent_req_post(req, ev); + smbd_smb2_create_finish(req); + return req; + + } else if (state->do_durable_reconnect) { + DATA_BLOB new_cookie = data_blob_null; + NTTIME now = timeval_to_nttime(&smb2req->request_time); + + status = smb2srv_open_recreate(smb2req->xconn, + smb1req->conn->session_info, + state->persistent_id, + state->create_guid, + now, -- Samba Shared Repository