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