2 * Unix SMB/CIFS implementation.
3 * collected prototypes header
5 * frozen from "make proto" in May 2008
7 * Copyright (C) Michael Adam 2008
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.
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.
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/>.
26 #include <sys/types.h>
29 #include "lib/util/access.h"
31 /* The following definitions come from lib/adt_tree.c */
33 /* The following definitions come from lib/audit.c */
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);
41 /* The following definitions come from lib/charcnv.c */
43 void gfree_charcnv(void);
44 size_t ucs2_align(const void *base_ptr, const void *p, int flags);
45 size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags);
46 size_t push_ascii_fstring(void *dest, const char *src);
47 size_t push_ascii_nstring(void *dest, const char *src);
48 size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
49 size_t pull_ascii_fstring(char *dest, const void *src);
50 size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src);
51 size_t push_string_check_fn(void *dest, const char *src,
52 size_t dest_len, int flags);
53 size_t push_string_base(const char *base, uint16_t flags2,
54 void *dest, const char *src,
55 size_t dest_len, int flags);
56 size_t pull_string_talloc(TALLOC_CTX *ctx,
63 size_t dos_PutUniCode(char *dst,const char *src, size_t len, bool null_terminate);
64 int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src);
66 /* The following definitions come from lib/dmallocmsg.c */
68 void register_dmalloc_msgs(struct messaging_context *msg_ctx);
70 /* The following definitions come from lib/dprintf.c */
72 void display_set_stderr(void);
74 /* The following definitions come from lib/errmap_unix.c */
76 NTSTATUS map_nt_error_from_unix(int unix_error);
77 int map_errno_from_nt_status(NTSTATUS status);
79 /* The following definitions come from lib/file_id.c */
81 struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf);
83 /* The following definitions come from lib/interface.c */
85 bool ismyaddr(const struct sockaddr *ip);
86 bool ismyip_v4(struct in_addr ip);
87 bool is_local_net(const struct sockaddr *from);
88 void setup_linklocal_scope_id(struct sockaddr *pss);
89 bool is_local_net_v4(struct in_addr from);
90 int iface_count(void);
91 int iface_count_v4_nl(void);
92 const struct in_addr *first_ipv4_iface(void);
93 struct interface *get_interface(int n);
94 const struct sockaddr_storage *iface_n_sockaddr_storage(int n);
95 const struct in_addr *iface_n_ip_v4(int n);
96 const struct in_addr *iface_n_bcast_v4(int n);
97 const struct sockaddr_storage *iface_n_bcast(int n);
98 const struct sockaddr_storage *iface_ip(const struct sockaddr *ip);
99 bool iface_local(const struct sockaddr *ip);
100 void load_interfaces(void);
101 void gfree_interfaces(void);
102 bool interfaces_changed(void);
104 /* The following definitions come from lib/ldap_debug_handler.c */
106 void init_ldap_debugging(void);
108 /* The following definitions come from lib/ldap_escape.c */
110 char *escape_ldap_string(TALLOC_CTX *mem_ctx, const char *s);
111 char *escape_rdn_val_string_alloc(const char *s);
113 /* The following definitions come from lib/ms_fnmatch.c */
115 int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
116 bool is_case_sensitive);
118 /* The following definitions come from lib/recvfile.c */
120 ssize_t sys_recvfile(int fromfd,
124 ssize_t sys_recvfile(int fromfd,
128 ssize_t drain_socket(int sockfd, size_t count);
130 /* The following definitions come from lib/sendfile.c */
132 ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, off_t offset, size_t count);
134 /* The following definitions come from lib/server_mutex.c */
136 struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name,
139 /* The following definitions come from lib/sharesec.c */
141 bool share_info_db_init(void);
142 struct security_descriptor *get_share_security_default( TALLOC_CTX *ctx, size_t *psize, uint32_t def_access);
143 struct security_descriptor *get_share_security( TALLOC_CTX *ctx, const char *servicename,
145 bool set_share_security(const char *share_name, struct security_descriptor *psd);
146 bool delete_share_security(const char *servicename);
147 bool share_access_check(const struct security_token *token,
148 const char *sharename,
149 uint32_t desired_access,
151 bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, struct security_descriptor **ppsd);
153 /* The following definitions come from lib/smbrun.c */
155 int smbrun_no_sanitize(const char *cmd, int *outfd, char * const *env);
156 int smbrun(const char *cmd, int *outfd, char * const *env);
157 int smbrunsecret(const char *cmd, const char *secret);
159 /* The following definitions come from lib/substitute.c */
161 void free_local_machine_name(void);
162 bool set_local_machine_name(const char *local_name, bool perm);
163 const char *get_local_machine_name(void);
164 bool set_remote_machine_name(const char *remote_name, bool perm);
165 const char *get_remote_machine_name(void);
166 void sub_set_smb_name(const char *name);
167 void set_current_user_info(const char *smb_name, const char *unix_name,
169 void sub_set_socket_ids(const char *peeraddr, const char *peername,
170 const char *sockaddr);
171 const char *get_current_username(void);
172 void standard_sub_basic(const char *smb_name, const char *domain_name,
173 char *str, size_t len);
174 char *talloc_sub_basic(TALLOC_CTX *mem_ctx, const char *smb_name,
175 const char *domain_name, const char *str);
176 char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
177 const char *input_string,
178 const char *username,
183 char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
184 const char *servicename, const char *user,
185 const char *connectpath, gid_t gid,
186 const char *smb_name, const char *domain_name,
188 void standard_sub_advanced(const char *servicename, const char *user,
189 const char *connectpath, gid_t gid,
190 const char *smb_name, const char *domain_name,
191 char *str, size_t len);
193 /* The following definitions come from lib/sysquotas.c */
195 int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
196 int sys_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
198 /* The following definitions come from lib/sysquotas_*.c */
200 int sys_get_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
201 int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
203 int sys_get_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
204 int sys_set_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
206 int sys_get_jfs2_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
207 int sys_set_jfs2_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
209 int sys_get_nfs_quota(const char *path, const char *bdev,
210 enum SMB_QUOTA_TYPE qtype,
211 unid_t id, SMB_DISK_QUOTA *dp);
212 int sys_set_nfs_quota(const char *path, const char *bdev,
213 enum SMB_QUOTA_TYPE qtype,
214 unid_t id, SMB_DISK_QUOTA *dp);
216 /* The following definitions come from lib/system.c */
218 ssize_t sys_send(int s, const void *msg, size_t len, int flags);
219 ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
220 int sys_fcntl_ptr(int fd, int cmd, void *arg);
221 int sys_fcntl_long(int fd, int cmd, long arg);
222 int sys_fcntl_int(int fd, int cmd, int arg);
223 void update_stat_ex_mtime(struct stat_ex *dst, struct timespec write_ts);
224 void update_stat_ex_itime(struct stat_ex *dst, struct timespec itime);
225 void update_stat_ex_create_time(struct stat_ex *dst, struct timespec create_time);
226 void update_stat_ex_file_id(struct stat_ex *dst, uint64_t file_id);
227 void update_stat_ex_from_saved_stat(struct stat_ex *dst,
228 const struct stat_ex *src);
229 int sys_stat(const char *fname, SMB_STRUCT_STAT *sbuf,
230 bool fake_dir_create_times);
231 int sys_fstat(int fd, SMB_STRUCT_STAT *sbuf,
232 bool fake_dir_create_times);
233 int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
234 bool fake_dir_create_times);
235 int sys_posix_fallocate(int fd, off_t offset, off_t len);
236 int sys_fallocate(int fd, uint32_t mode, off_t offset, off_t len);
237 void kernel_flock(int fd, uint32_t share_mode, uint32_t access_mask);
238 DIR *sys_fdopendir(int fd);
239 int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev);
240 int sys_mknodat(int dirfd, const char *path, mode_t mode, SMB_DEV_T dev);
241 char *sys_getwd(void);
242 void set_effective_capability(enum smbd_capability capability);
243 void drop_effective_capability(enum smbd_capability capability);
244 long sys_random(void);
245 void sys_srandom(unsigned int seed);
246 int groups_max(void);
247 int sys_getgroups(int setlen, gid_t *gidset);
248 int sys_setgroups(gid_t UNUSED(primary_gid), int setlen, gid_t *gidset);
249 uint32_t unix_dev_major(SMB_DEV_T dev);
250 uint32_t unix_dev_minor(SMB_DEV_T dev);
251 char *sys_realpath(const char *path);
253 int sys_get_number_of_cores(void);
257 void init_stat_ex_from_stat (struct stat_ex *dst,
258 const struct stat *src,
259 bool fake_dir_create_times);
261 /* The following definitions come from lib/system_smbd.c */
263 bool getgroups_unix_user(TALLOC_CTX *mem_ctx, const char *user,
265 gid_t **ret_groups, uint32_t *p_ngroups);
267 /* The following definitions come from lib/tallocmsg.c */
269 void register_msg_pool_usage(struct messaging_context *msg_ctx);
271 /* The following definitions come from lib/time.c */
273 void push_dos_date(uint8_t *buf, int offset, time_t unixdate, int zone_offset);
274 void push_dos_date2(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
275 void push_dos_date3(uint8_t *buf,int offset,time_t unixdate, int zone_offset);
276 uint32_t convert_time_t_to_uint32_t(time_t t);
277 time_t convert_uint32_t_to_time_t(uint32_t u);
278 bool nt_time_is_zero(const NTTIME *nt);
279 time_t generalized_to_unix_time(const char *str);
280 int get_server_zone_offset(void);
281 int set_server_zone_offset(time_t t);
282 char *timeval_string(TALLOC_CTX *ctx, const struct timeval *tp, bool hires);
283 char *current_timestring(TALLOC_CTX *ctx, bool hires);
284 void srv_put_dos_date(char *buf,int offset,time_t unixdate);
285 void srv_put_dos_date2(char *buf,int offset, time_t unixdate);
286 void srv_put_dos_date3(char *buf,int offset,time_t unixdate);
287 void round_timespec(enum timestamp_set_resolution res, struct timespec *ts);
288 void put_long_date_timespec(enum timestamp_set_resolution res, char *p, struct timespec ts);
289 void put_long_date(char *p, time_t t);
290 void dos_filetime_timespec(struct timespec *tsp);
291 time_t make_unix_date(const void *date_ptr, int zone_offset);
292 time_t make_unix_date2(const void *date_ptr, int zone_offset);
293 time_t make_unix_date3(const void *date_ptr, int zone_offset);
294 time_t srv_make_unix_date(const void *date_ptr);
295 time_t srv_make_unix_date2(const void *date_ptr);
296 time_t srv_make_unix_date3(const void *date_ptr);
297 struct timespec interpret_long_date(const char *p);
299 void get_process_uptime(struct timeval *ret_time);
300 void get_startup_time(struct timeval *ret_time);
301 time_t nt_time_to_unix_abs(const NTTIME *nt);
302 time_t uint64s_nt_time_to_unix_abs(const uint64_t *src);
303 void unix_to_nt_time_abs(NTTIME *nt, time_t t);
304 const char *time_to_asc(const time_t t);
305 const char *display_time(NTTIME nttime);
306 bool nt_time_is_set(const NTTIME *nt);
308 /* The following definitions come from lib/username.c */
310 void flush_pwnam_cache(void);
311 char *get_user_home_dir(TALLOC_CTX *mem_ctx, const char *user);
312 struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
314 /* The following definitions come from lib/util_names.c */
315 const char *get_global_sam_name(void);
316 const char *my_sam_name(void);
318 /* The following definitions come from lib/util.c */
320 enum protocol_types get_Protocol(void);
321 void set_Protocol(enum protocol_types p);
322 void gfree_names(void);
323 void gfree_all( void );
324 const char *my_netbios_names(int i);
325 bool set_netbios_aliases(const char **str_array);
326 bool init_names(void);
327 bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
328 bool fake_dir_create_times);
329 bool socket_exist(const char *fname);
330 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
331 bool check_same_dev_ino(const SMB_STRUCT_STAT *sbuf1,
332 const SMB_STRUCT_STAT *sbuf2);
333 bool check_same_stat(const SMB_STRUCT_STAT *sbuf1,
334 const SMB_STRUCT_STAT *sbuf2);
335 void show_msg(const char *buf);
336 int set_message_bcc(char *buf,int num_bytes);
337 ssize_t message_push_blob(uint8_t **outbuf, DATA_BLOB blob);
338 char *unix_clean_name(TALLOC_CTX *ctx, const char *s);
339 char *clean_name(TALLOC_CTX *ctx, const char *s);
340 ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, off_t pos);
341 NTSTATUS init_before_fork(void);
342 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
343 struct tevent_context *ev_ctx,
344 bool parent_longlived,
345 const char *comment);
346 NTSTATUS smbd_reinit_after_fork(struct messaging_context *msg_ctx,
347 struct tevent_context *ev_ctx,
348 bool parent_longlived,
349 const char *comment);
350 void *malloc_(size_t size);
351 void *Realloc(void *p, size_t size, bool free_old_on_error);
352 void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
353 void *element, void *_array, uint32_t *num_elements,
354 ssize_t *array_size);
355 char *get_myname(TALLOC_CTX *ctx);
356 char *get_mydnsdomname(TALLOC_CTX *ctx);
357 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
358 char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
359 bool process_exists(const struct server_id pid);
360 const char *uidtoname(uid_t uid);
361 char *gidtoname(gid_t gid);
362 uid_t nametouid(const char *name);
363 gid_t nametogid(const char *name);
364 void smb_panic_s3(const char *why);
365 const char *readdirname(DIR *p);
366 bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensitive);
367 void set_namearray(name_compare_entry **ppname_array, const char *namelist);
368 void free_namearray(name_compare_entry *name_array);
369 bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type);
370 bool fcntl_getlock(int fd, int op, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid);
371 int map_process_lock_to_ofd_lock(int op);
372 bool is_myname(const char *s);
373 void ra_lanman_string( const char *native_lanman );
374 const char *get_remote_arch_str(void);
375 enum remote_arch_types get_remote_arch_from_str(const char *remote_arch_string);
376 void set_remote_arch(enum remote_arch_types type);
377 enum remote_arch_types get_remote_arch(void);
378 bool remote_arch_cache_update(const struct GUID *client_guid);
379 bool remote_arch_cache_delete(const struct GUID *client_guid);
380 const char *tab_depth(int level, int depth);
381 int str_checksum(const char *s);
382 void zero_free(void *p, size_t size);
383 int set_maxfiles(int requested_max);
384 int smb_mkstemp(char *name_template);
385 void *smb_xmalloc_array(size_t size, unsigned int count);
386 char *myhostname(void);
387 char *myhostname_upper(void);
388 #include "lib/util_path.h"
389 bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
391 bool ms_has_wild(const char *s);
392 bool ms_has_wild_w(const smb_ucs2_t *s);
393 bool mask_match(const char *string, const char *pattern, bool is_case_sensitive);
394 bool mask_match_search(const char *string, const char *pattern, bool is_case_sensitive);
395 bool mask_match_list(const char *string, char **list, int listLen, bool is_case_sensitive);
396 #include "lib/util/unix_match.h"
397 bool name_to_fqdn(fstring fqdn, const char *name);
398 uint32_t map_share_mode_to_deny_mode(uint32_t share_access, uint32_t private_options);
400 #include "lib/util_procid.h"
402 #define serverid_equal(p1, p2) server_id_equal(p1,p2)
403 struct server_id interpret_pid(const char *pid_string);
404 bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t off);
405 char *get_safe_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
406 char *get_safe_str_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
407 int get_safe_SVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, int failval);
408 int get_safe_IVAL(const char *buf_base, size_t buf_len, char *ptr, size_t off, int failval);
409 bool split_domain_user(TALLOC_CTX *mem_ctx,
410 const char *full_name,
413 const char *strip_hostname(const char *s);
414 bool any_nt_status_not_ok(NTSTATUS err1, NTSTATUS err2, NTSTATUS *result);
415 int timeval_to_msec(struct timeval t);
416 char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname);
417 bool is_executable(const char *fname);
418 bool map_open_params_to_ntcreate(const char *smb_base_fname,
419 int deny_mode, int open_func,
420 uint32_t *paccess_mask,
421 uint32_t *pshare_mode,
422 uint32_t *pcreate_disposition,
423 uint32_t *pcreate_options,
424 uint32_t *pprivate_flags);
425 struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct security_unix_token *tok);
426 struct security_unix_token *root_unix_token(TALLOC_CTX *mem_ctx);
427 char *utok_string(TALLOC_CTX *mem_ctx, const struct security_unix_token *tok);
428 bool dir_check_ftype(uint32_t mode, uint32_t dirtype);
430 /* The following definitions come from lib/util_builtin.c */
432 bool lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32_t rid, const char **name);
433 bool lookup_builtin_name(const char *name, uint32_t *rid);
434 const char *builtin_domain_name(void);
435 bool sid_check_is_builtin(const struct dom_sid *sid);
436 bool sid_check_is_in_builtin(const struct dom_sid *sid);
437 bool sid_check_is_wellknown_builtin(const struct dom_sid *sid);
439 /* The following definitions come from lib/util_nscd.c */
441 void smb_nscd_flush_user_cache(void);
442 void smb_nscd_flush_group_cache(void);
444 /* The following definitions come from lib/util_nttoken.c */
446 struct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_token *ptoken);
447 NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
448 const struct security_token *token_1,
449 const struct security_token *token_2,
450 struct security_token **token_out);
451 bool token_sid_in_ace(const struct security_token *token, const struct security_ace *ace);
453 /* The following definitions come from lib/util_sec.c */
456 uid_t sec_initial_uid(void);
457 gid_t sec_initial_gid(void);
458 bool root_mode(void);
459 bool non_root_mode(void);
460 void gain_root_privilege(void);
461 void gain_root_group_privilege(void);
462 void set_effective_uid(uid_t uid);
463 void set_effective_gid(gid_t gid);
464 void save_re_uid(void);
465 void restore_re_uid_fromroot(void);
466 void restore_re_uid(void);
467 void save_re_gid(void);
468 void restore_re_gid(void);
469 int set_re_uid(void);
470 void become_user_permanently(uid_t uid, gid_t gid);
471 int set_thread_credentials(uid_t uid,
474 const gid_t *gidset);
475 bool is_setuid_root(void) ;
477 /* The following definitions come from lib/util_sid.c */
479 char *sid_to_fstring(fstring sidstr_out, const struct dom_sid *sid);
480 bool sid_linearize(uint8_t *outbuf, size_t len, const struct dom_sid *sid);
481 bool non_mappable_sid(struct dom_sid *sid);
482 char *sid_binstring_hex_talloc(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
483 struct netr_SamInfo3;
484 NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
485 const struct netr_SamInfo3 *info3,
486 struct dom_sid **user_sids,
487 uint32_t *num_user_sids,
488 bool include_user_group_rid);
490 /* The following definitions come from lib/util_sock.c */
492 bool is_broadcast_addr(const struct sockaddr *pss);
493 bool is_loopback_ip_v4(struct in_addr ip);
494 bool is_loopback_addr(const struct sockaddr *pss);
495 bool is_zero_addr(const struct sockaddr_storage *pss);
496 void zero_ip_v4(struct in_addr *ip);
497 void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
499 bool same_net(const struct sockaddr *ip1,
500 const struct sockaddr *ip2,
501 const struct sockaddr *mask);
502 bool sockaddr_equal(const struct sockaddr *ip1,
503 const struct sockaddr *ip2);
504 bool is_address_any(const struct sockaddr *psa);
505 uint16_t get_sockaddr_port(const struct sockaddr_storage *pss);
506 char *print_sockaddr(char *dest,
508 const struct sockaddr_storage *psa);
509 char *print_canonical_sockaddr(TALLOC_CTX *ctx,
510 const struct sockaddr_storage *pss);
511 int get_socket_port(int fd);
512 const char *client_addr(int fd, char *addr, size_t addrlen);
513 const char *client_socket_addr(int fd, char *addr, size_t addr_len);
514 int client_socket_port(int fd);
515 bool is_a_socket(int fd);
516 void set_socket_options(int fd, const char *options);
517 ssize_t read_udp_v4_socket(int fd,
520 struct sockaddr_storage *psa);
521 NTSTATUS read_fd_with_timeout(int fd, char *buf,
522 size_t mincnt, size_t maxcnt,
523 unsigned int time_out,
525 NTSTATUS read_data_ntstatus(int fd, char *buffer, size_t N);
527 bool send_keepalive(int client);
528 NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
529 unsigned int timeout,
531 NTSTATUS receive_smb_raw(int fd,
534 unsigned int timeout,
537 int open_socket_in(int type,
540 const struct sockaddr_storage *psock,
542 NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
543 int timeout, int *pfd);
544 struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
545 struct tevent_context *ev,
546 const struct sockaddr_storage *pss,
549 NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd);
550 struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
551 struct tevent_context *ev,
552 struct timeval wait_time,
553 const struct sockaddr_storage *pss,
556 NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd);
557 int open_udp_socket(const char *host, int port);
558 const char *get_peer_addr(int fd, char *addr, size_t addr_len);
560 struct tsocket_address;
562 int get_remote_hostname(const struct tsocket_address *remote_address,
564 TALLOC_CTX *mem_ctx);
566 int create_pipe_sock(const char *socket_dir,
567 const char *socket_name,
569 const char *get_mydnsfullname(void);
570 bool is_myname_or_ipaddr(const char *s);
571 int poll_one_fd(int fd, int events, int timeout, int *revents);
572 int poll_intr_one_fd(int fd, int events, int timeout, int *revents);
574 /* The following definitions come from lib/util_str.c */
576 bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize);
577 bool strnequal(const char *s1,const char *s2,size_t n);
578 bool strcsequal(const char *s1,const char *s2);
579 bool strnorm(char *s, int case_default);
580 char *push_skip_string(char *buf);
581 char *skip_string(const char *base, size_t len, char *buf);
582 size_t str_charnum(const char *s);
583 bool trim_char(char *s,char cfront,char cback);
584 bool strhasupper(const char *s);
585 bool strhaslower(const char *s);
586 bool in_list(const char *s, const char *list, bool casesensitive);
587 void fstring_sub(char *s,const char *pattern,const char *insert);
588 char *realloc_string_sub2(char *string,
591 bool remove_unsafe_characters,
592 bool allow_trailing_dollar);
593 char *realloc_string_sub(char *string,
596 char *talloc_string_sub2(TALLOC_CTX *mem_ctx, const char *src,
599 bool remove_unsafe_characters,
601 bool allow_trailing_dollar);
602 char *talloc_string_sub(TALLOC_CTX *mem_ctx,
606 void all_string_sub(char *s,const char *pattern,const char *insert, size_t len);
607 char *talloc_all_string_sub(TALLOC_CTX *ctx,
611 char *octal_string(int i);
612 char *string_truncate(char *s, unsigned int length);
613 char *strchr_m(const char *src, char c);
614 char *strrchr_m(const char *s, char c);
615 char *strnrchr_m(const char *s, char c, unsigned int n);
616 char *strstr_m(const char *src, const char *findstr);
617 bool strlower_m(char *s);
618 bool strupper_m(char *s);
619 size_t strlen_m(const char *s);
620 size_t strlen_m_term(const char *s);
621 size_t strlen_m_term_null(const char *s);
622 int fstr_sprintf(fstring s, const char *fmt, ...);
623 bool str_list_sub_basic( char **list, const char *smb_name,
624 const char *domain_name );
625 bool str_list_substitute(char **list, const char *pattern, const char *insert);
627 char *ipstr_list_make(char **ipstr_list,
628 const struct ip_service *ip_list,
630 int ipstr_list_parse(const char *ipstr_list, struct ip_service **ip_list);
631 void ipstr_list_free(char* ipstr_list);
632 uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr);
633 uint64_t conv_str_size(const char * str);
634 int asprintf_strupper_m(char **strp, const char *fmt, ...)
635 PRINTF_ATTRIBUTE(2,3);
636 char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...)
637 PRINTF_ATTRIBUTE(2,3);
638 char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...)
639 PRINTF_ATTRIBUTE(2,3);
640 bool validate_net_name( const char *name,
641 const char *invalid_chars,
643 char *escape_shell_string(const char *src);
644 ssize_t full_path_tos(const char *dir, const char *name,
645 char *tmpbuf, size_t tmpbuf_len,
646 char **pdst, char **to_free);
648 /* The following definitions come from lib/version.c */
650 const char *samba_version_string(void);
652 /* The following definitions come from lib/wins_srv.c */
654 bool wins_srv_is_dead(struct in_addr wins_ip, struct in_addr src_ip);
655 void wins_srv_alive(struct in_addr wins_ip, struct in_addr src_ip);
656 void wins_srv_died(struct in_addr wins_ip, struct in_addr src_ip);
657 unsigned wins_srv_count(void);
658 char **wins_srv_tags(void);
659 void wins_srv_tags_free(char **list);
660 struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip);
661 bool wins_server_tag_ips(const char *tag, TALLOC_CTX *mem_ctx,
662 struct in_addr **pservers, int *pnum_servers);
663 unsigned wins_srv_count_tag(const char *tag);
665 #ifndef ASN1_MAX_OIDS
666 #define ASN1_MAX_OIDS 20
668 bool spnego_parse_negTokenInit(TALLOC_CTX *ctx,
670 char *OIDs[ASN1_MAX_OIDS],
673 DATA_BLOB spnego_gen_krb5_wrap(TALLOC_CTX *ctx, const DATA_BLOB ticket, const uint8_t tok_id[2]);
675 /* The following definitions come from libsmb/conncache.c */
677 NTSTATUS check_negative_conn_cache( const char *domain, const char *server);
678 void add_failed_connection_entry(const char *domain, const char *server, NTSTATUS result) ;
679 void flush_negative_conn_cache_for_domain(const char *domain);
681 /* The following definitions come from libsmb/errormap.c */
683 NTSTATUS dos_to_ntstatus(uint8_t eclass, uint32_t ecode);
685 /* The following definitions come from libsmb/namecache.c */
687 bool namecache_store(const char *name,
690 struct ip_service *ip_list);
691 bool namecache_fetch(const char *name,
693 struct ip_service **ip_list,
695 bool namecache_delete(const char *name, int name_type);
696 void namecache_flush(void);
697 bool namecache_status_store(const char *keyname, int keyname_type,
698 int name_type, const struct sockaddr_storage *keyip,
699 const char *srvname);
700 bool namecache_status_fetch(const char *keyname,
703 const struct sockaddr_storage *keyip,
706 /* The following definitions come from libsmb/namequery_dc.c */
708 bool get_dc_name(const char *domain,
711 struct sockaddr_storage *ss_out);
713 /* The following definitions come from libsmb/smberr.c */
715 const char *smb_dos_err_name(uint8_t e_class, uint16_t num);
716 const char *get_dos_error_msg(WERROR result);
717 const char *smb_dos_err_class(uint8_t e_class);
718 WERROR map_werror_from_unix(int error);
720 /* The following definitions come from libsmb/trusts_util.c */
722 struct netlogon_creds_cli_context;
723 struct messaging_context;
724 struct dcerpc_binding_handle;
725 char *trust_pw_new_value(TALLOC_CTX *mem_ctx,
726 enum netr_SchannelType sec_channel_type,
728 NTSTATUS trust_pw_change(struct netlogon_creds_cli_context *context,
729 struct messaging_context *msg_ctx,
730 struct dcerpc_binding_handle *b,
735 /* The following definitions come from param/loadparm.c */
737 #include "source3/param/param_proto.h"
739 char *lp_servicename(TALLOC_CTX *ctx, int);
740 const char *lp_const_servicename(int);
741 bool lp_autoloaded(int);
742 const char *lp_dnsdomain(void);
743 int lp_winbind_max_domain_connections(void);
744 bool lp_idmap_range(const char *domain_name, uint32_t *low, uint32_t *high);
745 bool lp_idmap_default_range(uint32_t *low, uint32_t *high);
746 const char *lp_idmap_backend(const char *domain_name);
747 const char *lp_idmap_default_backend (void);
748 int lp_security(void);
749 int lp_client_max_protocol(void);
750 int lp_client_ipc_min_protocol(void);
751 int lp_client_ipc_max_protocol(void);
752 int lp_client_ipc_signing(void);
753 int lp_smb2_max_credits(void);
754 int lp_cups_encrypt(void);
755 bool lp_widelinks(int );
756 int lp_rpc_low_port(void);
757 int lp_rpc_high_port(void);
758 bool lp_lanman_auth(void);
760 int lp_wi_scan_global_parametrics(
761 const char *regex, size_t max_matches,
762 bool (*cb)(const char *string, regmatch_t matches[],
766 char *lp_parm_talloc_string(TALLOC_CTX *ctx, int snum, const char *type, const char *option, const char *def);
767 const char *lp_parm_const_string(int snum, const char *type, const char *option, const char *def);
768 struct loadparm_service;
769 const char *lp_parm_const_string_service(struct loadparm_service *service, const char *type,
770 const char *option, const char *def);
771 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def);
772 int lp_parm_int(int snum, const char *type, const char *option, int def);
773 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def);
774 unsigned long long lp_parm_ulonglong(int snum, const char *type,
776 unsigned long long def);
777 bool lp_parm_bool(int snum, const char *type, const char *option, bool def);
779 int lp_parm_enum(int snum, const char *type, const char *option,
780 const struct enum_list *_enum, int def);
781 char *canonicalize_servicename(TALLOC_CTX *ctx, const char *src);
782 bool lp_add_home(const char *pszHomename, int iDefaultService,
783 const char *user, const char *pszHomedir);
784 int lp_add_service(const char *pszService, int iDefaultService);
785 bool lp_add_printer(const char *pszPrintername, int iDefaultService);
786 bool lp_parameter_is_valid(const char *pszParmName);
787 bool lp_parameter_is_global(const char *pszParmName);
788 bool lp_canonicalize_parameter(const char *parm_name, const char **canon_parm,
790 bool lp_canonicalize_parameter_with_value(const char *parm_name,
792 const char **canon_parm,
793 const char **canon_val);
794 void show_parameter_list(void);
795 bool lp_invert_boolean(const char *str, const char **inverse_str);
796 bool lp_canonicalize_boolean(const char *str, const char**canon_str);
797 bool process_registry_service(const char *service_name);
798 bool process_registry_shares(void);
799 bool lp_config_backend_is_registry(void);
800 bool lp_config_backend_is_file(void);
801 bool lp_file_list_changed(void);
802 const char *lp_ldap_machine_suffix(TALLOC_CTX *ctx);
803 const char *lp_ldap_user_suffix(TALLOC_CTX *ctx);
804 const char *lp_ldap_group_suffix(TALLOC_CTX *ctx);
805 const char *lp_ldap_idmap_suffix(TALLOC_CTX *ctx);
807 /* Return a pointer to a service by name. */
808 struct loadparm_service *lp_service(const char *pszServiceName);
809 struct loadparm_service *lp_servicebynum(int snum);
810 struct loadparm_service *lp_default_loadparm_service(void);
811 void *lp_parm_ptr(struct loadparm_service *service, struct parm_struct *parm);
812 void *lp_local_ptr_by_snum(int snum, struct parm_struct *parm);
813 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue);
814 bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue);
815 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal);
816 bool lp_snum_ok(int iService);
817 void lp_add_one_printer(const char *name, const char *comment,
818 const char *location, void *pdata);
819 bool lp_loaded(void);
820 void lp_killunused(struct smbd_server_connection *sconn,
821 bool (*snumused) (struct smbd_server_connection *, int));
822 void lp_kill_all_services(void);
823 void lp_killservice(int iServiceIn);
824 const char* server_role_str(uint32_t role);
825 enum usershare_err parse_usershare_file(TALLOC_CTX *ctx,
826 SMB_STRUCT_STAT *psbuf,
827 const char *servicename,
833 char **pp_cp_share_name,
834 struct security_descriptor **ppsd,
836 int load_usershare_service(const char *servicename);
837 int load_usershare_shares(struct smbd_server_connection *sconn,
838 bool (*snumused) (struct smbd_server_connection *, int));
839 void gfree_loadparm(void);
840 bool lp_load_initial_only(const char *pszFname);
841 bool lp_load_global(const char *file_name);
842 bool lp_load_with_shares(const char *file_name);
843 bool lp_load_client(const char *file_name);
844 bool lp_load_global_no_reinit(const char *file_name);
845 bool lp_load_no_reinit(const char *file_name);
846 bool lp_load_client_no_reinit(const char *file_name);
847 bool lp_load_with_registry_shares(const char *pszFname);
848 int lp_numservices(void);
849 void lp_dump(FILE *f, bool show_defaults, int maxtoprint);
850 void lp_dump_one(FILE * f, bool show_defaults, int snum);
851 int lp_servicenumber(const char *pszServiceName);
852 const char *volume_label(TALLOC_CTX *ctx, int snum);
853 bool lp_domain_master(void);
854 bool lp_preferred_master(void);
855 void lp_remove_service(int snum);
856 void lp_copy_service(int snum, const char *new_name);
857 int lp_default_server_announce(void);
858 const char *lp_printername(TALLOC_CTX *ctx, int snum);
859 void lp_set_logfile(const char *name);
860 int lp_maxprintjobs(int snum);
861 const char *lp_printcapname(void);
862 bool lp_disable_spoolss( void );
863 void lp_set_spoolss_state( uint32_t state );
864 uint32_t lp_get_spoolss_state( void );
865 struct smb_signing_state;
866 bool lp_use_sendfile(int snum, struct smb_signing_state *signing_state);
867 void set_use_sendfile(int snum, bool val);
868 void lp_set_mangling_method(const char *new_method);
869 bool lp_posix_pathnames(void);
870 void lp_set_posix_pathnames(void);
871 enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp);
872 void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val);
873 int lp_min_receive_file_size(void);
874 char* lp_perfcount_module(TALLOC_CTX *ctx);
875 void widelinks_warning(int snum);
876 const char *lp_ncalrpc_dir(void);
877 void _lp_set_server_role(int server_role);
879 /* The following definitions come from param/loadparm_ctx.c */
881 const struct loadparm_s3_helpers *loadparm_s3_helpers(void);
883 /* The following definitions come from param/loadparm_server_role.c */
885 int lp_server_role(void);
886 void set_server_role(void);
888 /* The following definitions come from param/util.c */
890 uint32_t get_int_param( const char* param );
891 char* get_string_param( const char* param );
893 /* The following definitions come from lib/server_contexts.c */
894 struct tevent_context *global_event_context(void);
895 void global_event_context_free(void);
896 struct messaging_context *global_messaging_context(void);
897 void global_messaging_context_free(void);
899 /* The following definitions come from lib/sessionid_tdb.c */
901 NTSTATUS sessionid_traverse_read(int (*fn)(const char *key,
902 struct sessionid *session,
906 /* The following definitions come from utils/passwd_util.c */
908 char *stdin_new_passwd( void);
909 char *get_pass( const char *prompt, bool stdin_get);
911 /* The following definitions come from lib/avahi.c */
913 struct AvahiPoll *tevent_avahi_poll(TALLOC_CTX *mem_ctx,
914 struct tevent_context *ev);
916 /* The following definitions come from libsmb/smbsock_connect.c */
918 struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx,
919 struct tevent_context *ev,
920 const struct sockaddr_storage *addr,
922 const char *called_name,
924 const char *calling_name,
926 NTSTATUS smbsock_connect_recv(struct tevent_req *req, int *sock,
928 NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port,
929 const char *called_name, int called_type,
930 const char *calling_name, int calling_type,
931 int *pfd, uint16_t *ret_port, int sec_timeout);
933 struct tevent_req *smbsock_any_connect_send(TALLOC_CTX *mem_ctx,
934 struct tevent_context *ev,
935 const struct sockaddr_storage *addrs,
936 const char **called_names,
938 const char **calling_names,
940 size_t num_addrs, uint16_t port);
941 NTSTATUS smbsock_any_connect_recv(struct tevent_req *req, int *pfd,
942 size_t *chosen_index, uint16_t *chosen_port);
943 NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs,
944 const char **called_names,
946 const char **calling_names,
951 int *pfd, size_t *chosen_index,
952 uint16_t *chosen_port);
954 /* The following definitions come from lib/util_wellknown.c */
956 bool sid_check_is_wellknown_domain(const struct dom_sid *sid, const char **name);
957 bool sid_check_is_in_wellknown_domain(const struct dom_sid *sid);
958 bool lookup_wellknown_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
959 const char **domain, const char **name);
960 bool lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name,
961 struct dom_sid *sid, const char **domain);
963 /* The following definitions come from lib/util_specialsids.c */
964 bool sid_check_is_asserted_identity(const struct dom_sid *sid);
965 bool sid_check_is_in_asserted_identity(const struct dom_sid *sid);
966 const char *asserted_identity_domain_name(void);
968 /* The following definitions come from lib/filename_util.c */
970 NTSTATUS get_full_smb_filename(TALLOC_CTX *ctx, const struct smb_filename *smb_fname,
972 struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx,
973 const char *base_name,
974 const char *stream_name,
975 const SMB_STRUCT_STAT *psbuf,
977 struct smb_filename *synthetic_smb_fname_split(TALLOC_CTX *ctx,
980 const char *smb_fname_str_dbg(const struct smb_filename *smb_fname);
981 const char *fsp_str_dbg(const struct files_struct *fsp);
982 const char *fsp_fnum_dbg(const struct files_struct *fsp);
983 struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx,
984 const struct smb_filename *in);
985 struct smb_filename *cp_smb_filename_nostream(TALLOC_CTX *mem_ctx,
986 const struct smb_filename *in);
987 bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname);
988 bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
989 bool is_named_stream(const struct smb_filename *smb_fname);
990 bool is_invalid_windows_ea_name(const char *name);
991 bool ea_list_has_invalid_name(struct ea_list *ea_list);
992 bool split_stream_filename(TALLOC_CTX *ctx,
993 const char *filename_in,
995 char **streamname_out);
997 /* The following definitions come from lib/dummyroot.c */
999 void become_root(void);
1000 void unbecome_root(void);
1002 /* The following definitions come from lib/smbd_shim.c */
1004 int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out);
1005 void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
1007 NTSTATUS can_delete_directory_fsp(files_struct *fsp);
1008 bool change_to_root_user(void);
1009 bool become_authenticated_pipe_user(struct auth_session_info *session_info);
1010 bool unbecome_authenticated_pipe_user(void);
1012 void contend_level2_oplocks_begin(files_struct *fsp,
1013 enum level2_contention_type type);
1014 void contend_level2_oplocks_end(files_struct *fsp,
1015 enum level2_contention_type type);
1017 /* The following definitions come from lib/per_thread_cwd.c */
1019 void per_thread_cwd_check(void);
1020 bool per_thread_cwd_supported(void);
1021 void per_thread_cwd_disable(void);
1022 void per_thread_cwd_activate(void);
1024 #endif /* _PROTO_H_ */