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