lib: remove unused pieces of string_wrappers.h
[abartlet/samba.git/.git] / source3 / include / proto.h
1 /*
2  * Unix SMB/CIFS implementation.
3  * collected prototypes header
4  *
5  * frozen from "make proto" in May 2008
6  *
7  * Copyright (C) Michael Adam 2008
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef _PROTO_H_
24 #define _PROTO_H_
25
26
27 /* The following definitions come from auth/auth.c  */
28
29 NTSTATUS smb_register_auth(int version, const char *name, auth_init_function init);
30 bool load_auth_module(struct auth_context *auth_context, 
31                       const char *module, auth_methods **ret) ;
32 NTSTATUS make_auth_context_subsystem(TALLOC_CTX *mem_ctx,
33                                      struct auth_context **auth_context);
34 NTSTATUS make_auth_context_fixed(TALLOC_CTX *mem_ctx,
35                                  struct auth_context **auth_context,
36                                  uchar chal[8]) ;
37
38 /* The following definitions come from auth/auth_builtin.c  */
39
40 NTSTATUS auth_builtin_init(void);
41
42 /* The following definitions come from auth/auth_compat.c  */
43
44 NTSTATUS check_plaintext_password(const char *smb_name,
45                                   DATA_BLOB plaintext_password,
46                                   struct auth_serversupplied_info **server_info);
47 bool password_ok(struct auth_context *actx, bool global_encrypted,
48                  const char *session_workgroup,
49                  const char *smb_name, DATA_BLOB password_blob);
50
51 /* The following definitions come from auth/auth_domain.c  */
52
53 void attempt_machine_password_change(void);
54 NTSTATUS auth_domain_init(void);
55
56 NTSTATUS auth_netlogond_init(void);
57
58 /* The following definitions come from auth/auth_ntlmssp.c  */
59
60 NTSTATUS auth_ntlmssp_steal_session_info(TALLOC_CTX *mem_ctx,
61                                 struct auth_ntlmssp_state *auth_ntlmssp_state,
62                                 struct auth_serversupplied_info **session_info);
63 NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state);
64
65
66 /* The following definitions come from auth/auth_sam.c  */
67
68 NTSTATUS check_sam_security(const DATA_BLOB *challenge,
69                             TALLOC_CTX *mem_ctx,
70                             const struct auth_usersupplied_info *user_info,
71                             struct auth_serversupplied_info **server_info);
72 NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
73                                   TALLOC_CTX *mem_ctx,
74                                   const struct auth_usersupplied_info *user_info,
75                                   struct netr_SamInfo3 **pinfo3);
76 NTSTATUS auth_sam_init(void);
77
78 /* The following definitions come from auth/auth_server.c  */
79
80 NTSTATUS auth_server_init(void);
81
82 /* The following definitions come from auth/auth_unix.c  */
83
84 NTSTATUS auth_unix_init(void);
85
86 /* The following definitions come from auth/auth_util.c  */
87
88 NTSTATUS make_user_info_map(struct auth_usersupplied_info **user_info,
89                             const char *smb_name,
90                             const char *client_domain,
91                             const char *workstation_name,
92                             DATA_BLOB *lm_pwd,
93                             DATA_BLOB *nt_pwd,
94                             const struct samr_Password *lm_interactive_pwd,
95                             const struct samr_Password *nt_interactive_pwd,
96                             const char *plaintext,
97                             enum auth_password_state password_state);
98 bool make_user_info_netlogon_network(struct auth_usersupplied_info **user_info,
99                                      const char *smb_name, 
100                                      const char *client_domain, 
101                                      const char *workstation_name,
102                                      uint32 logon_parameters,
103                                      const uchar *lm_network_pwd,
104                                      int lm_pwd_len,
105                                      const uchar *nt_network_pwd,
106                                      int nt_pwd_len);
107 bool make_user_info_netlogon_interactive(struct auth_usersupplied_info **user_info,
108                                          const char *smb_name, 
109                                          const char *client_domain, 
110                                          const char *workstation_name,
111                                          uint32 logon_parameters,
112                                          const uchar chal[8], 
113                                          const uchar lm_interactive_pwd[16], 
114                                          const uchar nt_interactive_pwd[16], 
115                                          const uchar *dc_sess_key);
116 bool make_user_info_for_reply(struct auth_usersupplied_info **user_info,
117                               const char *smb_name, 
118                               const char *client_domain,
119                               const uint8 chal[8],
120                               DATA_BLOB plaintext_password);
121 NTSTATUS make_user_info_for_reply_enc(struct auth_usersupplied_info **user_info,
122                                       const char *smb_name,
123                                       const char *client_domain, 
124                                       DATA_BLOB lm_resp, DATA_BLOB nt_resp);
125 bool make_user_info_guest(struct auth_usersupplied_info **user_info) ;
126 NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
127                               struct samu *sampass);
128 NTSTATUS create_local_token(struct auth_serversupplied_info *server_info);
129 NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
130                                     bool is_guest,
131                                     uid_t *uid, gid_t *gid,
132                                     char **found_username,
133                                     struct security_token **token);
134 bool user_in_group_sid(const char *username, const struct dom_sid *group_sid);
135 bool user_in_group(const char *username, const char *groupname);
136 NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
137                              char *unix_username,
138                              struct passwd *pwd);
139 NTSTATUS make_serverinfo_from_username(TALLOC_CTX *mem_ctx,
140                                        const char *username,
141                                        bool is_guest,
142                                        struct auth_serversupplied_info **presult);
143 struct auth_serversupplied_info *copy_serverinfo(TALLOC_CTX *mem_ctx,
144                                                  const struct auth_serversupplied_info *src);
145 bool init_guest_info(void);
146 NTSTATUS init_system_info(void);
147 bool session_info_set_session_key(struct auth_serversupplied_info *info,
148                                  DATA_BLOB session_key);
149 NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
150                                 struct auth_serversupplied_info **server_info);
151 NTSTATUS make_session_info_system(TALLOC_CTX *mem_ctx,
152                                  struct auth_serversupplied_info **session_info);
153 const struct auth_serversupplied_info *get_session_info_system(void);
154 bool copy_current_user(struct current_user *dst, struct current_user *src);
155 struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, const char *domuser,
156                              char **p_save_username, bool create );
157 NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, 
158                                 const char *sent_nt_username,
159                                 const char *domain,
160                                 struct auth_serversupplied_info **server_info,
161                                 struct netr_SamInfo3 *info3);
162 NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
163                                           const char *sent_nt_username,
164                                           const char *domain,
165                                           const struct wbcAuthUserInfo *info,
166                                           struct auth_serversupplied_info **server_info);
167 void free_user_info(struct auth_usersupplied_info **user_info);
168 bool make_auth_methods(struct auth_context *auth_context, auth_methods **auth_method) ;
169 bool is_trusted_domain(const char* dom_name);
170
171 /* The following definitions come from auth/user_info.c  */
172
173 NTSTATUS make_user_info(struct auth_usersupplied_info **ret_user_info,
174                         const char *smb_name,
175                         const char *internal_username,
176                         const char *client_domain,
177                         const char *domain,
178                         const char *workstation_name,
179                         const DATA_BLOB *lm_pwd,
180                         const DATA_BLOB *nt_pwd,
181                         const struct samr_Password *lm_interactive_pwd,
182                         const struct samr_Password *nt_interactive_pwd,
183                         const char *plaintext_password,
184                         enum auth_password_state password_state);
185 void free_user_info(struct auth_usersupplied_info **user_info);
186
187 /* The following definitions come from auth/auth_winbind.c  */
188
189 NTSTATUS auth_winbind_init(void);
190
191 /* The following definitions come from auth/server_info.c  */
192
193 struct netr_SamInfo2;
194 struct netr_SamInfo3;
195 struct netr_SamInfo6;
196
197 struct auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx);
198 NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
199                                 uint8_t *pipe_session_key,
200                                 size_t pipe_session_key_len,
201                                 struct netr_SamInfo2 *sam2);
202 NTSTATUS serverinfo_to_SamInfo3(const struct auth_serversupplied_info *server_info,
203                                 uint8_t *pipe_session_key,
204                                 size_t pipe_session_key_len,
205                                 struct netr_SamInfo3 *sam3);
206 NTSTATUS serverinfo_to_SamInfo6(struct auth_serversupplied_info *server_info,
207                                 uint8_t *pipe_session_key,
208                                 size_t pipe_session_key_len,
209                                 struct netr_SamInfo6 *sam6);
210 NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
211                           struct samu *samu,
212                           const char *login_server,
213                           struct netr_SamInfo3 **_info3,
214                           struct extra_auth_info *extra);
215 struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
216                                          struct netr_SamInfo3 *orig);
217 struct netr_SamInfo3 *wbcAuthUserInfo_to_netr_SamInfo3(TALLOC_CTX *mem_ctx,
218                                         const struct wbcAuthUserInfo *info);
219
220 /* The following definitions come from auth/auth_wbc.c  */
221
222 NTSTATUS auth_wbc_init(void);
223
224 /* The following definitions come from auth/pampass.c  */
225
226 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
227 bool smb_pam_close_session(char *user, char *tty, char *rhost);
228 NTSTATUS smb_pam_accountcheck(const char *user, const char *rhost);
229 NTSTATUS smb_pam_passcheck(const char * user, const char * rhost,
230                            const char * password);
231 bool smb_pam_passchange(const char *user, const char *rhost,
232                         const char *oldpassword, const char *newpassword);
233 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
234 bool smb_pam_close_session(char *in_user, char *tty, char *rhost);
235
236 /* The following definitions come from auth/pass_check.c  */
237
238 void dfs_unlogin(void);
239 NTSTATUS pass_check(const struct passwd *pass,
240                     const char *user,
241                     const char *rhost,
242                     const char *password,
243                     bool run_cracker);
244
245 /* The following definitions come from auth/token_util.c  */
246
247 bool nt_token_check_sid ( const struct dom_sid *sid, const struct security_token *token );
248 bool nt_token_check_domain_rid( struct security_token *token, uint32 rid );
249 struct security_token *get_root_nt_token( void );
250 NTSTATUS add_aliases(const struct dom_sid *domain_sid,
251                      struct security_token *token);
252 NTSTATUS create_builtin_users(const struct dom_sid *sid);
253 NTSTATUS create_builtin_administrators(const struct dom_sid *sid);
254 struct security_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
255                                             const struct dom_sid *user_sid,
256                                             bool is_guest,
257                                             int num_groupsids,
258                                             const struct dom_sid *groupsids);
259 NTSTATUS create_local_nt_token_from_info3(TALLOC_CTX *mem_ctx,
260                                           bool is_guest,
261                                           struct netr_SamInfo3 *info3,
262                                           struct extra_auth_info *extra,
263                                           struct security_token **ntok);
264 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
265                            int n_groups, gid_t *groups);
266
267 /* The following definitions come from groupdb/mapping.c  */
268
269 NTSTATUS add_initial_entry(gid_t gid, const char *sid, enum lsa_SidType sid_name_use, const char *nt_name, const char *comment);
270 bool get_domain_group_from_sid(struct dom_sid sid, GROUP_MAP *map);
271 int smb_create_group(const char *unix_group, gid_t *new_gid);
272 int smb_delete_group(const char *unix_group);
273 int smb_set_primary_group(const char *unix_group, const char* unix_user);
274 int smb_add_user_group(const char *unix_group, const char *unix_user);
275 int smb_delete_user_group(const char *unix_group, const char *unix_user);
276 NTSTATUS pdb_default_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
277                                  struct dom_sid sid);
278 NTSTATUS pdb_default_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
279                                  gid_t gid);
280 NTSTATUS pdb_default_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
281                                  const char *name);
282 NTSTATUS pdb_default_add_group_mapping_entry(struct pdb_methods *methods,
283                                                 GROUP_MAP *map);
284 NTSTATUS pdb_default_update_group_mapping_entry(struct pdb_methods *methods,
285                                                    GROUP_MAP *map);
286 NTSTATUS pdb_default_delete_group_mapping_entry(struct pdb_methods *methods,
287                                                    struct dom_sid sid);
288 NTSTATUS pdb_default_enum_group_mapping(struct pdb_methods *methods,
289                                            const struct dom_sid *sid, enum lsa_SidType sid_name_use,
290                                            GROUP_MAP **pp_rmap, size_t *p_num_entries,
291                                            bool unix_only);
292 NTSTATUS pdb_default_create_alias(struct pdb_methods *methods,
293                                   const char *name, uint32 *rid);
294 NTSTATUS pdb_default_delete_alias(struct pdb_methods *methods,
295                                   const struct dom_sid *sid);
296 NTSTATUS pdb_default_get_aliasinfo(struct pdb_methods *methods,
297                                    const struct dom_sid *sid,
298                                    struct acct_info *info);
299 NTSTATUS pdb_default_set_aliasinfo(struct pdb_methods *methods,
300                                    const struct dom_sid *sid,
301                                    struct acct_info *info);
302 NTSTATUS pdb_default_add_aliasmem(struct pdb_methods *methods,
303                                   const struct dom_sid *alias, const struct dom_sid *member);
304 NTSTATUS pdb_default_del_aliasmem(struct pdb_methods *methods,
305                                   const struct dom_sid *alias, const struct dom_sid *member);
306 NTSTATUS pdb_default_enum_aliasmem(struct pdb_methods *methods,
307                                    const struct dom_sid *alias, TALLOC_CTX *mem_ctx,
308                                    struct dom_sid **pp_members,
309                                    size_t *p_num_members);
310 NTSTATUS pdb_default_alias_memberships(struct pdb_methods *methods,
311                                        TALLOC_CTX *mem_ctx,
312                                        const struct dom_sid *domain_sid,
313                                        const struct dom_sid *members,
314                                        size_t num_members,
315                                        uint32 **pp_alias_rids,
316                                        size_t *p_num_alias_rids);
317 NTSTATUS pdb_nop_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
318                                  struct dom_sid sid);
319 NTSTATUS pdb_nop_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
320                                  gid_t gid);
321 NTSTATUS pdb_nop_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
322                                  const char *name);
323 NTSTATUS pdb_nop_add_group_mapping_entry(struct pdb_methods *methods,
324                                                 GROUP_MAP *map);
325 NTSTATUS pdb_nop_update_group_mapping_entry(struct pdb_methods *methods,
326                                                    GROUP_MAP *map);
327 NTSTATUS pdb_nop_delete_group_mapping_entry(struct pdb_methods *methods,
328                                                    struct dom_sid sid);
329 NTSTATUS pdb_nop_enum_group_mapping(struct pdb_methods *methods,
330                                            enum lsa_SidType sid_name_use,
331                                            GROUP_MAP **rmap, size_t *num_entries,
332                                            bool unix_only);
333 bool pdb_get_dom_grp_info(const struct dom_sid *sid, struct acct_info *info);
334 bool pdb_set_dom_grp_info(const struct dom_sid *sid, const struct acct_info *info);
335 NTSTATUS pdb_create_builtin_alias(uint32 rid);
336
337 /* The following definitions come from groupdb/mapping_tdb.c  */
338
339 const struct mapping_backend *groupdb_tdb_init(void);
340
341 /* The following definitions come from intl/lang_tdb.c  */
342
343 bool lang_tdb_init(const char *lang);
344 const char *lang_msg(const char *msgid);
345 void lang_msg_free(const char *msgstr);
346 char *lang_tdb_current(void);
347
348 /* The following definitions come from lib/access.c  */
349
350 bool client_match(const char *tok, const void *item);
351 bool list_match(const char **list,const void *item,
352                 bool (*match_fn)(const char *, const void *));
353 bool allow_access(const char **deny_list,
354                 const char **allow_list,
355                 const char *cname,
356                 const char *caddr);
357
358 /* The following definitions come from passdb/account_pol.c  */
359
360 void account_policy_names_list(const char ***names, int *num_names);
361 const char *decode_account_policy_name(enum pdb_policy_type type);
362 const char *get_account_policy_attr(enum pdb_policy_type type);
363 const char *account_policy_get_desc(enum pdb_policy_type type);
364 enum pdb_policy_type account_policy_name_to_typenum(const char *name);
365 bool account_policy_get_default(enum pdb_policy_type type, uint32_t *val);
366 bool init_account_policy(void);
367 bool account_policy_get(enum pdb_policy_type type, uint32_t *value);
368 bool account_policy_set(enum pdb_policy_type type, uint32_t value);
369 bool cache_account_policy_set(enum pdb_policy_type type, uint32_t value);
370 bool cache_account_policy_get(enum pdb_policy_type type, uint32_t *value);
371 struct db_context *get_account_pol_db( void );
372
373 /* The following definitions come from lib/adt_tree.c  */
374
375
376 /* The following definitions come from lib/afs.c  */
377
378 char *afs_createtoken_str(const char *username, const char *cell);
379 bool afs_login(connection_struct *conn);
380 bool afs_login(connection_struct *conn);
381 char *afs_createtoken_str(const char *username, const char *cell);
382
383 /* The following definitions come from lib/afs_settoken.c  */
384
385 int afs_syscall( int subcall,
386           char * path,
387           int cmd,
388           char * cmarg,
389           int follow);
390 bool afs_settoken_str(const char *token_string);
391 bool afs_settoken_str(const char *token_string);
392
393 /* The following definitions come from lib/audit.c  */
394
395 const char *audit_category_str(uint32 category);
396 const char *audit_param_str(uint32 category);
397 const char *audit_description_str(uint32 category);
398 bool get_audit_category_from_param(const char *param, uint32 *audit_category);
399 const char *audit_policy_str(TALLOC_CTX *mem_ctx, uint32 policy);
400
401 /* The following definitions come from lib/bitmap.c  */
402
403 struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n);
404 int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src);
405 bool bitmap_set(struct bitmap *bm, unsigned i);
406 bool bitmap_clear(struct bitmap *bm, unsigned i);
407 bool bitmap_query(struct bitmap *bm, unsigned i);
408 int bitmap_find(struct bitmap *bm, unsigned ofs);
409
410 /* The following definitions come from lib/charcnv.c  */
411
412 char lp_failed_convert_char(void);
413 void lazy_initialize_conv(void);
414 void gfree_charcnv(void);
415 void init_iconv(void);
416 size_t convert_string(charset_t from, charset_t to,
417                       void const *src, size_t srclen, 
418                       void *dest, size_t destlen);
419 size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen);
420 char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *s);
421 char *strupper_talloc(TALLOC_CTX *ctx, const char *s);
422 size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen);
423 char *talloc_strdup_lower(TALLOC_CTX *ctx, const char *s);
424 char *strlower_talloc(TALLOC_CTX *ctx, const char *s);
425 size_t ucs2_align(const void *base_ptr, const void *p, int flags);
426 size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags);
427 size_t push_ascii_fstring(void *dest, const char *src);
428 size_t push_ascii_nstring(void *dest, const char *src);
429 size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
430 size_t pull_ascii_fstring(char *dest, const void *src);
431 size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src);
432 size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags);
433 size_t push_utf8_fstring(void *dest, const char *src);
434 bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
435                       size_t *converted_size);
436 size_t pull_ucs2(const void *base_ptr, char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
437 size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
438                         const void *base_ptr,
439                         char **ppdest,
440                         const void *src,
441                         size_t src_len,
442                         int flags);
443 size_t pull_ucs2_fstring(char *dest, const void *src);
444 bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src,
445                       size_t *converted_size);
446 bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
447                       size_t *converted_size);
448 bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src,
449                       size_t *converted_size);
450 bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
451                        size_t *converted_size);
452 size_t push_string_check_fn(void *dest, const char *src,
453                             size_t dest_len, int flags);
454 size_t push_string_base(const char *base, uint16 flags2,
455                         void *dest, const char *src,
456                         size_t dest_len, int flags);
457 size_t pull_string_fn(const void *base_ptr,
458                         uint16 smb_flags2,
459                         char *dest,
460                         const void *src,
461                         size_t dest_len,
462                         size_t src_len,
463                         int flags);
464 size_t pull_string_talloc(TALLOC_CTX *ctx,
465                         const void *base_ptr,
466                         uint16 smb_flags2,
467                         char **ppdest,
468                         const void *src,
469                         size_t src_len,
470                         int flags);
471 size_t align_string(const void *base_ptr, const char *p, int flags);
472
473 /* The following definitions come from lib/conn_tdb.c  */
474
475 struct db_record *connections_fetch_entry(TALLOC_CTX *mem_ctx,
476                                           connection_struct *conn,
477                                           const char *name);
478 int connections_traverse(int (*fn)(struct db_record *rec,
479                                    void *private_data),
480                          void *private_data);
481 int connections_forall(int (*fn)(struct db_record *rec,
482                                  const struct connections_key *key,
483                                  const struct connections_data *data,
484                                  void *private_data),
485                        void *private_data);
486 int connections_forall_read(int (*fn)(const struct connections_key *key,
487                                       const struct connections_data *data,
488                                       void *private_data),
489                             void *private_data);
490 bool connections_init(bool rw);
491
492 /* The following definitions come from lib/dmallocmsg.c  */
493
494 void register_dmalloc_msgs(struct messaging_context *msg_ctx);
495
496 /* The following definitions come from lib/dprintf.c  */
497
498 void display_set_stderr(void);
499
500 /* The following definitions come from lib/errmap_unix.c  */
501
502 NTSTATUS map_nt_error_from_unix(int unix_error);
503 int map_errno_from_nt_status(NTSTATUS status);
504
505 /* The following definitions come from lib/file_id.c  */
506
507 struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf);
508 bool file_id_equal(const struct file_id *id1, const struct file_id *id2);
509 const char *file_id_string_tos(const struct file_id *id);
510 void push_file_id_16(char *buf, const struct file_id *id);
511 void push_file_id_24(char *buf, const struct file_id *id);
512 void pull_file_id_24(char *buf, struct file_id *id);
513
514 /* The following definitions come from lib/gencache.c  */
515
516 bool gencache_set(const char *keystr, const char *value, time_t timeout);
517 bool gencache_del(const char *keystr);
518 bool gencache_get(const char *keystr, char **valstr, time_t *timeout);
519 bool gencache_parse(const char *keystr,
520                     void (*parser)(time_t timeout, DATA_BLOB blob,
521                                    void *private_data),
522                     void *private_data);
523 bool gencache_get_data_blob(const char *keystr, DATA_BLOB *blob,
524                             time_t *timeout, bool *was_expired);
525 bool gencache_stabilize(void);
526 bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob, time_t timeout);
527 void gencache_iterate_blobs(void (*fn)(const char *key, DATA_BLOB value,
528                                        time_t timeout, void *private_data),
529                             void *private_data, const char *pattern);
530 void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr),
531                       void* data, const char* keystr_pattern);
532
533 /* The following definitions come from lib/interface.c  */
534
535 bool ismyaddr(const struct sockaddr *ip);
536 bool ismyip_v4(struct in_addr ip);
537 bool is_local_net(const struct sockaddr *from);
538 void setup_linklocal_scope_id(struct sockaddr *pss);
539 bool is_local_net_v4(struct in_addr from);
540 int iface_count(void);
541 int iface_count_v4_nl(void);
542 const struct in_addr *first_ipv4_iface(void);
543 struct interface *get_interface(int n);
544 const struct sockaddr_storage *iface_n_sockaddr_storage(int n);
545 const struct in_addr *iface_n_ip_v4(int n);
546 const struct in_addr *iface_n_bcast_v4(int n);
547 const struct sockaddr_storage *iface_n_bcast(int n);
548 const struct sockaddr_storage *iface_ip(const struct sockaddr *ip);
549 bool iface_local(const struct sockaddr *ip);
550 void load_interfaces(void);
551 void gfree_interfaces(void);
552 bool interfaces_changed(void);
553
554 /* The following definitions come from lib/ldap_debug_handler.c  */
555
556 void init_ldap_debugging(void);
557
558 /* The following definitions come from lib/ldap_escape.c  */
559
560 char *escape_ldap_string(TALLOC_CTX *mem_ctx, const char *s);
561 char *escape_rdn_val_string_alloc(const char *s);
562
563 /* The following definitions come from lib/module.c  */
564
565 NTSTATUS smb_load_module(const char *module_name);
566 int smb_load_modules(const char **modules);
567 NTSTATUS smb_probe_module(const char *subsystem, const char *module);
568 NTSTATUS smb_load_module(const char *module_name);
569 int smb_load_modules(const char **modules);
570 NTSTATUS smb_probe_module(const char *subsystem, const char *module);
571 void init_modules(void);
572
573 /* The following definitions come from lib/ms_fnmatch.c  */
574
575 int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
576                bool is_case_sensitive);
577 int gen_fnmatch(const char *pattern, const char *string);
578
579 /* The following definitions come from lib/pidfile.c  */
580
581 pid_t pidfile_pid(const char *name);
582 void pidfile_create(const char *program_name);
583 void pidfile_unlink(void);
584
585 /* The following definitions come from lib/privileges.c  */
586
587 bool get_privileges_for_sids(uint64_t *privileges, struct dom_sid *slist, int scount);
588 NTSTATUS get_privileges_for_sid_as_set(TALLOC_CTX *mem_ctx, PRIVILEGE_SET **privileges, struct dom_sid *sid);
589 NTSTATUS privilege_enumerate_accounts(struct dom_sid **sids, int *num_sids);
590 NTSTATUS privilege_enum_sids(enum sec_privilege privilege, TALLOC_CTX *mem_ctx,
591                              struct dom_sid **sids, int *num_sids);
592 bool grant_privilege_set(const struct dom_sid *sid, struct lsa_PrivilegeSet *set);
593 bool grant_privilege_by_name( const struct dom_sid *sid, const char *name);
594 bool revoke_all_privileges( const struct dom_sid *sid );
595 bool revoke_privilege_set(const struct dom_sid *sid, struct lsa_PrivilegeSet *set);
596 bool revoke_privilege_by_name(const struct dom_sid *sid, const char *name);
597 NTSTATUS privilege_create_account(const struct dom_sid *sid );
598 NTSTATUS privilege_delete_account(const struct dom_sid *sid);
599 bool is_privileged_sid( const struct dom_sid *sid );
600 bool grant_all_privileges( const struct dom_sid *sid );
601
602 /* The following definitions come from lib/recvfile.c  */
603
604 ssize_t sys_recvfile(int fromfd,
605                         int tofd,
606                         SMB_OFF_T offset,
607                         size_t count);
608 ssize_t sys_recvfile(int fromfd,
609                         int tofd,
610                         SMB_OFF_T offset,
611                         size_t count);
612 ssize_t drain_socket(int sockfd, size_t count);
613
614 /* The following definitions come from lib/secdesc.c  */
615
616 uint32_t get_sec_info(const struct security_descriptor *sd);
617 struct security_descriptor *sec_desc_merge(TALLOC_CTX *ctx, struct security_descriptor *new_sdb, struct security_descriptor *old_sdb);
618 struct sec_desc_buf *sec_desc_merge_buf(TALLOC_CTX *ctx, struct sec_desc_buf *new_sdb, struct sec_desc_buf *old_sdb);
619 struct security_descriptor *make_sec_desc(TALLOC_CTX *ctx,
620                         enum security_descriptor_revision revision,
621                         uint16 type,
622                         const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
623                         struct security_acl *sacl, struct security_acl *dacl, size_t *sd_size);
624 struct security_descriptor *dup_sec_desc(TALLOC_CTX *ctx, const struct security_descriptor *src);
625 NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
626                            struct security_descriptor *secdesc,
627                            uint8 **data, size_t *len);
628 NTSTATUS marshall_sec_desc_buf(TALLOC_CTX *mem_ctx,
629                                struct sec_desc_buf *secdesc_buf,
630                                uint8_t **data, size_t *len);
631 NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
632                              struct security_descriptor **psecdesc);
633 NTSTATUS unmarshall_sec_desc_buf(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
634                                  struct sec_desc_buf **psecdesc_buf);
635 struct security_descriptor *make_standard_sec_desc(TALLOC_CTX *ctx, const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
636                                  struct security_acl *dacl, size_t *sd_size);
637 struct sec_desc_buf *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, struct security_descriptor *sec_desc);
638 struct sec_desc_buf *dup_sec_desc_buf(TALLOC_CTX *ctx, struct sec_desc_buf *src);
639 NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, const struct dom_sid *sid, uint32 mask, size_t *sd_size);
640 NTSTATUS sec_desc_mod_sid(struct security_descriptor *sd, struct dom_sid *sid, uint32 mask);
641 NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, struct security_descriptor **psd, struct dom_sid *sid, size_t *sd_size);
642 bool sd_has_inheritable_components(const struct security_descriptor *parent_ctr, bool container);
643 NTSTATUS se_create_child_secdesc(TALLOC_CTX *ctx,
644                                         struct security_descriptor **ppsd,
645                                         size_t *psize,
646                                         const struct security_descriptor *parent_ctr,
647                                         const struct dom_sid *owner_sid,
648                                         const struct dom_sid *group_sid,
649                                         bool container);
650 NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
651                                         struct sec_desc_buf **ppsdb,
652                                         const struct security_descriptor *parent_ctr,
653                                         bool container);
654
655 /* The following definitions come from lib/sendfile.c  */
656
657 ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
658
659 /* The following definitions come from lib/server_mutex.c  */
660
661 struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
662                                      int timeout);
663
664 /* The following definitions come from lib/sharesec.c  */
665
666 bool share_info_db_init(void);
667 struct security_descriptor *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32 def_access);
668 struct security_descriptor *get_share_security( TALLOC_CTX *ctx, const char *servicename,
669                               size_t *psize);
670 bool set_share_security(const char *share_name, struct security_descriptor *psd);
671 bool delete_share_security(const char *servicename);
672 bool share_access_check(const struct security_token *token, const char *sharename,
673                         uint32 desired_access);
674 bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, struct security_descriptor **ppsd);
675
676 /* The following definitions come from lib/smbrun.c  */
677
678 int smbrun_no_sanitize(const char *cmd, int *outfd);
679 int smbrun(const char *cmd, int *outfd);
680 int smbrunsecret(const char *cmd, const char *secret);
681
682 /* The following definitions come from lib/sock_exec.c  */
683
684 int sock_exec(const char *prog);
685
686 /* The following definitions come from lib/substitute.c  */
687
688 void free_local_machine_name(void);
689 bool set_local_machine_name(const char *local_name, bool perm);
690 const char *get_local_machine_name(void);
691 bool set_remote_machine_name(const char *remote_name, bool perm);
692 const char *get_remote_machine_name(void);
693 void sub_set_smb_name(const char *name);
694 void set_current_user_info(const char *smb_name, const char *unix_name,
695                            const char *domain);
696 void sub_set_socket_ids(const char *peeraddr, const char *peername,
697                         const char *sockaddr);
698 const char *get_current_username(void);
699 void standard_sub_basic(const char *smb_name, const char *domain_name,
700                         char *str, size_t len);
701 char *talloc_sub_basic(TALLOC_CTX *mem_ctx, const char *smb_name,
702                        const char *domain_name, const char *str);
703 char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
704                         const char *input_string,
705                         const char *username,
706                         const char *domain,
707                         uid_t uid,
708                         gid_t gid);
709 char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
710                           const char *servicename, const char *user,
711                           const char *connectpath, gid_t gid,
712                           const char *smb_name, const char *domain_name,
713                           const char *str);
714 void standard_sub_advanced(const char *servicename, const char *user,
715                            const char *connectpath, gid_t gid,
716                            const char *smb_name, const char *domain_name,
717                            char *str, size_t len);
718 char *standard_sub_conn(TALLOC_CTX *ctx, connection_struct *conn, const char *str);
719
720 /* The following definitions come from lib/sysacls.c  */
721
722 int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p);
723 int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p);
724 int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
725 void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d);
726 int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d);
727 int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
728 int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm);
729 char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p);
730 SMB_ACL_T sys_acl_init(int count);
731 int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p);
732 int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type);
733 int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p);
734 int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d);
735 int sys_acl_free_text(char *text);
736 int sys_acl_free_acl(SMB_ACL_T acl_d) ;
737 int sys_acl_free_qualifier(void *qual, SMB_ACL_TAG_T tagtype);
738 int sys_acl_valid(SMB_ACL_T acl_d);
739 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, 
740                            const char *path_p, SMB_ACL_TYPE_T type);
741 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
742 int sys_acl_set_file(vfs_handle_struct *handle,
743                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
744 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
745                    SMB_ACL_T acl_d);
746 int sys_acl_delete_def_file(vfs_handle_struct *handle,
747                             const char *path);
748 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
749                            const char *path_p, SMB_ACL_TYPE_T type);
750 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
751 int sys_acl_set_file(vfs_handle_struct *handle,
752                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
753 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
754                    SMB_ACL_T acl_d);
755 int sys_acl_delete_def_file(vfs_handle_struct *handle,
756                             const char *path);
757 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
758                            const char *path_p, SMB_ACL_TYPE_T type);
759 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
760 int sys_acl_set_file(vfs_handle_struct *handle,
761                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
762 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
763                    SMB_ACL_T acl_d);
764 int sys_acl_delete_def_file(vfs_handle_struct *handle,
765                             const char *path);
766 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
767                            const char *path_p, SMB_ACL_TYPE_T type);
768 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
769 int sys_acl_set_file(vfs_handle_struct *handle,
770                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
771 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
772                    SMB_ACL_T acl_d);
773 int sys_acl_delete_def_file(vfs_handle_struct *handle,
774                             const char *path);
775 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
776                            const char *path_p, SMB_ACL_TYPE_T type);
777 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
778 int sys_acl_set_file(vfs_handle_struct *handle,
779                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
780 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
781                    SMB_ACL_T acl_d);
782 int sys_acl_delete_def_file(vfs_handle_struct *handle,
783                             const char *path);
784 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
785                            const char *path_p, SMB_ACL_TYPE_T type);
786 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
787 int sys_acl_set_file(vfs_handle_struct *handle,
788                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
789 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
790                    SMB_ACL_T acl_d);
791 int sys_acl_delete_def_file(vfs_handle_struct *handle,
792                             const char *path);
793 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
794                            const char *path_p, SMB_ACL_TYPE_T type);
795 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp);
796 int sys_acl_set_file(vfs_handle_struct *handle,
797                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d);
798 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
799                    SMB_ACL_T acl_d);
800 int sys_acl_delete_def_file(vfs_handle_struct *handle,
801                             const char *path);
802 int no_acl_syscall_error(int err);
803
804 /* The following definitions come from lib/sysquotas.c  */
805
806 int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
807 int sys_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
808
809 /* The following definitions come from lib/sysquotas_*.c  */
810
811 int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
812 int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
813
814 int sys_get_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
815 int sys_set_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
816
817 int sys_get_nfs_quota(const char *path, const char *bdev,
818                       enum SMB_QUOTA_TYPE qtype,
819                       unid_t id, SMB_DISK_QUOTA *dp);
820 int sys_set_nfs_quota(const char *path, const char *bdev,
821                       enum SMB_QUOTA_TYPE qtype,
822                       unid_t id, SMB_DISK_QUOTA *dp);
823
824 /* The following definitions come from lib/system.c  */
825
826 void *sys_memalign( size_t align, size_t size );
827 int sys_usleep(long usecs);
828 ssize_t sys_read(int fd, void *buf, size_t count);
829 ssize_t sys_write(int fd, const void *buf, size_t count);
830 ssize_t sys_writev(int fd, const struct iovec *iov, int iovcnt);
831 ssize_t sys_pread(int fd, void *buf, size_t count, SMB_OFF_T off);
832 ssize_t sys_pwrite(int fd, const void *buf, size_t count, SMB_OFF_T off);
833 ssize_t sys_send(int s, const void *msg, size_t len, int flags);
834 ssize_t sys_sendto(int s,  const void *msg, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
835 ssize_t sys_recv(int fd, void *buf, size_t count, int flags);
836 ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
837 int sys_fcntl_ptr(int fd, int cmd, void *arg);
838 int sys_fcntl_long(int fd, int cmd, long arg);
839 void update_stat_ex_mtime(struct stat_ex *dst, struct timespec write_ts);
840 void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time);
841 int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf,
842              bool fake_dir_create_times);
843 int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf,
844               bool fake_dir_create_times);
845 int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
846               bool fake_dir_create_times);
847 int sys_ftruncate(int fd, SMB_OFF_T offset);
848 int sys_posix_fallocate(int fd, SMB_OFF_T offset, SMB_OFF_T len);
849 int sys_fallocate(int fd, enum vfs_fallocate_mode mode, SMB_OFF_T offset, SMB_OFF_T len);
850 SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence);
851 int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence);
852 SMB_OFF_T sys_ftell(FILE *fp);
853 int sys_creat(const char *path, mode_t mode);
854 int sys_open(const char *path, int oflag, mode_t mode);
855 FILE *sys_fopen(const char *path, const char *type);
856 void kernel_flock(int fd, uint32 share_mode, uint32 access_mask);
857 SMB_STRUCT_DIR *sys_opendir(const char *name);
858 SMB_STRUCT_DIR *sys_fdopendir(int fd);
859 SMB_STRUCT_DIRENT *sys_readdir(SMB_STRUCT_DIR *dirp);
860 void sys_seekdir(SMB_STRUCT_DIR *dirp, long offset);
861 long sys_telldir(SMB_STRUCT_DIR *dirp);
862 void sys_rewinddir(SMB_STRUCT_DIR *dirp);
863 int sys_closedir(SMB_STRUCT_DIR *dirp);
864 int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
865 int sys_waitpid(pid_t pid,int *status,int options);
866 char *sys_getwd(char *s);
867 void set_effective_capability(enum smbd_capability capability);
868 void drop_effective_capability(enum smbd_capability capability);
869 long sys_random(void);
870 void sys_srandom(unsigned int seed);
871 int groups_max(void);
872 int sys_getgroups(int setlen, gid_t *gidset);
873 int sys_setgroups(gid_t UNUSED(primary_gid), int setlen, gid_t *gidset);
874 void sys_setpwent(void);
875 struct passwd *sys_getpwent(void);
876 void sys_endpwent(void);
877 struct passwd *sys_getpwnam(const char *name);
878 struct passwd *sys_getpwuid(uid_t uid);
879 struct group *sys_getgrnam(const char *name);
880 struct group *sys_getgrgid(gid_t gid);
881 int sys_popen(const char *command);
882 int sys_pclose(int fd);
883 ssize_t sys_getxattr (const char *path, const char *name, void *value, size_t size);
884 ssize_t sys_lgetxattr (const char *path, const char *name, void *value, size_t size);
885 ssize_t sys_fgetxattr (int filedes, const char *name, void *value, size_t size);
886 ssize_t sys_listxattr (const char *path, char *list, size_t size);
887 ssize_t sys_llistxattr (const char *path, char *list, size_t size);
888 ssize_t sys_flistxattr (int filedes, char *list, size_t size);
889 int sys_removexattr (const char *path, const char *name);
890 int sys_lremovexattr (const char *path, const char *name);
891 int sys_fremovexattr (int filedes, const char *name);
892 int sys_setxattr (const char *path, const char *name, const void *value, size_t size, int flags);
893 int sys_lsetxattr (const char *path, const char *name, const void *value, size_t size, int flags);
894 int sys_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags);
895 uint32 unix_dev_major(SMB_DEV_T dev);
896 uint32 unix_dev_minor(SMB_DEV_T dev);
897 int sys_aio_read(SMB_STRUCT_AIOCB *aiocb);
898 int sys_aio_write(SMB_STRUCT_AIOCB *aiocb);
899 ssize_t sys_aio_return(SMB_STRUCT_AIOCB *aiocb);
900 int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb);
901 int sys_aio_error(const SMB_STRUCT_AIOCB *aiocb);
902 int sys_aio_fsync(int op, SMB_STRUCT_AIOCB *aiocb);
903 int sys_aio_suspend(const SMB_STRUCT_AIOCB * const cblist[], int n, const struct timespec *timeout);
904 int sys_aio_read(SMB_STRUCT_AIOCB *aiocb);
905 int sys_aio_write(SMB_STRUCT_AIOCB *aiocb);
906 ssize_t sys_aio_return(SMB_STRUCT_AIOCB *aiocb);
907 int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb);
908 int sys_aio_error(const SMB_STRUCT_AIOCB *aiocb);
909 int sys_aio_fsync(int op, SMB_STRUCT_AIOCB *aiocb);
910 int sys_aio_suspend(const SMB_STRUCT_AIOCB * const cblist[], int n, const struct timespec *timeout);
911 int sys_getpeereid( int s, uid_t *uid);
912 int sys_getnameinfo(const struct sockaddr *psa,
913                         socklen_t salen,
914                         char *host,
915                         size_t hostlen,
916                         char *service,
917                         size_t servlen,
918                         int flags);
919 int sys_connect(int fd, const struct sockaddr * addr);
920
921 /* The following definitions come from lib/system_smbd.c  */
922
923 bool getgroups_unix_user(TALLOC_CTX *mem_ctx, const char *user,
924                          gid_t primary_gid,
925                          gid_t **ret_groups, uint32_t *p_ngroups);
926
927 /* The following definitions come from lib/tallocmsg.c  */
928
929 void register_msg_pool_usage(struct messaging_context *msg_ctx);
930
931 /* The following definitions come from lib/time.c  */
932
933 void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset);
934 void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
935 void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
936 uint32_t convert_time_t_to_uint32_t(time_t t);
937 time_t convert_uint32_t_to_time_t(uint32_t u);
938 bool nt_time_is_zero(const NTTIME *nt);
939 time_t generalized_to_unix_time(const char *str);
940 int get_server_zone_offset(void);
941 int set_server_zone_offset(time_t t);
942 char *timeval_string(TALLOC_CTX *ctx, const struct timeval *tp, bool hires);
943 char *current_timestring(TALLOC_CTX *ctx, bool hires);
944 void srv_put_dos_date(char *buf,int offset,time_t unixdate);
945 void srv_put_dos_date2(char *buf,int offset, time_t unixdate);
946 void srv_put_dos_date3(char *buf,int offset,time_t unixdate);
947 void round_timespec(enum timestamp_set_resolution res, struct timespec *ts);
948 void put_long_date_timespec(enum timestamp_set_resolution res, char *p, struct timespec ts);
949 void put_long_date(char *p, time_t t);
950 void dos_filetime_timespec(struct timespec *tsp);
951 time_t make_unix_date(const void *date_ptr, int zone_offset);
952 time_t make_unix_date2(const void *date_ptr, int zone_offset);
953 time_t make_unix_date3(const void *date_ptr, int zone_offset);
954 time_t srv_make_unix_date(const void *date_ptr);
955 time_t srv_make_unix_date2(const void *date_ptr);
956 time_t srv_make_unix_date3(const void *date_ptr);
957 struct timespec convert_time_t_to_timespec(time_t t);
958 struct timespec convert_timeval_to_timespec(const struct timeval tv);
959 struct timeval convert_timespec_to_timeval(const struct timespec ts);
960 struct timespec timespec_current(void);
961 struct timespec timespec_min(const struct timespec *ts1,
962                            const struct timespec *ts2);
963 int timespec_compare(const struct timespec *ts1, const struct timespec *ts2);
964 void round_timespec_to_sec(struct timespec *ts);
965 void round_timespec_to_usec(struct timespec *ts);
966 struct timespec interpret_long_date(const char *p);
967 void TimeInit(void);
968 void get_process_uptime(struct timeval *ret_time);
969 void get_startup_time(struct timeval *ret_time);
970 time_t nt_time_to_unix_abs(const NTTIME *nt);
971 time_t uint64s_nt_time_to_unix_abs(const uint64_t *src);
972 void unix_timespec_to_nt_time(NTTIME *nt, struct timespec ts);
973 void unix_to_nt_time_abs(NTTIME *nt, time_t t);
974 const char *time_to_asc(const time_t t);
975 const char *display_time(NTTIME nttime);
976 bool nt_time_is_set(const NTTIME *nt);
977
978 /* The following definitions come from lib/username.c  */
979
980 struct passwd *tcopy_passwd(TALLOC_CTX *mem_ctx, const struct passwd *from) ;
981 void flush_pwnam_cache(void);
982 struct passwd *getpwuid_alloc(TALLOC_CTX *mem_ctx, uid_t uid) ;
983 char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
984 struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
985
986 /* The following definitions come from lib/util_names.c  */
987 void gfree_netbios_names(void);
988 bool set_global_myname(const char *myname);
989 const char *global_myname(void);
990 bool set_global_myworkgroup(const char *myworkgroup);
991 const char *lp_workgroup(void);
992 const char *get_global_sam_name(void);
993
994 /* The following definitions come from lib/util.c  */
995
996 enum protocol_types get_Protocol(void);
997 void set_Protocol(enum protocol_types  p);
998 bool all_zero(const uint8_t *ptr, size_t size);
999 bool set_global_scope(const char *scope);
1000 const char *global_scope(void);
1001 void gfree_names(void);
1002 void gfree_all( void );
1003 const char *my_netbios_names(int i);
1004 bool set_netbios_aliases(const char **str_array);
1005 bool init_names(void);
1006 struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx);
1007 const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info);
1008 void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
1009                                     const char *username);
1010 const char *get_cmdline_auth_info_domain(const struct user_auth_info *auth_info);
1011 void set_cmdline_auth_info_domain(struct user_auth_info *auth_info,
1012                                   const char *domain);
1013 void set_cmdline_auth_info_password(struct user_auth_info *auth_info,
1014                                     const char *password);
1015 const char *get_cmdline_auth_info_password(const struct user_auth_info *auth_info);
1016 bool set_cmdline_auth_info_signing_state(struct user_auth_info *auth_info,
1017                                          const char *arg);
1018 int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info);
1019 void set_cmdline_auth_info_use_ccache(struct user_auth_info *auth_info,
1020                                       bool b);
1021 bool get_cmdline_auth_info_use_ccache(const struct user_auth_info *auth_info);
1022 void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info,
1023                                         bool b);
1024 bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info);
1025 void set_cmdline_auth_info_fallback_after_kerberos(struct user_auth_info *auth_info,
1026                                         bool b);
1027 bool get_cmdline_auth_info_fallback_after_kerberos(const struct user_auth_info *auth_info);
1028 void set_cmdline_auth_info_use_krb5_ticket(struct user_auth_info *auth_info);
1029 void set_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info);
1030 void set_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info);
1031 bool get_cmdline_auth_info_got_pass(const struct user_auth_info *auth_info);
1032 bool get_cmdline_auth_info_smb_encrypt(const struct user_auth_info *auth_info);
1033 bool get_cmdline_auth_info_use_machine_account(const struct user_auth_info *auth_info);
1034 struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx,
1035                                                  const struct user_auth_info *info);
1036 bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_info);
1037 void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info);
1038 bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
1039                      bool fake_dir_create_times);
1040 bool socket_exist(const char *fname);
1041 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
1042 SMB_OFF_T get_file_size(char *file_name);
1043 char *attrib_string(uint16 mode);
1044 void show_msg(char *buf);
1045 void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num);
1046 void smb_setlen(char *buf,int len);
1047 int set_message_bcc(char *buf,int num_bytes);
1048 ssize_t message_push_blob(uint8 **outbuf, DATA_BLOB blob);
1049 char *unix_clean_name(TALLOC_CTX *ctx, const char *s);
1050 char *clean_name(TALLOC_CTX *ctx, const char *s);
1051 ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos);
1052 int set_blocking(int fd, bool set);
1053 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
1054                            struct event_context *ev_ctx,
1055                            struct server_id id,
1056                            bool parent_longlived);
1057 void *malloc_(size_t size);
1058 void *memalign_array(size_t el_size, size_t align, unsigned int count);
1059 void *calloc_array(size_t size, size_t nmemb);
1060 void *Realloc(void *p, size_t size, bool free_old_on_error);
1061 void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
1062                         void *element, void *_array, uint32 *num_elements,
1063                         ssize_t *array_size);
1064 char *get_myname(TALLOC_CTX *ctx);
1065 char *get_mydnsdomname(TALLOC_CTX *ctx);
1066 int interpret_protocol(const char *str,int def);
1067 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
1068 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
1069 bool process_exists(const struct server_id pid);
1070 const char *uidtoname(uid_t uid);
1071 char *gidtoname(gid_t gid);
1072 uid_t nametouid(const char *name);
1073 gid_t nametogid(const char *name);
1074 void smb_panic_s3(const char *why);
1075 void log_stack_trace(void);
1076 const char *readdirname(SMB_STRUCT_DIR *p);
1077 bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensitive);
1078 void set_namearray(name_compare_entry **ppname_array, const char *namelist);
1079 void free_namearray(name_compare_entry *name_array);
1080 bool fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
1081 bool fcntl_getlock(int fd, SMB_OFF_T *poffset, SMB_OFF_T *pcount, int *ptype, pid_t *ppid);
1082 bool is_myname(const char *s);
1083 bool is_myworkgroup(const char *s);
1084 void ra_lanman_string( const char *native_lanman );
1085 const char *get_remote_arch_str(void);
1086 void set_remote_arch(enum remote_arch_types type);
1087 enum remote_arch_types get_remote_arch(void);
1088 const char *tab_depth(int level, int depth);
1089 int str_checksum(const char *s);
1090 void zero_free(void *p, size_t size);
1091 int set_maxfiles(int requested_max);
1092 int smb_mkstemp(char *name_template);
1093 void *smb_xmalloc_array(size_t size, unsigned int count);
1094 char *myhostname(void);
1095 char *lock_path(const char *name);
1096 char *pid_path(const char *name);
1097 char *lib_path(const char *name);
1098 char *modules_path(const char *name);
1099 char *data_path(const char *name);
1100 char *state_path(const char *name);
1101 char *cache_path(const char *name);
1102 const char *shlib_ext(void);
1103 bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
1104                     const char **name);
1105 bool ms_has_wild(const char *s);
1106 bool ms_has_wild_w(const smb_ucs2_t *s);
1107 bool mask_match(const char *string, const char *pattern, bool is_case_sensitive);
1108 bool mask_match_search(const char *string, const char *pattern, bool is_case_sensitive);
1109 bool mask_match_list(const char *string, char **list, int listLen, bool is_case_sensitive);
1110 bool unix_wild_match(const char *pattern, const char *string);
1111 bool name_to_fqdn(fstring fqdn, const char *name);
1112 void *talloc_append_blob(TALLOC_CTX *mem_ctx, void *buf, DATA_BLOB blob);
1113 uint32 map_share_mode_to_deny_mode(uint32 share_access, uint32 private_options);
1114 pid_t procid_to_pid(const struct server_id *proc);
1115 void set_my_vnn(uint32 vnn);
1116 uint32 get_my_vnn(void);
1117 void set_my_unique_id(uint64_t unique_id);
1118 struct server_id pid_to_procid(pid_t pid);
1119 struct server_id procid_self(void);
1120 bool procid_equal(const struct server_id *p1, const struct server_id *p2);
1121 bool cluster_id_equal(const struct server_id *id1,
1122                       const struct server_id *id2);
1123 bool procid_is_me(const struct server_id *pid);
1124 struct server_id interpret_pid(const char *pid_string);
1125 char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid);
1126 char *procid_str_static(const struct server_id *pid);
1127 bool procid_valid(const struct server_id *pid);
1128 bool procid_is_local(const struct server_id *pid);
1129 bool trans_oob(uint32_t bufsize, uint32_t offset, uint32_t length);
1130 bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t off);
1131 char *get_safe_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
1132 char *get_safe_str_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
1133 int get_safe_SVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, int failval);
1134 int get_safe_IVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, int failval);
1135 void split_domain_user(TALLOC_CTX *mem_ctx,
1136                        const char *full_name,
1137                        char **domain,
1138                        char **user);
1139 void *_talloc_zero_zeronull(const void *ctx, size_t size, const char *name);
1140 void *_talloc_memdup_zeronull(const void *t, const void *p, size_t size, const char *name);
1141 void *_talloc_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
1142 void *_talloc_zero_array_zeronull(const void *ctx, size_t el_size, unsigned count, const char *name);
1143 void *talloc_zeronull(const void *context, size_t size, const char *name);
1144 const char *strip_hostname(const char *s);
1145 bool tevent_req_poll_ntstatus(struct tevent_req *req,
1146                               struct tevent_context *ev,
1147                               NTSTATUS *status);
1148 bool any_nt_status_not_ok(NTSTATUS err1, NTSTATUS err2, NTSTATUS *result);
1149 int timeval_to_msec(struct timeval t);
1150
1151 /* The following definitions come from lib/util_file.c  */
1152
1153 char **file_lines_pload(const char *syscmd, int *numlines);
1154 void file_lines_free(char **lines);
1155
1156 /* The following definitions come from lib/util_nscd.c  */
1157
1158 void smb_nscd_flush_user_cache(void);
1159 void smb_nscd_flush_group_cache(void);
1160
1161 /* The following definitions come from lib/util_nttoken.c  */
1162
1163 struct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_token *ptoken);
1164 NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
1165                         const struct security_token *token_1,
1166                         const struct security_token *token_2,
1167                         struct security_token **token_out);
1168 bool token_sid_in_ace(const struct security_token *token, const struct security_ace *ace);
1169
1170 /* The following definitions come from ..libcli/registry/util_reg.c  */
1171
1172 const char *str_regtype(int type);
1173 int regtype_by_string(const char *str);
1174 bool push_reg_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *s);
1175 bool push_reg_multi_sz(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char **a);
1176 bool pull_reg_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char **s);
1177 bool pull_reg_multi_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char ***a);
1178
1179 /* The following definitions come from lib/util_sec.c  */
1180
1181 void sec_init(void);
1182 uid_t sec_initial_uid(void);
1183 gid_t sec_initial_gid(void);
1184 bool non_root_mode(void);
1185 void gain_root_privilege(void);
1186 void gain_root_group_privilege(void);
1187 void set_effective_uid(uid_t uid);
1188 void set_effective_gid(gid_t gid);
1189 void save_re_uid(void);
1190 void restore_re_uid_fromroot(void);
1191 void restore_re_uid(void);
1192 void save_re_gid(void);
1193 void restore_re_gid(void);
1194 int set_re_uid(void);
1195 void become_user_permanently(uid_t uid, gid_t gid);
1196 bool is_setuid_root(void) ;
1197
1198 /* The following definitions come from lib/util_sid.c  */
1199
1200 char *sid_to_fstring(fstring sidstr_out, const struct dom_sid *sid);
1201 char *sid_string_talloc(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
1202 char *sid_string_dbg(const struct dom_sid *sid);
1203 char *sid_string_tos(const struct dom_sid *sid);
1204 bool sid_linearize(char *outbuf, size_t len, const struct dom_sid *sid);
1205 bool non_mappable_sid(struct dom_sid *sid);
1206 char *sid_binstring_hex(const struct dom_sid *sid);
1207 NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
1208                               const struct netr_SamInfo3 *info3,
1209                               struct dom_sid **user_sids,
1210                               uint32_t *num_user_sids,
1211                               bool include_user_group_rid,
1212                               bool skip_ressource_groups);
1213
1214 /* The following definitions come from lib/util_sock.c  */
1215
1216 bool is_broadcast_addr(const struct sockaddr *pss);
1217 bool is_loopback_ip_v4(struct in_addr ip);
1218 bool is_loopback_addr(const struct sockaddr *pss);
1219 bool is_zero_addr(const struct sockaddr_storage *pss);
1220 void zero_ip_v4(struct in_addr *ip);
1221 void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
1222                 struct in_addr ip);
1223 bool same_net(const struct sockaddr *ip1,
1224                 const struct sockaddr *ip2,
1225                 const struct sockaddr *mask);
1226 bool sockaddr_equal(const struct sockaddr *ip1,
1227                 const struct sockaddr *ip2);
1228 bool is_address_any(const struct sockaddr *psa);
1229 uint16_t get_sockaddr_port(const struct sockaddr_storage *pss);
1230 char *print_sockaddr(char *dest,
1231                         size_t destlen,
1232                         const struct sockaddr_storage *psa);
1233 char *print_canonical_sockaddr(TALLOC_CTX *ctx,
1234                         const struct sockaddr_storage *pss);
1235 const char *client_name(int fd);
1236 int get_socket_port(int fd);
1237 const char *client_addr(int fd, char *addr, size_t addrlen);
1238 const char *client_socket_addr(int fd, char *addr, size_t addr_len);
1239 int client_socket_port(int fd);
1240 void set_smb_read_error(enum smb_read_errors *pre,
1241                         enum smb_read_errors newerr);
1242 void cond_set_smb_read_error(enum smb_read_errors *pre,
1243                         enum smb_read_errors newerr);
1244 bool is_a_socket(int fd);
1245 void set_socket_options(int fd, const char *options);
1246 ssize_t read_udp_v4_socket(int fd,
1247                         char *buf,
1248                         size_t len,
1249                         struct sockaddr_storage *psa);
1250 NTSTATUS read_fd_with_timeout(int fd, char *buf,
1251                                   size_t mincnt, size_t maxcnt,
1252                                   unsigned int time_out,
1253                                   size_t *size_ret);
1254 NTSTATUS read_data(int fd, char *buffer, size_t N);
1255 ssize_t write_data(int fd, const char *buffer, size_t N);
1256 ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt);
1257 bool send_keepalive(int client);
1258 NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
1259                                           unsigned int timeout,
1260                                           size_t *len);
1261 NTSTATUS receive_smb_raw(int fd,
1262                         char *buffer,
1263                         size_t buflen,
1264                         unsigned int timeout,
1265                         size_t maxlen,
1266                         size_t *p_len);
1267 int open_socket_in(int type,
1268                 uint16_t port,
1269                 int dlevel,
1270                 const struct sockaddr_storage *psock,
1271                 bool rebind);
1272 NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
1273                          int timeout, int *pfd);
1274 struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
1275                                         struct event_context *ev,
1276                                         const struct sockaddr_storage *pss,
1277                                         uint16_t port,
1278                                         int timeout);
1279 NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd);
1280 struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
1281                                               struct event_context *ev,
1282                                               struct timeval wait_time,
1283                                               const struct sockaddr_storage *pss,
1284                                               uint16_t port,
1285                                               int timeout);
1286 NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd);
1287 int open_udp_socket(const char *host, int port);
1288 const char *get_peer_name(int fd, bool force_lookup);
1289 const char *get_peer_addr(int fd, char *addr, size_t addr_len);
1290 int create_pipe_sock(const char *socket_dir,
1291                      const char *socket_name,
1292                      mode_t dir_perms);
1293 const char *get_mydnsfullname(void);
1294 bool is_myname_or_ipaddr(const char *s);
1295 struct tevent_req *getaddrinfo_send(TALLOC_CTX *mem_ctx,
1296                                     struct tevent_context *ev,
1297                                     struct fncall_context *ctx,
1298                                     const char *node,
1299                                     const char *service,
1300                                     const struct addrinfo *hints);
1301 int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res);
1302 int poll_one_fd(int fd, int events, int timeout, int *revents);
1303 int poll_intr_one_fd(int fd, int events, int timeout, int *revents);
1304 struct tevent_req *tstream_read_packet_send(TALLOC_CTX *mem_ctx,
1305                                             struct tevent_context *ev,
1306                                             struct tstream_context *stream,
1307                                             size_t initial,
1308                                             ssize_t (*more)(uint8_t *buf,
1309                                                             size_t buflen,
1310                                                             void *private_data),
1311                                             void *private_data);
1312 ssize_t tstream_read_packet_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
1313                                  uint8_t **pbuf, int *perrno);
1314
1315 /* The following definitions come from lib/util_str.c  */
1316
1317 bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize);
1318 int StrCaseCmp(const char *s, const char *t);
1319 int StrnCaseCmp(const char *s, const char *t, size_t len);
1320 bool strnequal(const char *s1,const char *s2,size_t n);
1321 bool strcsequal(const char *s1,const char *s2);
1322 void strnorm(char *s, int case_default);
1323 bool strisnormal(const char *s, int case_default);
1324 char *push_skip_string(char *buf);
1325 char *skip_string(const char *base, size_t len, char *buf);
1326 size_t str_charnum(const char *s);
1327 size_t str_ascii_charnum(const char *s);
1328 bool trim_char(char *s,char cfront,char cback);
1329 bool strhasupper(const char *s);
1330 bool strhaslower(const char *s);
1331 char *safe_strcpy_fn(char *dest,
1332                 const char *src,
1333                 size_t maxlength);
1334 char *safe_strcat_fn(char *dest,
1335                 const char *src,
1336                 size_t maxlength);
1337 char *alpha_strcpy(char *dest,
1338                 const char *src,
1339                 const char *other_safe_chars,
1340                 size_t maxlength);
1341 char *StrnCpy(char *dest,const char *src,size_t n);
1342 bool in_list(const char *s, const char *list, bool casesensitive);
1343 void string_free(char **s);
1344 bool string_set(char **dest,const char *src);
1345 void string_sub2(char *s,const char *pattern, const char *insert, size_t len,
1346                  bool remove_unsafe_characters, bool replace_once,
1347                  bool allow_trailing_dollar);
1348 void string_sub_once(char *s, const char *pattern,
1349                 const char *insert, size_t len);
1350 void string_sub(char *s,const char *pattern, const char *insert, size_t len);
1351 void fstring_sub(char *s,const char *pattern,const char *insert);
1352 char *realloc_string_sub2(char *string,
1353                         const char *pattern,
1354                         const char *insert,
1355                         bool remove_unsafe_characters,
1356                         bool allow_trailing_dollar);
1357 char *realloc_string_sub(char *string,
1358                         const char *pattern,
1359                         const char *insert);
1360 char *talloc_string_sub2(TALLOC_CTX *mem_ctx, const char *src,
1361                         const char *pattern,
1362                         const char *insert,
1363                         bool remove_unsafe_characters,
1364                         bool replace_once,
1365                         bool allow_trailing_dollar);
1366 char *talloc_string_sub(TALLOC_CTX *mem_ctx,
1367                         const char *src,
1368                         const char *pattern,
1369                         const char *insert);
1370 void all_string_sub(char *s,const char *pattern,const char *insert, size_t len);
1371 char *talloc_all_string_sub(TALLOC_CTX *ctx,
1372                                 const char *src,
1373                                 const char *pattern,
1374                                 const char *insert);
1375 char *octal_string(int i);
1376 char *string_truncate(char *s, unsigned int length);
1377 char *strchr_m(const char *src, char c);
1378 char *strrchr_m(const char *s, char c);
1379 char *strnrchr_m(const char *s, char c, unsigned int n);
1380 char *strstr_m(const char *src, const char *findstr);
1381 void strlower_m(char *s);
1382 void strupper_m(char *s);
1383 size_t strlen_m(const char *s);
1384 size_t strlen_m_term(const char *s);
1385 size_t strlen_m_term_null(const char *s);
1386 int fstr_sprintf(fstring s, const char *fmt, ...);
1387 bool str_list_sub_basic( char **list, const char *smb_name,
1388                          const char *domain_name );
1389 bool str_list_substitute(char **list, const char *pattern, const char *insert);
1390
1391 char *ipstr_list_make(char **ipstr_list,
1392                         const struct ip_service *ip_list,
1393                         int ip_count);
1394 int ipstr_list_parse(const char *ipstr_list, struct ip_service **ip_list);
1395 void ipstr_list_free(char* ipstr_list);
1396 DATA_BLOB base64_decode_data_blob(const char *s);
1397 void base64_decode_inplace(char *s);
1398 char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data);
1399 uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr);
1400 SMB_OFF_T conv_str_size(const char * str);
1401 void string_append(char **left, const char *right);
1402 bool add_string_to_array(TALLOC_CTX *mem_ctx,
1403                          const char *str, const char ***strings,
1404                          int *num);
1405 void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len,
1406                     size_t *bufsize, const char *fmt, ...);
1407 int asprintf_strupper_m(char **strp, const char *fmt, ...);
1408 char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...);
1409 char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...);
1410 char *sstring_sub(const char *src, char front, char back);
1411 bool validate_net_name( const char *name,
1412                 const char *invalid_chars,
1413                 int max_len);
1414 char *escape_shell_string(const char *src);
1415 char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
1416 char *sanitize_username(TALLOC_CTX *mem_ctx, const char *username);
1417
1418 /* The following definitions come from lib/util_unistr.c  */
1419
1420 void gfree_case_tables(void);
1421 void load_case_tables(void);
1422 size_t dos_PutUniCode(char *dst,const char *src, size_t len, bool null_terminate);
1423 char *skip_unibuf(char *src, size_t len);
1424 int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags);
1425 int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src);
1426 bool isvalid83_w(smb_ucs2_t c);
1427 size_t strlen_w(const smb_ucs2_t *src);
1428 size_t strnlen_w(const smb_ucs2_t *src, size_t max);
1429 smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
1430 smb_ucs2_t *strchr_wa(const smb_ucs2_t *s, char c);
1431 smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
1432 smb_ucs2_t *strnrchr_w(const smb_ucs2_t *s, smb_ucs2_t c, unsigned int n);
1433 smb_ucs2_t *strstr_w(const smb_ucs2_t *s, const smb_ucs2_t *ins);
1434 bool strlower_w(smb_ucs2_t *s);
1435 bool strupper_w(smb_ucs2_t *s);
1436 void strnorm_w(smb_ucs2_t *s, int case_default);
1437 int strcmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b);
1438 int strncmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b, size_t len);
1439 int strcasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b);
1440 int strncasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b, size_t len);
1441 bool strequal_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
1442 bool strnequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2,size_t n);
1443 smb_ucs2_t *strdup_w(const smb_ucs2_t *src);
1444 smb_ucs2_t *strndup_w(const smb_ucs2_t *src, size_t len);
1445 smb_ucs2_t *strncpy_w(smb_ucs2_t *dest, const smb_ucs2_t *src, const size_t max);
1446 smb_ucs2_t *strncat_w(smb_ucs2_t *dest, const smb_ucs2_t *src, const size_t max);
1447 smb_ucs2_t *strcat_w(smb_ucs2_t *dest, const smb_ucs2_t *src);
1448 void string_replace_w(smb_ucs2_t *s, smb_ucs2_t oldc, smb_ucs2_t newc);
1449 bool trim_string_w(smb_ucs2_t *s, const smb_ucs2_t *front,
1450                                   const smb_ucs2_t *back);
1451 int strcmp_wa(const smb_ucs2_t *a, const char *b);
1452 int strncmp_wa(const smb_ucs2_t *a, const char *b, size_t len);
1453 smb_ucs2_t *strpbrk_wa(const smb_ucs2_t *s, const char *p);
1454 smb_ucs2_t *strstr_wa(const smb_ucs2_t *s, const char *ins);
1455 int toupper_ascii(int c);
1456 int tolower_ascii(int c);
1457 int isupper_ascii(int c);
1458 int islower_ascii(int c);
1459
1460 /* The following definitions come from lib/version.c  */
1461
1462 const char *samba_version_string(void);
1463
1464 /* The following definitions come from lib/winbind_util.c  */
1465
1466 bool winbind_lookup_name(const char *dom_name, const char *name, struct dom_sid *sid,
1467                          enum lsa_SidType *name_type);
1468 bool winbind_lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
1469                         const char **domain, const char **name,
1470                         enum lsa_SidType *name_type);
1471 bool winbind_ping(void);
1472 bool winbind_sid_to_uid(uid_t *puid, const struct dom_sid *sid);
1473 bool winbind_uid_to_sid(struct dom_sid *sid, uid_t uid);
1474 bool winbind_sid_to_gid(gid_t *pgid, const struct dom_sid *sid);
1475 bool winbind_gid_to_sid(struct dom_sid *sid, gid_t gid);
1476 struct passwd * winbind_getpwnam(const char * sname);
1477 struct passwd * winbind_getpwsid(const struct dom_sid *sid);
1478 wbcErr wb_is_trusted_domain(const char *domain);
1479 bool winbind_lookup_rids(TALLOC_CTX *mem_ctx,
1480                          const struct dom_sid *domain_sid,
1481                          int num_rids, uint32 *rids,
1482                          const char **domain_name,
1483                          const char ***names, enum lsa_SidType **types);
1484 bool winbind_allocate_uid(uid_t *uid);
1485 bool winbind_allocate_gid(gid_t *gid);
1486 bool winbind_get_groups(TALLOC_CTX *mem_ctx,
1487                         const char *account,
1488                         uint32_t *num_groups,
1489                         gid_t ** _groups);
1490 bool winbind_get_sid_aliases(TALLOC_CTX *mem_ctx,
1491                              const struct dom_sid *dom_sid,
1492                              const struct dom_sid *members,
1493                              size_t num_members,
1494                              uint32_t **pp_alias_rids,
1495                              size_t *p_num_alias_rids);
1496
1497
1498 /* The following definitions come from lib/wins_srv.c  */
1499
1500 bool wins_srv_is_dead(struct in_addr wins_ip, struct in_addr src_ip);
1501 void wins_srv_alive(struct in_addr wins_ip, struct in_addr src_ip);
1502 void wins_srv_died(struct in_addr wins_ip, struct in_addr src_ip);
1503 unsigned wins_srv_count(void);
1504 char **wins_srv_tags(void);
1505 void wins_srv_tags_free(char **list);
1506 struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip);
1507 unsigned wins_srv_count_tag(const char *tag);
1508
1509 /* The following definitions come from libsmb/cliconnect.c  */
1510
1511 ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user, 
1512                               const char *pass, const char *user_domain,
1513                                     const char * dest_realm);
1514
1515 NTSTATUS cli_session_setup(struct cli_state *cli,
1516                            const char *user,
1517                            const char *pass, int passlen,
1518                            const char *ntpass, int ntpasslen,
1519                            const char *workgroup);
1520 struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
1521                                                   struct event_context *ev,
1522                                                   struct cli_state *cli,
1523                                                   struct tevent_req **psmbreq);
1524 struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
1525                                                 struct event_context *ev,
1526                                                 struct cli_state *cli);
1527 NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
1528 struct tevent_req *cli_ulogoff_send(TALLOC_CTX *mem_ctx,
1529                                     struct tevent_context *ev,
1530                                     struct cli_state *cli);
1531 NTSTATUS cli_ulogoff_recv(struct tevent_req *req);
1532 NTSTATUS cli_ulogoff(struct cli_state *cli);
1533 struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
1534                                         struct event_context *ev,
1535                                         struct cli_state *cli,
1536                                         const char *share, const char *dev,
1537                                         const char *pass, int passlen,
1538                                         struct tevent_req **psmbreq);
1539 struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
1540                                       struct event_context *ev,
1541                                       struct cli_state *cli,
1542                                       const char *share, const char *dev,
1543                                       const char *pass, int passlen);
1544 NTSTATUS cli_tcon_andx_recv(struct tevent_req *req);
1545 NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share,
1546                        const char *dev, const char *pass, int passlen);
1547 struct tevent_req *cli_tdis_send(TALLOC_CTX *mem_ctx,
1548                                  struct tevent_context *ev,
1549                                  struct cli_state *cli);
1550 NTSTATUS cli_tdis_recv(struct tevent_req *req);
1551 NTSTATUS cli_tdis(struct cli_state *cli);
1552 void cli_negprot_sendsync(struct cli_state *cli);
1553 NTSTATUS cli_negprot(struct cli_state *cli);
1554 struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
1555                                     struct event_context *ev,
1556                                     struct cli_state *cli);
1557 NTSTATUS cli_negprot_recv(struct tevent_req *req);
1558 bool cli_session_request(struct cli_state *cli,
1559                          struct nmb_name *calling, struct nmb_name *called);
1560 NTSTATUS cli_connect(struct cli_state *cli,
1561                 const char *host,
1562                 struct sockaddr_storage *dest_ss);
1563 NTSTATUS cli_start_connection(struct cli_state **output_cli, 
1564                               const char *my_name, 
1565                               const char *dest_host, 
1566                               struct sockaddr_storage *dest_ss, int port,
1567                               int signing_state, int flags);
1568 NTSTATUS cli_full_connection(struct cli_state **output_cli, 
1569                              const char *my_name, 
1570                              const char *dest_host, 
1571                              struct sockaddr_storage *dest_ss, int port,
1572                              const char *service, const char *service_type,
1573                              const char *user, const char *domain, 
1574                              const char *password, int flags,
1575                              int signing_state);
1576 bool attempt_netbios_session_request(struct cli_state **ppcli, const char *srchost, const char *desthost,
1577                                      struct sockaddr_storage *pdest_ss);
1578 NTSTATUS cli_raw_tcon(struct cli_state *cli, 
1579                       const char *service, const char *pass, const char *dev,
1580                       uint16 *max_xmit, uint16 *tid);
1581 struct cli_state *get_ipc_connect(char *server,
1582                                 struct sockaddr_storage *server_ss,
1583                                 const struct user_auth_info *user_info);
1584 struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
1585                                 struct ip_service *mb_ip,
1586                                 const struct user_auth_info *user_info,
1587                                 char **pp_workgroup_out);
1588 struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
1589                                         const struct user_auth_info *user_info,
1590                                         char **pp_workgroup_out);
1591
1592 /* The following definitions come from libsmb/clidfs.c  */
1593
1594 NTSTATUS cli_cm_force_encryption(struct cli_state *c,
1595                         const char *username,
1596                         const char *password,
1597                         const char *domain,
1598                         const char *sharename);
1599 struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
1600                                 struct cli_state *referring_cli,
1601                                 const char *server,
1602                                 const char *share,
1603                                 const struct user_auth_info *auth_info,
1604                                 bool show_hdr,
1605                                 bool force_encrypt,
1606                                 int max_protocol,
1607                                 int port,
1608                                 int name_type);
1609 void cli_cm_display(const struct cli_state *c);
1610 struct client_dfs_referral;
1611 NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx,
1612                         struct cli_state *cli,
1613                         const char *path,
1614                         struct client_dfs_referral **refs,
1615                         size_t *num_refs,
1616                         size_t *consumed);
1617 bool cli_resolve_path(TALLOC_CTX *ctx,
1618                         const char *mountpt,
1619                         const struct user_auth_info *dfs_auth_info,
1620                         struct cli_state *rootcli,
1621                         const char *path,
1622                         struct cli_state **targetcli,
1623                         char **pp_targetpath);
1624
1625 bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
1626                         struct cli_state *cli,
1627                         const char *sharename,
1628                         char **pp_newserver,
1629                         char **pp_newshare,
1630                         bool force_encrypt,
1631                         const char *username,
1632                         const char *password,
1633                         const char *domain);
1634
1635 /* The following definitions come from libsmb/clientgen.c  */
1636
1637 int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
1638 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
1639 void cli_set_port(struct cli_state *cli, int port);
1640 bool cli_state_seqnum_persistent(struct cli_state *cli,
1641                                  uint16_t mid);
1642 bool cli_state_seqnum_remove(struct cli_state *cli,
1643                              uint16_t mid);
1644 bool cli_receive_smb(struct cli_state *cli);
1645 bool cli_send_smb(struct cli_state *cli);
1646 bool cli_send_smb_direct_writeX(struct cli_state *cli,
1647                                 const char *p,
1648                                 size_t extradata);
1649 void cli_setup_packet_buf(struct cli_state *cli, char *buf);
1650 void cli_setup_packet(struct cli_state *cli);
1651 void cli_setup_bcc(struct cli_state *cli, void *p);
1652 NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain);
1653 NTSTATUS cli_set_username(struct cli_state *cli, const char *username);
1654 NTSTATUS cli_set_password(struct cli_state *cli, const char *password);
1655 NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password);
1656 struct cli_state *cli_initialise(void);
1657 struct cli_state *cli_initialise_ex(int signing_state);
1658 void cli_nt_pipes_close(struct cli_state *cli);
1659 void cli_shutdown(struct cli_state *cli);
1660 void cli_sockopt(struct cli_state *cli, const char *options);
1661 uint16 cli_setpid(struct cli_state *cli, uint16 pid);
1662 bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
1663 struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
1664                                  struct cli_state *cli, uint16_t num_echos,
1665                                  DATA_BLOB data);
1666 NTSTATUS cli_echo_recv(struct tevent_req *req);
1667 NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
1668 bool cli_ucs2(struct cli_state *cli);
1669 bool is_andx_req(uint8_t cmd);
1670 NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli,
1671                  uint8_t smb_command, uint8_t additional_flags,
1672                  uint8_t wct, uint16_t *vwv,
1673                  uint32_t num_bytes, const uint8_t *bytes,
1674                  struct tevent_req **result_parent,
1675                  uint8_t min_wct, uint8_t *pwct, uint16_t **pvwv,
1676                  uint32_t *pnum_bytes, uint8_t **pbytes);
1677
1678 /* The following definitions come from libsmb/clierror.c  */
1679
1680 const char *cli_errstr(struct cli_state *cli);
1681 NTSTATUS cli_nt_error(struct cli_state *cli);
1682 void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode);
1683 int cli_errno(struct cli_state *cli);
1684 bool cli_is_error(struct cli_state *cli);
1685 bool cli_is_nt_error(struct cli_state *cli);
1686 bool cli_is_dos_error(struct cli_state *cli);
1687 NTSTATUS cli_get_nt_error(struct cli_state *cli);
1688 void cli_set_nt_error(struct cli_state *cli, NTSTATUS status);
1689 void cli_reset_error(struct cli_state *cli);
1690 bool cli_state_is_connected(struct cli_state *cli);
1691
1692 /* The following definitions come from libsmb/clifile.c  */
1693
1694 struct tevent_req *cli_setpathinfo_send(TALLOC_CTX *mem_ctx,
1695                                         struct tevent_context *ev,
1696                                         struct cli_state *cli,
1697                                         uint16_t level,
1698                                         const char *path,
1699                                         uint8_t *data,
1700                                         size_t data_len);
1701 NTSTATUS cli_setpathinfo_recv(struct tevent_req *req);
1702 NTSTATUS cli_setpathinfo(struct cli_state *cli,
1703                          uint16_t level,
1704                          const char *path,
1705                          uint8_t *data,
1706                          size_t data_len);
1707
1708 struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx,
1709                                         struct event_context *ev,
1710                                         struct cli_state *cli,
1711                                         const char *oldname,
1712                                         const char *newname);
1713 NTSTATUS cli_posix_symlink_recv(struct tevent_req *req);
1714 NTSTATUS cli_posix_symlink(struct cli_state *cli,
1715                         const char *oldname,
1716                         const char *newname);
1717 struct tevent_req *cli_posix_readlink_send(TALLOC_CTX *mem_ctx,
1718                                         struct event_context *ev,
1719                                         struct cli_state *cli,
1720                                         const char *fname,
1721                                         size_t len);
1722 NTSTATUS cli_posix_readlink_recv(struct tevent_req *req, struct cli_state *cli,
1723                                 char *retpath, size_t len);
1724 NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname,
1725                         char *linkpath, size_t len);
1726 struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx,
1727                                         struct event_context *ev,
1728                                         struct cli_state *cli,
1729                                         const char *oldname,
1730                                         const char *newname);
1731 NTSTATUS cli_posix_hardlink_recv(struct tevent_req *req);
1732 NTSTATUS cli_posix_hardlink(struct cli_state *cli,
1733                         const char *oldname,
1734                         const char *newname);
1735 uint32_t unix_perms_to_wire(mode_t perms);
1736 mode_t wire_perms_to_unix(uint32_t perms);
1737 struct tevent_req *cli_posix_getfacl_send(TALLOC_CTX *mem_ctx,
1738                                         struct event_context *ev,
1739                                         struct cli_state *cli,
1740                                         const char *fname);
1741 NTSTATUS cli_posix_getfacl_recv(struct tevent_req *req,
1742                                 TALLOC_CTX *mem_ctx,
1743                                 size_t *prb_size,
1744                                 char **retbuf);
1745 NTSTATUS cli_posix_getfacl(struct cli_state *cli,
1746                         const char *fname,
1747                         TALLOC_CTX *mem_ctx,
1748                         size_t *prb_size,
1749                         char **retbuf);
1750 struct tevent_req *cli_posix_stat_send(TALLOC_CTX *mem_ctx,
1751                                         struct event_context *ev,
1752                                         struct cli_state *cli,
1753                                         const char *fname);
1754 NTSTATUS cli_posix_stat_recv(struct tevent_req *req,
1755                                 SMB_STRUCT_STAT *sbuf);
1756 NTSTATUS cli_posix_stat(struct cli_state *cli,
1757                         const char *fname,
1758                         SMB_STRUCT_STAT *sbuf);
1759 struct tevent_req *cli_posix_chmod_send(TALLOC_CTX *mem_ctx,
1760                                         struct event_context *ev,
1761                                         struct cli_state *cli,
1762                                         const char *fname,
1763                                         mode_t mode);
1764 NTSTATUS cli_posix_chmod_recv(struct tevent_req *req);
1765 NTSTATUS cli_posix_chmod(struct cli_state *cli, const char *fname, mode_t mode);
1766 struct tevent_req *cli_posix_chown_send(TALLOC_CTX *mem_ctx,
1767                                         struct event_context *ev,
1768                                         struct cli_state *cli,
1769                                         const char *fname,
1770                                         uid_t uid,
1771                                         gid_t gid);
1772 NTSTATUS cli_posix_chown_recv(struct tevent_req *req);
1773 NTSTATUS cli_posix_chown(struct cli_state *cli,
1774                         const char *fname,
1775                         uid_t uid,
1776                         gid_t gid);
1777 struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
1778                                 struct event_context *ev,
1779                                 struct cli_state *cli,
1780                                 const char *fname_src,
1781                                 const char *fname_dst);
1782 NTSTATUS cli_rename_recv(struct tevent_req *req);
1783 NTSTATUS cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
1784 struct tevent_req *cli_ntrename_send(TALLOC_CTX *mem_ctx,
1785                                 struct event_context *ev,
1786                                 struct cli_state *cli,
1787                                 const char *fname_src,
1788                                 const char *fname_dst);
1789 NTSTATUS cli_ntrename_recv(struct tevent_req *req);
1790 NTSTATUS cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
1791
1792 struct tevent_req *cli_nt_hardlink_send(TALLOC_CTX *mem_ctx,
1793                                 struct event_context *ev,
1794                                 struct cli_state *cli,
1795                                 const char *fname_src,
1796                                 const char *fname_dst);
1797 NTSTATUS cli_nt_hardlink_recv(struct tevent_req *req);
1798 NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
1799
1800 struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
1801                                 struct event_context *ev,
1802                                 struct cli_state *cli,
1803                                 const char *fname,
1804                                 uint16_t mayhave_attrs);
1805 NTSTATUS cli_unlink_recv(struct tevent_req *req);
1806 NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
1807
1808 struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
1809                                   struct event_context *ev,
1810                                   struct cli_state *cli,
1811                                   const char *dname);
1812 NTSTATUS cli_mkdir_recv(struct tevent_req *req);
1813 NTSTATUS cli_mkdir(struct cli_state *cli, const char *dname);
1814 struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
1815                                   struct event_context *ev,
1816                                   struct cli_state *cli,
1817                                   const char *dname);
1818 NTSTATUS cli_rmdir_recv(struct tevent_req *req);
1819 NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname);
1820 struct tevent_req *cli_nt_delete_on_close_send(TALLOC_CTX *mem_ctx,
1821                                         struct event_context *ev,
1822                                         struct cli_state *cli,
1823                                         uint16_t fnum,
1824                                         bool flag);
1825 NTSTATUS cli_nt_delete_on_close_recv(struct tevent_req *req);
1826 NTSTATUS cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
1827 struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
1828                                      struct event_context *ev,
1829                                      struct cli_state *cli,
1830                                      const char *fname,
1831                                      uint32_t CreatFlags,
1832                                      uint32_t DesiredAccess,
1833                                      uint32_t FileAttributes,
1834                                      uint32_t ShareAccess,
1835                                      uint32_t CreateDisposition,
1836                                      uint32_t CreateOptions,
1837                                      uint8_t SecurityFlags);
1838 NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum);
1839 NTSTATUS cli_ntcreate(struct cli_state *cli,
1840                       const char *fname,
1841                       uint32_t CreatFlags,
1842                       uint32_t DesiredAccess,
1843                       uint32_t FileAttributes,
1844                       uint32_t ShareAccess,
1845                       uint32_t CreateDisposition,
1846                       uint32_t CreateOptions,
1847                       uint8_t SecurityFlags,
1848                       uint16_t *pfid);
1849 uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
1850                             size_t str_len, size_t *pconverted_size);
1851 uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
1852                               const uint8_t *bytes, size_t num_bytes);
1853 struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
1854                                    struct event_context *ev,
1855                                    struct cli_state *cli, const char *fname,
1856                                    int flags, int share_mode,
1857                                    struct tevent_req **psmbreq);
1858 struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
1859                                  struct cli_state *cli, const char *fname,
1860                                  int flags, int share_mode);
1861 NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *fnum);
1862 NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
1863 struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
1864                                     struct event_context *ev,
1865                                     struct cli_state *cli, uint16_t fnum,
1866                                     struct tevent_req **psubreq);
1867 struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
1868                                   struct event_context *ev,
1869                                   struct cli_state *cli, uint16_t fnum);
1870 NTSTATUS cli_close_recv(struct tevent_req *req);
1871 NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum);
1872 struct tevent_req *cli_ftruncate_send(TALLOC_CTX *mem_ctx,
1873                                         struct event_context *ev,
1874                                         struct cli_state *cli,
1875                                         uint16_t fnum,
1876                                         uint64_t size);
1877 NTSTATUS cli_ftruncate_recv(struct tevent_req *req);
1878 NTSTATUS cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
1879 NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
1880                       uint32_t offset, uint32_t len,
1881                       int timeout, unsigned char locktype);
1882 bool cli_lock(struct cli_state *cli, uint16_t fnum,
1883               uint32_t offset, uint32_t len, int timeout, enum brl_type lock_type);
1884 struct tevent_req *cli_unlock_send(TALLOC_CTX *mem_ctx,
1885                                 struct event_context *ev,
1886                                 struct cli_state *cli,
1887                                 uint16_t fnum,
1888                                 uint64_t offset,
1889                                 uint64_t len);
1890 NTSTATUS cli_unlock_recv(struct tevent_req *req);
1891 NTSTATUS cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len);
1892 bool cli_lock64(struct cli_state *cli, uint16_t fnum,
1893                 uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type);
1894 struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx,
1895                                 struct event_context *ev,
1896                                 struct cli_state *cli,
1897                                 uint16_t fnum,
1898                                 uint64_t offset,
1899                                 uint64_t len);
1900 NTSTATUS cli_unlock64_recv(struct tevent_req *req);
1901 NTSTATUS cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
1902 struct tevent_req *cli_posix_lock_send(TALLOC_CTX *mem_ctx,
1903                                         struct event_context *ev,
1904                                         struct cli_state *cli,
1905                                         uint16_t fnum,
1906                                         uint64_t offset,
1907                                         uint64_t len,
1908                                         bool wait_lock,
1909                                         enum brl_type lock_type);
1910 NTSTATUS cli_posix_lock_recv(struct tevent_req *req);
1911 NTSTATUS cli_posix_lock(struct cli_state *cli, uint16_t fnum,
1912                         uint64_t offset, uint64_t len,
1913                         bool wait_lock, enum brl_type lock_type);
1914 struct tevent_req *cli_posix_unlock_send(TALLOC_CTX *mem_ctx,
1915                                         struct event_context *ev,
1916                                         struct cli_state *cli,
1917                                         uint16_t fnum,
1918                                         uint64_t offset,
1919                                         uint64_t len);
1920 NTSTATUS cli_posix_unlock_recv(struct tevent_req *req);
1921 NTSTATUS cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
1922 struct tevent_req *cli_getattrE_send(TALLOC_CTX *mem_ctx,
1923                                 struct event_context *ev,
1924                                 struct cli_state *cli,
1925                                 uint16_t fnum);
1926 NTSTATUS cli_getattrE_recv(struct tevent_req *req,
1927                         uint16_t *attr,
1928                         SMB_OFF_T *size,
1929                         time_t *change_time,
1930                         time_t *access_time,
1931                         time_t *write_time);
1932 NTSTATUS cli_getattrE(struct cli_state *cli,
1933                         uint16_t fnum,
1934                         uint16_t *attr,
1935                         SMB_OFF_T *size,
1936                         time_t *change_time,
1937                         time_t *access_time,
1938                         time_t *write_time);
1939 struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
1940                                 struct event_context *ev,
1941                                 struct cli_state *cli,
1942                                 uint16_t fnum,
1943                                 time_t change_time,
1944                                 time_t access_time,
1945                                 time_t write_time);
1946 NTSTATUS cli_setattrE_recv(struct tevent_req *req);
1947 NTSTATUS cli_setattrE(struct cli_state *cli,
1948                         uint16_t fnum,
1949                         time_t change_time,
1950                         time_t access_time,
1951                         time_t write_time);
1952 struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
1953                                 struct event_context *ev,
1954                                 struct cli_state *cli,
1955                                 const char *fname);
1956 NTSTATUS cli_getatr_recv(struct tevent_req *req,
1957                                 uint16_t *attr,
1958                                 SMB_OFF_T *size,
1959                                 time_t *write_time);
1960 NTSTATUS cli_getatr(struct cli_state *cli,
1961                         const char *fname,
1962                         uint16_t *attr,
1963                         SMB_OFF_T *size,
1964                         time_t *write_time);
1965 struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
1966                                 struct event_context *ev,
1967                                 struct cli_state *cli,
1968                                 const char *fname,
1969                                 uint16_t attr,
1970                                 time_t mtime);
1971 NTSTATUS cli_setatr_recv(struct tevent_req *req);
1972 NTSTATUS cli_setatr(struct cli_state *cli,
1973                 const char *fname,
1974                 uint16_t attr,
1975                 time_t mtime);
1976 struct tevent_req *cli_chkpath_send(TALLOC_CTX *mem_ctx,
1977                                   struct event_context *ev,
1978                                   struct cli_state *cli,
1979                                   const char *fname);
1980 NTSTATUS cli_chkpath_recv(struct tevent_req *req);
1981 NTSTATUS cli_chkpath(struct cli_state *cli, const char *path);
1982 struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
1983                                   struct event_context *ev,
1984                                   struct cli_state *cli);
1985 NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
1986                           int *avail);
1987 NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
1988 struct tevent_req *cli_ctemp_send(TALLOC_CTX *mem_ctx,
1989                                 struct event_context *ev,
1990                                 struct cli_state *cli,
1991                                 const char *path);
1992 NTSTATUS cli_ctemp_recv(struct tevent_req *req,
1993                         TALLOC_CTX *ctx,
1994                         uint16_t *pfnum,
1995                         char **outfile);
1996 NTSTATUS cli_ctemp(struct cli_state *cli,
1997                         TALLOC_CTX *ctx,
1998                         const char *path,
1999                         uint16_t *pfnum,
2000                         char **out_path);
2001 NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob);
2002 NTSTATUS cli_set_ea_path(struct cli_state *cli, const char *path,
2003                          const char *ea_name, const char *ea_val,
2004                          size_t ea_len);
2005 NTSTATUS cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum,
2006                          const char *ea_name, const char *ea_val,
2007                          size_t ea_len);
2008 struct tevent_req *cli_get_ea_list_path_send(TALLOC_CTX *mem_ctx,
2009                                              struct tevent_context *ev,
2010                                              struct cli_state *cli,
2011                                              const char *fname);
2012 NTSTATUS cli_get_ea_list_path_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
2013                                    size_t *pnum_eas, struct ea_struct **peas);
2014 NTSTATUS cli_get_ea_list_path(struct cli_state *cli, const char *path,
2015                 TALLOC_CTX *ctx,
2016                 size_t *pnum_eas,
2017                 struct ea_struct **pea_list);
2018 struct tevent_req *cli_posix_open_send(TALLOC_CTX *mem_ctx,
2019                                         struct event_context *ev,
2020                                         struct cli_state *cli,
2021                                         const char *fname,
2022                                         int flags,
2023                                         mode_t mode);
2024 NTSTATUS cli_posix_open_recv(struct tevent_req *req, uint16_t *pfnum);
2025 NTSTATUS cli_posix_open(struct cli_state *cli, const char *fname,
2026                         int flags, mode_t mode, uint16_t *fnum);
2027 struct tevent_req *cli_posix_mkdir_send(TALLOC_CTX *mem_ctx,
2028                                         struct event_context *ev,
2029                                         struct cli_state *cli,
2030                                         const char *fname,
2031                                         mode_t mode);
2032 NTSTATUS cli_posix_mkdir_recv(struct tevent_req *req);
2033 NTSTATUS cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode);
2034
2035 struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx,
2036                                         struct event_context *ev,
2037                                         struct cli_state *cli,
2038                                         const char *fname);
2039 NTSTATUS cli_posix_unlink_recv(struct tevent_req *req);
2040 NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname);
2041
2042 struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx,
2043                                         struct event_context *ev,
2044                                         struct cli_state *cli,
2045                                         const char *fname);
2046 NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
2047 NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname);
2048 struct tevent_req *cli_notify_send(TALLOC_CTX *mem_ctx,
2049                                    struct tevent_context *ev,
2050                                    struct cli_state *cli, uint16_t fnum,
2051                                    uint32_t buffer_size,
2052                                    uint32_t completion_filter, bool recursive);
2053 NTSTATUS cli_notify_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
2054                          uint32_t *pnum_changes,
2055                          struct notify_change **pchanges);
2056
2057 /* The following definitions come from libsmb/clifsinfo.c  */
2058
2059 struct tevent_req *cli_unix_extensions_version_send(TALLOC_CTX *mem_ctx,
2060                                                     struct tevent_context *ev,
2061                                                     struct cli_state *cli);
2062 NTSTATUS cli_unix_extensions_version_recv(struct tevent_req *req,
2063                                           uint16_t *pmajor, uint16_t *pminor,
2064                                           uint32_t *pcaplow,
2065                                           uint32_t *pcaphigh);
2066 NTSTATUS cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor,
2067                                      uint16 *pminor, uint32 *pcaplow,
2068                                      uint32 *pcaphigh);
2069 struct tevent_req *cli_set_unix_extensions_capabilities_send(
2070         TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli,
2071         uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh);
2072 NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req);
2073 NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli,
2074                                               uint16 major, uint16 minor,
2075                                               uint32 caplow, uint32 caphigh);
2076 struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
2077                                              struct tevent_context *ev,
2078                                              struct cli_state *cli);
2079 NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr);
2080 NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
2081 NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name,
2082                                 uint32 *pserial_number, time_t *pdate);
2083 NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
2084                                    uint64_t *total_allocation_units,
2085                                    uint64_t *caller_allocation_units,
2086                                    uint64_t *actual_allocation_units,
2087                                    uint64_t *sectors_per_allocation_unit,
2088                                    uint64_t *bytes_per_sector);
2089 NTSTATUS cli_get_posix_fs_info(struct cli_state *cli,
2090                                uint32 *optimal_transfer_size,
2091                                uint32 *block_size,
2092                                uint64_t *total_blocks,
2093                                uint64_t *blocks_available,
2094                                uint64_t *user_blocks_available,
2095                                uint64_t *total_file_nodes,
2096                                uint64_t *free_file_nodes,
2097                                uint64_t *fs_identifier);
2098 NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli, 
2099                                 const char *user,
2100                                 const char *pass,
2101                                 const char *domain);
2102 NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli);
2103 NTSTATUS cli_force_encryption(struct cli_state *c,
2104                         const char *username,
2105                         const char *password,
2106                         const char *domain);
2107
2108 /* The following definitions come from libsmb/clikrb5.c  */
2109
2110 bool unwrap_edata_ntstatus(TALLOC_CTX *mem_ctx, 
2111                            DATA_BLOB *edata, 
2112                            DATA_BLOB *edata_out);
2113 bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_pac_data);
2114
2115 /* The following definitions come from libsmb/clilist.c  */
2116
2117 NTSTATUS cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
2118                       NTSTATUS (*fn)(const char *, struct file_info *,
2119                                  const char *, void *), void *state);
2120 NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
2121                         uint16_t attribute, int info_level,
2122                         NTSTATUS (*fn)(const char *mnt, struct file_info *finfo,
2123                                    const char *mask, void *private_data),
2124                         void *private_data);
2125 struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
2126                                  struct tevent_context *ev,
2127                                  struct cli_state *cli,
2128                                  const char *mask,
2129                                  uint16_t attribute,
2130                                  uint16_t info_level);
2131 NTSTATUS cli_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
2132                        struct file_info **finfo, size_t *num_finfo);
2133 NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
2134                   NTSTATUS (*fn)(const char *, struct file_info *, const char *,
2135                              void *), void *state);
2136
2137 /* The following definitions come from libsmb/climessage.c  */
2138
2139 struct tevent_req *cli_message_send(TALLOC_CTX *mem_ctx,
2140                                     struct tevent_context *ev,
2141                                     struct cli_state *cli,
2142                                     const char *host, const char *username,
2143                                     const char *message);
2144 NTSTATUS cli_message_recv(struct tevent_req *req);
2145 NTSTATUS cli_message(struct cli_state *cli, const char *host,
2146                      const char *username, const char *message);
2147
2148 /* The following definitions come from libsmb/clioplock.c  */
2149
2150 struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
2151                                        struct tevent_context *ev,
2152                                        struct cli_state *cli,
2153                                        uint16_t fnum, uint8_t level);
2154 NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
2155 NTSTATUS cli_oplock_ack(struct cli_state *cli, uint16_t fnum, unsigned char level);
2156 void cli_oplock_handler(struct cli_state *cli, 
2157                         NTSTATUS (*handler)(struct cli_state *, uint16_t, unsigned char));
2158
2159 /* The following definitions come from libsmb/cliprint.c  */
2160
2161 int cli_print_queue(struct cli_state *cli,
2162                     void (*fn)(struct print_job_info *));
2163 int cli_printjob_del(struct cli_state *cli, int job);
2164
2165 /* The following definitions come from libsmb/cliquota.c  */
2166
2167 NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum);
2168 void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
2169 NTSTATUS cli_get_user_quota(struct cli_state *cli, int quota_fnum,
2170                             SMB_NTQUOTA_STRUCT *pqt);
2171 NTSTATUS cli_set_user_quota(struct cli_state *cli, int quota_fnum,
2172                             SMB_NTQUOTA_STRUCT *pqt);
2173 NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
2174                              SMB_NTQUOTA_LIST **pqt_list);
2175 NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum,
2176                                SMB_NTQUOTA_STRUCT *pqt);
2177 NTSTATUS cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum,
2178                                SMB_NTQUOTA_STRUCT *pqt);
2179
2180 /* The following definitions come from libsmb/clireadwrite.c  */
2181
2182 struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
2183                                         struct event_context *ev,
2184                                         struct cli_state *cli, uint16_t fnum,
2185                                         off_t offset, size_t size,
2186                                         struct tevent_req **psmbreq);
2187 struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
2188                                       struct event_context *ev,
2189                                       struct cli_state *cli, uint16_t fnum,
2190                                       off_t offset, size_t size);
2191 NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
2192                             uint8_t **rcvbuf);
2193 struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
2194                                  struct event_context *ev,
2195                                  struct cli_state *cli,
2196                                  uint16_t fnum, off_t start_offset,
2197                                  SMB_OFF_T size, size_t window_size,
2198                                  NTSTATUS (*sink)(char *buf, size_t n,
2199                                                   void *priv),
2200                                  void *priv);
2201 NTSTATUS cli_pull_recv(struct tevent_req *req, SMB_OFF_T *received);
2202 NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
2203                   off_t start_offset, SMB_OFF_T size, size_t window_size,
2204                   NTSTATUS (*sink)(char *buf, size_t n, void *priv),
2205                   void *priv, SMB_OFF_T *received);
2206 ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
2207                  off_t offset, size_t size);
2208 ssize_t cli_write(struct cli_state *cli,
2209                  uint16_t fnum, uint16 write_mode,
2210                  const char *buf, off_t offset, size_t size);
2211 ssize_t cli_smbwrite(struct cli_state *cli,
2212                      uint16_t fnum, char *buf, off_t offset, size_t size1);
2213 struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
2214                                          struct event_context *ev,
2215                                          struct cli_state *cli, uint16_t fnum,
2216                                          uint16_t mode, const uint8_t *buf,
2217                                          off_t offset, size_t size,
2218                                          struct tevent_req **reqs_before,
2219                                          int num_reqs_before,
2220                                          struct tevent_req **psmbreq);
2221 struct tevent_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
2222                                        struct event_context *ev,
2223                                        struct cli_state *cli, uint16_t fnum,
2224                                        uint16_t mode, const uint8_t *buf,
2225                                        off_t offset, size_t size);
2226 NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten);
2227
2228 struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
2229                                  struct cli_state *cli,
2230                                  uint16_t fnum, uint16_t mode,
2231                                  off_t start_offset, size_t window_size,
2232                                  size_t (*source)(uint8_t *buf, size_t n,
2233                                                   void *priv),
2234                                  void *priv);
2235 NTSTATUS cli_push_recv(struct tevent_req *req);
2236 NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
2237                   off_t start_offset, size_t window_size,
2238                   size_t (*source)(uint8_t *buf, size_t n, void *priv),
2239                   void *priv);
2240
2241 /* The following definitions come from libsmb/clisecdesc.c  */
2242
2243 struct security_descriptor *cli_query_secdesc(struct cli_state *cli, uint16_t fnum,
2244                             TALLOC_CTX *mem_ctx);
2245 NTSTATUS cli_set_secdesc(struct cli_state *cli, uint16_t fnum,
2246                          struct security_descriptor *sd);
2247
2248 /* The following definitions come from libsmb/clispnego.c  */
2249
2250 DATA_BLOB spnego_gen_negTokenInit(TALLOC_CTX *ctx,
2251                                   const char *OIDs[],
2252                                   DATA_BLOB *psecblob,
2253                                   const char *principal);
2254
2255 #ifndef ASN1_MAX_OIDS
2256 #define ASN1_MAX_OIDS 20
2257 #endif
2258 bool spnego_parse_negTokenInit(TALLOC_CTX *ctx,
2259                                DATA_BLOB blob,
2260                                char *OIDs[ASN1_MAX_OIDS],
2261                                char **principal,
2262                                DATA_BLOB *secblob);
2263 DATA_BLOB spnego_gen_krb5_wrap(TALLOC_CTX *ctx, const DATA_BLOB ticket, const uint8 tok_id[2]);
2264 bool spnego_parse_krb5_wrap(TALLOC_CTX *ctx, DATA_BLOB blob, DATA_BLOB *ticket, uint8 tok_id[2]);
2265 int spnego_gen_krb5_negTokenInit(TALLOC_CTX *ctx,
2266                             const char *principal, int time_offset,
2267                             DATA_BLOB *targ,
2268                             DATA_BLOB *session_key_krb5, uint32 extra_ap_opts,
2269                             time_t *expire_time);
2270 bool spnego_parse_challenge(TALLOC_CTX *ctx, const DATA_BLOB blob,
2271                             DATA_BLOB *chal1, DATA_BLOB *chal2);
2272 DATA_BLOB spnego_gen_auth(TALLOC_CTX *ctx, DATA_BLOB blob);
2273 bool spnego_parse_auth(TALLOC_CTX *ctx, DATA_BLOB blob, DATA_BLOB *auth);
2274 DATA_BLOB spnego_gen_auth_response(TALLOC_CTX *ctx, DATA_BLOB *reply, NTSTATUS nt_status,
2275                                    const char *mechOID);
2276 bool spnego_parse_auth_response(TALLOC_CTX *ctx,
2277                                 DATA_BLOB blob, NTSTATUS nt_status,
2278                                 const char *mechOID,
2279                                 DATA_BLOB *auth);
2280
2281 bool spnego_parse_auth_and_mic(TALLOC_CTX *ctx, DATA_BLOB blob,
2282                                 DATA_BLOB *auth, DATA_BLOB *signature);
2283 DATA_BLOB spnego_gen_auth_response_and_mic(TALLOC_CTX *ctx,
2284                                            NTSTATUS nt_status,
2285                                            const char *mechOID,
2286                                            DATA_BLOB *reply,
2287                                            DATA_BLOB *mechlistMIC);
2288 bool spnego_mech_list_blob(TALLOC_CTX *mem_ctx,
2289                            char **oid_list, DATA_BLOB *data);
2290
2291 /* The following definitions come from libsmb/clistr.c  */
2292
2293 size_t clistr_push_fn(struct cli_state *cli,
2294                         void *dest,
2295                         const char *src,
2296                         int dest_len,
2297                         int flags);
2298 size_t clistr_pull_fn(const char *inbuf,
2299                         char *dest,
2300                         const void *src,
2301                         int dest_len,
2302                         int src_len,
2303                         int flags);
2304 size_t clistr_pull_talloc(TALLOC_CTX *ctx,
2305                           const char *base,
2306                           uint16_t flags2,
2307                           char **pp_dest,
2308                           const void *src,
2309                           int src_len,
2310                           int flags);
2311 size_t clistr_align_out(struct cli_state *cli, const void *p, int flags);
2312
2313 /* The following definitions come from libsmb/clitrans.c  */
2314
2315 struct tevent_req *cli_trans_send(
2316         TALLOC_CTX *mem_ctx, struct event_context *ev,
2317         struct cli_state *cli, uint8_t cmd,
2318         const char *pipe_name, uint16_t fid, uint16_t function, int flags,
2319         uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
2320         uint8_t *param, uint32_t num_param, uint32_t max_param,
2321         uint8_t *data, uint32_t num_data, uint32_t max_data);
2322 NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
2323                         uint16_t *recv_flags2,
2324                         uint16_t **setup, uint8_t min_setup,
2325                         uint8_t *num_setup,
2326                         uint8_t **param, uint32_t min_param,
2327                         uint32_t *num_param,
2328                         uint8_t **data, uint32_t min_data,
2329                         uint32_t *num_data);
2330 NTSTATUS cli_trans(TALLOC_CTX *mem_ctx, struct cli_state *cli,
2331                    uint8_t trans_cmd,
2332                    const char *pipe_name, uint16_t fid, uint16_t function,
2333                    int flags,
2334                    uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
2335                    uint8_t *param, uint32_t num_param, uint32_t max_param,
2336                    uint8_t *data, uint32_t num_data, uint32_t max_data,
2337                    uint16_t *recv_flags2,
2338                    uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
2339                    uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
2340                    uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
2341
2342 /* The following definitions come from libsmb/conncache.c  */
2343
2344 NTSTATUS check_negative_conn_cache( const char *domain, const char *server);
2345 void add_failed_connection_entry(const char *domain, const char *server, NTSTATUS result) ;
2346 void flush_negative_conn_cache_for_domain(const char *domain);
2347
2348 /* The following definitions come from libsmb/dsgetdcname.c  */
2349
2350 struct netr_DsRGetDCNameInfo;
2351
2352 void debug_dsdcinfo_flags(int lvl, uint32_t flags);
2353 NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
2354                      struct messaging_context *msg_ctx,
2355                      const char *domain_name,
2356                      const struct GUID *domain_guid,
2357                      const char *site_name,
2358                      uint32_t flags,
2359                      struct netr_DsRGetDCNameInfo **info);
2360
2361 /* The following definitions come from libsmb/errormap.c  */
2362
2363 NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode);
2364 void ntstatus_to_dos(NTSTATUS ntstatus, uint8 *eclass, uint32 *ecode);
2365 NTSTATUS werror_to_ntstatus(WERROR error);
2366 WERROR ntstatus_to_werror(NTSTATUS error);
2367 NTSTATUS map_nt_error_from_gss(uint32 gss_maj, uint32 minor);
2368
2369 /* The following definitions come from libsmb/namecache.c  */
2370
2371 bool namecache_store(const char *name,
2372                         int name_type,
2373                         int num_names,
2374                         struct ip_service *ip_list);
2375 bool namecache_fetch(const char *name,
2376                         int name_type,
2377                         struct ip_service **ip_list,
2378                         int *num_names);
2379 bool namecache_delete(const char *name, int name_type);
2380 void namecache_flush(void);
2381 bool namecache_status_store(const char *keyname, int keyname_type,
2382                 int name_type, const struct sockaddr_storage *keyip,
2383                 const char *srvname);
2384 bool namecache_status_fetch(const char *keyname,
2385                                 int keyname_type,
2386                                 int name_type,
2387                                 const struct sockaddr_storage *keyip,
2388                                 char *srvname_out);
2389
2390 /* The following definitions come from libsmb/namequery.c  */
2391
2392 bool saf_store( const char *domain, const char *servername );
2393 bool saf_join_store( const char *domain, const char *servername );
2394 bool saf_delete( const char *domain );
2395 char *saf_fetch( const char *domain );
2396 struct tevent_req *node_status_query_send(TALLOC_CTX *mem_ctx,
2397                                           struct tevent_context *ev,
2398                                           struct nmb_name *name,
2399                                           const struct sockaddr_storage *addr);
2400 NTSTATUS node_status_query_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
2401                                 struct node_status **pnode_status,
2402                                 int *pnum_names,
2403                                 struct node_status_extra *extra);
2404 NTSTATUS node_status_query(TALLOC_CTX *mem_ctx, struct nmb_name *name,
2405                            const struct sockaddr_storage *addr,
2406                            struct node_status **pnode_status,
2407                            int *pnum_names,
2408                            struct node_status_extra *extra);
2409 bool name_status_find(const char *q_name,
2410                         int q_type,
2411                         int type,
2412                         const struct sockaddr_storage *to_ss,
2413                         fstring name);
2414 int ip_service_compare(struct ip_service *ss1, struct ip_service *ss2);
2415 struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx,
2416                                    struct tevent_context *ev,
2417                                    const char *name, int name_type,
2418                                    bool bcast, bool recurse,
2419                                    const struct sockaddr_storage *addr);
2420 NTSTATUS name_query_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
2421                          struct sockaddr_storage **addrs, int *num_addrs,
2422                          uint8_t *flags);
2423 NTSTATUS name_query(const char *name, int name_type,
2424                     bool bcast, bool recurse,
2425                     const struct sockaddr_storage *to_ss,
2426                     TALLOC_CTX *mem_ctx,
2427                     struct sockaddr_storage **addrs,
2428                     int *num_addrs, uint8_t *flags);
2429 NTSTATUS name_resolve_bcast(const char *name,
2430                         int name_type,
2431                         struct ip_service **return_iplist,
2432                         int *return_count);
2433 NTSTATUS resolve_wins(const char *name,
2434                 int name_type,
2435                 struct ip_service **return_iplist,
2436                 int *return_count);
2437 NTSTATUS internal_resolve_name(const char *name,
2438                                 int name_type,
2439                                 const char *sitename,
2440                                 struct ip_service **return_iplist,
2441                                 int *return_count,
2442                                 const char *resolve_order);
2443 bool resolve_name(const char *name,
2444                 struct sockaddr_storage *return_ss,
2445                 int name_type,
2446                 bool prefer_ipv4);
2447 NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
2448                 const char *name,
2449                 int name_type,
2450                 struct sockaddr_storage **return_ss_arr,
2451                 unsigned int *p_num_entries);
2452 bool find_master_ip(const char *group, struct sockaddr_storage *master_ss);
2453 bool get_pdc_ip(const char *domain, struct sockaddr_storage *pss);
2454 NTSTATUS get_sorted_dc_list( const char *domain,
2455                         const char *sitename,
2456                         struct ip_service **ip_list,
2457                         int *count,
2458                         bool ads_only );
2459 NTSTATUS get_kdc_list( const char *realm,
2460                         const char *sitename,
2461                         struct ip_service **ip_list,
2462                         int *count);
2463
2464 /* The following definitions come from libsmb/namequery_dc.c  */
2465
2466 bool get_dc_name(const char *domain,
2467                 const char *realm,
2468                 fstring srv_name,
2469                 struct sockaddr_storage *ss_out);
2470
2471 /* The following definitions come from libsmb/nmblib.c  */
2472
2473 void debug_nmb_packet(struct packet_struct *p);
2474 void put_name(char *dest, const char *name, int pad, unsigned int name_type);
2475 char *nmb_namestr(const struct nmb_name *n);
2476 struct packet_struct *copy_packet(struct packet_struct *packet);
2477 void free_packet(struct packet_struct *packet);
2478 int packet_trn_id(struct packet_struct *p);
2479 struct packet_struct *parse_packet(char *buf,int length,
2480                                    enum packet_type packet_type,
2481                                    struct in_addr ip,
2482                                    int port);
2483 struct packet_struct *read_packet(int fd,enum packet_type packet_type);
2484 void make_nmb_name( struct nmb_name *n, const char *name, int type);
2485 bool nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
2486 int build_packet(char *buf, size_t buflen, struct packet_struct *p);
2487 bool send_packet(struct packet_struct *p);
2488 bool match_mailslot_name(struct packet_struct *p, const char *mailslot_name);
2489 int matching_len_bits(unsigned char *p1, unsigned char *p2, size_t len);
2490 void sort_query_replies(char *data, int n, struct in_addr ip);
2491 char *name_mangle(TALLOC_CTX *mem_ctx, const char *In, char name_type);
2492 int name_extract(unsigned char *buf,size_t buf_len, unsigned int ofs, fstring name);
2493 int name_len(unsigned char *s1, size_t buf_len);
2494
2495 /* The following definitions come from libsmb/nterr.c  */
2496
2497 const char *nt_errstr(NTSTATUS nt_code);
2498 const char *get_friendly_nt_error_msg(NTSTATUS nt_code);
2499 const char *get_nt_error_c_code(NTSTATUS nt_code);
2500 NTSTATUS nt_status_string_to_code(const char *nt_status_str);
2501 NTSTATUS nt_status_squash(NTSTATUS nt_status);
2502
2503 /* The following definitions come from libsmb/ntlmssp.c  */
2504 struct ntlmssp_state;
2505 NTSTATUS ntlmssp_set_username(struct ntlmssp_state *ntlmssp_state, const char *user) ;
2506 NTSTATUS ntlmssp_set_hashes(struct ntlmssp_state *ntlmssp_state,
2507                             const uint8_t lm_hash[16],
2508                             const uint8_t nt_hash[16]) ;
2509 NTSTATUS ntlmssp_set_password(struct ntlmssp_state *ntlmssp_state, const char *password) ;
2510 NTSTATUS ntlmssp_set_domain(struct ntlmssp_state *ntlmssp_state, const char *domain) ;
2511 void ntlmssp_want_feature_list(struct ntlmssp_state *ntlmssp_state, char *feature_list);
2512 void ntlmssp_want_feature(struct ntlmssp_state *ntlmssp_state, uint32_t feature);
2513 NTSTATUS ntlmssp_update(struct ntlmssp_state *ntlmssp_state,
2514                         const DATA_BLOB in, DATA_BLOB *out) ;
2515 NTSTATUS ntlmssp_server_start(TALLOC_CTX *mem_ctx,
2516                               bool is_standalone,
2517                               const char *netbios_name,
2518                               const char *netbios_domain,
2519                               const char *dns_name,
2520                               const char *dns_domain,
2521                               struct ntlmssp_state **ntlmssp_state);
2522 NTSTATUS ntlmssp_client_start(TALLOC_CTX *mem_ctx,
2523                               const char *netbios_name,
2524                               const char *netbios_domain,
2525                               bool use_ntlmv2,
2526                               struct ntlmssp_state **_ntlmssp_state);
2527
2528 /* The following definitions come from libsmb/passchange.c  */
2529
2530 NTSTATUS remote_password_change(const char *remote_machine, const char *user_name, 
2531                                 const char *old_passwd, const char *new_passwd,
2532                                 char **err_str);
2533
2534 /* The following definitions come from libsmb/samlogon_cache.c  */
2535
2536 bool netsamlogon_cache_init(void);
2537 bool netsamlogon_cache_shutdown(void);
2538 void netsamlogon_clear_cached_user(const struct dom_sid *user_sid);
2539 bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3);
2540 struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct dom_sid *user_sid);
2541 bool netsamlogon_cache_have(const struct dom_sid *user_sid);
2542
2543 /* The following definitions come from libsmb/smb_seal.c  */
2544
2545 NTSTATUS get_enc_ctx_num(const uint8_t *buf, uint16 *p_enc_ctx_num);
2546 bool common_encryption_on(struct smb_trans_enc_state *es);
2547 NTSTATUS common_ntlm_decrypt_buffer(struct ntlmssp_state *ntlmssp_state, char *buf);
2548 NTSTATUS common_ntlm_encrypt_buffer(struct ntlmssp_state *ntlmssp_state,
2549                                 uint16 enc_ctx_num,
2550                                 char *buf,
2551                                 char **ppbuf_out);
2552 NTSTATUS common_encrypt_buffer(struct smb_trans_enc_state *es, char *buffer, char **buf_out);
2553 NTSTATUS common_decrypt_buffer(struct smb_trans_enc_state *es, char *buf);
2554 void common_free_encryption_state(struct smb_trans_enc_state **pp_es);
2555 void common_free_enc_buffer(struct smb_trans_enc_state *es, char *buf);
2556 bool cli_encryption_on(struct cli_state *cli);
2557 void cli_free_encryption_context(struct cli_state *cli);
2558 void cli_free_enc_buffer(struct cli_state *cli, char *buf);
2559 NTSTATUS cli_decrypt_message(struct cli_state *cli);
2560 NTSTATUS cli_encrypt_message(struct cli_state *cli, char *buf, char **buf_out);
2561
2562 /* The following definitions come from libsmb/clisigning.c  */
2563
2564 bool cli_simple_set_signing(struct cli_state *cli,
2565                             const DATA_BLOB user_session_key,
2566                             const DATA_BLOB response);
2567 bool cli_temp_set_signing(struct cli_state *cli);
2568 void cli_calculate_sign_mac(struct cli_state *cli, char *buf, uint32_t *seqnum);
2569 bool cli_check_sign_mac(struct cli_state *cli, const char *buf, uint32_t seqnum);
2570 bool client_is_signing_on(struct cli_state *cli);
2571 bool client_is_signing_allowed(struct cli_state *cli);
2572 bool client_is_signing_mandatory(struct cli_state *cli);
2573 void cli_set_signing_negotiated(struct cli_state *cli);
2574
2575 /* The following definitions come from smbd/signing.c  */
2576
2577 struct smbd_server_connection;
2578 bool srv_check_sign_mac(struct smbd_server_connection *conn,
2579                         const char *inbuf, uint32_t *seqnum, bool trusted_channel);
2580 void srv_calculate_sign_mac(struct smbd_server_connection *conn,
2581                             char *outbuf, uint32_t seqnum);
2582 void srv_cancel_sign_response(struct smbd_server_connection *conn);
2583 bool srv_init_signing(struct smbd_server_connection *conn);
2584 void srv_set_signing_negotiated(struct smbd_server_connection *conn);
2585 bool srv_is_signing_active(struct smbd_server_connection *conn);
2586 bool srv_is_signing_negotiated(struct smbd_server_connection *conn);
2587 void srv_set_signing(struct smbd_server_connection *conn,
2588                      const DATA_BLOB user_session_key,
2589                      const DATA_BLOB response);
2590
2591 /* The following definitions come from libsmb/smberr.c  */
2592
2593 const char *smb_dos_err_name(uint8 e_class, uint16 num);
2594 const char *get_dos_error_msg(WERROR result);
2595 const char *smb_dos_err_class(uint8 e_class);
2596 char *smb_dos_errstr(char *inbuf);
2597 WERROR map_werror_from_unix(int error);
2598
2599 /* The following definitions come from libsmb/trustdom_cache.c  */
2600
2601 bool trustdom_cache_enable(void);
2602 bool trustdom_cache_shutdown(void);
2603 bool trustdom_cache_store(char* name, char* alt_name, const struct dom_sid *sid,
2604                           time_t timeout);
2605 bool trustdom_cache_fetch(const char* name, struct dom_sid* sid);
2606 uint32 trustdom_cache_fetch_timestamp( void );
2607 bool trustdom_cache_store_timestamp( uint32 t, time_t timeout );
2608 void trustdom_cache_flush(void);
2609 void update_trustdom_cache( void );
2610
2611 /* The following definitions come from libsmb/trusts_util.c  */
2612
2613 NTSTATUS trust_pw_change_and_store_it(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 
2614                                       const char *domain,
2615                                       const char *account_name,
2616                                       unsigned char orig_trust_passwd_hash[16],
2617                                       enum netr_SchannelType sec_channel_type);
2618 NTSTATUS trust_pw_find_change_and_store_it(struct rpc_pipe_client *cli, 
2619                                            TALLOC_CTX *mem_ctx, 
2620                                            const char *domain) ;
2621 bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain,
2622                                      char ***domain_names, uint32 *num_domains,
2623                                      struct dom_sid **sids );
2624 NTSTATUS change_trust_account_password( const char *domain, const char *remote_machine);
2625
2626 /* The following definitions come from libsmb/unexpected.c  */
2627
2628 struct nb_packet_server;
2629 struct nb_packet_reader;
2630
2631 NTSTATUS nb_packet_server_create(TALLOC_CTX *mem_ctx,
2632                                  struct tevent_context *ev,
2633                                  int max_clients,
2634                                  struct nb_packet_server **presult);
2635 void nb_packet_dispatch(struct nb_packet_server *server,
2636                         struct packet_struct *p);
2637 struct tevent_req *nb_packet_reader_send(TALLOC_CTX *mem_ctx,
2638                                          struct tevent_context *ev,
2639                                          enum packet_type type,
2640                                          int trn_id,
2641                                          const char *mailslot_name);
2642 NTSTATUS nb_packet_reader_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
2643                                struct nb_packet_reader **preader);
2644 struct tevent_req *nb_packet_read_send(TALLOC_CTX *mem_ctx,
2645                                        struct tevent_context *ev,
2646                                        struct nb_packet_reader *reader);
2647 NTSTATUS nb_packet_read_recv(struct tevent_req *req,
2648                              struct packet_struct **ppacket);
2649
2650 /* The following definitions come from locking/brlock.c  */
2651
2652 bool brl_same_context(const struct lock_context *ctx1, 
2653                              const struct lock_context *ctx2);
2654 NTSTATUS brl_lock_failed(files_struct *fsp, const struct lock_struct *lock, bool blocking_lock);
2655 void brl_init(bool read_only);
2656 void brl_shutdown(void);
2657
2658 NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
2659                 struct lock_struct *plock,
2660                 bool blocking_lock);
2661
2662 NTSTATUS brl_lock(struct messaging_context *msg_ctx,
2663                 struct byte_range_lock *br_lck,
2664                 uint64_t smblctx,
2665                 struct server_id pid,
2666                 br_off start,
2667                 br_off size, 
2668                 enum brl_type lock_type,
2669                 enum brl_flavour lock_flav,
2670                 bool blocking_lock,
2671                 uint64_t *psmblctx,
2672                 struct blocking_lock_record *blr);
2673 bool brl_unlock(struct messaging_context *msg_ctx,
2674                 struct byte_range_lock *br_lck,
2675                 uint64_t smblctx,
2676                 struct server_id pid,
2677                 br_off start,
2678                 br_off size,
2679                 enum brl_flavour lock_flav);
2680 bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
2681                                struct byte_range_lock *br_lck,
2682                                const struct lock_struct *plock);
2683 bool brl_locktest(struct byte_range_lock *br_lck,
2684                 uint64_t smblctx,
2685                 struct server_id pid,
2686                 br_off start,
2687                 br_off size, 
2688                 enum brl_type lock_type,
2689                 enum brl_flavour lock_flav);
2690 NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
2691                 uint64_t *psmblctx,
2692                 struct server_id pid,
2693                 br_off *pstart,
2694                 br_off *psize, 
2695                 enum brl_type *plock_type,
2696                 enum brl_flavour lock_flav);
2697 bool brl_lock_cancel(struct byte_range_lock *br_lck,
2698                 uint64_t smblctx,
2699                 struct server_id pid,
2700                 br_off start,
2701                 br_off size,
2702                 enum brl_flavour lock_flav,
2703                 struct blocking_lock_record *blr);
2704 bool brl_lock_cancel_default(struct byte_range_lock *br_lck,
2705                 struct lock_struct *plock);
2706 void brl_close_fnum(struct messaging_context *msg_ctx,
2707                     struct byte_range_lock *br_lck);
2708 int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
2709                           enum brl_type lock_type,
2710                           enum brl_flavour lock_flav,
2711                           br_off start, br_off size,
2712                           void *private_data),
2713                void *private_data);
2714 struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
2715                                         files_struct *fsp);
2716 struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp);
2717 void brl_register_msgs(struct messaging_context *msg_ctx);
2718
2719 /* The following definitions come from locking/locking.c  */
2720
2721 const char *lock_type_name(enum brl_type lock_type);
2722 const char *lock_flav_name(enum brl_flavour lock_flav);
2723 void init_strict_lock_struct(files_struct *fsp,
2724                                 uint64_t smblctx,
2725                                 br_off start,
2726                                 br_off size,
2727                                 enum brl_type lock_type,
2728                                 struct lock_struct *plock);
2729 bool strict_lock_default(files_struct *fsp,
2730                                 struct lock_struct *plock);
2731 void strict_unlock_default(files_struct *fsp,
2732                                 struct lock_struct *plock);
2733 NTSTATUS query_lock(files_struct *fsp,
2734                         uint64_t *psmblctx,
2735                         uint64_t *pcount,
2736                         uint64_t *poffset,
2737                         enum brl_type *plock_type,
2738                         enum brl_flavour lock_flav);
2739 struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
2740                         files_struct *fsp,
2741                         uint64_t smblctx,
2742                         uint64_t count,
2743                         uint64_t offset,
2744                         enum brl_type lock_type,
2745                         enum brl_flavour lock_flav,
2746                         bool blocking_lock,
2747                         NTSTATUS *perr,
2748                         uint64_t *psmblctx,
2749                         struct blocking_lock_record *blr);
2750 NTSTATUS do_unlock(struct messaging_context *msg_ctx,
2751                         files_struct *fsp,
2752                         uint64_t smblctx,
2753                         uint64_t count,
2754                         uint64_t offset,
2755                         enum brl_flavour lock_flav);
2756 NTSTATUS do_lock_cancel(files_struct *fsp,
2757                         uint64 smblctx,
2758                         uint64_t count,
2759                         uint64_t offset,
2760                         enum brl_flavour lock_flav,
2761                         struct blocking_lock_record *blr);
2762 void locking_close_file(struct messaging_context *msg_ctx,
2763                         files_struct *fsp,
2764                         enum file_close_type close_type);
2765 bool locking_init(void);
2766 bool locking_init_readonly(void);
2767 bool locking_end(void);
2768 char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
2769 struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
2770                                             const struct file_id id,
2771                                             const char *servicepath,
2772                                             const struct smb_filename *smb_fname,
2773                                             const struct timespec *old_write_time);
2774 struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
2775                                                   const struct file_id id);
2776 bool rename_share_filename(struct messaging_context *msg_ctx,
2777                         struct share_mode_lock *lck,
2778                         const char *servicepath,
2779                         uint32_t orig_name_hash,
2780                         uint32_t new_name_hash,
2781                         const struct smb_filename *smb_fname);
2782 void get_file_infos(struct file_id id,
2783                     uint32_t name_hash,
2784                     bool *delete_on_close,
2785                     struct timespec *write_time);
2786 bool is_valid_share_mode_entry(const struct share_mode_entry *e);
2787 bool is_deferred_open_entry(const struct share_mode_entry *e);
2788 bool is_unused_share_mode_entry(const struct share_mode_entry *e);
2789 void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
2790                     uid_t uid, uint64_t mid, uint16 op_type);
2791 void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
2792                        struct timeval request_time,
2793                        struct server_id pid, struct file_id id);
2794 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
2795 void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid,
2796                              struct server_id pid);
2797 bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
2798 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
2799 NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode);
2800 const struct security_unix_token *get_delete_on_close_token(struct share_mode_lock *lck, uint32_t name_hash);
2801 void set_delete_on_close_lck(files_struct *fsp,
2802                         struct share_mode_lock *lck,
2803                         bool delete_on_close,
2804                         const struct security_unix_token *tok);
2805 bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const struct security_unix_token *tok);
2806 bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash);
2807 bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
2808 bool set_write_time(struct file_id fileid, struct timespec write_time);
2809 int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *,
2810                                  const char *, void *),
2811                       void *private_data);
2812
2813 /* The following definitions come from locking/posix.c  */
2814
2815 bool is_posix_locked(files_struct *fsp,
2816                         uint64_t *pu_offset,
2817                         uint64_t *pu_count,
2818                         enum brl_type *plock_type,
2819                         enum brl_flavour lock_flav);
2820 bool posix_locking_init(bool read_only);
2821 bool posix_locking_end(void);
2822 void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount);
2823 int fd_close_posix(struct files_struct *fsp);
2824 bool set_posix_lock_windows_flavour(files_struct *fsp,
2825                         uint64_t u_offset,
2826                         uint64_t u_count,
2827                         enum brl_type lock_type,
2828                         const struct lock_context *lock_ctx,
2829                         const struct lock_struct *plocks,
2830                         int num_locks,
2831                         int *errno_ret);
2832 bool release_posix_lock_windows_flavour(files_struct *fsp,
2833                                 uint64_t u_offset,
2834                                 uint64_t u_count,
2835                                 enum brl_type deleted_lock_type,
2836                                 const struct lock_context *lock_ctx,
2837                                 const struct lock_struct *plocks,
2838                                 int num_locks);
2839 bool set_posix_lock_posix_flavour(files_struct *fsp,
2840                         uint64_t u_offset,
2841                         uint64_t u_count,
2842                         enum brl_type lock_type,
2843                         int *errno_ret);
2844 bool release_posix_lock_posix_flavour(files_struct *fsp,
2845                                 uint64_t u_offset,
2846                                 uint64_t u_count,
2847                                 const struct lock_context *lock_ctx,
2848                                 const struct lock_struct *plocks,
2849                                 int num_locks);
2850
2851 /* The following definitions come from modules/vfs_default.c  */
2852
2853 ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size);
2854 ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size);
2855 NTSTATUS vfs_default_init(void);
2856
2857 /* The following definitions come from param/loadparm.c  */
2858
2859 char *lp_smb_ports(void);
2860 char *lp_dos_charset(void);
2861 char *lp_unix_charset(void);
2862 char *lp_display_charset(void);
2863 char *lp_logfile(void);
2864 char *lp_configfile(void);
2865 char *lp_smb_passwd_file(void);
2866 char *lp_private_dir(void);
2867 char *lp_serverstring(void);
2868 int lp_printcap_cache_time(void);
2869 char *lp_addport_cmd(void);
2870 char *lp_enumports_cmd(void);
2871 char *lp_addprinter_cmd(void);
2872 char *lp_deleteprinter_cmd(void);
2873 char *lp_os2_driver_map(void);
2874 char *lp_lockdir(void);
2875 char *lp_statedir(void);
2876 char *lp_cachedir(void);
2877 char *lp_piddir(void);
2878 char *lp_mangling_method(void);
2879 int lp_mangle_prefix(void);
2880 char *lp_utmpdir(void);
2881 char *lp_wtmpdir(void);
2882 bool lp_utmp(void);
2883 char *lp_rootdir(void);
2884 char *lp_defaultservice(void);
2885 char *lp_msg_command(void);
2886 char *lp_get_quota_command(void);
2887 char *lp_set_quota_command(void);
2888 char *lp_auto_services(void);
2889 char *lp_passwd_program(void);
2890 char *lp_passwd_chat(void);
2891 char *lp_passwordserver(void);
2892 char *lp_name_resolve_order(void);
2893 char *lp_realm(void);
2894 const char *lp_afs_username_map(void);
2895 int lp_afs_token_lifetime(void);
2896 char *lp_log_nt_token_command(void);
2897 char *lp_username_map(void);
2898 const char *lp_logon_script(void);
2899 const char *lp_logon_path(void);
2900 const char *lp_logon_drive(void);
2901 const char *lp_logon_home(void);
2902 char *lp_remote_announce(void);
2903 char *lp_remote_browse_sync(void);
2904 bool lp_nmbd_bind_explicit_broadcast(void);
2905 const char **lp_wins_server_list(void);
2906 const char **lp_interfaces(void);
2907 const char *lp_socket_address(void);
2908 char *lp_nis_home_map_name(void);
2909 const char **lp_netbios_aliases(void);
2910 const char *lp_passdb_backend(void);
2911 const char **lp_preload_modules(void);
2912 char *lp_panic_action(void);
2913 char *lp_adduser_script(void);
2914 char *lp_renameuser_script(void);
2915 char *lp_deluser_script(void);
2916 const char *lp_guestaccount(void);
2917 char *lp_addgroup_script(void);
2918 char *lp_delgroup_script(void);
2919 char *lp_addusertogroup_script(void);
2920 char *lp_deluserfromgroup_script(void);
2921 char *lp_setprimarygroup_script(void);
2922 char *lp_addmachine_script(void);
2923 char *lp_shutdown_script(void);
2924 char *lp_abort_shutdown_script(void);
2925 char *lp_username_map_script(void);
2926 int lp_username_map_cache_time(void);
2927 char *lp_check_password_script(void);
2928 char *lp_wins_hook(void);
2929 const char *lp_template_homedir(void);
2930 const char *lp_template_shell(void);
2931 const char *lp_winbind_separator(void);
2932 int lp_acl_compatibility(void);
2933 bool lp_winbind_enum_users(void);
2934 bool lp_winbind_enum_groups(void);
2935 bool lp_winbind_use_default_domain(void);
2936 bool lp_winbind_trusted_domains_only(void);
2937 bool lp_winbind_nested_groups(void);
2938 int lp_winbind_expand_groups(void);
2939 bool lp_winbind_refresh_tickets(void);
2940 bool lp_winbind_offline_logon(void);
2941 bool lp_winbind_normalize_names(void);
2942 bool lp_winbind_rpc_only(void);
2943 bool lp_create_krb5_conf(void);
2944 int lp_winbind_max_domain_connections(void);
2945 const char *lp_idmap_backend(void);
2946 int lp_idmap_cache_time(void);
2947 int lp_idmap_negative_cache_time(void);
2948 int lp_keepalive(void);
2949 bool lp_passdb_expand_explicit(void);
2950 char *lp_ldap_suffix(void);
2951 char *lp_ldap_admin_dn(void);
2952 int lp_ldap_ssl(void);
2953 bool lp_ldap_ssl_ads(void);
2954 int lp_ldap_deref(void);
2955 int lp_ldap_follow_referral(void);
2956 int lp_ldap_passwd_sync(void);
2957 bool lp_ldap_delete_dn(void);
2958 int lp_ldap_replication_sleep(void);
2959 int lp_ldap_timeout(void);
2960 int lp_ldap_connection_timeout(void);
2961 int lp_ldap_page_size(void);
2962 int lp_ldap_debug_level(void);
2963 int lp_ldap_debug_threshold(void);
2964 char *lp_add_share_cmd(void);
2965 char *lp_change_share_cmd(void);
2966 char *lp_delete_share_cmd(void);
2967 char *lp_usershare_path(void);
2968 const char **lp_usershare_prefix_allow_list(void);
2969 const char **lp_usershare_prefix_deny_list(void);
2970 const char **lp_eventlog_list(void);
2971 bool lp_registry_shares(void);
2972 bool lp_usershare_allow_guests(void);
2973 bool lp_usershare_owner_only(void);
2974 bool lp_disable_netbios(void);
2975 bool lp_reset_on_zero_vc(void);
2976 bool lp_log_writeable_files_on_exit(void);
2977 bool lp_ms_add_printer_wizard(void);
2978 bool lp_dns_proxy(void);
2979 bool lp_wins_support(void);
2980 bool lp_we_are_a_wins_server(void);
2981 bool lp_wins_proxy(void);
2982 bool lp_local_master(void);
2983 bool lp_domain_logons(void);
2984 const char **lp_init_logon_delayed_hosts(void);
2985 int lp_init_logon_delay(void);
2986 bool lp_load_printers(void);
2987 bool lp_readraw(void);
2988 bool _lp_readraw(void);
2989 bool lp_large_readwrite(void);
2990 bool lp_writeraw(void);
2991 bool _lp_writeraw(void);
2992 bool lp_null_passwords(void);
2993 bool lp_obey_pam_restrictions(void);
2994 bool lp_encrypted_passwords(void);
2995 int lp_client_schannel(void);
2996 int lp_server_schannel(void);
2997 bool lp_syslog_only(void);
2998 bool lp_timestamp_logs(void);
2999 bool lp_debug_prefix_timestamp(void);
3000 bool lp_debug_hires_timestamp(void);
3001 bool lp_debug_pid(void);
3002 bool lp_debug_uid(void);
3003 bool lp_debug_class(void);
3004 bool lp_enable_core_files(void);
3005 bool lp_browse_list(void);
3006 bool lp_nis_home_map(void);
3007 bool lp_bind_interfaces_only(void);
3008 bool lp_pam_password_change(void);
3009 bool lp_unix_password_sync(void);
3010 bool lp_passwd_chat_debug(void);
3011 int lp_passwd_chat_timeout(void);
3012 bool lp_nt_pipe_support(void);
3013 bool lp_nt_status_support(void);
3014 bool lp_stat_cache(void);
3015 int lp_max_stat_cache_size(void);
3016 bool lp_allow_trusted_domains(void);
3017 bool lp_map_untrusted_to_domain(void);
3018 int lp_restrict_anonymous(void);
3019 bool lp_lanman_auth(void);
3020 bool lp_ntlm_auth(void);
3021 bool lp_client_plaintext_auth(void);
3022 bool lp_client_lanman_auth(void);
3023 bool lp_client_ntlmv2_auth(void);
3024 bool lp_host_msdfs(void);
3025 bool lp_kernel_oplocks(void);
3026 bool lp_enhanced_browsing(void);
3027 bool lp_use_mmap(void);
3028 bool lp_unix_extensions(void);
3029 bool lp_use_spnego(void);
3030 bool lp_client_use_spnego(void);
3031 bool lp_client_use_spnego_principal(void);
3032 bool lp_send_spnego_principal(void);
3033 bool lp_hostname_lookups(void);
3034 bool lp_change_notify(const struct share_params *p );
3035 bool lp_kernel_change_notify(const struct share_params *p );
3036 char * lp_dedicated_keytab_file(void);
3037 int lp_kerberos_method(void);
3038 bool lp_defer_sharing_violations(void);
3039 bool lp_enable_privileges(void);
3040 bool lp_enable_asu_support(void);
3041 int lp_os_level(void);
3042 int lp_max_ttl(void);
3043 int lp_max_wins_ttl(void);
3044 int lp_min_wins_ttl(void);
3045 int lp_max_log_size(void);
3046 int lp_max_open_files(void);
3047 int lp_open_files_db_hash_size(void);
3048 int lp_maxxmit(void);
3049 int lp_maxmux(void);
3050 int lp_passwordlevel(void);
3051 int lp_usernamelevel(void);
3052 int lp_deadtime(void);
3053 bool lp_getwd_cache(void);
3054 int lp_maxprotocol(void);
3055 int lp_minprotocol(void);
3056 int lp_security(void);
3057 const char **lp_auth_methods(void);
3058 bool lp_paranoid_server_security(void);
3059 int lp_maxdisksize(void);
3060 int lp_lpqcachetime(void);
3061 int lp_max_smbd_processes(void);
3062 bool _lp_disable_spoolss(void);
3063 int lp_syslog(void);
3064 int lp_lm_announce(void);
3065 int lp_lm_interval(void);
3066 int lp_machine_password_timeout(void);
3067 int lp_map_to_guest(void);
3068 int lp_oplock_break_wait_time(void);
3069 int lp_lock_spin_time(void);
3070 int lp_usershare_max_shares(void);
3071 const char *lp_socket_options(void);
3072 int lp_config_backend(void);
3073 int lp_smb2_max_read(void);
3074 int lp_smb2_max_write(void);
3075 int lp_smb2_max_trans(void);
3076 int lp_smb2_max_credits(void);
3077 char *lp_preexec(int );
3078 char *lp_postexec(int );
3079 char *lp_rootpreexec(int );
3080 char *lp_rootpostexec(int );
3081 char *lp_servicename(int );
3082 const char *lp_const_servicename(int );
3083 char *lp_pathname(int );
3084 char *lp_dontdescend(int );
3085 char *lp_username(int );
3086 const char **lp_invalid_users(int );
3087 const char **lp_valid_users(int );
3088 const char **lp_admin_users(int );
3089 const char **lp_svcctl_list(void);
3090 char *lp_cups_options(int );
3091 char *lp_cups_server(void);
3092 int lp_cups_encrypt(void);
3093 char *lp_iprint_server(void);
3094 int lp_cups_connection_timeout(void);
3095 const char *lp_ctdbd_socket(void);
3096 const char **lp_cluster_addresses(void);
3097 bool lp_clustering(void);
3098 int lp_ctdb_timeout(void);
3099 int lp_ctdb_locktime_warn_threshold(void);
3100 char *lp_printcommand(int );
3101 char *lp_lpqcommand(int );
3102 char *lp_lprmcommand(int );
3103 char *lp_lppausecommand(int );
3104 char *lp_lpresumecommand(int );
3105 char *lp_queuepausecommand(int );
3106 char *lp_queueresumecommand(int );
3107 const char *lp_printjob_username(int );
3108 const char **lp_hostsallow(int );
3109 const char **lp_hostsdeny(int );
3110 char *lp_magicscript(int );
3111 char *lp_magicoutput(int );
3112 char *lp_comment(int );
3113 char *lp_force_user(int );
3114 char *lp_force_group(int );
3115 const char **lp_readlist(int );
3116 const char **lp_writelist(int );
3117 const char **lp_printer_admin(int );
3118 char *lp_fstype(int );
3119 const char **lp_vfs_objects(int );
3120 char *lp_msdfs_proxy(int );
3121 char *lp_veto_files(int );
3122 char *lp_hide_files(int );
3123 char *lp_veto_oplocks(int );
3124 bool lp_msdfs_root(int );
3125 char *lp_aio_write_behind(int );
3126 char *lp_dfree_command(int );
3127 bool lp_autoloaded(int );
3128 bool lp_preexec_close(int );
3129 bool lp_rootpreexec_close(int );
3130 int lp_casesensitive(int );
3131 bool lp_preservecase(int );
3132 bool lp_shortpreservecase(int );
3133 bool lp_hide_dot_files(int );
3134 bool lp_hide_special_files(int );
3135 bool lp_hideunreadable(int );
3136 bool lp_hideunwriteable_files(int );
3137 bool lp_browseable(int );
3138 bool lp_access_based_share_enum(int );
3139 bool lp_readonly(int );
3140 bool lp_no_set_dir(int );
3141 bool lp_guest_ok(int );
3142 bool lp_guest_only(int );
3143 bool lp_administrative_share(int );
3144 bool lp_print_ok(int );
3145 bool lp_print_notify_backchannel(int );
3146 bool lp_map_hidden(int );
3147 bool lp_map_archive(int );
3148 bool lp_store_dos_attributes(int );
3149 bool lp_dmapi_support(int );
3150 bool lp_locking(const struct share_params *p );
3151 int lp_strict_locking(const struct share_params *p );
3152 bool lp_posix_locking(const struct share_params *p );
3153 bool lp_share_modes(int );
3154 bool lp_oplocks(int );
3155 bool lp_level2_oplocks(int );
3156 bool lp_onlyuser(int );
3157 bool lp_manglednames(const struct share_params *p );
3158 bool lp_widelinks(int );
3159 bool lp_symlinks(int );
3160 bool lp_syncalways(int );
3161 bool lp_strict_allocate(int );
3162 bool lp_strict_sync(int );
3163 bool lp_map_system(int );
3164 bool lp_delete_readonly(int );
3165 bool lp_fake_oplocks(int );
3166 bool lp_recursive_veto_delete(int );
3167 bool lp_dos_filemode(int );
3168 bool lp_dos_filetimes(int );
3169 bool lp_dos_filetime_resolution(int );
3170 bool lp_fake_dir_create_times(int);
3171 bool lp_async_smb_echo_handler(void);
3172 bool lp_multicast_dns_register(void);
3173 bool lp_blocking_locks(int );
3174 bool lp_inherit_perms(int );
3175 bool lp_inherit_acls(int );
3176 bool lp_inherit_owner(int );
3177 bool lp_use_client_driver(int );
3178 bool lp_default_devmode(int );
3179 bool lp_force_printername(int );
3180 bool lp_nt_acl_support(int );
3181 bool lp_force_unknown_acl_user(int );
3182 bool lp_ea_support(int );
3183 bool _lp_use_sendfile(int );
3184 bool lp_profile_acls(int );
3185 bool lp_map_acl_inherit(int );
3186 bool lp_afs_share(int );
3187 bool lp_acl_check_permissions(int );
3188 bool lp_acl_group_control(int );
3189 bool lp_acl_map_full_control(int );
3190 int lp_create_mask(int );
3191 int lp_force_create_mode(int );
3192 int lp_security_mask(int );
3193 int lp_force_security_mode(int );
3194 int lp_dir_mask(int );
3195 int lp_force_dir_mode(int );
3196 int lp_dir_security_mask(int );
3197 int lp_force_dir_security_mode(int );
3198 int lp_max_connections(int );
3199 int lp_defaultcase(int );
3200 int lp_minprintspace(int );
3201 int lp_printing(int );
3202 int lp_max_reported_jobs(int );
3203 int lp_oplock_contention_limit(int );
3204 int lp_csc_policy(int );
3205 int lp_write_cache_size(int );
3206 int lp_block_size(int );
3207 int lp_dfree_cache_time(int );
3208 int lp_allocation_roundup_size(int );
3209 int lp_aio_read_size(int );
3210 int lp_aio_write_size(int );
3211 int lp_map_readonly(int );
3212 int lp_directory_name_cache_size(int );
3213 int lp_smb_encrypt(int );
3214 char lp_magicchar(const struct share_params *p );
3215 int lp_winbind_cache_time(void);
3216 int lp_winbind_reconnect_delay(void);
3217 int lp_winbind_max_clients(void);
3218 const char **lp_winbind_nss_info(void);
3219 int lp_algorithmic_rid_base(void);
3220 int lp_name_cache_timeout(void);
3221 int lp_client_signing(void);
3222 int lp_server_signing(void);
3223 int lp_client_ldap_sasl_wrapping(void);
3224 char *lp_parm_talloc_string(int snum, const char *type, const char *option, const char *def);
3225 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def);
3226 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def);
3227 int lp_parm_int(int snum, const char *type, const char *option, int def);
3228 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def);
3229 bool lp_parm_bool(int snum, const char *type, const char *option, bool def);
3230 int lp_parm_enum(int snum, const char *type, const char *option,
3231                  const struct enum_list *_enum, int def);
3232 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src);
3233 bool lp_add_home(const char *pszHomename, int iDefaultService,
3234                  const char *user, const char *pszHomedir);
3235 int lp_add_service(const char *pszService, int iDefaultService);
3236 bool lp_add_printer(const char *pszPrintername, int iDefaultService);
3237 bool lp_parameter_is_valid(const char *pszParmName);
3238 bool lp_parameter_is_global(const char *pszParmName);
3239 bool lp_parameter_is_canonical(const char *parm_name);
3240 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
3241                                bool *inverse);
3242 bool lp_canonicalize_parameter_with_value(const char *parm_name,
3243                                           const char *val,
3244                                           const char **canon_parm,
3245                                           const char **canon_val);
3246 void show_parameter_list(void);
3247 bool lp_string_is_valid_boolean(const char *parm_value);
3248 bool lp_invert_boolean(const char *str, const char **inverse_str);
3249 bool lp_canonicalize_boolean(const char *str, const char**canon_str);
3250 bool service_ok(int iService);
3251 bool process_registry_service(const char *service_name);
3252 bool process_registry_shares(void);
3253 bool lp_config_backend_is_registry(void);
3254 bool lp_config_backend_is_file(void);
3255 bool lp_file_list_changed(void);
3256 bool lp_idmap_uid(uid_t *low, uid_t *high);
3257 bool lp_idmap_gid(gid_t *low, gid_t *high);
3258 const char *lp_ldap_machine_suffix(void);
3259 const char *lp_ldap_user_suffix(void);
3260 const char *lp_ldap_group_suffix(void);
3261 const char *lp_ldap_idmap_suffix(void);
3262 void *lp_local_ptr_by_snum(int snum, void *ptr);
3263 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue);
3264 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue);
3265 bool lp_set_option(const char *option);
3266 void init_locals(void);
3267 bool lp_is_default(int snum, struct parm_struct *parm);
3268 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal);
3269 struct parm_struct *lp_get_parameter(const char *param_name);
3270 struct parm_struct *lp_next_parameter(int snum, int *i, int allparameters);
3271 bool lp_snum_ok(int iService);
3272 void lp_add_one_printer(const char *name, const char *comment, void *pdata);
3273 bool lp_loaded(void);
3274 void lp_killunused(bool (*snumused) (int));
3275 void lp_kill_all_services(void);
3276 void lp_killservice(int iServiceIn);
3277 const char* server_role_str(uint32 role);
3278 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
3279                         SMB_STRUCT_STAT *psbuf,
3280                         const char *servicename,
3281                         int snum,
3282                         char **lines,
3283                         int numlines,
3284                         char **pp_sharepath,
3285                         char **pp_comment,
3286                         char **pp_cp_share_name,
3287                         struct security_descriptor **ppsd,
3288                         bool *pallow_guest);
3289 int load_usershare_service(const char *servicename);
3290 int load_usershare_shares(void);
3291 void gfree_loadparm(void);
3292 void lp_set_in_client(bool b);
3293 bool lp_is_in_client(void);
3294 bool lp_load(const char *pszFname,
3295              bool global_only,
3296              bool save_defaults,
3297              bool add_ipc,
3298              bool initialize_globals);
3299 bool lp_load_initial_only(const char *pszFname);
3300 bool lp_load_with_registry_shares(const char *pszFname,
3301                                   bool global_only,
3302                                   bool save_defaults,
3303                                   bool add_ipc,
3304                                   bool initialize_globals);
3305 int lp_numservices(void);
3306 void lp_dump(FILE *f, bool show_defaults, int maxtoprint);
3307 void lp_dump_one(FILE * f, bool show_defaults, int snum);
3308 int lp_servicenumber(const char *pszServiceName);
3309 bool share_defined(const char *service_name);
3310 struct share_params *get_share_params(TALLOC_CTX *mem_ctx,
3311                                       const char *sharename);
3312 struct share_iterator *share_list_all(TALLOC_CTX *mem_ctx);
3313 struct share_params *next_share(struct share_iterator *list);
3314 struct share_params *next_printer(struct share_iterator *list);
3315 struct share_params *snum2params_static(int snum);
3316 const char *volume_label(int snum);
3317 bool lp_domain_master(void);
3318 bool lp_domain_master_true_or_auto(void);
3319 bool lp_preferred_master(void);
3320 void lp_remove_service(int snum);
3321 void lp_copy_service(int snum, const char *new_name);
3322 int lp_default_server_announce(void);
3323 int lp_major_announce_version(void);
3324 int lp_minor_announce_version(void);
3325 void lp_set_name_resolve_order(const char *new_order);
3326 const char *lp_printername(int snum);
3327 void lp_set_logfile(const char *name);
3328 int lp_maxprintjobs(int snum);
3329 const char *lp_printcapname(void);
3330 bool lp_disable_spoolss( void );
3331 void lp_set_spoolss_state( uint32 state );
3332 uint32 lp_get_spoolss_state( void );
3333 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state);
3334 void set_use_sendfile(int snum, bool val);
3335 void set_store_dos_attributes(int snum, bool val);
3336 void lp_set_mangling_method(const char *new_method);
3337 bool lp_posix_pathnames(void);
3338 void lp_set_posix_pathnames(void);
3339 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp);
3340 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val);
3341 int lp_min_receive_file_size(void);
3342 char* lp_perfcount_module(void);
3343 void lp_set_passdb_backend(const char *backend);
3344 void widelinks_warning(int snum);
3345 char *lp_ncalrpc_dir(void);
3346
3347 /* The following definitions come from param/loadparm_server_role.c  */
3348
3349 int lp_server_role(void);
3350 void set_server_role(void);
3351
3352 /* The following definitions come from param/util.c  */
3353
3354 uint32 get_int_param( const char* param );
3355 char* get_string_param( const char* param );
3356
3357 /* The following definitions come from passdb/login_cache.c  */
3358
3359 bool login_cache_init(void);
3360 bool login_cache_shutdown(void);
3361 bool login_cache_read(struct samu *sampass, struct login_cache *entry);
3362 bool login_cache_write(const struct samu *sampass,
3363                        const struct login_cache *entry);
3364 bool login_cache_delentry(const struct samu *sampass);
3365
3366 /* The following definitions come from passdb/lookup_sid.c  */
3367
3368 bool lookup_name(TALLOC_CTX *mem_ctx,
3369                  const char *full_name, int flags,
3370                  const char **ret_domain, const char **ret_name,
3371                  struct dom_sid *ret_sid, enum lsa_SidType *ret_type);
3372 bool lookup_name_smbconf(TALLOC_CTX *mem_ctx,
3373                  const char *full_name, int flags,
3374                  const char **ret_domain, const char **ret_name,
3375                  struct dom_sid *ret_sid, enum lsa_SidType *ret_type);
3376 NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, int num_sids,
3377                      const struct dom_sid **sids, int level,
3378                      struct lsa_dom_info **ret_domains,
3379                      struct lsa_name_info **ret_names);
3380 bool lookup_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
3381                 const char **ret_domain, const char **ret_name,
3382                 enum lsa_SidType *ret_type);
3383 void store_uid_sid_cache(const struct dom_sid *psid, uid_t uid);
3384 void store_gid_sid_cache(const struct dom_sid *psid, gid_t gid);
3385 void uid_to_sid(struct dom_sid *psid, uid_t uid);
3386 void gid_to_sid(struct dom_sid *psid, gid_t gid);
3387 bool sid_to_uid(const struct dom_sid *psid, uid_t *puid);
3388 bool sid_to_gid(const struct dom_sid *psid, gid_t *pgid);
3389 NTSTATUS get_primary_group_sid(TALLOC_CTX *mem_ctx,
3390                                 const char *username,
3391                                 struct passwd **_pwd,
3392                                 struct dom_sid **_group_sid);
3393 bool delete_uid_cache(uid_t uid);
3394 bool delete_gid_cache(gid_t gid);
3395 bool delete_sid_cache(const struct dom_sid* psid);
3396 void flush_uid_cache(void);
3397 void flush_gid_cache(void);
3398
3399 /* The following definitions come from passdb/machine_sid.c  */
3400
3401 struct dom_sid  *get_global_sam_sid(void);
3402 void reset_global_sam_sid(void) ;
3403 bool sid_check_is_domain(const struct dom_sid  *sid);
3404 bool sid_check_is_in_our_domain(const struct dom_sid  *sid);
3405
3406 /* The following definitions come from passdb/passdb.c  */
3407
3408 const char *my_sam_name(void);
3409 struct samu *samu_new( TALLOC_CTX *ctx );
3410 NTSTATUS samu_set_unix(struct samu *user, const struct passwd *pwd);
3411 NTSTATUS samu_alloc_rid_unix(struct samu *user, const struct passwd *pwd);
3412 char *pdb_encode_acct_ctrl(uint32_t acct_ctrl, size_t length);
3413 uint32_t pdb_decode_acct_ctrl(const char *p);
3414 void pdb_sethexpwd(char p[33], const unsigned char *pwd, uint32_t acct_ctrl);
3415 bool pdb_gethexpwd(const char *p, unsigned char *pwd);
3416 void pdb_sethexhours(char *p, const unsigned char *hours);
3417 bool pdb_gethexhours(const char *p, unsigned char *hours);
3418 int algorithmic_rid_base(void);
3419 uid_t algorithmic_pdb_user_rid_to_uid(uint32_t user_rid);
3420 uid_t max_algorithmic_uid(void);
3421 uint32_t algorithmic_pdb_uid_to_user_rid(uid_t uid);
3422 gid_t pdb_group_rid_to_gid(uint32_t group_rid);
3423 gid_t max_algorithmic_gid(void);
3424 uint32_t algorithmic_pdb_gid_to_group_rid(gid_t gid);
3425 bool algorithmic_pdb_rid_is_user(uint32_t rid);
3426 bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid,
3427                             enum lsa_SidType *type);
3428 NTSTATUS local_password_change(const char *user_name,
3429                                 int local_flags,
3430                                 const char *new_passwd, 
3431                                 char **pp_err_str,
3432                                 char **pp_msg_str);
3433 bool init_samu_from_buffer(struct samu *sampass, uint32_t level,
3434                            uint8_t *buf, uint32_t buflen);
3435 uint32_t init_buffer_from_samu (uint8_t **buf, struct samu *sampass, bool size_only);
3436 bool pdb_copy_sam_account(struct samu *dst, struct samu *src );
3437 bool pdb_update_bad_password_count(struct samu *sampass, bool *updated);
3438 bool pdb_update_autolock_flag(struct samu *sampass, bool *updated);
3439 bool pdb_increment_bad_password_count(struct samu *sampass);
3440 bool is_dc_trusted_domain_situation(const char *domain_name);
3441 bool get_trust_pw_clear(const char *domain, char **ret_pwd,
3442                         const char **account_name,
3443                         enum netr_SchannelType *channel);
3444 bool get_trust_pw_hash(const char *domain, uint8_t ret_pwd[16],
3445                        const char **account_name,
3446                        enum netr_SchannelType *channel);
3447
3448 /* The following definitions come from passdb/pdb_compat.c  */
3449
3450 uint32_t pdb_get_user_rid (const struct samu *sampass);
3451 uint32_t pdb_get_group_rid (struct samu *sampass);
3452 bool pdb_set_user_sid_from_rid (struct samu *sampass, uint32_t rid, enum pdb_value_state flag);
3453 bool pdb_set_group_sid_from_rid (struct samu *sampass, uint32_t grid, enum pdb_value_state flag);
3454
3455 /* The following definitions come from passdb/pdb_get_set.c  */
3456
3457 uint32_t pdb_get_acct_ctrl(const struct samu *sampass);
3458 time_t pdb_get_logon_time(const struct samu *sampass);
3459 time_t pdb_get_logoff_time(const struct samu *sampass);
3460 time_t pdb_get_kickoff_time(const struct samu *sampass);
3461 time_t pdb_get_bad_password_time(const struct samu *sampass);
3462 time_t pdb_get_pass_last_set_time(const struct samu *sampass);
3463 time_t pdb_get_pass_can_change_time(const struct samu *sampass);
3464 time_t pdb_get_pass_can_change_time_noncalc(const struct samu *sampass);
3465 time_t pdb_get_pass_must_change_time(const struct samu *sampass);
3466 bool pdb_get_pass_can_change(const struct samu *sampass);
3467 uint16_t pdb_get_logon_divs(const struct samu *sampass);
3468 uint32_t pdb_get_hours_len(const struct samu *sampass);
3469 const uint8_t *pdb_get_hours(const struct samu *sampass);
3470 const uint8_t *pdb_get_nt_passwd(const struct samu *sampass);
3471 const uint8_t *pdb_get_lanman_passwd(const struct samu *sampass);
3472 const uint8_t *pdb_get_pw_history(const struct samu *sampass, uint32_t *current_hist_len);
3473 const char *pdb_get_plaintext_passwd(const struct samu *sampass);
3474 const struct dom_sid *pdb_get_user_sid(const struct samu *sampass);
3475 const struct dom_sid *pdb_get_group_sid(struct samu *sampass);
3476 enum pdb_value_state pdb_get_init_flags(const struct samu *sampass, enum pdb_elements element);
3477 const char *pdb_get_username(const struct samu *sampass);
3478 const char *pdb_get_domain(const struct samu *sampass);
3479 const char *pdb_get_nt_username(const struct samu *sampass);
3480 const char *pdb_get_fullname(const struct samu *sampass);
3481 const char *pdb_get_homedir(const struct samu *sampass);
3482 const char *pdb_get_dir_drive(const struct samu *sampass);
3483 const char *pdb_get_logon_script(const struct samu *sampass);
3484 const char *pdb_get_profile_path(const struct samu *sampass);
3485 const char *pdb_get_acct_desc(const struct samu *sampass);
3486 const char *pdb_get_workstations(const struct samu *sampass);
3487 const char *pdb_get_comment(const struct samu *sampass);
3488 const char *pdb_get_munged_dial(const struct samu *sampass);
3489 uint16_t pdb_get_bad_password_count(const struct samu *sampass);
3490 uint16_t pdb_get_logon_count(const struct samu *sampass);
3491 uint16_t pdb_get_country_code(const struct samu *sampass);
3492 uint16_t pdb_get_code_page(const struct samu *sampass);
3493 uint32_t pdb_get_unknown_6(const struct samu *sampass);
3494 void *pdb_get_backend_private_data(const struct samu *sampass, const struct pdb_methods *my_methods);
3495 bool pdb_set_acct_ctrl(struct samu *sampass, uint32_t acct_ctrl, enum pdb_value_state flag);
3496 bool pdb_set_logon_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
3497 bool pdb_set_logoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
3498 bool pdb_set_kickoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
3499 bool pdb_set_bad_password_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
3500 bool pdb_set_pass_can_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
3501 bool pdb_set_pass_must_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
3502 bool pdb_set_pass_last_set_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
3503 bool pdb_set_hours_len(struct samu *sampass, uint32_t len, enum pdb_value_state flag);
3504 bool pdb_set_logon_divs(struct samu *sampass, uint16_t hours, enum pdb_value_state flag);
3505 bool pdb_set_init_flags(struct samu *sampass, enum pdb_elements element, enum pdb_value_state value_flag);
3506 bool pdb_set_user_sid(struct samu *sampass, const struct dom_sid *u_sid, enum pdb_value_state flag);
3507 bool pdb_set_user_sid_from_string(struct samu *sampass, fstring u_sid, enum pdb_value_state flag);
3508 bool pdb_set_group_sid(struct samu *sampass, const struct dom_sid *g_sid, enum pdb_value_state flag);
3509 bool pdb_set_username(struct samu *sampass, const char *username, enum pdb_value_state flag);
3510 bool pdb_set_domain(struct samu *sampass, const char *domain, enum pdb_value_state flag);
3511 bool pdb_set_nt_username(struct samu *sampass, const char *nt_username, enum pdb_value_state flag);
3512 bool pdb_set_fullname(struct samu *sampass, const char *full_name, enum pdb_value_state flag);
3513 bool pdb_set_logon_script(struct samu *sampass, const char *logon_script, enum pdb_value_state flag);
3514 bool pdb_set_profile_path(struct samu *sampass, const char *profile_path, enum pdb_value_state flag);
3515 bool pdb_set_dir_drive(struct samu *sampass, const char *dir_drive, enum pdb_value_state flag);
3516 bool pdb_set_homedir(struct samu *sampass, const char *home_dir, enum pdb_value_state flag);
3517 bool pdb_set_acct_desc(struct samu *sampass, const char *acct_desc, enum pdb_value_state flag);
3518 bool pdb_set_workstations(struct samu *sampass, const char *workstations, enum pdb_value_state flag);
3519 bool pdb_set_comment(struct samu *sampass, const char *comment, enum pdb_value_state flag);
3520 bool pdb_set_munged_dial(struct samu *sampass, const char *munged_dial, enum pdb_value_state flag);
3521 bool pdb_set_nt_passwd(struct samu *sampass, const uint8_t pwd[NT_HASH_LEN], enum pdb_value_state flag);
3522 bool pdb_set_lanman_passwd(struct samu *sampass, const uint8_t pwd[LM_HASH_LEN], enum pdb_value_state flag);
3523 bool pdb_set_pw_history(struct samu *sampass, const uint8_t *pwd, uint32_t historyLen, enum pdb_value_state flag);
3524 bool pdb_set_plaintext_pw_only(struct samu *sampass, const char *password, enum pdb_value_state flag);
3525 bool pdb_set_bad_password_count(struct samu *sampass, uint16_t bad_password_count, enum pdb_value_state flag);
3526 bool pdb_set_logon_count(struct samu *sampass, uint16_t logon_count, enum pdb_value_state flag);
3527 bool pdb_set_country_code(struct samu *sampass, uint16_t country_code,
3528                           enum pdb_value_state flag);
3529 bool pdb_set_code_page(struct samu *sampass, uint16_t code_page,
3530                        enum pdb_value_state flag);
3531 bool pdb_set_unknown_6(struct samu *sampass, uint32_t unkn, enum pdb_value_state flag);
3532 bool pdb_set_hours(struct samu *sampass, const uint8 *hours, int hours_len,
3533                    enum pdb_value_state flag);
3534 bool pdb_set_backend_private_data(struct samu *sampass, void *private_data, 
3535                                    void (*free_fn)(void **), 
3536                                    const struct pdb_methods *my_methods, 
3537                                    enum pdb_value_state flag);
3538 bool pdb_set_pass_can_change(struct samu *sampass, bool canchange);
3539 bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext);
3540 uint32_t pdb_build_fields_present(struct samu *sampass);
3541
3542 /* The following definitions come from passdb/pdb_interface.c  */
3543
3544 NTSTATUS smb_register_passdb(int version, const char *name, pdb_init_function init) ;
3545 struct pdb_init_function_entry *pdb_find_backend_entry(const char *name);
3546 struct event_context *pdb_get_event_context(void);
3547 NTSTATUS make_pdb_method_name(struct pdb_methods **methods, const char *selected);
3548 struct pdb_domain_info *pdb_get_domain_info(TALLOC_CTX *mem_ctx);
3549 bool pdb_getsampwnam(struct samu *sam_acct, const char *username) ;
3550 bool pdb_getsampwsid(struct samu *sam_acct, const struct dom_sid *sid) ;
3551 NTSTATUS pdb_create_user(TALLOC_CTX *mem_ctx, const char *name, uint32_t flags,
3552                          uint32_t *rid);
3553 NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct);
3554 NTSTATUS pdb_add_sam_account(struct samu *sam_acct) ;
3555 NTSTATUS pdb_update_sam_account(struct samu *sam_acct) ;
3556 NTSTATUS pdb_delete_sam_account(struct samu *sam_acct) ;
3557 NTSTATUS pdb_rename_sam_account(struct samu *oldname, const char *newname);
3558 NTSTATUS pdb_update_login_attempts(struct samu *sam_acct, bool success);
3559 bool pdb_getgrsid(GROUP_MAP *map, struct dom_sid sid);
3560 bool pdb_getgrgid(GROUP_MAP *map, gid_t gid);
3561 bool pdb_getgrnam(GROUP_MAP *map, const char *name);
3562 NTSTATUS pdb_create_dom_group(TALLOC_CTX *mem_ctx, const char *name,
3563                               uint32_t *rid);
3564 NTSTATUS pdb_delete_dom_group(TALLOC_CTX *mem_ctx, uint32_t rid);
3565 NTSTATUS pdb_add_group_mapping_entry(GROUP_MAP *map);
3566 NTSTATUS pdb_update_group_mapping_entry(GROUP_MAP *map);
3567 NTSTATUS pdb_delete_group_mapping_entry(struct dom_sid sid);
3568 bool pdb_enum_group_mapping(const struct dom_sid *sid, enum lsa_SidType sid_name_use, GROUP_MAP **pp_rmap,
3569                             size_t *p_num_entries, bool unix_only);
3570 NTSTATUS pdb_enum_group_members(TALLOC_CTX *mem_ctx,
3571                                 const struct dom_sid *sid,
3572                                 uint32_t **pp_member_rids,
3573                                 size_t *p_num_members);
3574 NTSTATUS pdb_enum_group_memberships(TALLOC_CTX *mem_ctx, struct samu *user,
3575                                     struct dom_sid **pp_sids, gid_t **pp_gids,
3576                                     uint32_t *p_num_groups);
3577 NTSTATUS pdb_set_unix_primary_group(TALLOC_CTX *mem_ctx, struct samu *user);
3578 NTSTATUS pdb_add_groupmem(TALLOC_CTX *mem_ctx, uint32_t group_rid,
3579                           uint32_t member_rid);
3580 NTSTATUS pdb_del_groupmem(TALLOC_CTX *mem_ctx, uint32_t group_rid,
3581                           uint32_t member_rid);
3582 NTSTATUS pdb_create_alias(const char *name, uint32_t *rid);
3583 NTSTATUS pdb_delete_alias(const struct dom_sid *sid);
3584 NTSTATUS pdb_get_aliasinfo(const struct dom_sid *sid, struct acct_info *info);
3585 NTSTATUS pdb_set_aliasinfo(const struct dom_sid *sid, struct acct_info *info);
3586 NTSTATUS pdb_add_aliasmem(const struct dom_sid *alias, const struct dom_sid *member);
3587 NTSTATUS pdb_del_aliasmem(const struct dom_sid *alias, const struct dom_sid *member);
3588 NTSTATUS pdb_enum_aliasmem(const struct dom_sid *alias, TALLOC_CTX *mem_ctx,
3589                            struct dom_sid **pp_members, size_t *p_num_members);
3590 NTSTATUS pdb_enum_alias_memberships(TALLOC_CTX *mem_ctx,
3591                                     const struct dom_sid *domain_sid,
3592                                     const struct dom_sid *members, size_t num_members,
3593                                     uint32_t **pp_alias_rids,
3594                                     size_t *p_num_alias_rids);
3595 NTSTATUS pdb_lookup_rids(const struct dom_sid *domain_sid,
3596                          int num_rids,
3597                          uint32_t *rids,
3598                          const char **names,
3599                          enum lsa_SidType *attrs);
3600 NTSTATUS pdb_lookup_names(const struct dom_sid *domain_sid,
3601                           int num_names,
3602                           const char **names,
3603                           uint32_t *rids,
3604                           enum lsa_SidType *attrs);
3605 bool pdb_get_account_policy(enum pdb_policy_type type, uint32_t *value);
3606 bool pdb_set_account_policy(enum pdb_policy_type type, uint32_t value);
3607 bool pdb_get_seq_num(time_t *seq_num);
3608 bool pdb_uid_to_sid(uid_t uid, struct dom_sid *sid);
3609 bool pdb_gid_to_sid(gid_t gid, struct dom_sid *sid);
3610 bool pdb_sid_to_id(const struct dom_sid *sid, union unid_t *id,
3611                    enum lsa_SidType *type);
3612 uint32_t pdb_capabilities(void);
3613 bool pdb_new_rid(uint32_t *rid);
3614 bool initialize_password_db(bool reload, struct event_context *event_ctx);
3615 struct pdb_search *pdb_search_init(TALLOC_CTX *mem_ctx,
3616                                    enum pdb_search_type type);
3617 struct pdb_search *pdb_search_users(TALLOC_CTX *mem_ctx, uint32_t acct_flags);
3618 struct pdb_search *pdb_search_groups(TALLOC_CTX *mem_ctx);
3619 struct pdb_search *pdb_search_aliases(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
3620 uint32_t pdb_search_entries(struct pdb_search *search,
3621                           uint32_t start_idx, uint32_t max_entries,
3622                           struct samr_displayentry **result);
3623 bool pdb_get_trusteddom_pw(const char *domain, char** pwd, struct dom_sid *sid,
3624                            time_t *pass_last_set_time);
3625 bool pdb_set_trusteddom_pw(const char* domain, const char* pwd,
3626                            const struct dom_sid *sid);
3627 bool pdb_del_trusteddom_pw(const char *domain);
3628 NTSTATUS pdb_enum_trusteddoms(TALLOC_CTX *mem_ctx, uint32_t *num_domains,
3629                               struct trustdom_info ***domains);
3630 NTSTATUS pdb_get_trusted_domain(TALLOC_CTX *mem_ctx, const char *domain,
3631                                 struct pdb_trusted_domain **td);
3632 NTSTATUS pdb_get_trusted_domain_by_sid(TALLOC_CTX *mem_ctx, struct dom_sid *sid,
3633                                 struct pdb_trusted_domain **td);
3634 NTSTATUS pdb_set_trusted_domain(const char* domain,
3635                                 const struct pdb_trusted_domain *td);
3636 NTSTATUS pdb_del_trusted_domain(const char *domain);
3637 NTSTATUS pdb_enum_trusted_domains(TALLOC_CTX *mem_ctx, uint32_t *num_domains,
3638                                   struct pdb_trusted_domain ***domains);
3639 NTSTATUS make_pdb_method( struct pdb_methods **methods ) ;
3640
3641 /* The following definitions come from passdb/pdb_ldap.c  */
3642
3643 const char** get_userattr_list( TALLOC_CTX *mem_ctx, int schema_ver );
3644 NTSTATUS pdb_init_ldapsam_compat(struct pdb_methods **pdb_method, const char *location);
3645 NTSTATUS pdb_init_ldapsam(struct pdb_methods **pdb_method, const char *location);
3646 NTSTATUS pdb_ldap_init(void);
3647
3648 /* The following definitions come from passdb/pdb_nds.c  */
3649
3650 struct smbldap_state;
3651
3652 int pdb_nds_get_password(
3653         struct smbldap_state *ldap_state,
3654         char *object_dn,
3655         size_t *pwd_len,
3656         char *pwd );
3657 int pdb_nds_set_password(
3658         struct smbldap_state *ldap_state,
3659         char *object_dn,
3660         const char *pwd );
3661 NTSTATUS pdb_nds_init(void);
3662
3663 /* The following definitions come from passdb/pdb_nds.c  */
3664
3665 NTSTATUS pdb_ipa_init(void);
3666
3667 /* The following definitions come from passdb/pdb_smbpasswd.c  */
3668
3669 NTSTATUS pdb_smbpasswd_init(void) ;
3670
3671 /* The following definitions come from passdb/pdb_wbc_sam.c  */
3672
3673 NTSTATUS pdb_wbc_sam_init(void);
3674
3675 /* The following definitions come from passdb/pdb_tdb.c  */
3676
3677 NTSTATUS pdb_tdbsam_init(void);
3678
3679 /* The following definitions come from passdb/util_builtin.c  */
3680
3681 bool lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32 rid, const char **name);
3682 bool lookup_builtin_name(const char *name, uint32 *rid);
3683 const char *builtin_domain_name(void);
3684 bool sid_check_is_builtin(const struct dom_sid *sid);
3685 bool sid_check_is_in_builtin(const struct dom_sid *sid);
3686
3687 /* The following definitions come from passdb/util_unixsids.c  */
3688
3689 bool sid_check_is_unix_users(const struct dom_sid *sid);
3690 bool sid_check_is_in_unix_users(const struct dom_sid *sid);
3691 void uid_to_unix_users_sid(uid_t uid, struct dom_sid *sid);
3692 void gid_to_unix_groups_sid(gid_t gid, struct dom_sid *sid);
3693 const char *unix_users_domain_name(void);
3694 bool lookup_unix_user_name(const char *name, struct dom_sid *sid);
3695 bool sid_check_is_unix_groups(const struct dom_sid *sid);
3696 bool sid_check_is_in_unix_groups(const struct dom_sid *sid);
3697 const char *unix_groups_domain_name(void);
3698 bool lookup_unix_group_name(const char *name, struct dom_sid *sid);
3699
3700 /* The following definitions come from passdb/util_wellknown.c  */
3701
3702 bool sid_check_is_wellknown_domain(const struct dom_sid *sid, const char **name);
3703 bool sid_check_is_in_wellknown_domain(const struct dom_sid *sid);
3704 bool lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
3705                           const char **domain, const char **name);
3706 bool lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name,
3707                            struct dom_sid *sid, const char **domain);
3708
3709 /* The following definitions come from profile/profile.c  */
3710
3711 void set_profile_level(int level, struct server_id src);
3712 bool profile_setup(struct messaging_context *msg_ctx, bool rdonly);
3713
3714 /* The following definitions come from librpc/rpc/rpc_common.c  */
3715
3716 bool smb_register_ndr_interface(const struct ndr_interface_table *interface);
3717 const struct ndr_interface_table *get_iface_from_syntax(
3718         const struct ndr_syntax_id *syntax);
3719 const char *get_pipe_name_from_syntax(TALLOC_CTX *mem_ctx,
3720                                      const struct ndr_syntax_id *syntax);
3721
3722 /* The following definitions come from rpc_server/rpc_ncacn_np.c  */
3723
3724 struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
3725                                               const struct ndr_syntax_id *syntax,
3726                                               struct client_address *client_id,
3727                                               const struct auth_serversupplied_info *session_info,
3728                                               struct messaging_context *msg_ctx);
3729 NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
3730                                const struct ndr_interface_table *ndr_table,
3731                                struct client_address *client_id,
3732                                const struct auth_serversupplied_info *session_info,
3733                                struct messaging_context *msg_ctx,
3734                                struct dcerpc_binding_handle **binding_handle);
3735 NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
3736                                 const struct ndr_syntax_id *abstract_syntax,
3737                                 const struct auth_serversupplied_info *serversupplied_info,
3738                                 struct client_address *client_id,
3739                                 struct messaging_context *msg_ctx,
3740                                 struct rpc_pipe_client **presult);
3741 NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
3742                                  const struct ndr_syntax_id *syntax,
3743                                  const struct auth_serversupplied_info *session_info,
3744                                  struct client_address *client_id,
3745                                  struct messaging_context *msg_ctx,
3746                                  struct rpc_pipe_client **cli_pipe);
3747
3748 /* The following definitions come from rpc_client/cli_pipe_schannel.c  */
3749
3750 NTSTATUS get_schannel_session_key(struct cli_state *cli,
3751                                   const char *domain,
3752                                   uint32 *pneg_flags,
3753                                   struct rpc_pipe_client **presult);
3754
3755 /* The following definitions come from rpc_client/rpc_transport_np.c  */
3756
3757 struct tevent_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
3758                                               struct event_context *ev,
3759                                               struct cli_state *cli,
3760                                               const struct ndr_syntax_id *abstract_syntax);
3761 NTSTATUS rpc_transport_np_init_recv(struct tevent_req *req,
3762                                     TALLOC_CTX *mem_ctx,
3763                                     struct rpc_cli_transport **presult);
3764 NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli,
3765                                const struct ndr_syntax_id *abstract_syntax,
3766                                struct rpc_cli_transport **presult);
3767
3768 /* The following definitions come from rpc_client/rpc_transport_sock.c  */
3769
3770 NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
3771                                  struct rpc_cli_transport **presult);
3772
3773 /* The following definitions come from rpc_client/rpc_transport_tstream.c  */
3774
3775 NTSTATUS rpc_transport_tstream_init(TALLOC_CTX *mem_ctx,
3776                                 struct tstream_context **stream,
3777                                 struct rpc_cli_transport **presult);
3778 struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p);
3779
3780 /* The following definitions come from rpc_server/srv_eventlog_nt.c  */
3781
3782 /* The following definitions come from rpc_server/rpc_handles.c  */
3783
3784 size_t num_pipe_handles(struct pipes_struct *p);
3785 bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *syntax);
3786 bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
3787 bool find_policy_by_hnd(struct pipes_struct *p, const struct policy_handle *hnd,
3788                         void **data_p);
3789 bool close_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd);
3790 void close_policy_by_pipe(struct pipes_struct *p);
3791 bool pipe_access_check(struct pipes_struct *p);
3792
3793 void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,
3794                             uint32_t access_granted, size_t data_size,
3795                             const char *type, NTSTATUS *pstatus);
3796 #define policy_handle_create(_p, _hnd, _access, _type, _pstatus) \
3797         (_type *)_policy_handle_create((_p), (_hnd), (_access), sizeof(_type), #_type, \
3798                                        (_pstatus))
3799
3800 void *_policy_handle_find(struct pipes_struct *p,
3801                           const struct policy_handle *hnd,
3802                           uint32_t access_required, uint32_t *paccess_granted,
3803                           const char *name, const char *location,
3804                           NTSTATUS *pstatus);
3805 #define policy_handle_find(_p, _hnd, _access_required, _access_granted, _type, _pstatus) \
3806         (_type *)_policy_handle_find((_p), (_hnd), (_access_required), \
3807                                      (_access_granted), #_type, __location__, (_pstatus))
3808
3809
3810 /* The following definitions come from rpc_server/srv_rpc_register.c  */
3811
3812 struct rpc_srv_callbacks {
3813         bool (*init)(void *private_data);
3814         bool (*shutdown)(void *private_data);
3815         void *private_data;
3816 };
3817
3818 NTSTATUS rpc_srv_register(int version, const char *clnt,
3819                           const char *srv,
3820                           const struct ndr_interface_table *iface,
3821                           const struct api_struct *cmds, int size,
3822                           const struct rpc_srv_callbacks *rpc_srv_cb);
3823
3824 NTSTATUS rpc_srv_unregister(const struct ndr_interface_table *iface);
3825
3826 /* The following definitions come from rpc_server/srv_pipe.c  */
3827
3828 bool create_next_pdu(struct pipes_struct *p);
3829 bool api_pipe_bind_auth3(struct pipes_struct *p, struct ncacn_packet *pkt);
3830 bool setup_fault_pdu(struct pipes_struct *p, NTSTATUS status);
3831 NTSTATUS rpc_pipe_register_commands(int version, const char *clnt,
3832                                     const char *srv,
3833                                     const struct ndr_syntax_id *interface,
3834                                     const struct api_struct *cmds, int size);
3835 bool is_known_pipename(const char *cli_filename, struct ndr_syntax_id *syntax);
3836
3837 /* The following definitions come from rpc_server/srv_pipe_hnd.c  */
3838
3839 struct pipes_struct *get_first_internal_pipe(void);
3840 struct pipes_struct *get_next_internal_pipe(struct pipes_struct *p);
3841 bool check_open_pipes(void);
3842 int close_internal_rpc_pipe_hnd(struct pipes_struct *p);
3843
3844 bool fsp_is_np(struct files_struct *fsp);
3845 struct tsocket_address;
3846 NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
3847                  const struct tsocket_address *local_address,
3848                  const struct tsocket_address *remote_address,
3849                  struct client_address *client_id,
3850                  struct auth_serversupplied_info *session_info,
3851                  struct messaging_context *msg_ctx,
3852                  struct fake_file_handle **phandle);
3853 bool np_read_in_progress(struct fake_file_handle *handle);
3854 struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
3855                                  struct fake_file_handle *handle,
3856                                  const uint8_t *data, size_t len);
3857 NTSTATUS np_write_recv(struct tevent_req *req, ssize_t *pnwritten);
3858 struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
3859                                 struct fake_file_handle *handle,
3860                                 uint8_t *data, size_t len);
3861 NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
3862                       bool *is_data_outstanding);
3863
3864 ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n);
3865
3866 /* The following definitions come from rpc_server/srv_spoolss_nt.c  */
3867 void srv_spoolss_cleanup(void);
3868
3869 void do_drv_upgrade_printer(struct messaging_context *msg,
3870                             void *private_data,
3871                             uint32_t msg_type,
3872                             struct server_id server_id,
3873                             DATA_BLOB *data);
3874 void update_monitored_printq_cache(struct messaging_context *msg_ctx);
3875
3876 /* The following definitions come from rpc_server/srv_srvsvc_nt.c  */
3877
3878 char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname);
3879
3880 /* The following definitions come from rpc_server/srv_svcctl_nt.c  */
3881
3882 bool init_service_op_table( void );
3883 bool shutdown_service_op_table(void);
3884
3885 /* The following definitions come from rpcclient/cmd_dfs.c  */
3886
3887
3888 /* The following definitions come from rpcclient/cmd_dssetup.c  */
3889
3890
3891 /* The following definitions come from rpcclient/cmd_echo.c  */
3892
3893
3894 /* The following definitions come from rpcclient/cmd_lsarpc.c  */
3895
3896
3897 /* The following definitions come from rpcclient/cmd_netlogon.c  */
3898
3899
3900 /* The following definitions come from rpcclient/cmd_ntsvcs.c  */
3901
3902
3903 /* The following definitions come from rpcclient/cmd_samr.c  */
3904
3905
3906 /* The following definitions come from rpcclient/cmd_shutdown.c  */
3907
3908
3909 /* The following definitions come from rpcclient/cmd_spoolss.c  */
3910
3911
3912 /* The following definitions come from rpcclient/cmd_srvsvc.c  */
3913
3914
3915 /* The following definitions come from rpcclient/cmd_test.c  */
3916
3917
3918 /* The following definitions come from rpcclient/cmd_wkssvc.c  */
3919
3920
3921 /* The following definitions come from rpcclient/rpcclient.c  */
3922
3923
3924 /* The following definitions come from services/svc_netlogon.c  */
3925
3926
3927 /* The following definitions come from services/svc_rcinit.c  */
3928
3929
3930 /* The following definitions come from services/svc_spoolss.c  */
3931
3932
3933 /* The following definitions come from services/svc_winreg.c  */
3934
3935
3936 /* The following definitions come from services/svc_wins.c  */
3937
3938
3939 /* The following definitions come from smbd/aio.c  */
3940
3941 NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
3942                              struct smb_request *req,
3943                              files_struct *fsp, SMB_OFF_T startpos,
3944                              size_t smb_maxcnt);
3945 NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
3946                               struct smb_request *req,
3947                               files_struct *fsp, char *data,
3948                               SMB_OFF_T startpos,
3949                               size_t numtowrite);
3950 NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
3951                                 struct smb_request *smbreq,
3952                                 files_struct *fsp,
3953                                 TALLOC_CTX *ctx,
3954                                 DATA_BLOB *preadbuf,
3955                                 SMB_OFF_T startpos,
3956                                 size_t smb_maxcnt);
3957 NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
3958                                 struct smb_request *smbreq,
3959                                 files_struct *fsp,
3960                                 uint64_t in_offset,
3961                                 DATA_BLOB in_data,
3962                                 bool write_through);
3963 int wait_for_aio_completion(files_struct *fsp);
3964 void cancel_aio_by_fsp(files_struct *fsp);
3965 void smbd_aio_complete_aio_ex(struct aio_extra *aio_ex);
3966
3967 /* The following definitions come from smbd/blocking.c  */
3968
3969 void brl_timeout_fn(struct event_context *event_ctx,
3970                 struct timed_event *te,
3971                 struct timeval now,
3972                 void *private_data);
3973 struct timeval timeval_brl_min(const struct timeval *tv1,
3974                         const struct timeval *tv2);
3975 void process_blocking_lock_queue(struct smbd_server_connection *sconn);
3976 bool push_blocking_lock_request( struct byte_range_lock *br_lck,
3977                 struct smb_request *req,
3978                 files_struct *fsp,
3979                 int lock_timeout,
3980                 int lock_num,
3981                 uint64_t smblctx,
3982                 enum brl_type lock_type,
3983                 enum brl_flavour lock_flav,
3984                 uint64_t offset,
3985                 uint64_t count,
3986                 uint64_t blocking_smblctx);
3987 void cancel_pending_lock_requests_by_fid(files_struct *fsp,
3988                         struct byte_range_lock *br_lck,
3989                         enum file_close_type close_type);
3990 void remove_pending_lock_requests_by_mid_smb1(
3991         struct smbd_server_connection *sconn, uint64_t mid);
3992 bool blocking_lock_was_deferred_smb1(
3993         struct smbd_server_connection *sconn, uint64_t mid);
3994 struct blocking_lock_record *blocking_lock_cancel_smb1(files_struct *fsp,
3995                         uint64_t smblctx,
3996                         uint64_t offset,
3997                         uint64_t count,
3998                         enum brl_flavour lock_flav,
3999                         unsigned char locktype,
4000                         NTSTATUS err);
4001
4002 /* The following definitions come from smbd/close.c  */
4003
4004 void set_close_write_time(struct files_struct *fsp, struct timespec ts);
4005 NTSTATUS close_file(struct smb_request *req, files_struct *fsp,
4006                     enum file_close_type close_type);
4007 void msg_close_file(struct messaging_context *msg_ctx,
4008                     void *private_data,
4009                     uint32_t msg_type,
4010                     struct server_id server_id,
4011                     DATA_BLOB *data);
4012 NTSTATUS delete_all_streams(connection_struct *conn, const char *fname);
4013
4014 /* The following definitions come from smbd/conn.c  */
4015
4016 void conn_init(struct smbd_server_connection *sconn);
4017 int conn_num_open(struct smbd_server_connection *sconn);
4018 bool conn_snum_used(int snum);
4019 connection_struct *conn_find(struct smbd_server_connection *sconn,
4020                              unsigned cnum);
4021 connection_struct *conn_new(struct smbd_server_connection *sconn);
4022 bool conn_close_all(struct smbd_server_connection *sconn);
4023 bool conn_idle_all(struct smbd_server_connection *sconn, time_t t);
4024 void conn_clear_vuid_caches(struct smbd_server_connection *sconn, uint16 vuid);
4025 void conn_free(connection_struct *conn);
4026 void msg_force_tdis(struct messaging_context *msg,
4027                     void *private_data,
4028                     uint32_t msg_type,
4029                     struct server_id server_id,
4030                     DATA_BLOB *data);
4031
4032 /* The following definitions come from smbd/connection.c  */
4033
4034 bool yield_connection(connection_struct *conn, const char *name);
4035 int count_current_connections( const char *sharename, bool clear  );
4036 bool claim_connection(connection_struct *conn, const char *name);
4037
4038 /* The following definitions come from smbd/dfree.c  */
4039
4040 uint64_t sys_disk_free(connection_struct *conn, const char *path, bool small_query, 
4041                               uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
4042 uint64_t get_dfree_info(connection_struct *conn,
4043                         const char *path,
4044                         bool small_query,
4045                         uint64_t *bsize,
4046                         uint64_t *dfree,
4047                         uint64_t *dsize);
4048
4049 /* The following definitions come from smbd/dir.c  */
4050
4051 bool make_dir_struct(TALLOC_CTX *ctx,
4052                         char *buf,
4053                         const char *mask,
4054                         const char *fname,
4055                         SMB_OFF_T size,
4056                         uint32 mode,
4057                         time_t date,
4058                         bool uc);
4059 bool init_dptrs(struct smbd_server_connection *sconn);
4060 char *dptr_path(struct smbd_server_connection *sconn, int key);
4061 char *dptr_wcard(struct smbd_server_connection *sconn, int key);
4062 uint16 dptr_attr(struct smbd_server_connection *sconn, int key);
4063 void dptr_close(struct smbd_server_connection *sconn, int *key);
4064 void dptr_closecnum(connection_struct *conn);
4065 void dptr_idlecnum(connection_struct *conn);
4066 void dptr_closepath(struct smbd_server_connection *sconn,
4067                     char *path,uint16 spid);
4068 NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
4069                 const char *path, bool old_handle, bool expect_close,uint16 spid,
4070                 const char *wcard, bool wcard_has_wild, uint32 attr, struct dptr_struct **dptr_ret);
4071 void dptr_CloseDir(files_struct *fsp);
4072 void dptr_SeekDir(struct dptr_struct *dptr, long offset);
4073 long dptr_TellDir(struct dptr_struct *dptr);
4074 bool dptr_has_wild(struct dptr_struct *dptr);
4075 int dptr_dnum(struct dptr_struct *dptr);
4076 char *dptr_ReadDirName(TALLOC_CTX *ctx,
4077                         struct dptr_struct *dptr,
4078                         long *poffset,
4079                         SMB_STRUCT_STAT *pst);
4080 bool dptr_SearchDir(struct dptr_struct *dptr, const char *name, long *poffset, SMB_STRUCT_STAT *pst);
4081 void dptr_DirCacheAdd(struct dptr_struct *dptr, const char *name, long offset);
4082 void dptr_init_search_op(struct dptr_struct *dptr);
4083 bool dptr_fill(struct smbd_server_connection *sconn,
4084                char *buf1,unsigned int key);
4085 struct dptr_struct *dptr_fetch(struct smbd_server_connection *sconn,
4086                                char *buf,int *num);
4087 struct dptr_struct *dptr_fetch_lanman2(struct smbd_server_connection *sconn,
4088                                        int dptr_num);
4089 bool dir_check_ftype(connection_struct *conn, uint32 mode, uint32 dirtype);
4090 bool get_dir_entry(TALLOC_CTX *ctx,
4091                 struct dptr_struct *dirptr,
4092                 const char *mask,
4093                 uint32 dirtype,
4094                 char **pp_fname_out,
4095                 SMB_OFF_T *size,
4096                 uint32 *mode,
4097                 struct timespec *date,
4098                 bool check_descend,
4099                 bool ask_sharemode);
4100 bool is_visible_file(connection_struct *conn, const char *dir_path, const char *name, SMB_STRUCT_STAT *pst, bool use_veto);
4101 struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn,
4102                         const char *name, const char *mask, uint32 attr);
4103 const char *ReadDirName(struct smb_Dir *dirp, long *poffset,
4104                         SMB_STRUCT_STAT *sbuf, char **talloced);
4105 void RewindDir(struct smb_Dir *dirp, long *poffset);
4106 void SeekDir(struct smb_Dir *dirp, long offset);
4107 long TellDir(struct smb_Dir *dirp);
4108 void DirCacheAdd(struct smb_Dir *dirp, const char *name, long offset);
4109 bool SearchDir(struct smb_Dir *dirp, const char *name, long *poffset);
4110 NTSTATUS can_delete_directory(struct connection_struct *conn,
4111                                 const char *dirname);
4112
4113 /* The following definitions come from smbd/dmapi.c  */
4114
4115 const void *dmapi_get_current_session(void);
4116 bool dmapi_have_session(void);
4117 bool dmapi_new_session(void);
4118 bool dmapi_destroy_session(void);
4119 uint32 dmapi_file_flags(const char * const path);
4120
4121 /* The following definitions come from smbd/dnsregister.c  */
4122
4123 bool smbd_setup_mdns_registration(struct tevent_context *ev,
4124                                   TALLOC_CTX *mem_ctx,
4125                                   uint16_t port);
4126
4127 /* The following definitions come from smbd/dosmode.c  */
4128
4129 mode_t unix_mode(connection_struct *conn, int dosmode,
4130                  const struct smb_filename *smb_fname,
4131                  const char *inherit_from_dir);
4132 uint32 dos_mode_msdfs(connection_struct *conn,
4133                       const struct smb_filename *smb_fname);
4134 int dos_attributes_to_stat_dos_flags(uint32_t dosmode);
4135 uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname);
4136 int file_set_dosmode(connection_struct *conn, struct smb_filename *smb_fname,
4137                      uint32 dosmode, const char *parent_dir, bool newfile);
4138 NTSTATUS file_set_sparse(connection_struct *conn,
4139                          struct files_struct *fsp,
4140                          bool sparse);
4141 int file_ntimes(connection_struct *conn, const struct smb_filename *smb_fname,
4142                 struct smb_file_time *ft);
4143 bool set_sticky_write_time_path(struct file_id fileid, struct timespec mtime);
4144 bool set_sticky_write_time_fsp(struct files_struct *fsp,
4145                                struct timespec mtime);
4146
4147 NTSTATUS set_create_timespec_ea(connection_struct *conn,
4148                                 const struct smb_filename *smb_fname,
4149                                 struct timespec create_time);
4150
4151 struct timespec get_create_timespec(connection_struct *conn,
4152                                 struct files_struct *fsp,
4153                                 const struct smb_filename *smb_fname);
4154
4155 struct timespec get_change_timespec(connection_struct *conn,
4156                                 struct files_struct *fsp,
4157                                 const struct smb_filename *smb_fname);
4158
4159 /* The following definitions come from smbd/error.c  */
4160
4161 bool use_nt_status(void);
4162 void error_packet_set(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file);
4163 int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file);
4164 void reply_nt_error(struct smb_request *req, NTSTATUS ntstatus,
4165                     int line, const char *file);
4166 void reply_force_dos_error(struct smb_request *req, uint8 eclass, uint32 ecode,
4167                     int line, const char *file);
4168 void reply_both_error(struct smb_request *req, uint8 eclass, uint32 ecode,
4169                       NTSTATUS status, int line, const char *file);
4170 void reply_openerror(struct smb_request *req, NTSTATUS status);
4171
4172 /* The following definitions come from smbd/file_access.c  */
4173
4174 bool can_access_file_acl(struct connection_struct *conn,
4175                          const struct smb_filename *smb_fname,
4176                          uint32_t access_mask);
4177 bool can_delete_file_in_directory(connection_struct *conn,
4178                                   struct smb_filename *smb_fname);
4179 bool can_access_file_data(connection_struct *conn,
4180                           const struct smb_filename *smb_fname,
4181                           uint32 access_mask);
4182 bool can_write_to_file(connection_struct *conn,
4183                        const struct smb_filename *smb_fname);
4184 bool directory_has_default_acl(connection_struct *conn, const char *fname);
4185
4186 /* The following definitions come from smbd/fileio.c  */
4187
4188 ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n);
4189 void update_write_time_handler(struct event_context *ctx,
4190                                       struct timed_event *te,
4191                                       struct timeval now,
4192                                       void *private_data);
4193 void trigger_write_time_update(struct files_struct *fsp);
4194 void trigger_write_time_update_immediate(struct files_struct *fsp);
4195 ssize_t write_file(struct smb_request *req,
4196                         files_struct *fsp,
4197                         const char *data,
4198                         SMB_OFF_T pos,
4199                         size_t n);
4200 void delete_write_cache(files_struct *fsp);
4201 void set_filelen_write_cache(files_struct *fsp, SMB_OFF_T file_size);
4202 ssize_t flush_write_cache(files_struct *fsp, enum flush_reason_enum reason);
4203 NTSTATUS sync_file(connection_struct *conn, files_struct *fsp, bool write_through);
4204 int fsp_stat(files_struct *fsp);
4205
4206 /* The following definitions come from smbd/filename.c  */
4207
4208 NTSTATUS unix_convert(TALLOC_CTX *ctx,
4209                       connection_struct *conn,
4210                       const char *orig_path,
4211                       struct smb_filename **smb_fname,
4212                       uint32_t ucf_flags);
4213 NTSTATUS check_name(connection_struct *conn, const char *name);
4214 int get_real_filename(connection_struct *conn, const char *path,
4215                       const char *name, TALLOC_CTX *mem_ctx,
4216                       char **found_name);
4217 NTSTATUS filename_convert(TALLOC_CTX *mem_ctx,
4218                         connection_struct *conn,
4219                         bool dfs_path,
4220                         const char *name_in,
4221                         uint32_t ucf_flags,
4222                         bool *ppath_contains_wcard,
4223                         struct smb_filename **pp_smb_fname);
4224
4225 /* The following definitions come from smbd/filename_utils.c */
4226
4227 NTSTATUS get_full_smb_filename(TALLOC_CTX *ctx, const struct smb_filename *smb_fname,
4228                               char **full_name);
4229 NTSTATUS create_synthetic_smb_fname(TALLOC_CTX *ctx, const char *base_name,
4230                                     const char *stream_name,
4231                                     const SMB_STRUCT_STAT *psbuf,
4232                                     struct smb_filename **smb_fname_out);
4233 NTSTATUS create_synthetic_smb_fname_split(TALLOC_CTX *ctx,
4234                                           const char *fname,
4235                                           const SMB_STRUCT_STAT *psbuf,
4236                                           struct smb_filename **smb_fname_out);
4237 const char *smb_fname_str_dbg(const struct smb_filename *smb_fname);
4238 const char *fsp_str_dbg(const struct files_struct *fsp);
4239 NTSTATUS copy_smb_filename(TALLOC_CTX *ctx,
4240                            const struct smb_filename *smb_fname_in,
4241                            struct smb_filename **smb_fname_out);
4242 bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname);
4243 bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
4244
4245 /* The following definitions come from smbd/files.c  */
4246
4247 NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
4248                   files_struct **result);
4249 void file_close_conn(connection_struct *conn);
4250 void file_close_pid(struct smbd_server_connection *sconn, uint16 smbpid,
4251                     int vuid);
4252 bool file_init(struct smbd_server_connection *sconn);
4253 void file_close_user(struct smbd_server_connection *sconn, int vuid);
4254 struct files_struct *files_forall(
4255         struct smbd_server_connection *sconn,
4256         struct files_struct *(*fn)(struct files_struct *fsp,
4257                                    void *private_data),
4258         void *private_data);
4259 files_struct *file_find_fd(struct smbd_server_connection *sconn, int fd);
4260 files_struct *file_find_dif(struct smbd_server_connection *sconn,
4261                             struct file_id id, unsigned long gen_id);
4262 files_struct *file_find_di_first(struct smbd_server_connection *sconn,
4263                                  struct file_id id);
4264 files_struct *file_find_di_next(files_struct *start_fsp);
4265 bool file_find_subpath(files_struct *dir_fsp);
4266 void file_sync_all(connection_struct *conn);
4267 void file_free(struct smb_request *req, files_struct *fsp);
4268 files_struct *file_fsp(struct smb_request *req, uint16 fid);
4269 NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *from,
4270                       uint32 access_mask, uint32 share_access,
4271                       uint32 create_options, files_struct *to);
4272 NTSTATUS file_name_hash(connection_struct *conn,
4273                         const char *name, uint32_t *p_name_hash);
4274 NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
4275                            const struct smb_filename *smb_fname_in);
4276
4277 /* The following definitions come from smbd/ipc.c  */
4278
4279 void send_trans_reply(connection_struct *conn,
4280                       struct smb_request *req,
4281                       char *rparam, int rparam_len,
4282                       char *rdata, int rdata_len,
4283                       bool buffer_too_large);
4284 void reply_trans(struct smb_request *req);
4285 void reply_transs(struct smb_request *req);
4286
4287 /* The following definitions come from smbd/lanman.c  */
4288
4289 void api_reply(connection_struct *conn, uint16 vuid,
4290                struct smb_request *req,
4291                char *data, char *params,
4292                int tdscnt, int tpscnt,
4293                int mdrcnt, int mprcnt);
4294
4295 /* The following definitions come from smbd/mangle.c  */
4296
4297 void mangle_reset_cache(void);
4298 void mangle_change_to_posix(void);
4299 bool mangle_is_mangled(const char *s, const struct share_params *p);
4300 bool mangle_is_8_3(const char *fname, bool check_case,
4301                    const struct share_params *p);
4302 bool mangle_is_8_3_wildcards(const char *fname, bool check_case,
4303                              const struct share_params *p);
4304 bool mangle_must_mangle(const char *fname,
4305                    const struct share_params *p);
4306 bool mangle_lookup_name_from_8_3(TALLOC_CTX *ctx,
4307                         const char *in,
4308                         char **out, /* talloced on the given context. */
4309                         const struct share_params *p);
4310 bool name_to_8_3(const char *in,
4311                 char out[13],
4312                 bool cache83,
4313                 const struct share_params *p);
4314
4315 /* The following definitions come from smbd/mangle_hash.c  */
4316
4317 const struct mangle_fns *mangle_hash_init(void);
4318
4319 /* The following definitions come from smbd/mangle_hash2.c  */
4320
4321 const struct mangle_fns *mangle_hash2_init(void);
4322 const struct mangle_fns *posix_mangle_init(void);
4323
4324 /* The following definitions come from auth/user_util.c  */
4325
4326 bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out);
4327
4328 /* The following definitions come from auth/user_krb5.c  */
4329 struct PAC_LOGON_INFO;
4330 NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
4331                                      const char *cli_name,
4332                                      const char *princ_name,
4333                                      struct PAC_LOGON_INFO *logon_info,
4334                                      bool *is_mapped,
4335                                      bool *mapped_to_guest,
4336                                      char **ntuser,
4337                                      char **ntdomain,
4338                                      char **username,
4339                                      struct passwd **_pw);
4340 NTSTATUS make_server_info_krb5(TALLOC_CTX *mem_ctx,
4341                                 char *ntuser,
4342                                 char *ntdomain,
4343                                 char *username,
4344                                 struct passwd *pw,
4345                                 struct PAC_LOGON_INFO *logon_info,
4346                                 bool mapped_to_guest,
4347                                 struct auth_serversupplied_info **server_info);
4348
4349 /* The following definitions come from smbd/message.c  */
4350
4351 void reply_sends(struct smb_request *req);
4352 void reply_sendstrt(struct smb_request *req);
4353 void reply_sendtxt(struct smb_request *req);
4354 void reply_sendend(struct smb_request *req);
4355
4356 /* The following definitions come from smbd/msdfs.c  */
4357
4358 bool is_msdfs_link(connection_struct *conn,
4359                 const char *path,
4360                 SMB_STRUCT_STAT *sbufp);
4361 struct junction_map;
4362 NTSTATUS get_referred_path(TALLOC_CTX *ctx,
4363                         const char *dfs_path,
4364                         struct junction_map *jucn,
4365                         int *consumedcntp,
4366                         bool *self_referralp);
4367 int setup_dfs_referral(connection_struct *orig_conn,
4368                         const char *dfs_path,
4369                         int max_referral_level,
4370                         char **ppdata, NTSTATUS *pstatus);
4371 bool create_junction(TALLOC_CTX *ctx,
4372                 const char *dfs_path,
4373                 struct junction_map *jucn);
4374 bool create_msdfs_link(const struct junction_map *jucn);
4375 bool remove_msdfs_link(const struct junction_map *jucn);
4376 struct junction_map *enum_msdfs_links(TALLOC_CTX *ctx, size_t *p_num_jn);
4377 NTSTATUS resolve_dfspath(TALLOC_CTX *ctx,
4378                         connection_struct *conn,
4379                         bool dfs_pathnames,
4380                         const char *name_in,
4381                         char **pp_name_out);
4382 NTSTATUS resolve_dfspath_wcard(TALLOC_CTX *ctx,
4383                                 connection_struct *conn,
4384                                 bool dfs_pathnames,
4385                                 const char *name_in,
4386                                 bool allow_wcards,
4387                                 char **pp_name_out,
4388                                 bool *ppath_contains_wcard);
4389 NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
4390                                 connection_struct **pconn,
4391                                 int snum,
4392                                 const char *path,
4393                                 const struct auth_serversupplied_info *session_info,
4394                                 char **poldcwd);
4395
4396 /* The following definitions come from smbd/negprot.c  */
4397
4398 void reply_negprot(struct smb_request *req);
4399
4400 /* The following definitions come from smbd/notify.c  */
4401
4402 void change_notify_reply(struct smb_request *req,
4403                          NTSTATUS error_code,
4404                          uint32_t max_param,
4405                          struct notify_change_buf *notify_buf,
4406                          void (*reply_fn)(struct smb_request *req,
4407                                           NTSTATUS error_code,
4408                                           uint8_t *buf, size_t len));
4409 NTSTATUS change_notify_create(struct files_struct *fsp, uint32 filter,
4410                               bool recursive);
4411 NTSTATUS change_notify_add_request(struct smb_request *req,
4412                                 uint32 max_param,
4413                                 uint32 filter, bool recursive,
4414                                 struct files_struct *fsp,
4415                                 void (*reply_fn)(struct smb_request *req,
4416                                         NTSTATUS error_code,
4417                                         uint8_t *buf, size_t len));
4418 void remove_pending_change_notify_requests_by_mid(
4419         struct smbd_server_connection *sconn, uint64_t mid);
4420 void remove_pending_change_notify_requests_by_fid(files_struct *fsp,
4421                                                   NTSTATUS status);
4422 void notify_fname(connection_struct *conn, uint32 action, uint32 filter,
4423                   const char *path);
4424 char *notify_filter_string(TALLOC_CTX *mem_ctx, uint32 filter);
4425 struct sys_notify_context *sys_notify_context_create(connection_struct *conn,
4426                                                      TALLOC_CTX *mem_ctx, 
4427                                                      struct event_context *ev);
4428 NTSTATUS sys_notify_watch(struct sys_notify_context *ctx,
4429                           struct notify_entry *e,
4430                           void (*callback)(struct sys_notify_context *ctx, 
4431                                            void *private_data,
4432                                            struct notify_event *ev),
4433                           void *private_data, void *handle);
4434
4435 /* The following definitions come from smbd/notify_inotify.c  */
4436
4437 NTSTATUS inotify_watch(struct sys_notify_context *ctx,
4438                        struct notify_entry *e,
4439                        void (*callback)(struct sys_notify_context *ctx, 
4440                                         void *private_data,
4441                                         struct notify_event *ev),
4442                        void *private_data, 
4443                        void *handle_p);
4444
4445 /* The following definitions come from smbd/notify_internal.c  */
4446
4447 struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server, 
4448                                    struct messaging_context *messaging_ctx,
4449                                    struct event_context *ev,
4450                                    connection_struct *conn);
4451 bool notify_internal_parent_init(TALLOC_CTX *mem_ctx);
4452 NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0,
4453                     void (*callback)(void *, const struct notify_event *), 
4454                     void *private_data);
4455 NTSTATUS notify_remove(struct notify_context *notify, void *private_data);
4456 NTSTATUS notify_remove_onelevel(struct notify_context *notify,
4457                                 const struct file_id *fid,
4458                                 void *private_data);
4459 void notify_onelevel(struct notify_context *notify, uint32_t action,
4460                      uint32_t filter, struct file_id fid, const char *name);
4461 void notify_trigger(struct notify_context *notify,
4462                     uint32_t action, uint32_t filter, const char *path);
4463
4464 /* The following definitions come from smbd/ntquotas.c  */
4465
4466 int vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt);
4467 int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid *psid, SMB_NTQUOTA_STRUCT *qt);
4468 int vfs_get_user_ntquota_list(files_struct *fsp, SMB_NTQUOTA_LIST **qt_list);
4469 void *init_quota_handle(TALLOC_CTX *mem_ctx);
4470
4471 /* The following definitions come from smbd/nttrans.c  */
4472
4473 void send_nt_replies(connection_struct *conn,
4474                         struct smb_request *req, NTSTATUS nt_error,
4475                      char *params, int paramsize,
4476                      char *pdata, int datasize);
4477 void reply_ntcreate_and_X(struct smb_request *req);
4478 NTSTATUS set_sd(files_struct *fsp, uint8_t *data, uint32_t sd_len,
4479                        uint32_t security_info_sent);
4480 struct ea_list *read_nttrans_ea_list(TALLOC_CTX *ctx, const char *pdata, size_t data_size);
4481 void reply_ntcancel(struct smb_request *req);
4482 void reply_ntrename(struct smb_request *req);
4483 NTSTATUS smbd_do_query_security_desc(connection_struct *conn,
4484                                         TALLOC_CTX *mem_ctx,
4485                                         files_struct *fsp,
4486                                         uint32_t security_info_wanted,
4487                                         uint32_t max_data_count,
4488                                         uint8_t **ppmarshalled_sd,
4489                                         size_t *psd_size);
4490 void reply_nttrans(struct smb_request *req);
4491 void reply_nttranss(struct smb_request *req);
4492
4493 /* The following definitions come from smbd/open.c  */
4494
4495 NTSTATUS smb1_file_se_access_check(connection_struct *conn,
4496                                 const struct security_descriptor *sd,
4497                                 const struct security_token *token,
4498                                 uint32_t access_desired,
4499                                 uint32_t *access_granted);
4500 NTSTATUS fd_close(files_struct *fsp);
4501 void change_file_owner_to_parent(connection_struct *conn,
4502                                  const char *inherit_from_dir,
4503                                  files_struct *fsp);
4504 NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
4505                                     const char *inherit_from_dir,
4506                                     const char *fname,
4507                                     SMB_STRUCT_STAT *psbuf);
4508 bool is_executable(const char *fname);
4509 bool is_stat_open(uint32 access_mask);
4510 bool request_timed_out(struct timeval request_time,
4511                        struct timeval timeout);
4512 bool open_match_attributes(connection_struct *conn,
4513                            uint32 old_dos_attr,
4514                            uint32 new_dos_attr,
4515                            mode_t existing_unx_mode,
4516                            mode_t new_unx_mode,
4517                            mode_t *returned_unx_mode);
4518 NTSTATUS fcb_or_dos_open(struct smb_request *req,
4519                          connection_struct *conn,
4520                          files_struct *fsp_to_dup_into,
4521                          const struct smb_filename *smb_fname,
4522                          struct file_id id,
4523                          uint16 file_pid,
4524                          uint16 vuid,
4525                          uint32 access_mask,
4526                          uint32 share_access,
4527                          uint32 create_options);
4528 bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,
4529                                  int deny_mode, int open_func,
4530                                  uint32 *paccess_mask,
4531                                  uint32 *pshare_mode,
4532                                  uint32 *pcreate_disposition,
4533                                  uint32 *pcreate_options,
4534                                  uint32_t *pprivate_flags);
4535 void remove_deferred_open_entry(struct file_id id, uint64_t mid,
4536                                 struct server_id pid);
4537 NTSTATUS open_file_fchmod(connection_struct *conn,
4538                           struct smb_filename *smb_fname,
4539                           files_struct **result);
4540 NTSTATUS create_directory(connection_struct *conn, struct smb_request *req,
4541                           struct smb_filename *smb_dname);
4542 void msg_file_was_renamed(struct messaging_context *msg,
4543                           void *private_data,
4544                           uint32_t msg_type,
4545                           struct server_id server_id,
4546                           DATA_BLOB *data);
4547 NTSTATUS open_streams_for_delete(connection_struct *conn,
4548                                  const char *fname);
4549 NTSTATUS create_file_default(connection_struct *conn,
4550                              struct smb_request *req,
4551                              uint16_t root_dir_fid,
4552                              struct smb_filename * smb_fname,
4553                              uint32_t access_mask,
4554                              uint32_t share_access,
4555                              uint32_t create_disposition,
4556                              uint32_t create_options,
4557                              uint32_t file_attributes,
4558                              uint32_t oplock_request,
4559                              uint64_t allocation_size,
4560                              uint32_t private_flags,
4561                              struct security_descriptor *sd,
4562                              struct ea_list *ea_list,
4563
4564                              files_struct **result,
4565                              int *pinfo);
4566 NTSTATUS get_relative_fid_filename(connection_struct *conn,
4567                                    struct smb_request *req,
4568                                    uint16_t root_dir_fid,
4569                                    const struct smb_filename *smb_fname,
4570                                    struct smb_filename **smb_fname_out);
4571
4572 /* The following definitions come from smbd/oplock.c  */
4573
4574 int32 get_number_of_exclusive_open_oplocks(void);
4575 void break_kernel_oplock(struct messaging_context *msg_ctx, files_struct *fsp);
4576 bool set_file_oplock(files_struct *fsp, int oplock_type);
4577 void release_file_oplock(files_struct *fsp);
4578 bool remove_oplock(files_struct *fsp);
4579 bool downgrade_oplock(files_struct *fsp);
4580 bool should_notify_deferred_opens(void);
4581 void break_level2_to_none_async(files_struct *fsp);
4582 void reply_to_oplock_break_requests(files_struct *fsp);
4583 void process_oplock_async_level2_break_message(struct messaging_context *msg_ctx,
4584                                                       void *private_data,
4585                                                       uint32_t msg_type,
4586                                                       struct server_id src,
4587                                                       DATA_BLOB *data);
4588 void contend_level2_oplocks_begin(files_struct *fsp,
4589                                   enum level2_contention_type type);
4590 void contend_level2_oplocks_end(files_struct *fsp,
4591                                 enum level2_contention_type type);
4592 void share_mode_entry_to_message(char *msg, const struct share_mode_entry *e);
4593 void message_to_share_mode_entry(struct share_mode_entry *e, char *msg);
4594 bool init_oplocks(struct messaging_context *msg_ctx);
4595
4596 /* The following definitions come from smbd/oplock_irix.c  */
4597
4598 struct kernel_oplocks *irix_init_kernel_oplocks(TALLOC_CTX *mem_ctx) ;
4599
4600 /* The following definitions come from smbd/oplock_linux.c  */
4601
4602 void linux_set_lease_capability(void);
4603 int linux_set_lease_sighandler(int fd);
4604 int linux_setlease(int fd, int leasetype);
4605 struct kernel_oplocks *linux_init_kernel_oplocks(TALLOC_CTX *mem_ctx) ;
4606
4607 /* The following definitions come from smbd/oplock_onefs.c  */
4608
4609 struct kernel_oplocks *onefs_init_kernel_oplocks(TALLOC_CTX *mem_ctx);
4610
4611 /* The following definitions come from smbd/password.c  */
4612
4613 user_struct *get_valid_user_struct(struct smbd_server_connection *sconn,
4614                                    uint16 vuid);
4615 bool is_partial_auth_vuid(struct smbd_server_connection *sconn, uint16 vuid);
4616 user_struct *get_partial_auth_user_struct(struct smbd_server_connection *sconn,
4617                                           uint16 vuid);
4618 void invalidate_vuid(struct smbd_server_connection *sconn, uint16 vuid);
4619 void invalidate_all_vuids(struct smbd_server_connection *sconn);
4620 int register_initial_vuid(struct smbd_server_connection *sconn);
4621 int register_homes_share(const char *username);
4622 int register_existing_vuid(struct smbd_server_connection *sconn,
4623                         uint16 vuid,
4624                         struct auth_serversupplied_info *session_info,
4625                         DATA_BLOB response_blob,
4626                         const char *smb_name);
4627 void add_session_user(struct smbd_server_connection *sconn, const char *user);
4628 void add_session_workgroup(struct smbd_server_connection *sconn,
4629                            const char *workgroup);
4630 const char *get_session_workgroup(struct smbd_server_connection *sconn);
4631 bool user_in_netgroup(TALLOC_CTX *ctx, const char *user, const char *ngname);
4632 bool user_in_list(TALLOC_CTX *ctx, const char *user,const char **list);
4633 bool authorise_login(struct smbd_server_connection *sconn,
4634                      int snum, fstring user, DATA_BLOB password,
4635                      bool *guest);
4636
4637 /* The following definitions come from smbd/pipes.c  */
4638
4639 NTSTATUS open_np_file(struct smb_request *smb_req, const char *name,
4640                       struct files_struct **pfsp);
4641 void reply_open_pipe_and_X(connection_struct *conn, struct smb_request *req);
4642 void reply_pipe_write(struct smb_request *req);
4643 void reply_pipe_write_and_X(struct smb_request *req);
4644 void reply_pipe_read_and_X(struct smb_request *req);
4645
4646 /* The following definitions come from smbd/posix_acls.c  */
4647
4648 void create_file_sids(const SMB_STRUCT_STAT *psbuf, struct dom_sid *powner_sid, struct dom_sid *pgroup_sid);
4649 bool nt4_compatible_acls(void);
4650 uint32_t map_canon_ace_perms(int snum,
4651                                 enum security_ace_type *pacl_type,
4652                                 mode_t perms,
4653                                 bool directory_ace);
4654 NTSTATUS unpack_nt_owners(connection_struct *conn, uid_t *puser, gid_t *pgrp, uint32 security_info_sent, const struct security_descriptor *psd);
4655 SMB_ACL_T free_empty_sys_acl(connection_struct *conn, SMB_ACL_T the_acl);
4656 NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
4657                            struct security_descriptor **ppdesc);
4658 NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
4659                           uint32_t security_info, struct security_descriptor **ppdesc);
4660 NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid);
4661 NTSTATUS append_parent_acl(files_struct *fsp,
4662                                 const struct security_descriptor *pcsd,
4663                                 struct security_descriptor **pp_new_sd);
4664 NTSTATUS set_nt_acl(files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd);
4665 int get_acl_group_bits( connection_struct *conn, const char *fname, mode_t *mode );
4666 int chmod_acl(connection_struct *conn, const char *name, mode_t mode);
4667 int inherit_access_posix_acl(connection_struct *conn, const char *inherit_from_dir,
4668                        const char *name, mode_t mode);
4669 int fchmod_acl(files_struct *fsp, mode_t mode);
4670 bool set_unix_posix_default_acl(connection_struct *conn, const char *fname,
4671                                 const SMB_STRUCT_STAT *psbuf,
4672                                 uint16 num_def_acls, const char *pdata);
4673 bool set_unix_posix_acl(connection_struct *conn, files_struct *fsp, const char *fname, uint16 num_acls, const char *pdata);
4674 struct security_descriptor *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fname);
4675 NTSTATUS make_default_filesystem_acl(TALLOC_CTX *ctx,
4676                                         const char *name,
4677                                         SMB_STRUCT_STAT *psbuf,
4678                                         struct security_descriptor **ppdesc);
4679
4680 /* The following definitions come from smbd/process.c  */
4681
4682 void smbd_setup_sig_term_handler(void);
4683 void smbd_setup_sig_hup_handler(struct tevent_context *ev,
4684                                 struct messaging_context *msg_ctx);
4685 bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
4686                   bool no_signing, uint32_t seqnum,
4687                   bool do_encrypt,
4688                   struct smb_perfcount_data *pcd);
4689 int srv_set_message(char *buf,
4690                         int num_words,
4691                         int num_bytes,
4692                         bool zero);
4693 void remove_deferred_open_message_smb(uint64_t mid);
4694 void schedule_deferred_open_message_smb(uint64_t mid);
4695 bool open_was_deferred(uint64_t mid);
4696 bool get_deferred_open_message_state(struct smb_request *smbreq,
4697                                 struct timeval *p_request_time,
4698                                 void **pp_state);
4699 bool push_deferred_open_message_smb(struct smb_request *req,
4700                                 struct timeval request_time,
4701                                 struct timeval timeout,
4702                                 struct file_id id,
4703                                 char *private_data,
4704                                 size_t priv_len);
4705 struct idle_event *event_add_idle(struct event_context *event_ctx,
4706                                   TALLOC_CTX *mem_ctx,
4707                                   struct timeval interval,
4708                                   const char *name,
4709                                   bool (*handler)(const struct timeval *now,
4710                                                   void *private_data),
4711                                   void *private_data);
4712 NTSTATUS allow_new_trans(struct trans_state *list, uint64_t mid);
4713 void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes);
4714 const char *smb_fn_name(int type);
4715 void add_to_common_flags2(uint32 v);
4716 void remove_from_common_flags2(uint32 v);
4717 void construct_reply_common_req(struct smb_request *req, char *outbuf);
4718 size_t req_wct_ofs(struct smb_request *req);
4719 void chain_reply(struct smb_request *req);
4720 bool req_is_in_chain(struct smb_request *req);
4721 void smbd_process(struct smbd_server_connection *sconn);
4722
4723 /* The following definitions come from smbd/quotas.c  */
4724
4725 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
4726 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
4727 bool disk_quotas(const char *path,
4728                 uint64_t *bsize,
4729                 uint64_t *dfree,
4730                 uint64_t *dsize);
4731 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
4732 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
4733 bool disk_quotas(const char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
4734 bool disk_quotas_vxfs(const char *name, char *path, uint64_t *bsize, uint64_t *dfree, uint64_t *dsize);
4735 bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
4736 bool disk_quotas(const char *path,uint64_t *bsize,uint64_t *dfree,uint64_t *dsize);
4737
4738 /* The following definitions come from smbd/reply.c  */
4739
4740 NTSTATUS check_path_syntax(char *path);
4741 NTSTATUS check_path_syntax_wcard(char *path, bool *p_contains_wcard);
4742 NTSTATUS check_path_syntax_posix(char *path);
4743 size_t srvstr_get_path_wcard(TALLOC_CTX *ctx,
4744                         const char *inbuf,
4745                         uint16 smb_flags2,
4746                         char **pp_dest,
4747                         const char *src,
4748                         size_t src_len,
4749                         int flags,
4750                         NTSTATUS *err,
4751                         bool *contains_wcard);
4752 size_t srvstr_get_path(TALLOC_CTX *ctx,
4753                         const char *inbuf,
4754                         uint16 smb_flags2,
4755                         char **pp_dest,
4756                         const char *src,
4757                         size_t src_len,
4758                         int flags,
4759                         NTSTATUS *err);
4760 size_t srvstr_get_path_req_wcard(TALLOC_CTX *mem_ctx, struct smb_request *req,
4761                                  char **pp_dest, const char *src, int flags,
4762                                  NTSTATUS *err, bool *contains_wcard);
4763 size_t srvstr_get_path_req(TALLOC_CTX *mem_ctx, struct smb_request *req,
4764                            char **pp_dest, const char *src, int flags,
4765                            NTSTATUS *err);
4766 bool check_fsp_open(connection_struct *conn, struct smb_request *req,
4767                     files_struct *fsp);
4768 bool check_fsp(connection_struct *conn, struct smb_request *req,
4769                files_struct *fsp);
4770 bool check_fsp_ntquota_handle(connection_struct *conn, struct smb_request *req,
4771                               files_struct *fsp);
4772 void reply_special(struct smbd_server_connection *sconn, char *inbuf, size_t inbuf_len);
4773 void reply_tcon(struct smb_request *req);
4774 void reply_tcon_and_X(struct smb_request *req);
4775 void reply_unknown_new(struct smb_request *req, uint8 type);
4776 void reply_ioctl(struct smb_request *req);
4777 void reply_checkpath(struct smb_request *req);
4778 void reply_getatr(struct smb_request *req);
4779 void reply_setatr(struct smb_request *req);
4780 void reply_dskattr(struct smb_request *req);
4781 void reply_search(struct smb_request *req);
4782 void reply_fclose(struct smb_request *req);
4783 void reply_open(struct smb_request *req);
4784 void reply_open_and_X(struct smb_request *req);
4785 void reply_ulogoffX(struct smb_request *req);
4786 void reply_mknew(struct smb_request *req);
4787 void reply_ctemp(struct smb_request *req);
4788 NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req,
4789                           uint32 dirtype, struct smb_filename *smb_fname,
4790                           bool has_wild);
4791 void reply_unlink(struct smb_request *req);
4792 ssize_t fake_sendfile(files_struct *fsp, SMB_OFF_T startpos, size_t nread);
4793 void sendfile_short_send(files_struct *fsp,
4794                                 ssize_t nread,
4795                                 size_t headersize,
4796                                 size_t smb_maxcnt);
4797 void reply_readbraw(struct smb_request *req);
4798 void reply_lockread(struct smb_request *req);
4799 void reply_read(struct smb_request *req);
4800 void reply_read_and_X(struct smb_request *req);
4801 void error_to_writebrawerr(struct smb_request *req);
4802 void reply_writebraw(struct smb_request *req);
4803 void reply_writeunlock(struct smb_request *req);
4804 void reply_write(struct smb_request *req);
4805 bool is_valid_writeX_buffer(struct smbd_server_connection *sconn,
4806                             const uint8_t *inbuf);
4807 void reply_write_and_X(struct smb_request *req);
4808 void reply_lseek(struct smb_request *req);
4809 void reply_flush(struct smb_request *req);
4810 void reply_exit(struct smb_request *req);
4811 void reply_close(struct smb_request *req);
4812 void reply_writeclose(struct smb_request *req);
4813 void reply_lock(struct smb_request *req);
4814 void reply_unlock(struct smb_request *req);
4815 void reply_tdis(struct smb_request *req);
4816 void reply_echo(struct smb_request *req);
4817 void reply_printopen(struct smb_request *req);
4818 void reply_printclose(struct smb_request *req);
4819 void reply_printqueue(struct smb_request *req);
4820 void reply_printwrite(struct smb_request *req);
4821 void reply_mkdir(struct smb_request *req);
4822 void reply_rmdir(struct smb_request *req);
4823 NTSTATUS rename_internals_fsp(connection_struct *conn,
4824                         files_struct *fsp,
4825                         const struct smb_filename *smb_fname_dst_in,
4826                         uint32 attrs,
4827                         bool replace_if_exists);
4828 NTSTATUS rename_internals(TALLOC_CTX *ctx,
4829                         connection_struct *conn,
4830                         struct smb_request *req,
4831                         struct smb_filename *smb_fname_src,
4832                         struct smb_filename *smb_fname_dst,
4833                         uint32 attrs,
4834                         bool replace_if_exists,
4835                         bool src_has_wild,
4836                         bool dest_has_wild,
4837                         uint32_t access_mask);
4838 void reply_mv(struct smb_request *req);
4839 NTSTATUS copy_file(TALLOC_CTX *ctx,
4840                         connection_struct *conn,
4841                         struct smb_filename *smb_fname_src,
4842                         struct smb_filename *smb_fname_dst,
4843                         int ofun,
4844                         int count,
4845                         bool target_is_directory);
4846 void reply_copy(struct smb_request *req);
4847 uint64_t get_lock_pid(const uint8_t *data, int data_offset,
4848                     bool large_file_format);
4849 uint64_t get_lock_count(const uint8_t *data, int data_offset,
4850                         bool large_file_format);
4851 uint64_t get_lock_offset(const uint8_t *data, int data_offset,
4852                          bool large_file_format, bool *err);
4853 void reply_lockingX(struct smb_request *req);
4854 void reply_readbmpx(struct smb_request *req);
4855 void reply_readbs(struct smb_request *req);
4856 void reply_setattrE(struct smb_request *req);
4857 void reply_writebmpx(struct smb_request *req);
4858 void reply_writebs(struct smb_request *req);
4859 void reply_getattrE(struct smb_request *req);
4860
4861 /* The following definitions come from smbd/seal.c  */
4862
4863 uint16_t srv_enc_ctx(void);
4864 bool is_encrypted_packet(const uint8_t *inbuf);
4865 void srv_free_enc_buffer(char *buf);
4866 NTSTATUS srv_decrypt_buffer(char *buf);
4867 NTSTATUS srv_encrypt_buffer(char *buf, char **buf_out);
4868 NTSTATUS srv_request_encryption_setup(connection_struct *conn,
4869                                         unsigned char **ppdata,
4870                                         size_t *p_data_size,
4871                                         unsigned char **pparam,
4872                                         size_t *p_param_size);
4873 NTSTATUS srv_encryption_start(connection_struct *conn);
4874 void server_encryption_shutdown(void);
4875
4876 /* The following definitions come from smbd/sec_ctx.c  */
4877
4878 bool unix_token_equal(const struct security_unix_token *t1, const struct security_unix_token *t2);
4879 bool push_sec_ctx(void);
4880 void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, struct security_token *token);
4881 void set_root_sec_ctx(void);
4882 bool pop_sec_ctx(void);
4883 void init_sec_ctx(void);
4884
4885 /* The following definitions come from lib/server_contexts.c  */
4886 struct tevent_context *server_event_context(void);
4887 void server_event_context_free(void);
4888 struct messaging_context *server_messaging_context(void);
4889 void server_messaging_context_free(void);
4890
4891 /* The following definitions come from smbd/server.c  */
4892
4893 struct event_context *smbd_event_context(void);
4894 struct messaging_context *smbd_messaging_context(void);
4895 struct memcache *smbd_memcache(void);
4896 void reload_printers(struct tevent_context *ev,
4897                      struct messaging_context *msg_ctx);
4898 bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
4899                      bool test);
4900 void reload_pcap_change_notify(struct tevent_context *ev,
4901                                struct messaging_context *msg_ctx);
4902 void exit_server(const char *const explanation);
4903 void exit_server_cleanly(const char *const explanation);
4904 void exit_server_fault(void);
4905
4906 /* The following definitions come from smbd/service.c  */
4907
4908 bool set_conn_connectpath(connection_struct *conn, const char *connectpath);
4909 NTSTATUS set_conn_force_user_group(connection_struct *conn, int snum);
4910 bool set_current_service(connection_struct *conn, uint16 flags, bool do_chdir);
4911 void load_registry_shares(void);
4912 int add_home_service(const char *service, const char *username, const char *homedir);
4913 int find_service(TALLOC_CTX *ctx, const char *service, char **p_service_out);
4914 connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
4915                                         int snum, user_struct *vuser,
4916                                         DATA_BLOB password,
4917                                         const char *pdev,
4918                                         NTSTATUS *pstatus);
4919 connection_struct *make_connection(struct smbd_server_connection *sconn,
4920                                    const char *service_in, DATA_BLOB password,
4921                                    const char *pdev, uint16 vuid,
4922                                    NTSTATUS *status);
4923 void close_cnum(connection_struct *conn, uint16 vuid);
4924
4925 /* The following definitions come from smbd/session.c  */
4926 struct sessionid;
4927 bool session_init(void);
4928 bool session_claim(struct smbd_server_connection *sconn, user_struct *vuser);
4929 void session_yield(user_struct *vuser);
4930 int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list);
4931
4932 /* The following definitions come from lib/sessionid_tdb.c  */
4933
4934 bool sessionid_init(void);
4935 struct db_record *sessionid_fetch_record(TALLOC_CTX *mem_ctx, const char *key);
4936 int sessionid_traverse(int (*fn)(struct db_record *rec, const char *key,
4937                                  struct sessionid *session,
4938                                  void *private_data),
4939                        void *private_data);
4940 int sessionid_traverse_read(int (*fn)(const char *key,
4941                                       struct sessionid *session,
4942                                       void *private_data),
4943                             void *private_data);
4944
4945 /* The following definitions come from smbd/sesssetup.c  */
4946
4947 NTSTATUS do_map_to_guest(NTSTATUS status,
4948                 struct auth_serversupplied_info **session_info,
4949                 const char *user, const char *domain);
4950
4951 NTSTATUS parse_spnego_mechanisms(TALLOC_CTX *ctx,
4952                 DATA_BLOB blob_in,
4953                 DATA_BLOB *pblob_out,
4954                 char **kerb_mechOID);
4955 void reply_sesssetup_and_X(struct smb_request *req);
4956
4957 /* The following definitions come from smbd/share_access.c  */
4958
4959 bool token_contains_name_in_list(const char *username,
4960                                  const char *domain,
4961                                  const char *sharename,
4962                                  const struct security_token *token,
4963                                  const char **list);
4964 bool user_ok_token(const char *username, const char *domain,
4965                    const struct security_token *token, int snum);
4966 bool is_share_read_only_for_token(const char *username,
4967                                   const char *domain,
4968                                   const struct security_token *token,
4969                                   connection_struct *conn);
4970
4971 /* The following definitions come from smbd/srvstr.c  */
4972
4973 size_t srvstr_push_fn(const char *base_ptr, uint16 smb_flags2, void *dest,
4974                       const char *src, int dest_len, int flags);
4975 ssize_t message_push_string(uint8 **outbuf, const char *str, int flags);
4976
4977 /* The following definitions come from smbd/statcache.c  */
4978
4979 void stat_cache_add( const char *full_orig_name,
4980                 char *translated_path,
4981                 bool case_sensitive);
4982 bool stat_cache_lookup(connection_struct *conn,
4983                         char **pp_name,
4984                         char **pp_dirpath,
4985                         char **pp_start,
4986                         SMB_STRUCT_STAT *pst);
4987 void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
4988                                     const char *name);
4989 void stat_cache_delete(const char *name);
4990 unsigned int fast_string_hash(TDB_DATA *key);
4991 bool reset_stat_cache( void );
4992
4993 /* The following definitions come from smbd/statvfs.c  */
4994
4995 int sys_statvfs(const char *path, vfs_statvfs_struct *statbuf);
4996
4997 /* The following definitions come from smbd/trans2.c  */
4998
4999 uint64_t smb_roundup(connection_struct *conn, uint64_t val);
5000 uint64_t get_FileIndex(connection_struct *conn, const SMB_STRUCT_STAT *psbuf);
5001 NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
5002                       files_struct *fsp, const char *fname,
5003                       const char *ea_name, struct ea_struct *pea);
5004 NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
5005                                 files_struct *fsp, const char *fname,
5006                                 char ***pnames, size_t *pnum_names);
5007 NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
5008                 const struct smb_filename *smb_fname, struct ea_list *ea_list);
5009 struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t data_size, size_t *pbytes_used);
5010 void send_trans2_replies(connection_struct *conn,
5011                         struct smb_request *req,
5012                          const char *params,
5013                          int paramsize,
5014                          const char *pdata,
5015                          int datasize,
5016                          int max_data_bytes);
5017 unsigned char *create_volume_objectid(connection_struct *conn, unsigned char objid[16]);
5018 NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
5019                 connection_struct *conn,
5020                 struct smb_request *req,
5021                 bool overwrite_if_exists,
5022                 const struct smb_filename *smb_fname_old,
5023                 struct smb_filename *smb_fname_new);
5024 NTSTATUS smb_set_file_time(connection_struct *conn,
5025                            files_struct *fsp,
5026                            const struct smb_filename *smb_fname,
5027                            struct smb_file_time *ft,
5028                            bool setting_write_time);
5029 void reply_findclose(struct smb_request *req);
5030 void reply_findnclose(struct smb_request *req);
5031 void reply_trans2(struct smb_request *req);
5032 void reply_transs2(struct smb_request *req);
5033
5034 /* The following definitions come from smbd/uid.c  */
5035
5036 bool change_to_guest(void);
5037 void conn_clear_vuid_cache(connection_struct *conn, uint16_t vuid);
5038 bool change_to_user(connection_struct *conn, uint16 vuid);
5039 bool change_to_root_user(void);
5040 bool become_authenticated_pipe_user(struct pipes_struct *p);
5041 bool unbecome_authenticated_pipe_user(void);
5042 void become_root(void);
5043 void unbecome_root(void);
5044 bool become_user(connection_struct *conn, uint16 vuid);
5045 bool unbecome_user(void);
5046 uid_t get_current_uid(connection_struct *conn);
5047 gid_t get_current_gid(connection_struct *conn);
5048 const struct security_unix_token *get_current_utok(connection_struct *conn);
5049 const struct security_token *get_current_nttok(connection_struct *conn);
5050 uint16_t get_current_vuid(connection_struct *conn);
5051
5052 /* The following definitions come from smbd/utmp.c  */
5053
5054 void sys_utmp_claim(const char *username, const char *hostname,
5055                         const char *ip_addr_str,
5056                         const char *id_str, int id_num);
5057 void sys_utmp_yield(const char *username, const char *hostname,
5058                         const char *ip_addr_str,
5059                         const char *id_str, int id_num);
5060 void sys_utmp_yield(const char *username, const char *hostname,
5061                         const char *ip_addr_str,
5062                         const char *id_str, int id_num);
5063 void sys_utmp_claim(const char *username, const char *hostname,
5064                         const char *ip_addr_str,
5065                         const char *id_str, int id_num);
5066
5067 /* The following definitions come from smbd/vfs.c  */
5068
5069 NTSTATUS smb_register_vfs(int version, const char *name,
5070                           const struct vfs_fn_pointers *fns);
5071 bool vfs_init_custom(connection_struct *conn, const char *vfs_object);
5072 void *vfs_add_fsp_extension_notype(vfs_handle_struct *handle,
5073                                    files_struct *fsp, size_t ext_size,
5074                                    void (*destroy_fn)(void *p_data));
5075 void vfs_remove_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
5076 void *vfs_memctx_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
5077 void *vfs_fetch_fsp_extension(vfs_handle_struct *handle, files_struct *fsp);
5078 bool smbd_vfs_init(connection_struct *conn);
5079 NTSTATUS vfs_file_exist(connection_struct *conn, struct smb_filename *smb_fname);
5080 ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count);
5081 ssize_t vfs_pread_data(files_struct *fsp, char *buf,
5082                 size_t byte_count, SMB_OFF_T offset);
5083 ssize_t vfs_write_data(struct smb_request *req,
5084                         files_struct *fsp,
5085                         const char *buffer,
5086                         size_t N);
5087 ssize_t vfs_pwrite_data(struct smb_request *req,
5088                         files_struct *fsp,
5089                         const char *buffer,
5090                         size_t N,
5091                         SMB_OFF_T offset);
5092 int vfs_allocate_file_space(files_struct *fsp, uint64_t len);
5093 int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len);
5094 int vfs_slow_fallocate(files_struct *fsp, SMB_OFF_T offset, SMB_OFF_T len);
5095 int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len);
5096 SMB_OFF_T vfs_transfer_file(files_struct *in, files_struct *out, SMB_OFF_T n);
5097 const char *vfs_readdirname(connection_struct *conn, void *p,
5098                             SMB_STRUCT_STAT *sbuf, char **talloced);
5099 int vfs_ChDir(connection_struct *conn, const char *path);
5100 char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn);
5101 NTSTATUS check_reduced_name(connection_struct *conn, const char *fname);
5102 int vfs_stat_smb_fname(struct connection_struct *conn, const char *fname,
5103                        SMB_STRUCT_STAT *psbuf);
5104 int vfs_lstat_smb_fname(struct connection_struct *conn, const char *fname,
5105                         SMB_STRUCT_STAT *psbuf);
5106 NTSTATUS vfs_stat_fsp(files_struct *fsp);
5107 NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid);
5108
5109 /* The following definitions come from utils/passwd_util.c  */
5110
5111 char *stdin_new_passwd( void);
5112 char *get_pass( const char *prompt, bool stdin_get);
5113
5114 /* The following definitions come from winbindd/nss_info.c  */
5115
5116
5117 /* The following definitions come from winbindd/nss_info_template.c  */
5118
5119 NTSTATUS nss_info_template_init( void );
5120
5121 /* The following definitions come from lib/avahi.c */
5122
5123 struct AvahiPoll *tevent_avahi_poll(TALLOC_CTX *mem_ctx,
5124                                     struct tevent_context *ev);
5125
5126 /* The following definitions come from smbd/avahi_register.c */
5127
5128 void *avahi_start_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
5129                            uint16_t port);
5130
5131 /* The following definitions come from smbd/msg_idmap.c */
5132
5133 void msg_idmap_register_msgs(struct messaging_context *ctx);
5134
5135 /* The following definitions come from lib/fncall.c */
5136
5137 struct fncall_context *fncall_context_init(TALLOC_CTX *mem_ctx,
5138                                            int max_threads);
5139 struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
5140                                struct fncall_context *ctx,
5141                                void (*fn)(void *private_data),
5142                                void *private_data);
5143 int fncall_recv(struct tevent_req *req, int *perr);
5144
5145 /* The following definitions come from libsmb/smbsock_connect.c */
5146
5147 struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
5148                                         struct tevent_context *ev,
5149                                         const struct sockaddr_storage *addr,
5150                                         uint16_t port,
5151                                         const char *called_name,
5152                                         int called_type,
5153                                         const char *calling_name,
5154                                         int calling_type);
5155 NTSTATUS smbsock_connect_recv(struct tevent_req *req, int *sock,
5156                               uint16_t *ret_port);
5157 NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port,
5158                          const char *called_name, int called_type,
5159                          const char *calling_name, int calling_type,
5160                          int *pfd, uint16_t *ret_port);
5161
5162 struct tevent_req *smbsock_any_connect_send(TALLOC_CTX *mem_ctx,
5163                                             struct tevent_context *ev,
5164                                             const struct sockaddr_storage *addrs,
5165                                             const char **called_names,
5166                                             int *called_types,
5167                                             const char **calling_names,
5168                                             int *calling_types,
5169                                             size_t num_addrs, uint16_t port);
5170 NTSTATUS smbsock_any_connect_recv(struct tevent_req *req, int *pfd,
5171                                   size_t *chosen_index, uint16_t *chosen_port);
5172 NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs,
5173                              const char **called_names,
5174                              int *called_types,
5175                              const char **calling_names,
5176                              int *calling_types,
5177                              size_t num_addrs,
5178                              uint16_t port,
5179                              int *pfd, size_t *chosen_index,
5180                              uint16_t *chosen_port);
5181
5182 /* The following definitions come from rpc_server/srv_samr_nt.c */
5183 NTSTATUS access_check_object( struct security_descriptor *psd, struct security_token *token,
5184                               enum sec_privilege needed_priv_1, enum sec_privilege needed_priv_2,
5185                               uint32 rights_mask,
5186                               uint32 des_access, uint32 *acc_granted,
5187                               const char *debug );
5188 void map_max_allowed_access(const struct security_token *nt_token,
5189                             const struct security_unix_token *unix_token,
5190                             uint32_t *pacc_requested);
5191
5192 #endif /*  _PROTO_H_  */