#include "system/select.h"
#include "librpc/gen_ndr/smbXsrv.h"
-#if defined(HAVE_AIO)
-struct aio_extra;
-extern struct aio_extra *aio_list_head;
-extern struct tevent_signal *aio_signal_event;
extern int aio_pending_size;
extern int outstanding_aio_calls;
-#endif
#ifdef USE_DMAPI
struct smbd_dmapi_context;
NTSTATUS smbd_calculate_access_mask(connection_struct *conn,
const struct smb_filename *smb_fname,
+ bool use_privs,
uint32_t access_mask,
uint32_t *access_mask_out);
void reply_smb2002(struct smb_request *req, uint16_t choice);
void reply_smb20ff(struct smb_request *req, uint16_t choice);
void smbd_smb2_first_negprot(struct smbd_server_connection *sconn,
- const uint8_t *inbuf, size_t size);
+ uint8_t *inbuf, size_t size);
NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req,
NTSTATUS status,
smbd_smb2_request_done_ex(req, NT_STATUS_OK, body, dyn, __location__)
NTSTATUS smbd_smb2_send_oplock_break(struct smbd_server_connection *sconn,
- uint64_t file_id_persistent,
- uint64_t file_id_volatile,
+ struct smbXsrv_session *session,
+ struct smbXsrv_tcon *tcon,
+ struct smbXsrv_open *op,
uint8_t oplock_level);
NTSTATUS smbd_smb2_request_pending_queue(struct smbd_smb2_request *req,
NTSTATUS smb2_read_complete(struct tevent_req *req, ssize_t nread, int err);
NTSTATUS smbd_smb2_request_process_write(struct smbd_smb2_request *req);
NTSTATUS smb2_write_complete(struct tevent_req *req, ssize_t nwritten, int err);
+NTSTATUS smb2_write_complete_nosync(struct tevent_req *req, ssize_t nwritten,
+ int err);
NTSTATUS smbd_smb2_request_process_lock(struct smbd_smb2_request *req);
NTSTATUS smbd_smb2_request_process_ioctl(struct smbd_smb2_request *req);
NTSTATUS smbd_smb2_request_process_keepalive(struct smbd_smb2_request *req);
uint64_t mid);
void remove_deferred_open_message_smb2(
struct smbd_server_connection *sconn, uint64_t mid);
-void schedule_deferred_open_message_smb2(
+bool schedule_deferred_open_message_smb2(
struct smbd_server_connection *sconn, uint64_t mid);
bool push_deferred_open_message_smb2(struct smbd_smb2_request *smb2req,
struct timeval request_time,
struct msg_state *msg_state;
+ /*
+ * Link into libasys for asynchronous operations
+ */
+ struct asys_context *asys_ctx;
+ struct tevent_fd *asys_fde;
+
uint64_t smbd_idle_profstamp;
+ /*
+ * this session_table is used for SMB1 and SMB2,
+ */
struct smbXsrv_session_table *session_table;
+ /*
+ * this tcon_table is only used for SMB1.
+ */
struct smbXsrv_tcon_table *tcon_table;
+ /*
+ * this open_table is used for SMB1 and SMB2,
+ * because we have a global sconn->real_max_open_files
+ * limit.
+ */
struct smbXsrv_open_table *open_table;
};
NTSTATUS smb2srv_session_lookup(struct smbXsrv_connection *conn,
uint64_t session_id, NTTIME now,
struct smbXsrv_session **session);
+struct smbXsrv_session_global0;
+NTSTATUS smbXsrv_session_global_traverse(
+ int (*fn)(struct smbXsrv_session_global0 *, void *),
+ void *private_data);
struct tevent_req *smb2srv_session_close_previous_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct smbXsrv_connection *conn,
uint64_t volatile_id,
NTTIME now,
struct smbXsrv_open **_open);
+NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn,
+ struct auth_session_info *session_info,
+ uint64_t persistent_id,
+ struct GUID create_guid,
+ NTTIME now,
+ struct smbXsrv_open **_open);
struct smbd_smb2_request {
struct smbd_smb2_request *prev, *next;
- TALLOC_CTX *mem_pool;
- struct smbd_smb2_request **parent;
-
struct smbd_server_connection *sconn;
/* the session the request operates on, maybe NULL */
int current_idx;
bool do_signing;
+ bool do_encryption;
struct tevent_timer *async_te;
- bool cancelled;
bool compound_related;
+ /*
+ * the encryption key for the whole
+ * compound chain
+ */
+ DATA_BLOB first_key;
+ /*
+ * the signing key for the last
+ * request/response of a compound chain
+ */
+ DATA_BLOB last_key;
+
struct timeval request_time;
/* fake smb1 request. */
struct smb_request *smb1req;
struct files_struct *compat_chain_fsp;
- NTSTATUS next_status;
-
/*
* The sub request for async backend calls.
* This is used for SMB2 Cancel.
*/
struct tevent_req *subreq;
+#define SMBD_SMB2_TF_IOV_OFS 0
+#define SMBD_SMB2_HDR_IOV_OFS 1
+#define SMBD_SMB2_BODY_IOV_OFS 2
+#define SMBD_SMB2_DYN_IOV_OFS 3
+
+#define SMBD_SMB2_NUM_IOV_PER_REQ 4
+
+#define SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,ofs) \
+ (&req->dir.vector[(idx)+(ofs)])
+
+#define SMBD_SMB2_IDX_TF_IOV(req,dir,idx) \
+ SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,SMBD_SMB2_TF_IOV_OFS)
+#define SMBD_SMB2_IDX_HDR_IOV(req,dir,idx) \
+ SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,SMBD_SMB2_HDR_IOV_OFS)
+#define SMBD_SMB2_IDX_BODY_IOV(req,dir,idx) \
+ SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,SMBD_SMB2_BODY_IOV_OFS)
+#define SMBD_SMB2_IDX_DYN_IOV(req,dir,idx) \
+ SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,SMBD_SMB2_DYN_IOV_OFS)
+
+#define SMBD_SMB2_IN_TF_IOV(req) SMBD_SMB2_IDX_TF_IOV(req,in,req->current_idx)
+#define SMBD_SMB2_IN_TF_PTR(req) (uint8_t *)(SMBD_SMB2_IN_TF_IOV(req)->iov_base)
+#define SMBD_SMB2_IN_HDR_IOV(req) SMBD_SMB2_IDX_HDR_IOV(req,in,req->current_idx)
+#define SMBD_SMB2_IN_HDR_PTR(req) (uint8_t *)(SMBD_SMB2_IN_HDR_IOV(req)->iov_base)
+#define SMBD_SMB2_IN_BODY_IOV(req) SMBD_SMB2_IDX_BODY_IOV(req,in,req->current_idx)
+#define SMBD_SMB2_IN_BODY_PTR(req) (uint8_t *)(SMBD_SMB2_IN_BODY_IOV(req)->iov_base)
+#define SMBD_SMB2_IN_BODY_LEN(req) (SMBD_SMB2_IN_BODY_IOV(req)->iov_len)
+#define SMBD_SMB2_IN_DYN_IOV(req) SMBD_SMB2_IDX_DYN_IOV(req,in,req->current_idx)
+#define SMBD_SMB2_IN_DYN_PTR(req) (uint8_t *)(SMBD_SMB2_IN_DYN_IOV(req)->iov_base)
+#define SMBD_SMB2_IN_DYN_LEN(req) (SMBD_SMB2_IN_DYN_IOV(req)->iov_len)
+
+#define SMBD_SMB2_OUT_TF_IOV(req) SMBD_SMB2_IDX_TF_IOV(req,out,req->current_idx)
+#define SMBD_SMB2_OUT_TF_PTR(req) (uint8_t *)(SMBD_SMB2_OUT_TF_IOV(req)->iov_base)
+#define SMBD_SMB2_OUT_HDR_IOV(req) SMBD_SMB2_IDX_HDR_IOV(req,out,req->current_idx)
+#define SMBD_SMB2_OUT_HDR_PTR(req) (uint8_t *)(SMBD_SMB2_OUT_HDR_IOV(req)->iov_base)
+#define SMBD_SMB2_OUT_BODY_IOV(req) SMBD_SMB2_IDX_BODY_IOV(req,out,req->current_idx)
+#define SMBD_SMB2_OUT_BODY_PTR(req) (uint8_t *)(SMBD_SMB2_OUT_BODY_IOV(req)->iov_base)
+#define SMBD_SMB2_OUT_BODY_LEN(req) (SMBD_SMB2_OUT_BODY_IOV(req)->iov_len)
+#define SMBD_SMB2_OUT_DYN_IOV(req) SMBD_SMB2_IDX_DYN_IOV(req,out,req->current_idx)
+#define SMBD_SMB2_OUT_DYN_PTR(req) (uint8_t *)(SMBD_SMB2_OUT_DYN_IOV(req)->iov_base)
+#define SMBD_SMB2_OUT_DYN_LEN(req) (SMBD_SMB2_OUT_DYN_IOV(req)->iov_len)
+
struct {
- /* the NBT header is not allocated */
- uint8_t nbt_hdr[4];
/*
- * vector[0] NBT
+ * vector[0] TRANSPORT HEADER (empty)
* .
- * vector[1] SMB2
- * vector[2] fixed body
- * vector[3] dynamic body
+ * vector[1] SMB2_TRANSFORM (optional)
+ * vector[2] SMB2
+ * vector[3] fixed body
+ * vector[4] dynamic body
* .
* .
* .
- * vector[4] SMB2
- * vector[5] fixed body
- * vector[6] dynamic body
+ * vector[5] SMB2_TRANSFORM (optional)
+ * vector[6] SMB2
+ * vector[7] fixed body
+ * vector[8] dynamic body
* .
* .
* .
/* the NBT header is not allocated */
uint8_t nbt_hdr[4];
/*
- * vector[0] NBT
+ * vector[0] TRANSPORT HEADER
* .
- * vector[1] SMB2
- * vector[2] fixed body
- * vector[3] dynamic body
+ * vector[1] SMB2_TRANSFORM (optional)
+ * vector[2] SMB2
+ * vector[3] fixed body
+ * vector[4] dynamic body
* .
* .
* .
- * vector[4] SMB2
- * vector[5] fixed body
- * vector[6] dynamic body
+ * vector[5] SMB2_TRANSFORM (empty)
+ * vector[6] SMB2
+ * vector[7] fixed body
+ * vector[8] dynamic body
* .
* .
* .
struct auth_session_info *session_info;
- struct smbXsrv_session0 *session;
+ struct smbXsrv_session *session;
};
struct smbd_server_connection {
size_t num_files;
struct files_struct *files;
- struct bitmap *file_bmap;
int real_max_open_files;
struct fsp_singleton_cache fsp_fi_cache;
- unsigned long file_gen_counter;
- int first_file;
struct pending_message_list *deferred_open_queue;