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