diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 38d5b1f428b..a083f352261 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -591,6 +591,12 @@ void reply_ntcreate_and_X(struct smb_request *req) /* We have re-scheduled this call, no error. */ goto out; } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } + } reply_openerror(req, status); goto out; } @@ -1243,6 +1249,12 @@ static void call_nt_transact_create(connection_struct *conn, /* We have re-scheduled this call, no error. */ return; } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + return; + } + } reply_openerror(req, status); goto out; } @@ -1732,6 +1744,12 @@ void reply_ntrename(struct smb_request *req) /* We have re-scheduled this call. */ goto out; } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } + } reply_nterror(req, status); goto out; diff --git a/source3/smbd/open.c b/source3/smbd/open.c index f54c8cf6313..e33c7874883 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3506,38 +3506,6 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, SMB_ASSERT(NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)); - /* - * If we're returning a share violation, ensure we - * cope with the braindead 1 second delay (SMB1 only). - */ - - if (!(oplock_request & INTERNAL_OPEN_ONLY) && - !conn->sconn->using_smb2 && - lp_defer_sharing_violations()) { - struct timeval timeout; - int timeout_usecs; - - /* this is a hack to speed up torture tests - in 'make test' */ - timeout_usecs = lp_parm_int(SNUM(conn), - "smbd","sharedelay", - SHARING_VIOLATION_USEC_WAIT); - - /* This is a relative time, added to the absolute - request_time value to get the absolute timeout time. - Note that if this is the second or greater time we enter - this codepath for this particular request mid then - request_time is left as the absolute time of the *first* - time this request mid was processed. This is what allows - the request to eventually time out. */ - - timeout = timeval_set(0, timeout_usecs); - - if (!request_timed_out(req, timeout)) { - defer_open(lck, timeout, req, false, id); - } - } - TALLOC_FREE(lck); fd_close(fsp); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 946acb130d5..5664090f38c 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2308,6 +2308,10 @@ void reply_open(struct smb_request *req) create_options, private_flags); if (fsp == NULL) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } reply_openerror(req, status); goto out; } @@ -2495,9 +2499,15 @@ void reply_open_and_X(struct smb_request *req) create_options, private_flags); if (fsp == NULL) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } reply_openerror(req, status); goto out; } + + smb_action = FILE_WAS_OPENED; } @@ -2748,6 +2758,12 @@ void reply_mknew(struct smb_request *req) /* We have re-scheduled this call. */ goto out; } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } + } reply_openerror(req, status); goto out; } @@ -2885,6 +2901,13 @@ void reply_ctemp(struct smb_request *req) /* We have re-scheduled this call. */ goto out; } + if (NT_STATUS_EQUAL( + status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } + } reply_openerror(req, status); goto out; } @@ -3402,6 +3425,12 @@ void reply_unlink(struct smb_request *req) /* We have re-scheduled this call. */ goto out; } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } + } reply_nterror(req, status); goto out; } @@ -6545,6 +6574,12 @@ void reply_rmdir(struct smb_request *req) /* We have re-scheduled this call. */ goto out; } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } + } reply_nterror(req, status); goto out; } @@ -7678,6 +7713,12 @@ void reply_mv(struct smb_request *req) /* We have re-scheduled this call. */ goto out; } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } + } reply_nterror(req, status); goto out; } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 73515062729..d268558cfb8 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1454,9 +1454,14 @@ static void call_trans2open(connection_struct *conn, create_options, private_flags); if (fsp == NULL) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + goto out; + } reply_openerror(req, status); goto out; } + smb_action = FILE_WAS_OPENED; } @@ -6370,6 +6375,12 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd /* We have re-scheduled this call. */ return; } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + return; + } + } reply_nterror(req, status); return; } @@ -9322,6 +9333,12 @@ static void call_trans2setfilepathinfo(connection_struct *conn, /* We have re-scheduled this call. */ return; } + if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) { + bool ok = defer_smb1_sharing_violation(req); + if (ok) { + return; + } + } if (NT_STATUS_EQUAL(status, NT_STATUS_EVENT_PENDING)) { /* We have re-scheduled this call. */ return;