s3: Put a comment into the right place
[Samba/gebeck_regimport.git] / source3 / smbd / globals.c
blob80f6a6642773f50c22c7bee14288defaaada68d0
1 /*
2 Unix SMB/Netbios implementation.
3 smbd globals
4 Copyright (C) Stefan Metzmacher 2009
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
21 #include "smbd/smbd.h"
22 #include "smbd/globals.h"
23 #include "lib/smbd_shim.h"
24 #include "memcache.h"
25 #include "messages.h"
26 #include "tdb_compat.h"
28 int aio_pending_size = 100; /* tevent supports 100 signals SA_SIGINFO */
29 int outstanding_aio_calls = 0;
31 #ifdef USE_DMAPI
32 struct smbd_dmapi_context *dmapi_ctx = NULL;
33 #endif
36 bool dfree_broken = false;
38 /* how many write cache buffers have been allocated */
39 unsigned int allocated_write_caches = 0;
41 const struct mangle_fns *mangle_fns = NULL;
43 unsigned char *chartest = NULL;
44 TDB_CONTEXT *tdb_mangled_cache = NULL;
47 this determines how many characters are used from the original filename
48 in the 8.3 mangled name. A larger value leads to a weaker hash and more collisions.
49 The largest possible value is 6.
51 unsigned mangle_prefix = 0;
53 bool logged_ioctl_message = false;
55 time_t last_smb_conf_reload_time = 0;
56 time_t last_printer_reload_time = 0;
57 pid_t background_lpq_updater_pid = -1;
59 /****************************************************************************
60 structure to hold a linked list of queued messages.
61 for processing.
62 ****************************************************************************/
63 uint32_t common_flags2 = FLAGS2_LONG_PATH_COMPONENTS|FLAGS2_32_BIT_ERROR_CODES|FLAGS2_EXTENDED_ATTRIBUTES;
65 struct smb_trans_enc_state *partial_srv_trans_enc_ctx = NULL;
66 struct smb_trans_enc_state *srv_trans_enc_ctx = NULL;
68 /* A stack of security contexts. We include the current context as being
69 the first one, so there is room for another MAX_SEC_CTX_DEPTH more. */
70 struct sec_ctx sec_ctx_stack[MAX_SEC_CTX_DEPTH + 1];
71 int sec_ctx_stack_ndx = 0;
72 bool become_uid_done = false;
73 bool become_gid_done = false;
75 connection_struct *last_conn = NULL;
76 uint16_t last_flags = 0;
78 uint32_t global_client_caps = 0;
80 uint16_t fnf_handle = 257;
82 /* A stack of current_user connection contexts. */
83 struct conn_ctx conn_ctx_stack[MAX_SEC_CTX_DEPTH];
84 int conn_ctx_stack_ndx = 0;
86 struct vfs_init_function_entry *backends = NULL;
87 char *sparse_buf = NULL;
88 char *LastDir = NULL;
90 struct smbd_parent_context *am_parent = NULL;
91 struct memcache *smbd_memcache_ctx = NULL;
92 bool exit_firsttime = true;
94 struct smbXsrv_connection *global_smbXsrv_connection = NULL;
96 struct memcache *smbd_memcache(void)
98 if (!smbd_memcache_ctx) {
100 * Note we MUST use the NULL context here, not the
101 * autofree context, to avoid side effects in forked
102 * children exiting.
104 smbd_memcache_ctx = memcache_init(NULL,
105 lp_max_stat_cache_size()*1024);
107 if (!smbd_memcache_ctx) {
108 smb_panic("Could not init smbd memcache");
111 return smbd_memcache_ctx;
114 static const struct smbd_shim smbd_shim_fns =
116 .cancel_pending_lock_requests_by_fid = smbd_cancel_pending_lock_requests_by_fid,
117 .send_stat_cache_delete_message = smbd_send_stat_cache_delete_message,
118 .change_to_root_user = smbd_change_to_root_user,
120 .contend_level2_oplocks_begin = smbd_contend_level2_oplocks_begin,
121 .contend_level2_oplocks_end = smbd_contend_level2_oplocks_end,
123 .become_root = smbd_become_root,
124 .unbecome_root = smbd_unbecome_root
127 void smbd_init_globals(void)
129 set_smbd_shim(&smbd_shim_fns);
131 ZERO_STRUCT(conn_ctx_stack);
133 ZERO_STRUCT(sec_ctx_stack);