*/
#include "includes.h"
+#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "../libcli/smb/smb_common.h"
-#include "librpc/gen_ndr/messaging.h"
+#include "../lib/util/tevent_ntstatus.h"
+#include "messages.h"
struct smbd_smb2_lock_element {
uint64_t offset;
const uint8_t *inhdr;
const uint8_t *inbody;
const int i = req->current_idx;
- size_t expected_body_size = 0x30;
- size_t body_size;
uint32_t in_smbpid;
uint16_t in_lock_count;
uint64_t in_file_id_persistent;
struct tevent_req *subreq;
const uint8_t *lock_buffer;
uint16_t l;
+ NTSTATUS status;
- inhdr = (const uint8_t *)req->in.vector[i+0].iov_base;
- if (req->in.vector[i+1].iov_len != (expected_body_size & 0xFFFFFFFE)) {
- return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
+ status = smbd_smb2_request_verify_sizes(req, 0x30);
+ if (!NT_STATUS_IS_OK(status)) {
+ return smbd_smb2_request_error(req, status);
}
-
+ inhdr = (const uint8_t *)req->in.vector[i+0].iov_base;
inbody = (const uint8_t *)req->in.vector[i+1].iov_base;
- body_size = SVAL(inbody, 0x00);
- if (body_size != expected_body_size) {
- return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
- }
-
in_smbpid = IVAL(inhdr, SMB2_HDR_PID);
in_lock_count = CVAL(inbody, 0x02);
return tevent_req_post(req, ev);
}
- locks[i].smblctx = in_file_id_volatile;
+ locks[i].smblctx = fsp->fnum;
locks[i].offset = in_locks[i].offset;
locks[i].count = in_locks[i].length;
struct server_id server_id,
DATA_BLOB *data)
{
+ struct smbd_server_connection *sconn;
+
DEBUG(10,("received_unlock_msg (SMB2)\n"));
- process_blocking_lock_queue_smb2(smbd_server_conn, timeval_current());
+
+ sconn = msg_ctx_to_sconn(msg);
+ if (sconn == NULL) {
+ DEBUG(1, ("could not find sconn\n"));
+ return;
+ }
+ process_blocking_lock_queue_smb2(sconn, timeval_current());
}
/****************************************************************
blr->blr_private = NULL;
/* Add a pending lock record for this. */
- status = brl_lock(smbd_messaging_context(),
+ status = brl_lock(sconn->msg_ctx,
br_lck,
smblctx,
- procid_self(),
+ sconn_server_id(sconn),
offset,
count,
lock_type == READ_LOCK ? PENDING_READ_LOCK : PENDING_WRITE_LOCK,
/* Ensure we'll receive messages when this is unlocked. */
if (!sconn->smb2.locks.blocking_lock_unlock_state) {
- messaging_register(smbd_messaging_context(), NULL,
+ messaging_register(sconn->msg_ctx, NULL,
MSG_SMB_UNLOCK, received_unlock_msg);
sconn->smb2.locks.blocking_lock_unlock_state = true;
}
if (br_lck) {
brl_lock_cancel(br_lck,
blr->smblctx,
- procid_self(),
+ sconn_server_id(blr->fsp->conn->sconn),
blr->offset,
blr->count,
blr->lock_flav,
for(i = blr->lock_num - 1; i >= 0; i--) {
struct smbd_lock_element *e = &state->locks[i];
- do_unlock(smbd_messaging_context(),
+ do_unlock(blr->fsp->conn->sconn->msg_ctx,
blr->fsp,
e->smblctx,
e->count,
static void reprocess_blocked_smb2_lock(struct smbd_smb2_request *smb2req,
struct timeval tv_curr)
{
- NTSTATUS status;
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
struct blocking_lock_record *blr = NULL;
struct smbd_smb2_lock_state *state = NULL;
files_struct *fsp = NULL;
struct byte_range_lock *br_lck = NULL;
struct smbd_lock_element *e = &state->locks[blr->lock_num];
- br_lck = do_lock(smbd_messaging_context(),
+ br_lck = do_lock(fsp->conn->sconn->msg_ctx,
fsp,
e->smblctx,
e->count,
struct smbd_smb2_lock_state *state = NULL;
files_struct *fsp_curr = NULL;
int i = smb2req->current_idx;
- uint64_t in_file_id_volatile;
struct blocking_lock_record *blr = NULL;
const uint8_t *inhdr;
- const uint8_t *inbody;
nextreq = smb2req->next;
continue;
}
- inbody = (const uint8_t *)smb2req->in.vector[i+1].iov_base;
- in_file_id_volatile = BVAL(inbody, 0x10);
-
state = tevent_req_data(smb2req->subreq,
struct smbd_smb2_lock_state);
if (!state) {
continue;
}
- fsp_curr = file_fsp(state->smb1req, (uint16_t)in_file_id_volatile);
+ fsp_curr = smb2req->compat_chain_fsp;
if (fsp_curr == NULL) {
/* Strange - is this even possible ? */
continue;
/* Remove the entries from the lock db. */
brl_lock_cancel(br_lck,
blr->smblctx,
- procid_self(),
+ sconn_server_id(sconn),
blr->offset,
blr->count,
blr->lock_flav,