From 796874912d9935e202b8c767ca33d557dce9c43e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 11 Apr 2014 00:43:46 +0200 Subject: s3:smb2_server: use the same logic to avoid recvfile() for IPC/PRINT shares Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- source3/smbd/smb2_server.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source3/smbd/smb2_server.c') diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index 3c46efd7e60..13626f3cb55 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -2841,7 +2841,19 @@ static size_t get_min_receive_file_size(struct smbd_smb2_request *smb2_req) static bool is_smb2_recvfile_write(struct smbd_smb2_request_read_state *state) { + NTSTATUS status; uint32_t flags; + uint64_t file_id_persistent; + uint64_t file_id_volatile; + struct smbXsrv_open *op = NULL; + struct files_struct *fsp = NULL; + const uint8_t *body = NULL; + + /* + * This is only called with a pktbuf + * of at least SMBD_SMB2_SHORT_RECEIVEFILE_WRITE_LEN + * bytes + */ if (IVAL(state->pktbuf, 0) == SMB2_TF_MAGIC) { /* Transform header. Cannot recvfile. */ @@ -2873,6 +2885,35 @@ static bool is_smb2_recvfile_write(struct smbd_smb2_request_read_state *state) return false; } + body = &state->pktbuf[SMB2_HDR_BODY]; + + file_id_persistent = BVAL(body, 0x10); + file_id_volatile = BVAL(body, 0x18); + + status = smb2srv_open_lookup(state->req->sconn->conn, + file_id_persistent, + file_id_volatile, + 0, /* now */ + &op); + if (!NT_STATUS_IS_OK(status)) { + return false; + } + + fsp = op->compat; + if (fsp == NULL) { + return false; + } + if (fsp->conn == NULL) { + return false; + } + + if (IS_IPC(fsp->conn)) { + return false; + } + if (IS_PRINT(fsp->conn)) { + return false; + } + DEBUG(10,("Doing recvfile write len = %u\n", (unsigned int)(state->pktlen - SMBD_SMB2_SHORT_RECEIVEFILE_WRITE_LEN))); -- cgit