15085d9d3540d32d6b9633d486457a721d27b9db
[metze/samba/wip.git] / source3 / smbd / globals.h
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 #if defined(WITH_AIO)
21 struct aio_extra;
22 extern struct aio_extra *aio_list_head;
23 extern int aio_pending_size;
24 extern sig_atomic_t aio_signals_received;
25 extern int outstanding_aio_calls;
26 extern uint16_t *aio_pending_array;
27 #endif
28
29 /* dlink list we store pending lock records on. */
30 extern struct blocking_lock_record *blocking_lock_queue;
31
32 /* dlink list we move cancelled lock records onto. */
33 extern struct blocking_lock_record *blocking_lock_cancelled_queue;
34
35 /* The event that makes us process our blocking lock queue */
36 extern struct timed_event *brl_timeout;
37
38 extern bool blocking_lock_unlock_state;
39 extern bool blocking_lock_cancel_state;
40
41 #ifdef USE_DMAPI
42 struct smbd_dmapi_context;
43 extern struct smbd_dmapi_context *dmapi_ctx;
44 #endif
45
46 extern connection_struct *Connections;
47 /* number of open connections */
48 extern struct bitmap *bmap;
49 extern int num_open;
50
51 extern bool dfree_broken;
52
53 extern struct bitmap *dptr_bmap;
54 //struct dptr_struct;
55 extern struct dptr_struct *dirptrs;
56 extern int dirhandles_open;
57
58 /* how many write cache buffers have been allocated */
59 extern unsigned int allocated_write_caches;
60
61 extern int real_max_open_files;
62 extern struct bitmap *file_bmap;
63 extern files_struct *Files;
64 extern int files_used;
65 /* A singleton cache to speed up searching by dev/inode. */
66 struct fsp_singleton_cache {
67         files_struct *fsp;
68         struct file_id id;
69 };
70 extern struct fsp_singleton_cache fsp_fi_cache;
71 extern unsigned long file_gen_counter;
72 extern int first_file;
73
74 extern const struct mangle_fns *mangle_fns;
75
76 extern unsigned char *chartest;
77 extern TDB_CONTEXT *tdb_mangled_cache;
78
79 /* these tables are used to provide fast tests for characters */
80 extern unsigned char char_flags[256];
81 /*
82   this determines how many characters are used from the original filename
83   in the 8.3 mangled name. A larger value leads to a weaker hash and more collisions.
84   The largest possible value is 6.
85 */
86 extern unsigned mangle_prefix;
87 extern unsigned char base_reverse[256];
88
89 extern char *last_from;
90 extern char *last_to;
91
92 struct msg_state;
93 extern struct msg_state *smbd_msg_state;
94
95 extern bool global_encrypted_passwords_negotiated;
96 extern bool global_spnego_negotiated;
97 extern struct auth_context *negprot_global_auth_context;
98 extern bool done_negprot;
99
100 extern bool logged_ioctl_message;
101
102 /* users from session setup */
103 extern char *session_userlist;
104 /* workgroup from session setup. */
105 extern char *session_workgroup;
106 /* this holds info on user ids that are already validated for this VC */
107 extern user_struct *validated_users;
108 extern uint16_t next_vuid;
109 extern int num_validated_vuids;
110 #ifdef HAVE_NETGROUP
111 extern char *my_yp_domain;
112 #endif
113
114 extern bool already_got_session;
115
116 /*
117  * Size of data we can send to client. Set
118  *  by the client for all protocols above CORE.
119  *  Set by us for CORE protocol.
120  */
121 extern int max_send;
122 /*
123  * Size of the data we can receive. Set by us.
124  * Can be modified by the max xmit parameter.
125  */
126 extern int max_recv;
127 extern uint16 last_session_tag;
128 extern int trans_num;
129 extern char *orig_inbuf;
130
131 extern pid_t mypid;
132 extern time_t last_smb_conf_reload_time;
133 extern time_t last_printer_reload_time;
134 /****************************************************************************
135  structure to hold a linked list of queued messages.
136  for processing.
137 ****************************************************************************/
138 struct pending_message_list;
139 extern struct pending_message_list *deferred_open_queue;
140 extern uint32_t common_flags2;
141
142 struct smb_srv_trans_enc_ctx;
143 extern struct smb_srv_trans_enc_ctx *partial_srv_trans_enc_ctx;
144 extern struct smb_srv_trans_enc_ctx *srv_trans_enc_ctx;
145
146 struct sec_ctx {
147         UNIX_USER_TOKEN ut;
148         NT_USER_TOKEN *token;
149 };
150 /* A stack of security contexts.  We include the current context as being
151    the first one, so there is room for another MAX_SEC_CTX_DEPTH more. */
152 extern struct sec_ctx sec_ctx_stack[MAX_SEC_CTX_DEPTH + 1];
153 extern int sec_ctx_stack_ndx;
154 extern bool become_uid_done;
155 extern bool become_gid_done;
156
157 extern connection_struct *last_conn;
158 extern uint16_t last_flags;
159
160 extern struct db_context *session_db_ctx_ptr;
161
162 extern uint32_t global_client_caps;
163 extern bool done_sesssetup;
164 /****************************************************************************
165  List to store partial SPNEGO auth fragments.
166 ****************************************************************************/
167 struct pending_auth_data;
168 extern struct pending_auth_data *pd_list;
169
170 extern uint16_t fnf_handle;
171
172 struct conn_ctx {
173         connection_struct *conn;
174         uint16 vuid;
175 };
176 /* A stack of current_user connection contexts. */
177 extern struct conn_ctx conn_ctx_stack[MAX_SEC_CTX_DEPTH];
178 extern int conn_ctx_stack_ndx;
179
180 struct vfs_init_function_entry;
181 extern struct vfs_init_function_entry *backends;
182 extern char *sparse_buf;
183 extern char *LastDir;
184
185 #if HAVE_KERNEL_OPLOCKS_LINUX
186 extern SIG_ATOMIC_T oplock_signals_received;
187 #define FD_PENDING_SIZE 100
188 extern SIG_ATOMIC_T fd_pending_array[FD_PENDING_SIZE];
189 #endif
190
191 /* Current number of oplocks we have outstanding. */
192 extern int32_t exclusive_oplocks_open;
193 extern int32_t level_II_oplocks_open;
194 extern bool global_client_failed_oplock_break;
195 extern struct kernel_oplocks *koplocks;
196
197 extern struct notify_mid_map *notify_changes_by_mid;
198
199 extern int am_parent;
200 extern int server_fd;
201 extern struct event_context *smbd_event_ctx;
202 extern struct messaging_context *smbd_msg_ctx;
203 extern struct memcache *smbd_memcache_ctx;
204 extern bool exit_firsttime;
205 struct child_pid;
206 extern struct child_pid *children;
207 extern int num_children;
208
209 struct smbd_server_connection {
210         struct fd_event *fde;
211         uint64_t num_requests;
212 };
213 extern struct smbd_server_connection *smbd_server_conn;
214
215 void smbd_init_globals(void);