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"
2014-07-17 14:58:34 +04:00
# include "../lib/util/memcache.h"
2011-03-24 17:31:06 +03:00
# include "messages.h"
2015-03-12 17:40:16 +03:00
# include <tdb.h>
2009-01-08 14:03:45 +03:00
# ifdef USE_DMAPI
struct smbd_dmapi_context * dmapi_ctx = NULL ;
# endif
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 ;
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 ;
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 ;
2012-09-13 21:13:21 +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 ;
2014-05-20 21:47:13 +04:00
struct smbXsrv_client * global_smbXsrv_client = 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 ;
}
2009-01-08 14:03:45 +03:00
void smbd_init_globals ( void )
{
ZERO_STRUCT ( conn_ctx_stack ) ;
ZERO_STRUCT ( sec_ctx_stack ) ;
}
2019-08-08 20:26:28 +03:00
struct GUID smbd_request_guid ( struct smb_request * smb1req , uint16_t idx )
{
struct GUID v = {
. time_low = ( uint32_t ) smb1req - > mid ,
. time_hi_and_version = idx ,
} ;
if ( smb1req - > smb2req ! = NULL ) {
v . time_mid = ( uint16_t ) smb1req - > smb2req - > current_idx ;
} else {
v . time_mid = ( uint16_t ) ( uintptr_t ) smb1req - > vwv ;
}
2020-07-28 13:11:38 +03:00
SBVAL ( ( uint8_t * ) & v , 8 , smb1req - > xconn - > channel_id ) ;
2019-08-08 20:26:28 +03:00
return v ;
}