2c4f8b5821273c8ccd4e3043a4fcf2668f2b678d
[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 SIG_ATOMIC_T reload_after_sighup;
128 extern SIG_ATOMIC_T got_sig_term;
129 extern uint16 last_session_tag;
130 extern int trans_num;
131 extern char *orig_inbuf;
132
133 extern pid_t mypid;
134 extern time_t last_smb_conf_reload_time;
135 extern time_t last_printer_reload_time;
136 /****************************************************************************
137  structure to hold a linked list of queued messages.
138  for processing.
139 ****************************************************************************/
140 struct pending_message_list;
141 extern struct pending_message_list *deferred_open_queue;
142 extern uint32_t common_flags2;
143
144 struct smb_srv_trans_enc_ctx;
145 extern struct smb_srv_trans_enc_ctx *partial_srv_trans_enc_ctx;
146 extern struct smb_srv_trans_enc_ctx *srv_trans_enc_ctx;
147
148 struct sec_ctx {
149         UNIX_USER_TOKEN ut;
150         NT_USER_TOKEN *token;
151 };
152 /* A stack of security contexts.  We include the current context as being
153    the first one, so there is room for another MAX_SEC_CTX_DEPTH more. */
154 extern struct sec_ctx sec_ctx_stack[MAX_SEC_CTX_DEPTH + 1];
155 extern int sec_ctx_stack_ndx;
156 extern bool become_uid_done;
157 extern bool become_gid_done;
158
159 extern connection_struct *last_conn;
160 extern uint16_t last_flags;
161
162 extern struct db_context *session_db_ctx_ptr;
163
164 extern uint32_t global_client_caps;
165 extern bool done_sesssetup;
166 /****************************************************************************
167  List to store partial SPNEGO auth fragments.
168 ****************************************************************************/
169 struct pending_auth_data;
170 extern struct pending_auth_data *pd_list;
171
172 extern uint16_t fnf_handle;
173
174 struct conn_ctx {
175         connection_struct *conn;
176         uint16 vuid;
177 };
178 /* A stack of current_user connection contexts. */
179 extern struct conn_ctx conn_ctx_stack[MAX_SEC_CTX_DEPTH];
180 extern int conn_ctx_stack_ndx;
181
182 struct vfs_init_function_entry;
183 extern struct vfs_init_function_entry *backends;
184 extern char *sparse_buf;
185 extern char *LastDir;
186
187 #if HAVE_KERNEL_OPLOCKS_LINUX
188 extern SIG_ATOMIC_T oplock_signals_received;
189 #define FD_PENDING_SIZE 100
190 extern SIG_ATOMIC_T fd_pending_array[FD_PENDING_SIZE];
191 #endif
192
193 /* Current number of oplocks we have outstanding. */
194 extern int32_t exclusive_oplocks_open;
195 extern int32_t level_II_oplocks_open;
196 extern bool global_client_failed_oplock_break;
197 extern struct kernel_oplocks *koplocks;
198
199 extern struct notify_mid_map *notify_changes_by_mid;
200
201 extern int am_parent;
202 extern SIG_ATOMIC_T got_sig_cld;
203 extern int server_fd;
204 extern struct event_context *smbd_event_ctx;
205 extern struct messaging_context *smbd_msg_ctx;
206 extern struct memcache *smbd_memcache_ctx;
207 extern bool exit_firsttime;
208 struct child_pid;
209 extern struct child_pid *children;
210 extern int num_children;
211
212 struct smbd_server_connection {
213         struct fd_event *fde;
214         uint64_t num_requests;
215 };
216 extern struct smbd_server_connection *smbd_server_conn;
217
218 void smbd_init_globals(void);