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