source: vendor/3.6.23/source3/smbd/globals.c

Last change on this file was 860, checked in by Silvan Scherrer, 11 years ago

Samba 3.6: updated vendor to latest version

File size: 4.5 KB
Line 
1/*
2 Unix SMB/Netbios implementation.
3 smbd globals
4 Copyright (C) Stefan Metzmacher 2009
5
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.
10
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.
15
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/>.
18*/
19
20#include "includes.h"
21#include "smbd/smbd.h"
22#include "smbd/globals.h"
23#include "memcache.h"
24#include "messages.h"
25#include <tdb.h>
26
27#if defined(WITH_AIO)
28struct aio_extra *aio_list_head = NULL;
29struct tevent_signal *aio_signal_event = NULL;
30int aio_pending_size = 0;
31int outstanding_aio_calls = 0;
32#endif
33
34#ifdef USE_DMAPI
35struct smbd_dmapi_context *dmapi_ctx = NULL;
36#endif
37
38
39bool dfree_broken = false;
40
41/* how many write cache buffers have been allocated */
42unsigned int allocated_write_caches = 0;
43
44const struct mangle_fns *mangle_fns = NULL;
45
46unsigned char *chartest = NULL;
47TDB_CONTEXT *tdb_mangled_cache = NULL;
48
49/*
50 this determines how many characters are used from the original filename
51 in the 8.3 mangled name. A larger value leads to a weaker hash and more collisions.
52 The largest possible value is 6.
53*/
54unsigned mangle_prefix = 0;
55
56struct msg_state *smbd_msg_state = NULL;
57
58bool logged_ioctl_message = false;
59
60time_t last_smb_conf_reload_time = 0;
61time_t last_printer_reload_time = 0;
62/****************************************************************************
63 structure to hold a linked list of queued messages.
64 for processing.
65****************************************************************************/
66struct pending_message_list *deferred_open_queue = NULL;
67uint32_t common_flags2 = FLAGS2_LONG_PATH_COMPONENTS|FLAGS2_32_BIT_ERROR_CODES|FLAGS2_EXTENDED_ATTRIBUTES;
68
69struct smb_srv_trans_enc_ctx *partial_srv_trans_enc_ctx = NULL;
70struct smb_srv_trans_enc_ctx *srv_trans_enc_ctx = NULL;
71
72/* A stack of security contexts. We include the current context as being
73 the first one, so there is room for another MAX_SEC_CTX_DEPTH more. */
74struct sec_ctx sec_ctx_stack[MAX_SEC_CTX_DEPTH + 1];
75int sec_ctx_stack_ndx = 0;
76bool become_uid_done = false;
77bool become_gid_done = false;
78
79connection_struct *last_conn = NULL;
80uint16_t last_flags = 0;
81
82uint32_t global_client_caps = 0;
83
84uint16_t fnf_handle = 257;
85
86/* A stack of current_user connection contexts. */
87struct conn_ctx conn_ctx_stack[MAX_SEC_CTX_DEPTH];
88int conn_ctx_stack_ndx = 0;
89
90struct vfs_init_function_entry *backends = NULL;
91char *sparse_buf = NULL;
92char *LastDir = NULL;
93
94/* Current number of oplocks we have outstanding. */
95int32_t exclusive_oplocks_open = 0;
96int32_t level_II_oplocks_open = 0;
97struct kernel_oplocks *koplocks = NULL;
98
99int am_parent = 1;
100struct memcache *smbd_memcache_ctx = NULL;
101bool exit_firsttime = true;
102struct child_pid *children = 0;
103int num_children = 0;
104
105struct smbd_server_connection *smbd_server_conn = NULL;
106
107struct smbd_server_connection *msg_ctx_to_sconn(struct messaging_context *msg_ctx)
108{
109 struct server_id my_id, msg_id;
110
111 my_id = messaging_server_id(smbd_server_conn->msg_ctx);
112 msg_id = messaging_server_id(msg_ctx);
113
114 if (!procid_equal(&my_id, &msg_id)) {
115 return NULL;
116 }
117 return smbd_server_conn;
118}
119
120struct messaging_context *smbd_messaging_context(void)
121{
122 struct messaging_context *msg_ctx = server_messaging_context();
123 if (likely(msg_ctx != NULL)) {
124 return msg_ctx;
125 }
126 smb_panic("Could not init smbd's messaging context.\n");
127 return NULL;
128}
129
130struct memcache *smbd_memcache(void)
131{
132 if (!smbd_memcache_ctx) {
133 /*
134 * Note we MUST use the NULL context here, not the
135 * autofree context, to avoid side effects in forked
136 * children exiting.
137 */
138 smbd_memcache_ctx = memcache_init(NULL,
139 lp_max_stat_cache_size()*1024);
140 }
141 if (!smbd_memcache_ctx) {
142 smb_panic("Could not init smbd memcache");
143 }
144
145 return smbd_memcache_ctx;
146}
147
148
149void smbd_init_globals(void)
150{
151 ZERO_STRUCT(conn_ctx_stack);
152
153 ZERO_STRUCT(sec_ctx_stack);
154
155 smbd_server_conn = talloc_zero(smbd_event_context(), struct smbd_server_connection);
156 if (!smbd_server_conn) {
157 exit_server("failed to create smbd_server_connection");
158 }
159
160 smbd_server_conn->smb1.echo_handler.trusted_fd = -1;
161 smbd_server_conn->smb1.echo_handler.socket_lock_fd = -1;
162}
Note: See TracBrowser for help on using the repository browser.