2009-01-08 14:03:45 +03:00
/*
Unix SMB / Netbios implementation .
smbd globals
Copyright ( C ) Stefan Metzmacher 2009
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/>.
*/
# include "includes.h"
2011-03-22 18:57:01 +03:00
# include "smbd/smbd.h"
2009-01-08 14:03:45 +03:00
# include "smbd/globals.h"
2011-05-31 07:18:37 +04:00
# include "lib/smbd_shim.h"
2010-08-18 14:24:35 +04:00
# include "memcache.h"
2011-03-24 17:31:06 +03:00
# include "messages.h"
2011-06-20 13:10:25 +04:00
# include "tdb_compat.h"
2009-01-08 14:03:45 +03:00
2012-06-06 03:23:22 +04:00
# if defined(HAVE_AIO)
2009-01-08 14:03:45 +03:00
struct aio_extra * aio_list_head = NULL ;
2009-01-22 20:04:17 +03:00
struct tevent_signal * aio_signal_event = NULL ;
2012-06-25 14:23:22 +04:00
int aio_pending_size = 100 ; /* tevent supports 100 signals SA_SIGINFO */
2009-01-08 14:03:45 +03:00
int outstanding_aio_calls = 0 ;
# endif
# ifdef USE_DMAPI
struct smbd_dmapi_context * dmapi_ctx = NULL ;
# endif
bool dfree_broken = false ;
/* how many write cache buffers have been allocated */
unsigned int allocated_write_caches = 0 ;
const struct mangle_fns * mangle_fns = NULL ;
unsigned char * chartest = NULL ;
TDB_CONTEXT * tdb_mangled_cache = NULL ;
/*
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.
*/
unsigned mangle_prefix = 0 ;
bool logged_ioctl_message = false ;
time_t last_smb_conf_reload_time = 0 ;
time_t last_printer_reload_time = 0 ;
2011-08-04 01:04:50 +04:00
pid_t background_lpq_updater_pid = - 1 ;
2011-08-02 00:50:51 +04:00
2009-01-08 14:03:45 +03:00
/****************************************************************************
structure to hold a linked list of queued messages .
for processing .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-09-17 20:29:07 +04:00
uint32_t common_flags2 = FLAGS2_LONG_PATH_COMPONENTS | FLAGS2_32_BIT_ERROR_CODES | FLAGS2_EXTENDED_ATTRIBUTES ;
2009-01-08 14:03:45 +03:00
2011-10-19 09:33:04 +04:00
struct smb_trans_enc_state * partial_srv_trans_enc_ctx = NULL ;
struct smb_trans_enc_state * srv_trans_enc_ctx = NULL ;
2009-01-08 14:03:45 +03: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 . */
struct sec_ctx sec_ctx_stack [ MAX_SEC_CTX_DEPTH + 1 ] ;
int sec_ctx_stack_ndx = 0 ;
bool become_uid_done = false ;
bool become_gid_done = false ;
connection_struct * last_conn = NULL ;
uint16_t last_flags = 0 ;
uint32_t global_client_caps = 0 ;
uint16_t fnf_handle = 257 ;
/* A stack of current_user connection contexts. */
struct conn_ctx conn_ctx_stack [ MAX_SEC_CTX_DEPTH ] ;
int conn_ctx_stack_ndx = 0 ;
struct vfs_init_function_entry * backends = NULL ;
char * sparse_buf = NULL ;
2010-07-13 20:30:35 +04:00
char * LastDir = NULL ;
2009-01-08 14:03:45 +03:00
2011-12-13 17:58:50 +04:00
struct smbd_parent_context * am_parent = NULL ;
2009-01-08 14:03:45 +03:00
struct memcache * smbd_memcache_ctx = NULL ;
bool exit_firsttime = true ;
2012-05-24 15:46:11 +04:00
struct smbXsrv_connection * global_smbXsrv_connection = NULL ;
2009-01-08 17:38:47 +03:00
2010-05-26 04:48:15 +04:00
struct memcache * smbd_memcache ( void )
{
if ( ! smbd_memcache_ctx ) {
2010-06-11 00:17:35 +04:00
/*
* Note we MUST use the NULL context here , not the
* autofree context , to avoid side effects in forked
* children exiting .
*/
smbd_memcache_ctx = memcache_init ( NULL ,
2010-05-26 04:48:15 +04:00
lp_max_stat_cache_size ( ) * 1024 ) ;
}
if ( ! smbd_memcache_ctx ) {
smb_panic ( " Could not init smbd memcache " ) ;
}
return smbd_memcache_ctx ;
}
2011-05-31 07:18:37 +04:00
static const struct smbd_shim smbd_shim_fns =
{
. cancel_pending_lock_requests_by_fid = smbd_cancel_pending_lock_requests_by_fid ,
. send_stat_cache_delete_message = smbd_send_stat_cache_delete_message ,
. change_to_root_user = smbd_change_to_root_user ,
2011-08-05 20:17:43 +04:00
2011-05-31 07:18:37 +04:00
. contend_level2_oplocks_begin = smbd_contend_level2_oplocks_begin ,
. contend_level2_oplocks_end = smbd_contend_level2_oplocks_end ,
. become_root = smbd_become_root ,
. unbecome_root = smbd_unbecome_root
} ;
2010-05-26 04:48:15 +04:00
2009-01-08 14:03:45 +03:00
void smbd_init_globals ( void )
{
2011-05-31 07:18:37 +04:00
set_smbd_shim ( & smbd_shim_fns ) ;
2009-01-08 14:03:45 +03:00
ZERO_STRUCT ( conn_ctx_stack ) ;
ZERO_STRUCT ( sec_ctx_stack ) ;
}