853d4e57e202e760437396c9fae4ab1e9b54150e
[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 #include <sys/types.h>
27 #include <regex.h>
28
29 #include "lib/util/access.h"
30
31 /* The following definitions come from lib/adt_tree.c  */
32
33 /* The following definitions come from lib/audit.c  */
34
35 const char *audit_category_str(uint32_t category);
36 const char *audit_param_str(uint32_t category);
37 const char *audit_description_str(uint32_t category);
38 bool get_audit_category_from_param(const char *param, uint32_t *audit_category);
39 const char *audit_policy_str(TALLOC_CTX *mem_ctx, uint32_t policy);
40
41 /* The following definitions come from lib/charcnv.c  */
42
43 void gfree_charcnv(void);
44 size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags);
45 size_t push_ascii_fstring(void *dest, const char *src);
46 size_t push_ascii_nstring(void *dest, const char *src);
47 size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
48 size_t pull_ascii_fstring(char *dest, const void *src);
49 size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src);
50 size_t push_string_check_fn(void *dest, const char *src,
51                             size_t dest_len, int flags);
52 size_t push_string_base(const char *base, uint16_t flags2,
53                         void *dest, const char *src,
54                         size_t dest_len, int flags);
55 size_t pull_string_talloc(TALLOC_CTX *ctx,
56                         const void *base_ptr,
57                         uint16_t smb_flags2,
58                         char **ppdest,
59                         const void *src,
60                         size_t src_len,
61                         int flags);
62 size_t dos_PutUniCode(char *dst,const char *src, size_t len, bool null_terminate);
63 int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src);
64
65 /* The following definitions come from lib/dmallocmsg.c  */
66
67 void register_dmalloc_msgs(struct messaging_context *msg_ctx);
68
69 /* The following definitions come from lib/dprintf.c  */
70
71 void display_set_stderr(void);
72
73 /* The following definitions come from lib/errmap_unix.c  */
74
75 NTSTATUS map_nt_error_from_unix(int unix_error);
76
77 /* The following definitions come from lib/file_id.c  */
78
79 struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf);
80
81 NTSTATUS vfs_at_fspcwd(TALLOC_CTX *mem_ctx,
82                        struct connection_struct *conn,
83                        struct files_struct **_fsp);
84
85 NTSTATUS vfs_fget_dos_attributes(struct files_struct *fsp,
86                                  uint32_t *dosmode);
87
88 #include "source3/lib/interface.h"
89
90 /* The following definitions come from lib/ldap_debug_handler.c  */
91
92 void init_ldap_debugging(void);
93
94 /* The following definitions come from lib/ldap_escape.c  */
95
96 char *escape_ldap_string(TALLOC_CTX *mem_ctx, const char *s);
97 char *escape_rdn_val_string_alloc(const char *s);
98
99 /* The following definitions come from lib/ms_fnmatch.c  */
100
101 int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
102                bool is_case_sensitive);
103
104 /* The following definitions come from lib/recvfile.c  */
105
106 ssize_t sys_recvfile(int fromfd,
107                         int tofd,
108                         off_t offset,
109                         size_t count);
110 ssize_t sys_recvfile(int fromfd,
111                         int tofd,
112                         off_t offset,
113                         size_t count);
114 ssize_t drain_socket(int sockfd, size_t count);
115
116 /* The following definitions come from lib/sendfile.c  */
117
118 ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset, size_t count);
119
120 /* The following definitions come from lib/server_mutex.c  */
121
122 struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
123                                      int timeout);
124
125 /* The following definitions come from lib/sharesec.c  */
126
127 NTSTATUS share_info_db_init(void);
128 struct security_descriptor *get_share_security( TALLOC_CTX *ctx, const char *servicename,
129                               size_t *psize);
130 NTSTATUS set_share_security(const char *share_name,
131                             struct security_descriptor *psd);
132 NTSTATUS delete_share_security(const char *servicename);
133 bool share_access_check(const struct security_token *token,
134                         const char *sharename,
135                         uint32_t desired_access,
136                         uint32_t *pgranted);
137 bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, struct security_descriptor **ppsd);
138
139 /* The following definitions come from lib/smbrun.c  */
140
141 int smbrun_no_sanitize(const char *cmd, int *outfd, char * const *env);
142 int smbrun(const char *cmd, int *outfd, char * const *env);
143 int smbrunsecret(const char *cmd, const char *secret);
144
145 /* The following definitions come from lib/sysquotas.c  */
146
147 int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
148 int sys_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
149
150 /* The following definitions come from lib/sysquotas_*.c  */
151
152 int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
153 int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
154
155 int sys_get_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
156 int sys_set_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
157
158 int sys_get_jfs2_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
159 int sys_set_jfs2_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
160
161 int sys_get_nfs_quota(const char *path, const char *bdev,
162                       enum SMB_QUOTA_TYPE qtype,
163                       unid_t id, SMB_DISK_QUOTA *dp);
164 int sys_set_nfs_quota(const char *path, const char *bdev,
165                       enum SMB_QUOTA_TYPE qtype,
166                       unid_t id, SMB_DISK_QUOTA *dp);
167
168 /* The following definitions come from lib/system.c  */
169
170 ssize_t sys_send(int s, const void *msg, size_t len, int flags);
171 ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
172 int sys_fcntl_ptr(int fd, int cmd, void *arg);
173 int sys_fcntl_long(int fd, int cmd, long arg);
174 int sys_fcntl_int(int fd, int cmd, int arg);
175 void update_stat_ex_mtime(struct stat_ex *dst, struct timespec write_ts);
176 void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time);
177 void update_stat_ex_from_saved_stat(struct stat_ex *dst,
178                                     const struct stat_ex *src);
179 int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf,
180              bool fake_dir_create_times);
181 int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf,
182               bool fake_dir_create_times);
183 int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
184               bool fake_dir_create_times);
185 int sys_fstatat(int fd,
186                 const char *pathname,
187                 SMB_STRUCT_STAT *sbuf,
188                 int flags,
189                 bool fake_dir_create_times);
190 int sys_posix_fallocate(int fd, off_t offset, off_t len);
191 int sys_fallocate(int fd, uint32_t mode, off_t offset, off_t len);
192 DIR *sys_fdopendir(int fd);
193 int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
194 int sys_mknodat(int dirfd, const char *path, mode_t mode, SMB_DEV_T dev);
195 char *sys_getwd(void);
196 void set_effective_capability(enum smbd_capability capability);
197 void drop_effective_capability(enum smbd_capability capability);
198 long sys_random(void);
199 void sys_srandom(unsigned int seed);
200 int getgroups_max(void);
201 int setgroups_max(void);
202 int sys_getgroups(int setlen, gid_t *gidset);
203 int sys_setgroups(gid_t UNUSED(primary_gid), int setlen, gid_t *gidset);
204 uint32_t unix_dev_major(SMB_DEV_T dev);
205 uint32_t unix_dev_minor(SMB_DEV_T dev);
206 char *sys_realpath(const char *path);
207 #if 0
208 int sys_get_number_of_cores(void);
209 #endif
210
211 bool sys_have_proc_fds(void);
212 const char *sys_proc_fd_path(int fd, char *buf, size_t bufsize);
213
214 struct stat;
215 void init_stat_ex_from_stat (struct stat_ex *dst,
216                             const struct stat *src,
217                             bool fake_dir_create_times);
218
219 /* The following definitions come from lib/system_smbd.c  */
220
221 bool getgroups_unix_user(TALLOC_CTX *mem_ctx, const char *user,
222                          gid_t primary_gid,
223                          gid_t **ret_groups, uint32_t *p_ngroups);
224
225 /* The following definitions come from lib/tallocmsg.c  */
226
227 void register_msg_pool_usage(TALLOC_CTX *mem_ctx,
228                              struct messaging_context *msg_ctx);
229
230 /* The following definitions come from lib/time.c  */
231
232 void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset);
233 void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
234 void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
235 uint32_t convert_time_t_to_uint32_t(time_t t);
236 time_t convert_uint32_t_to_time_t(uint32_t u);
237 bool nt_time_is_zero(const NTTIME *nt);
238 time_t generalized_to_unix_time(const char *str);
239 int get_server_zone_offset(void);
240 int set_server_zone_offset(time_t t);
241 char *timeval_string(TALLOC_CTX *ctx, const struct timeval *tp, bool hires);
242 char *current_timestring(TALLOC_CTX *ctx, bool hires);
243 void srv_put_dos_date(char *buf,int offset,time_t unixdate);
244 void srv_put_dos_date2(char *buf,int offset, time_t unixdate);
245 void srv_put_dos_date3(char *buf,int offset,time_t unixdate);
246 void round_timespec(enum timestamp_set_resolution res, struct timespec *ts);
247 void put_long_date_timespec(enum timestamp_set_resolution res, char *p, struct timespec ts);
248 void put_long_date_full_timespec(enum timestamp_set_resolution res,
249                                  char *p,
250                                  const struct timespec *ts);
251 struct timespec pull_long_date_full_timespec(const char *p);
252 void put_long_date(char *p, time_t t);
253 void dos_filetime_timespec(struct timespec *tsp);
254 time_t make_unix_date(const void *date_ptr, int zone_offset);
255 time_t make_unix_date2(const void *date_ptr, int zone_offset);
256 time_t make_unix_date3(const void *date_ptr, int zone_offset);
257 time_t srv_make_unix_date(const void *date_ptr);
258 time_t srv_make_unix_date2(const void *date_ptr);
259 time_t srv_make_unix_date3(const void *date_ptr);
260 struct timespec interpret_long_date(const char *p);
261 void TimeInit(void);
262 void get_process_uptime(struct timeval *ret_time);
263 void get_startup_time(struct timeval *ret_time);
264 time_t nt_time_to_unix_abs(const NTTIME *nt);
265 void unix_to_nt_time_abs(NTTIME *nt, time_t t);
266 const char *time_to_asc(const time_t t);
267 const char *display_time(NTTIME nttime);
268 bool nt_time_is_set(const NTTIME *nt);
269
270 /* The following definitions come from lib/username.c  */
271
272 void flush_pwnam_cache(void);
273 char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
274 struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
275
276 /* The following definitions come from lib/util_names.c  */
277 const char *get_global_sam_name(void);
278 const char *my_sam_name(void);
279 bool is_allowed_domain(const char *domain_name);
280
281 /* The following definitions come from lib/util.c  */
282
283 enum protocol_types get_Protocol(void);
284 void set_Protocol(enum protocol_types  p);
285 void gfree_all( void );
286 bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
287                      bool fake_dir_create_times);
288 bool socket_exist(const char *fname);
289 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
290 bool check_same_dev_ino(const SMB_STRUCT_STAT *sbuf1,
291                         const SMB_STRUCT_STAT *sbuf2);
292 bool check_same_stat(const SMB_STRUCT_STAT *sbuf1,
293                         const SMB_STRUCT_STAT *sbuf2);
294 void show_msg(const char *buf);
295 int set_message_bcc(char *buf,int num_bytes);
296 ssize_t message_push_blob(uint8_t **outbuf, DATA_BLOB blob);
297 char *unix_clean_name(TALLOC_CTX *ctx, const char *s);
298 char *clean_name(TALLOC_CTX *ctx, const char *s);
299 ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, off_t pos);
300 NTSTATUS init_before_fork(void);
301 int parent_watch_fd(void);
302 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
303                            struct tevent_context *ev_ctx,
304                            bool parent_longlived);
305 NTSTATUS smbd_reinit_after_fork(struct messaging_context *msg_ctx,
306                                 struct tevent_context *ev_ctx,
307                                 bool parent_longlived);
308 void *malloc_(size_t size);
309 void *Realloc(void *p, size_t size, bool free_old_on_error);
310 void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
311                         void *element, void *_array, uint32_t *num_elements,
312                         ssize_t *array_size);
313 char *get_myname(TALLOC_CTX *ctx);
314 char *get_mydnsdomname(TALLOC_CTX *ctx);
315 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
316 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
317 bool process_exists(const struct server_id pid);
318 const char *uidtoname(uid_t uid);
319 char *gidtoname(gid_t gid);
320 uid_t nametouid(const char *name);
321 gid_t nametogid(const char *name);
322 void smb_panic_s3(const char *why);
323 const char *readdirname(DIR *p);
324 bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensitive);
325 void set_namearray(name_compare_entry **ppname_array, const char *namelist);
326 void free_namearray(name_compare_entry *name_array);
327 bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type);
328 bool fcntl_getlock(int fd, int op, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid);
329 int map_process_lock_to_ofd_lock(int op);
330 bool is_myname(const char *s);
331 void ra_lanman_string( const char *native_lanman );
332 const char *get_remote_arch_str(void);
333 enum remote_arch_types get_remote_arch_from_str(const char *remote_arch_string);
334 void set_remote_arch(enum remote_arch_types type);
335 enum remote_arch_types get_remote_arch(void);
336 bool remote_arch_cache_update(const struct GUID *client_guid);
337 bool remote_arch_cache_delete(const struct GUID *client_guid);
338 int str_checksum(const char *s);
339 void zero_free(void *p, size_t size);
340 int set_maxfiles(int requested_max);
341 void *smb_xmalloc_array(size_t size, unsigned int count);
342 char *myhostname(void);
343 char *myhostname_upper(void);
344 #include "lib/util_path.h"
345 bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
346                     const char **name);
347 bool ms_has_wild(const char *s);
348 bool ms_has_wild_w(const smb_ucs2_t *s);
349 bool mask_match(const char *string, const char *pattern, bool is_case_sensitive);
350 bool mask_match_search(const char *string, const char *pattern, bool is_case_sensitive);
351 bool mask_match_list(const char *string, char **list, int listLen, bool is_case_sensitive);
352 #include "lib/util/unix_match.h"
353 bool name_to_fqdn(fstring fqdn, const char *name);
354
355 #include "lib/util_procid.h"
356
357 struct server_id interpret_pid(const char *pid_string);
358 bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t off);
359 char *get_safe_str_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
360 bool split_domain_user(TALLOC_CTX *mem_ctx,
361                        const char *full_name,
362                        char **domain,
363                        char **user);
364 const char *strip_hostname(const char *s);
365 bool any_nt_status_not_ok(NTSTATUS err1, NTSTATUS err2, NTSTATUS *result);
366 int timeval_to_msec(struct timeval t);
367 char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname);
368 bool is_executable(const char *fname);
369 bool map_open_params_to_ntcreate(const char *smb_base_fname,
370                                  int deny_mode, int open_func,
371                                  uint32_t *paccess_mask,
372                                  uint32_t *pshare_mode,
373                                  uint32_t *pcreate_disposition,
374                                  uint32_t *pcreate_options,
375                                  uint32_t *pprivate_flags);
376 struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct security_unix_token *tok);
377 struct security_unix_token *root_unix_token(TALLOC_CTX *mem_ctx);
378 char *utok_string(TALLOC_CTX *mem_ctx, const struct security_unix_token *tok);
379 bool dir_check_ftype(uint32_t mode, uint32_t dirtype);
380
381 /* The following definitions come from lib/util_builtin.c  */
382
383 bool lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32_t rid, const char **name);
384 bool lookup_builtin_name(const char *name, uint32_t *rid);
385 const char *builtin_domain_name(void);
386 bool sid_check_is_builtin(const struct dom_sid *sid);
387 bool sid_check_is_in_builtin(const struct dom_sid *sid);
388 bool sid_check_is_wellknown_builtin(const struct dom_sid *sid);
389
390 /* The following definitions come from lib/util_nscd.c  */
391
392 void smb_nscd_flush_user_cache(void);
393 void smb_nscd_flush_group_cache(void);
394
395 /* The following definitions come from lib/util_nttoken.c  */
396
397 NTSTATUS merge_with_system_token(TALLOC_CTX *mem_ctx,
398                                  const struct security_token *token_1,
399                                  struct security_token **token_out);
400 bool token_sid_in_ace(const struct security_token *token, const struct security_ace *ace);
401
402 /* The following definitions come from lib/util_sec.c  */
403
404 void sec_init(void);
405 uid_t sec_initial_uid(void);
406 gid_t sec_initial_gid(void);
407 bool root_mode(void);
408 bool non_root_mode(void);
409 void gain_root_privilege(void);
410 void gain_root_group_privilege(void);
411 void set_effective_uid(uid_t uid);
412 void set_effective_gid(gid_t gid);
413 void save_re_uid(void);
414 void restore_re_uid_fromroot(void);
415 void restore_re_uid(void);
416 void save_re_gid(void);
417 void restore_re_gid(void);
418 int set_re_uid(void);
419 void become_user_permanently(uid_t uid, gid_t gid);
420 int set_thread_credentials(uid_t uid,
421                         gid_t gid,
422                         size_t setlen,
423                         const gid_t *gidset);
424 bool is_setuid_root(void) ;
425
426 /* The following definitions come from lib/util_sid.c  */
427
428 char *sid_to_fstring(fstring sidstr_out, const struct dom_sid *sid);
429 bool sid_linearize(uint8_t *outbuf, size_t len, const struct dom_sid *sid);
430 bool non_mappable_sid(struct dom_sid *sid);
431 char *sid_binstring_hex_talloc(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
432 struct netr_SamInfo3;
433 NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
434                               const struct netr_SamInfo3 *info3,
435                               struct dom_sid **user_sids,
436                               uint32_t *num_user_sids,
437                               bool include_user_group_rid);
438 bool security_token_find_npa_flags(const struct security_token *token,
439                                    uint32_t *_flags);
440 void security_token_del_npa_flags(struct security_token *token);
441
442 /* The following definitions come from lib/util_sock.c  */
443
444 bool is_broadcast_addr(const struct sockaddr *pss);
445 bool is_loopback_ip_v4(struct in_addr ip);
446 bool is_loopback_addr(const struct sockaddr *pss);
447 bool is_zero_addr(const struct sockaddr_storage *pss);
448 void zero_ip_v4(struct in_addr *ip);
449 void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
450                 struct in_addr ip);
451 bool same_net(const struct sockaddr *ip1,
452                 const struct sockaddr *ip2,
453                 const struct sockaddr *mask);
454 bool sockaddr_equal(const struct sockaddr *ip1,
455                 const struct sockaddr *ip2);
456 bool is_address_any(const struct sockaddr *psa);
457 uint16_t get_sockaddr_port(const struct sockaddr_storage *pss);
458 char *print_sockaddr(char *dest,
459                         size_t destlen,
460                         const struct sockaddr_storage *psa);
461 char *print_canonical_sockaddr(TALLOC_CTX *ctx,
462                         const struct sockaddr_storage *pss);
463 bool is_a_socket(int fd);
464 void set_socket_options(int fd, const char *options);
465 NTSTATUS read_fd_with_timeout(int fd, char *buf,
466                                   size_t mincnt, size_t maxcnt,
467                                   unsigned int time_out,
468                                   size_t *size_ret);
469 NTSTATUS read_data_ntstatus(int fd, char *buffer, size_t N);
470
471 NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
472                                           unsigned int timeout,
473                                           size_t *len);
474 NTSTATUS receive_smb_raw(int fd,
475                         char *buffer,
476                         size_t buflen,
477                         unsigned int timeout,
478                         size_t maxlen,
479                         size_t *p_len);
480 int open_socket_in(
481         int type,
482         const struct sockaddr_storage *paddr,
483         uint16_t port,
484         bool rebind);
485 NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
486                          int timeout, int *pfd);
487 struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
488                                         struct tevent_context *ev,
489                                         const struct sockaddr_storage *pss,
490                                         uint16_t port,
491                                         int timeout);
492 NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd);
493 struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
494                                               struct tevent_context *ev,
495                                               struct timeval wait_time,
496                                               const struct sockaddr_storage *pss,
497                                               uint16_t port,
498                                               int timeout);
499 NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd);
500 const char *get_peer_addr(int fd, char *addr, size_t addr_len);
501
502 struct tsocket_address;
503
504 int get_remote_hostname(const struct tsocket_address *remote_address,
505                         char **name,
506                         TALLOC_CTX *mem_ctx);
507
508 int create_pipe_sock(const char *socket_dir,
509                      const char *socket_name,
510                      mode_t dir_perms);
511 const char *get_mydnsfullname(void);
512 bool is_myname_or_ipaddr(const char *s);
513 int poll_one_fd(int fd, int events, int timeout, int *revents);
514 int poll_intr_one_fd(int fd, int events, int timeout, int *revents);
515
516 /* The following definitions come from lib/util_str.c  */
517
518 bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize);
519 bool strnequal(const char *s1,const char *s2,size_t n);
520 bool strcsequal(const char *s1,const char *s2);
521 char *skip_string(const char *base, size_t len, char *buf);
522 size_t str_charnum(const char *s);
523 bool trim_char(char *s,char cfront,char cback);
524 bool strhasupper(const char *s);
525 bool strhaslower(const char *s);
526 bool in_list(const char *s, const char *list, bool casesensitive);
527 char *realloc_string_sub2(char *string,
528                         const char *pattern,
529                         const char *insert,
530                         bool remove_unsafe_characters,
531                         bool allow_trailing_dollar);
532 char *realloc_string_sub(char *string,
533                         const char *pattern,
534                         const char *insert);
535 void all_string_sub(char *s,const char *pattern,const char *insert, size_t len);
536 char *string_truncate(char *s, unsigned int length);
537 char *strchr_m(const char *src, char c);
538 char *strrchr_m(const char *s, char c);
539 char *strnrchr_m(const char *s, char c, unsigned int n);
540 char *strstr_m(const char *src, const char *findstr);
541 bool strlower_m(char *s);
542 bool strupper_m(char *s);
543 size_t strlen_m(const char *s);
544 size_t strlen_m_term(const char *s);
545 size_t strlen_m_term_null(const char *s);
546 int fstr_sprintf(fstring s, const char *fmt, ...);
547
548 uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr);
549 uint64_t conv_str_size(const char * str);
550 char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...)
551                                  PRINTF_ATTRIBUTE(2,3);
552 char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...)
553                                  PRINTF_ATTRIBUTE(2,3);
554 bool validate_net_name( const char *name,
555                 const char *invalid_chars,
556                 int max_len);
557 char *escape_shell_string(const char *src);
558 ssize_t full_path_tos(const char *dir, const char *name,
559                       char *tmpbuf, size_t tmpbuf_len,
560                       char **pdst, char **to_free);
561
562 /* The following definitions come from lib/version.c  */
563
564 const char *samba_version_string(void);
565
566 /* The following definitions come from lib/wins_srv.c  */
567
568 bool wins_srv_is_dead(struct in_addr wins_ip, struct in_addr src_ip);
569 void wins_srv_alive(struct in_addr wins_ip, struct in_addr src_ip);
570 void wins_srv_died(struct in_addr wins_ip, struct in_addr src_ip);
571 unsigned wins_srv_count(void);
572 char **wins_srv_tags(void);
573 void wins_srv_tags_free(char **list);
574 struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip);
575 bool wins_server_tag_ips(const char *tag, TALLOC_CTX *mem_ctx,
576                          struct in_addr **pservers, size_t *pnum_servers);
577 unsigned wins_srv_count_tag(const char *tag);
578
579 /* The following definitions come from libsmb/conncache.c  */
580
581 NTSTATUS check_negative_conn_cache( const char *domain, const char *server);
582 void add_failed_connection_entry(const char *domain, const char *server, NTSTATUS result) ;
583 void flush_negative_conn_cache_for_domain(const char *domain);
584
585 /* The following definitions come from libsmb/errormap.c  */
586
587 NTSTATUS dos_to_ntstatus(uint8_t eclass, uint32_t ecode);
588
589 /* The following definitions come from libsmb/namecache.c  */
590
591 bool namecache_store(const char *name,
592                         int name_type,
593                         size_t num_names,
594                         struct samba_sockaddr *sa_list);
595 bool namecache_fetch(TALLOC_CTX *ctx,
596                         const char *name,
597                         int name_type,
598                         struct samba_sockaddr **sa_list,
599                         size_t *num_names);
600 bool namecache_delete(const char *name, int name_type);
601 void namecache_flush(void);
602 bool namecache_status_store(const char *keyname, int keyname_type,
603                 int name_type, const struct sockaddr_storage *keyip,
604                 const char *srvname);
605 bool namecache_status_fetch(const char *keyname,
606                                 int keyname_type,
607                                 int name_type,
608                                 const struct sockaddr_storage *keyip,
609                                 char *srvname_out);
610
611 /* The following definitions come from libsmb/namequery_dc.c  */
612
613 bool get_dc_name(const char *domain,
614                 const char *realm,
615                 fstring srv_name,
616                 struct sockaddr_storage *ss_out);
617
618 /* The following definitions come from libsmb/smberr.c  */
619
620 const char *smb_dos_err_name(uint8_t e_class, uint16_t num);
621 const char *get_dos_error_msg(WERROR result);
622 const char *smb_dos_err_class(uint8_t e_class);
623 WERROR map_werror_from_unix(int error);
624
625 /* The following definitions come from libsmb/trusts_util.c  */
626
627 struct netlogon_creds_cli_context;
628 struct messaging_context;
629 struct dcerpc_binding_handle;
630 char *trust_pw_new_value(TALLOC_CTX *mem_ctx,
631                          enum netr_SchannelType sec_channel_type,
632                          int security);
633 NTSTATUS trust_pw_change(struct netlogon_creds_cli_context *context,
634                          struct messaging_context *msg_ctx,
635                          struct dcerpc_binding_handle *b,
636                          const char *domain,
637                          const char *dcname,
638                          bool force);
639
640 /* The following definitions come from lib/sessionid_tdb.c  */
641 struct sessionid;
642 NTSTATUS sessionid_traverse_read(int (*fn)(const char *key,
643                                            struct sessionid *session,
644                                            void *private_data),
645                                  void *private_data);
646
647 /* The following definitions come from lib/avahi.c */
648
649 struct AvahiPoll *tevent_avahi_poll(TALLOC_CTX *mem_ctx,
650                                     struct tevent_context *ev);
651
652 /* The following definitions come from libsmb/smbsock_connect.c */
653
654 struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
655                                         struct tevent_context *ev,
656                                         const struct sockaddr_storage *addr,
657                                         uint16_t port,
658                                         const char *called_name,
659                                         int called_type,
660                                         const char *calling_name,
661                                         int calling_type);
662 NTSTATUS smbsock_connect_recv(struct tevent_req *req, int *sock,
663                               uint16_t *ret_port);
664 NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port,
665                          const char *called_name, int called_type,
666                          const char *calling_name, int calling_type,
667                          int *pfd, uint16_t *ret_port, int sec_timeout);
668
669 struct tevent_req *smbsock_any_connect_send(TALLOC_CTX *mem_ctx,
670                                             struct tevent_context *ev,
671                                             const struct sockaddr_storage *addrs,
672                                             const char **called_names,
673                                             int *called_types,
674                                             const char **calling_names,
675                                             int *calling_types,
676                                             size_t num_addrs, uint16_t port);
677 NTSTATUS smbsock_any_connect_recv(struct tevent_req *req, int *pfd,
678                                   size_t *chosen_index, uint16_t *chosen_port);
679 NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs,
680                              const char **called_names,
681                              int *called_types,
682                              const char **calling_names,
683                              int *calling_types,
684                              size_t num_addrs,
685                              uint16_t port,
686                              int sec_timeout,
687                              int *pfd, size_t *chosen_index,
688                              uint16_t *chosen_port);
689
690 /* The following definitions come from lib/util_wellknown.c  */
691
692 bool sid_check_is_wellknown_domain(const struct dom_sid *sid, const char **name);
693 bool sid_check_is_in_wellknown_domain(const struct dom_sid *sid);
694 bool lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
695                           const char **domain, const char **name);
696 bool lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name,
697                            struct dom_sid *sid, const char **domain);
698
699 /* The following definitions come from lib/filename_util.c */
700
701 NTSTATUS get_full_smb_filename(TALLOC_CTX *ctx, const struct smb_filename *smb_fname,
702                               char **full_name);
703 struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx,
704                                          const char *base_name,
705                                          const char *stream_name,
706                                          const SMB_STRUCT_STAT *psbuf,
707                                          NTTIME twrp,
708                                          uint32_t flags);
709 NTSTATUS filename_convert_dirfsp(
710         TALLOC_CTX *ctx,
711         connection_struct *conn,
712         const char *name_in,
713         uint32_t ucf_flags,
714         NTTIME twrp,
715         struct files_struct **pdirfsp,
716         struct smb_filename **psmb_name_rel);
717 char *full_path_from_dirfsp_at_basename(TALLOC_CTX *mem_ctx,
718                                         const struct files_struct *dirfsp,
719                                         const char *at_base_name);
720 struct smb_filename *full_path_from_dirfsp_atname(
721         TALLOC_CTX *mem_ctx,
722         const struct files_struct *dirfsp,
723         const struct smb_filename *atname);
724 struct smb_filename *synthetic_smb_fname_split(TALLOC_CTX *ctx,
725                                                 const char *fname,
726                                                 bool posix_path);
727 const char *smb_fname_str_dbg(const struct smb_filename *smb_fname);
728 const char *fsp_str_dbg(const struct files_struct *fsp);
729 const char *fsp_fnum_dbg(const struct files_struct *fsp);
730 struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx,
731                                      const struct smb_filename *in);
732 struct smb_filename *cp_smb_filename_nostream(TALLOC_CTX *mem_ctx,
733                                      const struct smb_filename *in);
734 bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname);
735 bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
736 bool is_named_stream(const struct smb_filename *smb_fname);
737 bool is_invalid_windows_ea_name(const char *name);
738 bool ea_list_has_invalid_name(struct ea_list *ea_list);
739 bool split_stream_filename(TALLOC_CTX *ctx,
740                         const char *filename_in,
741                         char **filename_out,
742                         char **streamname_out);
743
744 /* The following definitions come from lib/dummyroot.c */
745
746 void become_root(void);
747 void unbecome_root(void);
748
749 /* The following definitions come from lib/smbd_shim.c */
750
751 int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out);
752 bool lp_allow_local_address(
753         int snum, const struct tsocket_address *local_address);
754 NTSTATUS can_delete_directory_fsp(files_struct *fsp);
755 bool change_to_root_user(void);
756 bool become_authenticated_pipe_user(struct auth_session_info *session_info);
757 bool unbecome_authenticated_pipe_user(void);
758
759 void contend_level2_oplocks_begin(files_struct *fsp,
760                                   enum level2_contention_type type);
761 void contend_level2_oplocks_end(files_struct *fsp,
762                                 enum level2_contention_type type);
763
764 /* The following definitions come from lib/per_thread_cwd.c */
765
766 void per_thread_cwd_check(void);
767 bool per_thread_cwd_supported(void);
768 void per_thread_cwd_disable(void);
769 void per_thread_cwd_activate(void);
770
771 #endif /*  _PROTO_H_  */