X-Git-Url: http://git.samba.org/samba.git/?a=blobdiff_plain;f=source3%2Fsmbd%2Fglobals.h;h=02f1e58b77bb006a86da509995bfdcdeefa33cff;hb=dcd0edfdc90a009a87fc8b0bafbd09e2711ebccb;hp=20bd13676bc0ed877a7ff5d9a8087282fbaf3726;hpb=e23785ae37bae80d3e356e44a00b21a0037c860e;p=garming%2Fsamba-autobuild%2F.git diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 20bd13676bc..02f1e58b77b 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -20,17 +20,13 @@ #include "system/select.h" #include "librpc/gen_ndr/smbXsrv.h" - -extern int aio_pending_size; -extern int outstanding_aio_calls; +#include "smbprofile.h" #ifdef USE_DMAPI struct smbd_dmapi_context; extern struct smbd_dmapi_context *dmapi_ctx; #endif -extern bool dfree_broken; - /* how many write cache buffers have been allocated */ extern unsigned int allocated_write_caches; @@ -93,6 +89,9 @@ extern uint16_t fnf_handle; struct conn_ctx { connection_struct *conn; uint64_t vuid; + bool need_chdir; + bool done_chdir; + userdom_struct user_info; }; /* A stack of current_user connection contexts. */ extern struct conn_ctx conn_ctx_stack[MAX_SEC_CTX_DEPTH]; @@ -144,6 +143,13 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, char **ppdata, unsigned int *pdata_size); +NTSTATUS smbd_do_setfsinfo(connection_struct *conn, + struct smb_request *req, + TALLOC_CTX *mem_ctx, + uint16_t info_level, + files_struct *fsp, + const DATA_BLOB *pdata); + NTSTATUS smbd_do_setfilepathinfo(connection_struct *conn, struct smb_request *req, TALLOC_CTX *mem_ctx, @@ -170,6 +176,7 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, uint32_t dirtype, bool dont_descend, bool ask_sharemode, + bool get_dosmode, bool (*match_fn)(TALLOC_CTX *ctx, void *private_data, const char *dname, @@ -178,6 +185,7 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, bool (*mode_fn)(TALLOC_CTX *ctx, void *private_data, struct smb_filename *smb_fname, + bool get_dosmode, uint32_t *_mode), void *private_data, char **_fname, @@ -188,22 +196,25 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx, NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx, connection_struct *conn, struct dptr_struct *dirptr, - uint16 flags2, + uint16_t flags2, const char *path_mask, - uint32 dirtype, + uint32_t dirtype, int info_level, int requires_resume_key, bool dont_descend, bool ask_sharemode, + bool get_dosmode, uint8_t align, bool do_pad, char **ppdata, char *base_data, char *end_data, int space_remaining, + struct smb_filename **smb_fname, bool *got_exact_match, int *_last_entry_off, - struct ea_list *name_list); + struct ea_list *name_list, + struct file_id *file_id); NTSTATUS smbd_calculate_access_mask(connection_struct *conn, const struct smb_filename *smb_fname, @@ -221,11 +232,16 @@ void smbd_server_connection_terminate_ex(struct smbXsrv_connection *xconn, const char *smb2_opcode_name(uint16_t opcode); bool smbd_is_smb2_header(const uint8_t *inbuf, size_t size); +bool smbd_smb2_is_compound(const struct smbd_smb2_request *req); + +NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd, + struct smbXsrv_connection **_xconn); 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 smbXsrv_connection *xconn, - const uint8_t *inpdu, size_t size); +void smbd_smb2_process_negprot(struct smbXsrv_connection *xconn, + uint64_t expected_seq_low, + const uint8_t *inpdu, size_t size); DATA_BLOB smbd_smb2_generate_outbody(struct smbd_smb2_request *req, size_t size); @@ -242,11 +258,17 @@ NTSTATUS smbd_smb2_request_done_ex(struct smbd_smb2_request *req, #define smbd_smb2_request_done(req, body, dyn) \ smbd_smb2_request_done_ex(req, NT_STATUS_OK, body, dyn, __location__) -NTSTATUS smbd_smb2_send_oplock_break(struct smbd_server_connection *sconn, +NTSTATUS smbd_smb2_send_oplock_break(struct smbXsrv_connection *xconn, struct smbXsrv_session *session, struct smbXsrv_tcon *tcon, struct smbXsrv_open *op, uint8_t oplock_level); +NTSTATUS smbd_smb2_send_lease_break(struct smbXsrv_connection *xconn, + uint16_t new_epoch, + uint32_t lease_flags, + struct smb2_lease_key *lease_key, + uint32_t current_lease_state, + uint32_t new_lease_state); NTSTATUS smbd_smb2_request_pending_queue(struct smbd_smb2_request *req, struct tevent_req *subreq, @@ -262,6 +284,9 @@ NTSTATUS smbd_smb2_request_verify_creditcharge(struct smbd_smb2_request *req, NTSTATUS smbd_smb2_request_verify_sizes(struct smbd_smb2_request *req, size_t expected_body_size); +void smb2_request_set_async_internal(struct smbd_smb2_request *req, + bool async_internal); + enum protocol_types smbd_smb2_protocol_dialect_match(const uint8_t *indyn, const int dialect_count, uint16_t *dialect); @@ -282,7 +307,7 @@ NTSTATUS smb2_write_complete_nosync(struct tevent_req *req, ssize_t nwritten, 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); -NTSTATUS smbd_smb2_request_process_find(struct smbd_smb2_request *req); +NTSTATUS smbd_smb2_request_process_query_directory(struct smbd_smb2_request *req); NTSTATUS smbd_smb2_request_process_notify(struct smbd_smb2_request *req); NTSTATUS smbd_smb2_request_process_getinfo(struct smbd_smb2_request *req); NTSTATUS smbd_smb2_request_process_setinfo(struct smbd_smb2_request *req); @@ -295,7 +320,9 @@ void smbd_smb2_request_dispatch_immediate(struct tevent_context *ctx, struct deferred_open_record; /* SMB1 -> SMB2 glue. */ -void send_break_message_smb2(files_struct *fsp, int level); +void send_break_message_smb2(files_struct *fsp, + uint32_t break_from, + uint32_t break_to); struct blocking_lock_record *get_pending_smb2req_blr(struct smbd_smb2_request *smb2req); bool push_blocking_lock_request_smb2( struct byte_range_lock *br_lck, struct smb_request *req, @@ -318,12 +345,12 @@ int map_smb2_oplock_levels_to_samba(uint8_t in_oplock_level); bool get_deferred_open_message_state_smb2(struct smbd_smb2_request *smb2req, struct timeval *p_request_time, struct deferred_open_record **open_rec); -bool open_was_deferred_smb2(struct smbd_server_connection *sconn, - uint64_t mid); +bool open_was_deferred_smb2( + struct smbXsrv_connection *xconn, uint64_t mid); void remove_deferred_open_message_smb2( - struct smbd_server_connection *sconn, uint64_t mid); + struct smbXsrv_connection *xconn, uint64_t mid); bool schedule_deferred_open_message_smb2( - struct smbd_server_connection *sconn, uint64_t mid); + struct smbXsrv_connection *xconn, uint64_t mid); bool push_deferred_open_message_smb2(struct smbd_smb2_request *smb2req, struct timeval request_time, struct timeval timeout, @@ -332,20 +359,19 @@ bool push_deferred_open_message_smb2(struct smbd_smb2_request *smb2req, struct smbXsrv_client; +struct smbXsrv_preauth { + uint8_t sha512_value[64]; +}; + struct smbXsrv_connection { struct smbXsrv_connection *prev, *next; struct smbXsrv_client *client; - struct smbd_server_connection *sconn; - const struct tsocket_address *local_address; const struct tsocket_address *remote_address; const char *remote_hostname; - struct tevent_context *ev_ctx; - struct messaging_context *msg_ctx; - enum protocol_types protocol; struct { @@ -490,6 +516,7 @@ struct smbXsrv_connection { struct { uint32_t capabilities; struct GUID guid; + bool guid_verified; uint16_t security_mode; uint16_t num_dialects; uint16_t *dialects; @@ -502,28 +529,13 @@ struct smbXsrv_connection { uint32_t max_trans; uint32_t max_read; uint32_t max_write; + uint16_t cipher; } server; + struct smbXsrv_preauth preauth; + struct smbd_smb2_request *requests; } smb2; - - uint64_t smbd_idle_profstamp; - - /* - * this session_table is used for SMB1 and SMB2, - */ - struct smbXsrv_session_table *session_table; - uint64_t last_session_id; - /* - * 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; }; const char *smbXsrv_connection_dbg(const struct smbXsrv_connection *xconn); @@ -531,24 +543,65 @@ const char *smbXsrv_connection_dbg(const struct smbXsrv_connection *xconn); NTSTATUS smbXsrv_version_global_init(const struct server_id *server_id); uint32_t smbXsrv_version_global_current(void); +struct smbXsrv_client_table; +NTSTATUS smbXsrv_client_global_init(void); +NTSTATUS smbXsrv_client_create(TALLOC_CTX *mem_ctx, + struct tevent_context *ev_ctx, + struct messaging_context *msg_ctx, + NTTIME now, + struct smbXsrv_client **_client); +NTSTATUS smbXsrv_client_update(struct smbXsrv_client *client); +NTSTATUS smbXsrv_client_remove(struct smbXsrv_client *client); +NTSTATUS smb2srv_client_lookup_global(struct smbXsrv_client *client, + struct GUID client_guid, + TALLOC_CTX *mem_ctx, + struct smbXsrv_client_global0 **_pass); +NTSTATUS smb2srv_client_connection_pass(struct smbd_smb2_request *smb2req, + struct smbXsrv_client_global0 *global); + NTSTATUS smbXsrv_connection_init_tables(struct smbXsrv_connection *conn, enum protocol_types protocol); -NTSTATUS smbXsrv_session_global_init(void); +NTSTATUS smbXsrv_session_global_init(struct messaging_context *msg_ctx); NTSTATUS smbXsrv_session_create(struct smbXsrv_connection *conn, NTTIME now, struct smbXsrv_session **_session); +NTSTATUS smbXsrv_session_add_channel(struct smbXsrv_session *session, + struct smbXsrv_connection *conn, + struct smbXsrv_channel_global0 **_c); NTSTATUS smbXsrv_session_update(struct smbXsrv_session *session); +struct smbXsrv_channel_global0; +NTSTATUS smbXsrv_session_find_channel(const struct smbXsrv_session *session, + const struct smbXsrv_connection *conn, + struct smbXsrv_channel_global0 **_c); +NTSTATUS smbXsrv_session_find_auth(const struct smbXsrv_session *session, + const struct smbXsrv_connection *conn, + NTTIME now, + struct smbXsrv_session_auth0 **_a); +NTSTATUS smbXsrv_session_create_auth(struct smbXsrv_session *session, + struct smbXsrv_connection *conn, + NTTIME now, + uint8_t in_flags, + uint8_t in_security_mode, + struct smbXsrv_session_auth0 **_a); +struct tevent_req *smb2srv_session_shutdown_send(TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct smbXsrv_session *session, + struct smbd_smb2_request *current_req); +NTSTATUS smb2srv_session_shutdown_recv(struct tevent_req *req); NTSTATUS smbXsrv_session_logoff(struct smbXsrv_session *session); -NTSTATUS smbXsrv_session_logoff_all(struct smbXsrv_connection *conn); +NTSTATUS smbXsrv_session_logoff_all(struct smbXsrv_client *client); NTSTATUS smb1srv_session_table_init(struct smbXsrv_connection *conn); NTSTATUS smb1srv_session_lookup(struct smbXsrv_connection *conn, uint16_t vuid, NTTIME now, struct smbXsrv_session **session); NTSTATUS smb2srv_session_table_init(struct smbXsrv_connection *conn); -NTSTATUS smb2srv_session_lookup(struct smbXsrv_connection *conn, - uint64_t session_id, NTTIME now, - struct smbXsrv_session **session); +NTSTATUS smb2srv_session_lookup_conn(struct smbXsrv_connection *conn, + uint64_t session_id, NTTIME now, + struct smbXsrv_session **session); +NTSTATUS smb2srv_session_lookup_client(struct smbXsrv_client *client, + 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 *), @@ -571,7 +624,7 @@ NTSTATUS smb1srv_tcon_create(struct smbXsrv_connection *conn, NTSTATUS smb1srv_tcon_lookup(struct smbXsrv_connection *conn, uint16_t tree_id, NTTIME now, struct smbXsrv_tcon **tcon); -NTSTATUS smb1srv_tcon_disconnect_all(struct smbXsrv_connection *conn); +NTSTATUS smb1srv_tcon_disconnect_all(struct smbXsrv_client *client); NTSTATUS smb2srv_tcon_table_init(struct smbXsrv_session *session); NTSTATUS smb2srv_tcon_create(struct smbXsrv_session *session, NTTIME now, @@ -603,6 +656,10 @@ NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn, uint64_t volatile_id, NTTIME now, struct smbXsrv_open **_open); +NTSTATUS smb2srv_open_lookup_replay_cache(struct smbXsrv_connection *conn, + const struct GUID *create_guid, + NTTIME now, + struct smbXsrv_open **_open); NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn, struct auth_session_info *session_info, uint64_t persistent_id, @@ -615,6 +672,11 @@ NTSTATUS smbXsrv_open_global_traverse( void *private_data); NTSTATUS smbXsrv_open_cleanup(uint64_t persistent_id); +bool smbXsrv_is_encrypted(uint8_t encryption_flags); +bool smbXsrv_is_partially_encrypted(uint8_t encryption_flags); +bool smbXsrv_set_crypto_flag(uint8_t *flags, uint8_t flag); +bool smbXsrv_is_signed(uint8_t signing_flags); +bool smbXsrv_is_partially_signed(uint8_t signing_flags); struct smbd_smb2_send_queue { struct smbd_smb2_send_queue *prev, *next; @@ -645,10 +707,20 @@ struct smbd_smb2_request { int current_idx; bool do_signing; + /* Was the request encrypted? */ + bool was_encrypted; + /* Should we encrypt? */ bool do_encryption; struct tevent_timer *async_te; bool compound_related; + /* + * Give the implementation of an SMB2 req a way to tell the SMB2 request + * processing engine that the internal request is going async, while + * preserving synchronous SMB2 behaviour. + */ + bool async_internal; + /* * the encryption key for the whole * compound chain @@ -659,13 +731,24 @@ struct smbd_smb2_request { * request/response of a compound chain */ DATA_BLOB last_key; + struct smbXsrv_preauth *preauth; struct timeval request_time; + SMBPROFILE_IOBYTES_ASYNC_STATE(profile); + /* fake smb1 request. */ struct smb_request *smb1req; struct files_struct *compat_chain_fsp; + /* + * Keep track of whether the outstanding request counters + * had been updated in dispatch, so that they need to be + * adapted again in reply. + */ + bool request_counters_updated; + uint64_t channel_generation; + /* * The sub request for async backend calls. * This is used for SMB2 Cancel. @@ -787,15 +870,17 @@ struct user_struct { struct smbXsrv_session *session; }; +struct pthreadpool_tevent; + struct smbd_server_connection { const struct tsocket_address *local_address; const struct tsocket_address *remote_address; const char *remote_hostname; struct tevent_context *ev_ctx; struct messaging_context *msg_ctx; - struct sys_notify_context *sys_notify_ctx; struct notify_context *notify_ctx; bool using_smb2; + bool aapl_zero_file_id; /* Apple-specific */ int trans_num; size_t num_users; @@ -853,13 +938,8 @@ struct smbd_server_connection { } locks; } smb2; - /* - * Link into libasys for asynchronous operations - */ - struct asys_context *asys_ctx; - struct tevent_fd *asys_fde; + struct pthreadpool_tevent *pool; - struct smbXsrv_connection *conn; struct smbXsrv_client *client; };