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