2009-01-08 12:03:45 +01:00
/*
Unix SMB / Netbios implementation .
smbd globals
Copyright ( C ) Stefan Metzmacher 2009
2010-04-28 14:56:12 -07:00
Copyright ( C ) Jeremy Allison 2010
2009-01-08 12:03:45 +01:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2011-02-03 21:55:02 +01:00
# include "system/select.h"
2011-12-15 14:45:56 +01:00
# include "librpc/gen_ndr/smbXsrv.h"
2011-02-03 21:55:02 +01:00
2012-06-06 09:23:22 +10:00
# if defined(HAVE_AIO)
2009-01-08 12:03:45 +01:00
struct aio_extra ;
extern struct aio_extra * aio_list_head ;
2009-01-22 18:04:17 +01:00
extern struct tevent_signal * aio_signal_event ;
2009-01-08 12:03:45 +01:00
extern int aio_pending_size ;
extern int outstanding_aio_calls ;
# endif
# 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 ;
/* A singleton cache to speed up searching by dev/inode. */
struct fsp_singleton_cache {
files_struct * fsp ;
struct file_id id ;
} ;
extern const struct mangle_fns * mangle_fns ;
extern unsigned char * chartest ;
2011-05-05 11:25:29 +02:00
struct tdb_context ;
extern struct tdb_context * tdb_mangled_cache ;
2009-01-08 12:03:45 +01:00
/*
this determines how many characters are used from the original filename
in the 8.3 mangled name . A larger value leads to a weaker hash and more collisions .
The largest possible value is 6.
*/
extern unsigned mangle_prefix ;
struct msg_state ;
extern bool logged_ioctl_message ;
extern int trans_num ;
extern time_t last_smb_conf_reload_time ;
extern time_t last_printer_reload_time ;
2011-08-03 17:04:50 -04:00
extern pid_t background_lpq_updater_pid ;
2009-01-08 12:03:45 +01:00
/****************************************************************************
structure to hold a linked list of queued messages .
for processing .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
extern uint32_t common_flags2 ;
2011-10-19 16:33:04 +11:00
extern struct smb_trans_enc_state * partial_srv_trans_enc_ctx ;
extern struct smb_trans_enc_state * srv_trans_enc_ctx ;
2009-01-08 12:03:45 +01:00
struct sec_ctx {
2011-02-11 18:49:15 +11:00
struct security_unix_token ut ;
2010-08-26 22:08:22 +10:00
struct security_token * token ;
2009-01-08 12:03:45 +01:00
} ;
/* A stack of security contexts. We include the current context as being
the first one , so there is room for another MAX_SEC_CTX_DEPTH more . */
extern struct sec_ctx sec_ctx_stack [ MAX_SEC_CTX_DEPTH + 1 ] ;
extern int sec_ctx_stack_ndx ;
extern bool become_uid_done ;
extern bool become_gid_done ;
extern connection_struct * last_conn ;
extern uint16_t last_flags ;
extern uint32_t global_client_caps ;
extern uint16_t fnf_handle ;
struct conn_ctx {
connection_struct * conn ;
2012-06-05 15:27:38 +02:00
uint64_t vuid ;
2009-01-08 12:03:45 +01:00
} ;
/* A stack of current_user connection contexts. */
extern struct conn_ctx conn_ctx_stack [ MAX_SEC_CTX_DEPTH ] ;
extern int conn_ctx_stack_ndx ;
struct vfs_init_function_entry ;
extern struct vfs_init_function_entry * backends ;
extern char * sparse_buf ;
2010-07-13 09:30:35 -07:00
extern char * LastDir ;
2009-01-08 12:03:45 +01:00
2011-12-13 14:58:50 +01:00
struct smbd_parent_context ;
extern struct smbd_parent_context * am_parent ;
2009-01-08 12:03:45 +01:00
extern struct memcache * smbd_memcache_ctx ;
extern bool exit_firsttime ;
2009-05-14 14:17:28 +02:00
struct tstream_context ;
struct smbd_smb2_request ;
2010-07-19 16:45:16 -07:00
DATA_BLOB negprot_spnego ( TALLOC_CTX * ctx , struct smbd_server_connection * sconn ) ;
2009-05-19 10:46:35 +02:00
2010-03-31 17:40:30 -07:00
void smbd_lock_socket ( struct smbd_server_connection * sconn ) ;
void smbd_unlock_socket ( struct smbd_server_connection * sconn ) ;
2010-03-18 09:17:43 +01:00
2009-07-07 18:09:16 +02:00
NTSTATUS smbd_do_locking ( struct smb_request * req ,
files_struct * fsp ,
uint8_t type ,
int32_t timeout ,
uint16_t num_ulocks ,
struct smbd_lock_element * ulocks ,
uint16_t num_locks ,
struct smbd_lock_element * locks ,
bool * async ) ;
2009-07-10 20:02:44 +02:00
NTSTATUS smbd_do_qfilepathinfo ( connection_struct * conn ,
TALLOC_CTX * mem_ctx ,
uint16_t info_level ,
files_struct * fsp ,
2009-08-12 15:08:23 -07:00
struct smb_filename * smb_fname ,
2009-07-10 20:02:44 +02:00
bool delete_pending ,
struct timespec write_time_ts ,
struct ea_list * ea_list ,
int lock_data_count ,
char * lock_data ,
uint16_t flags2 ,
unsigned int max_data_bytes ,
char * * ppdata ,
unsigned int * pdata_size ) ;
2009-07-13 09:01:56 +02:00
NTSTATUS smbd_do_setfilepathinfo ( connection_struct * conn ,
struct smb_request * req ,
TALLOC_CTX * mem_ctx ,
uint16_t info_level ,
files_struct * fsp ,
struct smb_filename * smb_fname ,
char * * ppdata , int total_data ,
int * ret_data_size ) ;
2009-07-13 12:05:34 +02:00
NTSTATUS smbd_do_qfsinfo ( connection_struct * conn ,
TALLOC_CTX * mem_ctx ,
uint16_t info_level ,
uint16_t flags2 ,
unsigned int max_data_bytes ,
char * * ppdata ,
int * ret_data_len ) ;
2009-08-06 20:53:13 +02:00
bool smbd_dirptr_get_entry ( TALLOC_CTX * ctx ,
struct dptr_struct * dirptr ,
const char * mask ,
uint32_t dirtype ,
bool dont_descend ,
bool ask_sharemode ,
bool ( * match_fn ) ( TALLOC_CTX * ctx ,
void * private_data ,
const char * dname ,
const char * mask ,
char * * _fname ) ,
bool ( * mode_fn ) ( TALLOC_CTX * ctx ,
void * private_data ,
struct smb_filename * smb_fname ,
uint32_t * _mode ) ,
void * private_data ,
char * * _fname ,
struct smb_filename * * _smb_fname ,
uint32_t * _mode ,
long * _prev_offset ) ;
2009-08-14 13:23:19 +02:00
bool smbd_dirptr_lanman2_entry ( TALLOC_CTX * ctx ,
connection_struct * conn ,
struct dptr_struct * dirptr ,
uint16 flags2 ,
const char * path_mask ,
uint32 dirtype ,
int info_level ,
int requires_resume_key ,
bool dont_descend ,
bool ask_sharemode ,
uint8_t align ,
bool do_pad ,
char * * ppdata ,
char * base_data ,
char * end_data ,
int space_remaining ,
bool * out_of_space ,
bool * got_exact_match ,
int * _last_entry_off ,
struct ea_list * name_list ) ;
2011-07-10 13:00:25 +02:00
NTSTATUS smbd_calculate_access_mask ( connection_struct * conn ,
const struct smb_filename * smb_fname ,
uint32_t access_mask ,
uint32_t * access_mask_out ) ;
2009-08-19 18:03:43 +02:00
2010-06-12 13:08:31 +02:00
void smbd_notify_cancel_by_smbreq ( const struct smb_request * smbreq ) ;
2009-08-15 10:07:00 +02:00
2009-06-02 16:07:08 +02:00
void smbd_server_connection_terminate_ex ( struct smbd_server_connection * sconn ,
const char * reason ,
const char * location ) ;
# define smbd_server_connection_terminate(sconn, reason) \
smbd_server_connection_terminate_ex ( sconn , reason , __location__ )
2010-07-04 18:02:19 +02:00
const char * smb2_opcode_name ( uint16_t opcode ) ;
2009-05-14 14:17:28 +02:00
bool smbd_is_smb2_header ( const uint8_t * inbuf , size_t size ) ;
2009-05-19 10:47:51 +02:00
void reply_smb2002 ( struct smb_request * req , uint16_t choice ) ;
2011-09-05 13:14:40 +02:00
void reply_smb20ff ( struct smb_request * req , uint16_t choice ) ;
2009-08-07 15:21:07 +02:00
void smbd_smb2_first_negprot ( struct smbd_server_connection * sconn ,
2009-05-14 14:17:28 +02:00
const uint8_t * inbuf , size_t size ) ;
2009-06-05 11:05:03 +02:00
NTSTATUS smbd_smb2_request_error_ex ( struct smbd_smb2_request * req ,
NTSTATUS status ,
DATA_BLOB * info ,
const char * location ) ;
# define smbd_smb2_request_error(req, status) \
smbd_smb2_request_error_ex ( req , status , NULL , __location__ )
2009-05-20 19:35:39 +02:00
NTSTATUS smbd_smb2_request_done_ex ( struct smbd_smb2_request * req ,
NTSTATUS status ,
2009-06-05 11:05:03 +02:00
DATA_BLOB body , DATA_BLOB * dyn ,
const char * location ) ;
# define smbd_smb2_request_done(req, body, dyn) \
smbd_smb2_request_done_ex ( req , NT_STATUS_OK , body , dyn , __location__ )
2009-05-14 14:17:28 +02:00
2009-06-09 20:44:13 +02:00
NTSTATUS smbd_smb2_send_oplock_break ( struct smbd_server_connection * sconn ,
2010-05-19 19:28:26 -07:00
uint64_t file_id_persistent ,
2009-06-09 20:44:13 +02:00
uint64_t file_id_volatile ,
uint8_t oplock_level ) ;
2009-08-15 10:01:38 +02:00
NTSTATUS smbd_smb2_request_pending_queue ( struct smbd_smb2_request * req ,
2011-11-14 15:42:55 +01:00
struct tevent_req * subreq ,
uint32_t defer_time ) ;
2009-06-09 22:33:32 +02:00
2009-06-02 11:54:00 +02:00
struct smb_request * smbd_smb2_fake_smb_request ( struct smbd_smb2_request * req ) ;
2010-06-08 21:20:07 -07:00
void remove_smb2_chained_fsp ( files_struct * fsp ) ;
2009-06-02 11:54:00 +02:00
2012-02-27 17:49:12 -08:00
NTSTATUS smbd_smb2_request_verify_creditcharge ( struct smbd_smb2_request * req ,
uint32_t data_length ) ;
2011-09-06 14:00:04 +02:00
NTSTATUS smbd_smb2_request_verify_sizes ( struct smbd_smb2_request * req ,
size_t expected_body_size ) ;
2009-05-14 15:32:02 +02:00
NTSTATUS smbd_smb2_request_process_negprot ( struct smbd_smb2_request * req ) ;
2009-05-15 11:20:34 +02:00
NTSTATUS smbd_smb2_request_process_sesssetup ( struct smbd_smb2_request * req ) ;
2009-05-15 11:40:19 +02:00
NTSTATUS smbd_smb2_request_process_logoff ( struct smbd_smb2_request * req ) ;
2009-05-15 11:50:20 +02:00
NTSTATUS smbd_smb2_request_process_tcon ( struct smbd_smb2_request * req ) ;
2009-05-22 12:42:24 +02:00
NTSTATUS smbd_smb2_request_process_tdis ( struct smbd_smb2_request * req ) ;
2009-05-28 00:07:26 +02:00
NTSTATUS smbd_smb2_request_process_create ( struct smbd_smb2_request * req ) ;
2009-06-02 13:42:28 +02:00
NTSTATUS smbd_smb2_request_process_close ( struct smbd_smb2_request * req ) ;
2009-06-02 12:06:34 +02:00
NTSTATUS smbd_smb2_request_process_flush ( struct smbd_smb2_request * req ) ;
2009-06-02 12:38:37 +02:00
NTSTATUS smbd_smb2_request_process_read ( struct smbd_smb2_request * req ) ;
2010-06-10 13:20:37 -07:00
NTSTATUS smb2_read_complete ( struct tevent_req * req , ssize_t nread , int err ) ;
2009-05-28 01:28:34 +02:00
NTSTATUS smbd_smb2_request_process_write ( struct smbd_smb2_request * req ) ;
2010-06-10 13:20:37 -07:00
NTSTATUS smb2_write_complete ( struct tevent_req * req , ssize_t nwritten , int err ) ;
2009-07-02 19:26:05 +02:00
NTSTATUS smbd_smb2_request_process_lock ( struct smbd_smb2_request * req ) ;
2009-06-05 17:32:58 +02:00
NTSTATUS smbd_smb2_request_process_ioctl ( struct smbd_smb2_request * req ) ;
2009-05-15 12:07:28 +02:00
NTSTATUS smbd_smb2_request_process_keepalive ( struct smbd_smb2_request * req ) ;
2009-07-02 12:28:58 +02:00
NTSTATUS smbd_smb2_request_process_find ( struct smbd_smb2_request * req ) ;
2009-06-29 22:31:13 +02:00
NTSTATUS smbd_smb2_request_process_notify ( struct smbd_smb2_request * req ) ;
2009-07-02 10:17:30 +02:00
NTSTATUS smbd_smb2_request_process_getinfo ( struct smbd_smb2_request * req ) ;
2009-07-02 11:40:07 +02:00
NTSTATUS smbd_smb2_request_process_setinfo ( struct smbd_smb2_request * req ) ;
2009-07-02 11:56:23 +02:00
NTSTATUS smbd_smb2_request_process_break ( struct smbd_smb2_request * req ) ;
2010-04-22 23:52:19 -07:00
NTSTATUS smbd_smb2_request_dispatch ( struct smbd_smb2_request * req ) ;
void smbd_smb2_request_dispatch_immediate ( struct tevent_context * ctx ,
struct tevent_immediate * im ,
void * private_data ) ;
2009-05-14 15:32:02 +02:00
2010-04-09 19:26:34 -07:00
/* SMB1 -> SMB2 glue. */
2010-04-24 00:29:41 -07:00
void send_break_message_smb2 ( files_struct * fsp , int level ) ;
2010-04-30 21:03:20 -07:00
struct blocking_lock_record * get_pending_smb2req_blr ( struct smbd_smb2_request * smb2req ) ;
2010-04-09 19:26:34 -07:00
bool push_blocking_lock_request_smb2 ( struct byte_range_lock * br_lck ,
2010-04-08 22:15:55 -07:00
struct smb_request * req ,
files_struct * fsp ,
int lock_timeout ,
int lock_num ,
2010-05-07 06:20:50 -07:00
uint64_t smblctx ,
2010-04-08 22:15:55 -07:00
enum brl_type lock_type ,
enum brl_flavour lock_flav ,
uint64_t offset ,
uint64_t count ,
2010-05-07 06:20:50 -07:00
uint64_t blocking_smblctx ) ;
2010-06-12 14:52:09 +02:00
void process_blocking_lock_queue_smb2 (
struct smbd_server_connection * sconn , struct timeval tv_curr ) ;
2010-04-29 17:08:12 -07:00
void cancel_pending_lock_requests_by_fid_smb2 ( files_struct * fsp ,
2010-05-07 01:20:26 -07:00
struct byte_range_lock * br_lck ,
enum file_close_type close_type ) ;
2010-04-22 23:52:19 -07:00
/* From smbd/smb2_create.c */
2010-04-24 00:29:41 -07:00
int map_smb2_oplock_levels_to_samba ( uint8_t in_oplock_level ) ;
2010-04-22 23:52:19 -07:00
bool get_deferred_open_message_state_smb2 ( struct smbd_smb2_request * smb2req ,
2010-04-09 19:26:34 -07:00
struct timeval * p_request_time ,
void * * pp_state ) ;
2010-06-12 14:44:53 +02:00
bool open_was_deferred_smb2 ( struct smbd_server_connection * sconn ,
uint64_t mid ) ;
2010-06-12 14:48:42 +02:00
void remove_deferred_open_message_smb2 (
struct smbd_server_connection * sconn , uint64_t mid ) ;
void schedule_deferred_open_message_smb2 (
struct smbd_server_connection * sconn , uint64_t mid ) ;
2010-04-22 23:52:19 -07:00
bool push_deferred_open_message_smb2 ( struct smbd_smb2_request * smb2req ,
2010-04-09 19:26:34 -07:00
struct timeval request_time ,
struct timeval timeout ,
2010-04-23 13:10:15 -07:00
struct file_id id ,
2010-04-09 19:26:34 -07:00
char * private_data ,
size_t priv_len ) ;
2010-04-07 19:00:44 -07:00
2011-12-15 14:45:56 +01:00
struct smbXsrv_connection {
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 {
struct {
uint32_t capabilities ;
struct GUID guid ;
uint16_t security_mode ;
uint16_t num_dialects ;
uint16_t * dialects ;
} client ;
struct {
uint32_t capabilities ;
struct GUID guid ;
uint16_t security_mode ;
uint16_t dialect ;
uint32_t max_trans ;
uint32_t max_read ;
uint32_t max_write ;
} server ;
} smb2 ;
2012-05-24 23:41:43 +02:00
struct msg_state * msg_state ;
2012-06-20 08:53:10 +02:00
uint64_t smbd_idle_profstamp ;
2011-12-15 14:45:56 +01:00
struct smbXsrv_session_table * session_table ;
2012-03-16 16:32:28 +01:00
struct smbXsrv_tcon_table * tcon_table ;
2011-12-15 14:45:56 +01:00
} ;
2012-05-08 16:01:21 +02:00
NTSTATUS smbXsrv_version_global_init ( const struct server_id * server_id ) ;
uint32_t smbXsrv_version_global_current ( void ) ;
2011-12-15 14:45:56 +01:00
NTSTATUS smbXsrv_connection_init_tables ( struct smbXsrv_connection * conn ,
enum protocol_types protocol ) ;
2011-12-15 14:45:56 +01:00
NTSTATUS smbXsrv_session_global_init ( void ) ;
NTSTATUS smbXsrv_session_create ( struct smbXsrv_connection * conn ,
NTTIME now ,
struct smbXsrv_session * * _session ) ;
NTSTATUS smbXsrv_session_update ( struct smbXsrv_session * session ) ;
NTSTATUS smbXsrv_session_logoff ( struct smbXsrv_session * session ) ;
NTSTATUS smbXsrv_session_logoff_all ( struct smbXsrv_connection * conn ) ;
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 ) ;
2012-03-16 16:32:28 +01:00
NTSTATUS smbXsrv_tcon_global_init ( void ) ;
NTSTATUS smbXsrv_tcon_update ( struct smbXsrv_tcon * tcon ) ;
NTSTATUS smbXsrv_tcon_disconnect ( struct smbXsrv_tcon * tcon , uint64_t vuid ) ;
NTSTATUS smb1srv_tcon_table_init ( struct smbXsrv_connection * conn ) ;
NTSTATUS smb1srv_tcon_create ( struct smbXsrv_connection * conn ,
NTTIME now ,
struct smbXsrv_tcon * * _tcon ) ;
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 smb2srv_tcon_table_init ( struct smbXsrv_session * session ) ;
NTSTATUS smb2srv_tcon_create ( struct smbXsrv_session * session ,
NTTIME now ,
struct smbXsrv_tcon * * _tcon ) ;
NTSTATUS smb2srv_tcon_lookup ( struct smbXsrv_session * session ,
uint32_t tree_id , NTTIME now ,
struct smbXsrv_tcon * * tcon ) ;
NTSTATUS smb2srv_tcon_disconnect_all ( struct smbXsrv_session * session ) ;
2009-05-14 14:17:28 +02:00
struct smbd_smb2_request {
2009-06-09 21:29:40 +02:00
struct smbd_smb2_request * prev , * next ;
2009-05-14 14:17:28 +02:00
TALLOC_CTX * mem_pool ;
2009-06-09 21:29:40 +02:00
struct smbd_smb2_request * * parent ;
2009-05-14 14:17:28 +02:00
2009-08-07 15:21:07 +02:00
struct smbd_server_connection * sconn ;
2009-05-14 14:17:28 +02:00
2009-05-20 20:51:10 +02:00
/* the session the request operates on, maybe NULL */
2012-03-27 11:09:05 +02:00
struct smbXsrv_session * session ;
2011-10-27 16:35:28 +02:00
uint64_t last_session_id ;
2009-05-20 20:51:10 +02:00
2009-05-15 11:50:20 +02:00
/* the tcon the request operates on, maybe NULL */
2012-03-27 11:09:05 +02:00
struct smbXsrv_tcon * tcon ;
2011-10-27 16:35:28 +02:00
uint32_t last_tid ;
2009-05-15 11:50:20 +02:00
2009-05-14 14:17:28 +02:00
int current_idx ;
2009-05-22 22:58:39 +02:00
bool do_signing ;
2011-11-09 11:47:33 +01:00
struct tevent_timer * async_te ;
2010-04-17 21:20:17 -07:00
bool cancelled ;
2011-08-25 23:33:41 +02:00
bool compound_related ;
2009-05-14 14:17:28 +02:00
2012-04-11 16:54:17 +02:00
struct timeval request_time ;
2010-06-08 21:20:07 -07:00
/* fake smb1 request. */
struct smb_request * smb1req ;
2009-06-05 20:02:21 +02:00
struct files_struct * compat_chain_fsp ;
2009-06-08 13:30:32 +02:00
NTSTATUS next_status ;
2009-08-15 10:01:38 +02:00
/*
* The sub request for async backend calls .
* This is used for SMB2 Cancel .
*/
struct tevent_req * subreq ;
2009-05-14 14:17:28 +02:00
struct {
/* the NBT header is not allocated */
uint8_t nbt_hdr [ 4 ] ;
/*
* vector [ 0 ] NBT
* .
* vector [ 1 ] SMB2
* vector [ 2 ] fixed body
* vector [ 3 ] dynamic body
* .
* .
* .
* vector [ 4 ] SMB2
* vector [ 5 ] fixed body
* vector [ 6 ] dynamic body
* .
* .
* .
*/
struct iovec * vector ;
int vector_count ;
} in ;
struct {
/* the NBT header is not allocated */
uint8_t nbt_hdr [ 4 ] ;
/*
* vector [ 0 ] NBT
* .
* vector [ 1 ] SMB2
* vector [ 2 ] fixed body
* vector [ 3 ] dynamic body
* .
* .
* .
* vector [ 4 ] SMB2
* vector [ 5 ] fixed body
* vector [ 6 ] dynamic body
* .
* .
* .
*/
struct iovec * vector ;
int vector_count ;
} out ;
} ;
2009-05-15 11:20:34 +02:00
struct smbd_server_connection ;
2012-06-05 12:07:43 +02:00
struct user_struct ;
2009-05-15 11:20:34 +02:00
2011-08-02 17:13:23 +02:00
struct pending_message_list ;
2009-05-26 12:07:16 +02:00
struct pending_auth_data ;
2012-06-05 12:07:43 +02:00
struct user_struct {
struct user_struct * next , * prev ;
2012-06-05 18:17:15 +02:00
uint64_t vuid ; /* Tag for this entry. */
2012-06-05 12:07:43 +02:00
char * session_keystr ; /* used by utmp and pam session code.
TDB key string */
int homes_snum ;
struct auth_session_info * session_info ;
2012-03-16 15:01:27 +01:00
struct smbXsrv_session0 * session ;
2012-06-05 12:07:43 +02:00
} ;
2009-01-08 15:38:47 +01:00
struct smbd_server_connection {
2010-08-14 14:52:59 +02:00
int sock ;
2010-04-27 13:36:21 +02:00
const struct tsocket_address * local_address ;
const struct tsocket_address * remote_address ;
2011-06-16 15:39:25 +02:00
const char * remote_hostname ;
2011-12-12 13:18:59 +01:00
struct tevent_context * ev_ctx ;
2010-07-04 17:50:04 +02:00
struct messaging_context * msg_ctx ;
2012-03-22 14:58:24 +01:00
struct sys_notify_context * sys_notify_ctx ;
2012-03-21 12:18:09 +01:00
struct notify_context * notify_ctx ;
2009-05-26 15:20:36 +02:00
struct {
bool got_session ;
} nbt ;
2010-06-09 19:12:02 -07:00
bool using_smb2 ;
2010-08-24 20:47:29 +02:00
int trans_num ;
2010-09-27 06:06:02 +02:00
2012-03-03 05:41:43 +01:00
size_t num_users ;
struct user_struct * users ;
2012-03-03 05:43:31 +01:00
size_t num_connections ;
struct connection_struct * connections ;
2012-03-03 05:44:16 +01:00
size_t num_files ;
2010-09-27 02:29:36 +02:00
struct files_struct * files ;
2012-03-03 05:44:16 +01:00
2010-09-27 06:06:02 +02:00
struct bitmap * file_bmap ;
int real_max_open_files ;
struct fsp_singleton_cache fsp_fi_cache ;
unsigned long file_gen_counter ;
int first_file ;
2011-08-02 17:13:23 +02:00
struct pending_message_list * deferred_open_queue ;
2011-03-17 16:16:54 -07:00
/* open directory handles. */
struct {
struct bitmap * dptr_bmap ;
struct dptr_struct * dirptrs ;
int dirhandles_open ;
} searches ;
2011-07-07 14:59:41 -07:00
uint64_t num_requests ;
2012-05-24 23:15:08 +02:00
/* Current number of oplocks we have outstanding. */
struct {
int32_t exclusive_open ;
int32_t level_II_open ;
2012-05-24 23:33:32 +02:00
struct kernel_oplocks * kernel_ops ;
2012-05-24 23:15:08 +02:00
} oplocks ;
2009-05-26 10:48:12 +02:00
struct {
struct fd_event * fde ;
2010-03-22 08:42:13 +01:00
struct {
/*
2010-08-28 17:25:22 +02:00
* fd for the fcntl lock mutexing access to our sock
2010-03-22 08:42:13 +01:00
*/
int socket_lock_fd ;
/*
* fd for the trusted pipe from
* echo handler child
*/
int trusted_fd ;
/*
* fde for the trusted_fd
*/
struct fd_event * trusted_fde ;
2010-03-31 17:40:30 -07:00
/*
* Reference count for the fcntl lock to
* allow recursive locks .
*/
int ref_count ;
2010-03-22 08:42:13 +01:00
} echo_handler ;
2009-05-26 12:48:58 +02:00
struct {
bool encrypted_passwords ;
bool spnego ;
2012-02-03 17:09:37 +11:00
struct auth4_context * auth_context ;
2009-05-26 12:48:58 +02:00
bool done ;
2009-05-26 14:56:08 +02:00
/*
* Size of the data we can receive . Set by us .
* Can be modified by the max xmit parameter .
*/
int max_recv ;
2009-05-26 12:48:58 +02:00
} negprot ;
2011-09-12 05:12:50 +02:00
struct {
uint16_t client_major ;
uint16_t client_minor ;
uint32_t client_cap_low ;
uint32_t client_cap_high ;
} unix_info ;
2009-05-26 15:21:16 +02:00
struct {
bool done_sesssetup ;
/*
* Size of data we can send to client . Set
* by the client for all protocols above CORE .
* Set by us for CORE protocol .
*/
int max_send ;
2012-06-05 18:17:15 +02:00
uint64_t last_session_tag ;
2009-05-26 15:21:16 +02:00
} sessions ;
2009-05-26 10:48:12 +02:00
struct smb_signing_state * signing_state ;
2009-06-30 10:17:38 +02:00
struct notify_mid_map * notify_mid_maps ;
2009-08-06 12:15:51 +02:00
2010-04-29 16:50:15 -07:00
struct {
/* dlink list we store pending lock records on. */
struct blocking_lock_record * blocking_lock_queue ;
/* dlink list we move cancelled lock records onto. */
struct blocking_lock_record * blocking_lock_cancelled_queue ;
/* The event that makes us process our blocking lock queue */
struct timed_event * brl_timeout ;
bool blocking_lock_unlock_state ;
bool blocking_lock_cancel_state ;
} locks ;
2009-05-26 10:48:12 +02:00
} smb1 ;
2009-05-14 14:17:28 +02:00
struct {
struct tevent_queue * recv_queue ;
struct tevent_queue * send_queue ;
struct tstream_context * stream ;
2011-09-05 13:14:40 +02:00
bool negprot_2ff ;
2010-04-30 21:03:20 -07:00
struct {
/* The event that makes us process our blocking lock queue */
struct timed_event * brl_timeout ;
bool blocking_lock_unlock_state ;
} locks ;
2009-06-09 21:29:40 +02:00
struct smbd_smb2_request * requests ;
2010-12-10 15:46:41 -08:00
uint64_t seqnum_low ;
uint32_t credits_granted ;
uint32_t max_credits ;
2011-09-23 17:18:14 +02:00
uint32_t max_trans ;
uint32_t max_read ;
uint32_t max_write ;
2012-02-27 17:45:09 -08:00
bool supports_multicredit ;
2010-12-10 15:46:41 -08:00
struct bitmap * credits_bitmap ;
2011-08-26 14:23:26 -07:00
bool compound_related_in_progress ;
2009-05-14 14:17:28 +02:00
} smb2 ;
2011-12-15 14:45:56 +01:00
struct smbXsrv_connection * conn ;
2009-01-08 15:38:47 +01:00
} ;
2009-05-14 14:17:28 +02:00
2012-05-24 13:46:11 +02:00
extern struct smbXsrv_connection * global_smbXsrv_connection ;
2009-01-08 15:38:47 +01:00
2009-01-08 12:03:45 +01:00
void smbd_init_globals ( void ) ;