s3:smb2_server: use the same logic to avoid recvfile() for IPC/PRINT shares
authorStefan Metzmacher <metze@samba.org>
Thu, 10 Apr 2014 22:43:46 +0000 (00:43 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 11 Apr 2014 19:41:08 +0000 (21:41 +0200)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb2_server.c

index 3c46efd7e60c2ef8b4c40d9d42b0f7b6fa8af11e..13626f3cb55d3696039298a59cf71f9709bb94fa 100644 (file)
@@ -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)));