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 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
,
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
);
65 /* The following definitions come from lib/dmallocmsg.c */
67 void register_dmalloc_msgs(struct messaging_context
*msg_ctx
);
69 /* The following definitions come from lib/dprintf.c */
71 void display_set_stderr(void);
73 /* The following definitions come from lib/errmap_unix.c */
75 NTSTATUS
map_nt_error_from_unix(int unix_error
);
77 /* The following definitions come from lib/file_id.c */
79 struct file_id
vfs_file_id_from_sbuf(connection_struct
*conn
, const SMB_STRUCT_STAT
*sbuf
);
81 NTSTATUS
vfs_at_fspcwd(TALLOC_CTX
*mem_ctx
,
82 struct connection_struct
*conn
,
83 struct files_struct
**_fsp
);
85 #include "source3/lib/interface.h"
87 /* The following definitions come from lib/ldap_debug_handler.c */
89 void init_ldap_debugging(void);
91 /* The following definitions come from lib/ldap_escape.c */
93 char *escape_ldap_string(TALLOC_CTX
*mem_ctx
, const char *s
);
94 char *escape_rdn_val_string_alloc(const char *s
);
96 /* The following definitions come from lib/ms_fnmatch.c */
98 int ms_fnmatch(const char *pattern
, const char *string
, bool translate_pattern
,
99 bool is_case_sensitive
);
101 /* The following definitions come from lib/recvfile.c */
103 ssize_t
sys_recvfile(int fromfd
,
107 ssize_t
sys_recvfile(int fromfd
,
111 ssize_t
drain_socket(int sockfd
, size_t count
);
113 /* The following definitions come from lib/sendfile.c */
115 ssize_t
sys_sendfile(int tofd
, int fromfd
, const DATA_BLOB
*header
, off_t offset
, size_t count
);
117 /* The following definitions come from lib/server_mutex.c */
119 struct named_mutex
*grab_named_mutex(TALLOC_CTX
*mem_ctx
, const char *name
,
122 /* The following definitions come from lib/sharesec.c */
124 NTSTATUS
share_info_db_init(void);
125 struct security_descriptor
*get_share_security( TALLOC_CTX
*ctx
, const char *servicename
,
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
,
134 bool parse_usershare_acl(TALLOC_CTX
*ctx
, const char *acl_str
, struct security_descriptor
**ppsd
);
136 /* The following definitions come from lib/smbrun.c */
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
);
142 /* The following definitions come from lib/sysquotas.c */
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
);
147 /* The following definitions come from lib/sysquotas_*.c */
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
);
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
);
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
);
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
);
165 /* The following definitions come from lib/system.c */
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 int sys_stat(const char *fname
, SMB_STRUCT_STAT
*sbuf
,
177 bool fake_dir_create_times
);
178 int sys_fstat(int fd
, SMB_STRUCT_STAT
*sbuf
,
179 bool fake_dir_create_times
);
180 int sys_lstat(const char *fname
,SMB_STRUCT_STAT
*sbuf
,
181 bool fake_dir_create_times
);
182 int sys_fstatat(int fd
,
183 const char *pathname
,
184 SMB_STRUCT_STAT
*sbuf
,
186 bool fake_dir_create_times
);
187 int sys_posix_fallocate(int fd
, off_t offset
, off_t len
);
188 int sys_fallocate(int fd
, uint32_t mode
, off_t offset
, off_t len
);
189 DIR *sys_fdopendir(int fd
);
190 int sys_mknod(const char *path
, mode_t mode
, SMB_DEV_T dev
);
191 int sys_mknodat(int dirfd
, const char *path
, mode_t mode
, SMB_DEV_T dev
);
192 char *sys_getwd(void);
193 void set_effective_capability(enum smbd_capability capability
);
194 void drop_effective_capability(enum smbd_capability capability
);
195 long sys_random(void);
196 void sys_srandom(unsigned int seed
);
197 int getgroups_max(void);
198 int setgroups_max(void);
199 int sys_getgroups(int setlen
, gid_t
*gidset
);
200 int sys_setgroups(gid_t
UNUSED(primary_gid
), int setlen
, gid_t
*gidset
);
201 uint32_t unix_dev_major(SMB_DEV_T dev
);
202 uint32_t unix_dev_minor(SMB_DEV_T dev
);
203 char *sys_realpath(const char *path
);
205 int sys_get_number_of_cores(void);
208 bool sys_have_proc_fds(void);
209 const char *sys_proc_fd_path(int fd
, char *buf
, size_t bufsize
);
212 void init_stat_ex_from_stat (struct stat_ex
*dst
,
213 const struct stat
*src
,
214 bool fake_dir_create_times
);
216 /* The following definitions come from lib/system_smbd.c */
218 bool getgroups_unix_user(TALLOC_CTX
*mem_ctx
, const char *user
,
220 gid_t
**ret_groups
, uint32_t *p_ngroups
);
222 /* The following definitions come from lib/tallocmsg.c */
224 void register_msg_pool_usage(TALLOC_CTX
*mem_ctx
,
225 struct messaging_context
*msg_ctx
);
227 /* The following definitions come from lib/time.c */
229 void push_dos_date(uint8_t *buf
, int offset
, time_t unixdate
, int zone_offset
);
230 void push_dos_date2(uint8_t *buf
,int offset
,time_t unixdate
, int zone_offset
);
231 void push_dos_date3(uint8_t *buf
,int offset
,time_t unixdate
, int zone_offset
);
232 uint32_t convert_time_t_to_uint32_t(time_t t
);
233 time_t convert_uint32_t_to_time_t(uint32_t u
);
234 bool nt_time_is_zero(const NTTIME
*nt
);
235 time_t generalized_to_unix_time(const char *str
);
236 int get_server_zone_offset(void);
237 int set_server_zone_offset(time_t t
);
238 char *timeval_string(TALLOC_CTX
*ctx
, const struct timeval
*tp
, bool hires
);
239 char *current_timestring(TALLOC_CTX
*ctx
, bool hires
);
240 void srv_put_dos_date(char *buf
,int offset
,time_t unixdate
);
241 void srv_put_dos_date2(char *buf
,int offset
, time_t unixdate
);
242 void srv_put_dos_date3(char *buf
,int offset
,time_t unixdate
);
243 void round_timespec(enum timestamp_set_resolution res
, struct timespec
*ts
);
244 void put_long_date_timespec(enum timestamp_set_resolution res
, char *p
, struct timespec ts
);
245 void put_long_date_full_timespec(enum timestamp_set_resolution res
,
247 const struct timespec
*ts
);
248 struct timespec
pull_long_date_full_timespec(const char *p
);
249 void put_long_date(char *p
, time_t t
);
250 void dos_filetime_timespec(struct timespec
*tsp
);
251 time_t make_unix_date(const void *date_ptr
, int zone_offset
);
252 time_t make_unix_date2(const void *date_ptr
, int zone_offset
);
253 time_t make_unix_date3(const void *date_ptr
, int zone_offset
);
254 time_t srv_make_unix_date(const void *date_ptr
);
255 time_t srv_make_unix_date2(const void *date_ptr
);
256 time_t srv_make_unix_date3(const void *date_ptr
);
257 struct timespec
interpret_long_date(const char *p
);
259 void get_process_uptime(struct timeval
*ret_time
);
260 void get_startup_time(struct timeval
*ret_time
);
261 time_t nt_time_to_unix_abs(const NTTIME
*nt
);
262 void unix_to_nt_time_abs(NTTIME
*nt
, time_t t
);
263 const char *time_to_asc(const time_t t
);
264 const char *display_time(NTTIME nttime
);
265 bool nt_time_is_set(const NTTIME
*nt
);
267 /* The following definitions come from lib/username.c */
269 void flush_pwnam_cache(void);
270 char *get_user_home_dir(TALLOC_CTX
*mem_ctx
, const char *user
);
271 struct passwd
*Get_Pwnam_alloc(TALLOC_CTX
*mem_ctx
, const char *user
);
273 /* The following definitions come from lib/util_names.c */
274 const char *get_global_sam_name(void);
275 const char *my_sam_name(void);
276 bool is_allowed_domain(const char *domain_name
);
278 /* The following definitions come from lib/util.c */
280 enum protocol_types
get_Protocol(void);
281 void set_Protocol(enum protocol_types p
);
282 void gfree_all( void );
283 bool file_exist_stat(const char *fname
,SMB_STRUCT_STAT
*sbuf
,
284 bool fake_dir_create_times
);
285 bool socket_exist(const char *fname
);
286 uint64_t get_file_size_stat(const SMB_STRUCT_STAT
*sbuf
);
287 bool check_same_dev_ino(const SMB_STRUCT_STAT
*sbuf1
,
288 const SMB_STRUCT_STAT
*sbuf2
);
289 bool check_same_stat(const SMB_STRUCT_STAT
*sbuf1
,
290 const SMB_STRUCT_STAT
*sbuf2
);
291 void show_msg(const char *buf
);
292 int set_message_bcc(char *buf
,int num_bytes
);
293 ssize_t
message_push_blob(uint8_t **outbuf
, DATA_BLOB blob
);
294 char *unix_clean_name(TALLOC_CTX
*ctx
, const char *s
);
295 char *clean_name(TALLOC_CTX
*ctx
, const char *s
);
296 ssize_t
write_data_at_offset(int fd
, const char *buffer
, size_t N
, off_t pos
);
297 NTSTATUS
init_before_fork(void);
298 int parent_watch_fd(void);
299 NTSTATUS
reinit_after_fork(struct messaging_context
*msg_ctx
,
300 struct tevent_context
*ev_ctx
,
301 bool parent_longlived
,
302 const char *comment
);
303 NTSTATUS
smbd_reinit_after_fork(struct messaging_context
*msg_ctx
,
304 struct tevent_context
*ev_ctx
,
305 bool parent_longlived
,
306 const char *comment
);
307 void *malloc_(size_t size
);
308 void *Realloc(void *p
, size_t size
, bool free_old_on_error
);
309 void add_to_large_array(TALLOC_CTX
*mem_ctx
, size_t element_size
,
310 void *element
, void *_array
, uint32_t *num_elements
,
311 ssize_t
*array_size
);
312 char *get_myname(TALLOC_CTX
*ctx
);
313 char *get_mydnsdomname(TALLOC_CTX
*ctx
);
314 char *automount_lookup(TALLOC_CTX
*ctx
, const char *user_name
);
315 char *automount_lookup(TALLOC_CTX
*ctx
, const char *user_name
);
316 bool process_exists(const struct server_id pid
);
317 const char *uidtoname(uid_t uid
);
318 char *gidtoname(gid_t gid
);
319 uid_t
nametouid(const char *name
);
320 gid_t
nametogid(const char *name
);
321 void smb_panic_s3(const char *why
);
322 const char *readdirname(DIR *p
);
323 bool is_in_path(const char *name
, name_compare_entry
*namelist
, bool case_sensitive
);
324 void set_namearray(name_compare_entry
**ppname_array
, const char *namelist
);
325 void free_namearray(name_compare_entry
*name_array
);
326 bool fcntl_lock(int fd
, int op
, off_t offset
, off_t count
, int type
);
327 bool fcntl_getlock(int fd
, int op
, off_t
*poffset
, off_t
*pcount
, int *ptype
, pid_t
*ppid
);
328 int map_process_lock_to_ofd_lock(int op
);
329 bool is_myname(const char *s
);
330 void ra_lanman_string( const char *native_lanman
);
331 const char *get_remote_arch_str(void);
332 enum remote_arch_types
get_remote_arch_from_str(const char *remote_arch_string
);
333 void set_remote_arch(enum remote_arch_types type
);
334 enum remote_arch_types
get_remote_arch(void);
335 bool remote_arch_cache_update(const struct GUID
*client_guid
);
336 bool remote_arch_cache_delete(const struct GUID
*client_guid
);
337 const char *tab_depth(int level
, int depth
);
338 int str_checksum(const char *s
);
339 void zero_free(void *p
, size_t size
);
340 int set_maxfiles(int requested_max
);
341 int smb_mkstemp(char *name_template
);
342 void *smb_xmalloc_array(size_t size
, unsigned int count
);
343 char *myhostname(void);
344 char *myhostname_upper(void);
345 #include "lib/util_path.h"
346 bool parent_dirname(TALLOC_CTX
*mem_ctx
, const char *dir
, char **parent
,
348 bool ms_has_wild(const char *s
);
349 bool ms_has_wild_w(const smb_ucs2_t
*s
);
350 bool mask_match(const char *string
, const char *pattern
, bool is_case_sensitive
);
351 bool mask_match_search(const char *string
, const char *pattern
, bool is_case_sensitive
);
352 bool mask_match_list(const char *string
, char **list
, int listLen
, bool is_case_sensitive
);
353 #include "lib/util/unix_match.h"
354 bool name_to_fqdn(fstring fqdn
, const char *name
);
355 uint32_t map_share_mode_to_deny_mode(uint32_t share_access
, uint32_t private_options
);
357 #include "lib/util_procid.h"
359 struct server_id
interpret_pid(const char *pid_string
);
360 bool is_offset_safe(const char *buf_base
, size_t buf_len
, char *ptr
, size_t off
);
361 char *get_safe_ptr(const char *buf_base
, size_t buf_len
, char *ptr
, size_t off
);
362 char *get_safe_str_ptr(const char *buf_base
, size_t buf_len
, char *ptr
, size_t off
);
363 int get_safe_SVAL(const char *buf_base
, size_t buf_len
, char *ptr
, size_t off
, int failval
);
364 int get_safe_IVAL(const char *buf_base
, size_t buf_len
, char *ptr
, size_t off
, int failval
);
365 bool split_domain_user(TALLOC_CTX
*mem_ctx
,
366 const char *full_name
,
369 const char *strip_hostname(const char *s
);
370 bool any_nt_status_not_ok(NTSTATUS err1
, NTSTATUS err2
, NTSTATUS
*result
);
371 int timeval_to_msec(struct timeval t
);
372 char *valid_share_pathname(TALLOC_CTX
*ctx
, const char *dos_pathname
);
373 bool is_executable(const char *fname
);
374 bool map_open_params_to_ntcreate(const char *smb_base_fname
,
375 int deny_mode
, int open_func
,
376 uint32_t *paccess_mask
,
377 uint32_t *pshare_mode
,
378 uint32_t *pcreate_disposition
,
379 uint32_t *pcreate_options
,
380 uint32_t *pprivate_flags
);
381 struct security_unix_token
*copy_unix_token(TALLOC_CTX
*ctx
, const struct security_unix_token
*tok
);
382 struct security_unix_token
*root_unix_token(TALLOC_CTX
*mem_ctx
);
383 char *utok_string(TALLOC_CTX
*mem_ctx
, const struct security_unix_token
*tok
);
384 bool dir_check_ftype(uint32_t mode
, uint32_t dirtype
);
386 /* The following definitions come from lib/util_builtin.c */
388 bool lookup_builtin_rid(TALLOC_CTX
*mem_ctx
, uint32_t rid
, const char **name
);
389 bool lookup_builtin_name(const char *name
, uint32_t *rid
);
390 const char *builtin_domain_name(void);
391 bool sid_check_is_builtin(const struct dom_sid
*sid
);
392 bool sid_check_is_in_builtin(const struct dom_sid
*sid
);
393 bool sid_check_is_wellknown_builtin(const struct dom_sid
*sid
);
395 /* The following definitions come from lib/util_nscd.c */
397 void smb_nscd_flush_user_cache(void);
398 void smb_nscd_flush_group_cache(void);
400 /* The following definitions come from lib/util_nttoken.c */
402 struct security_token
*dup_nt_token(TALLOC_CTX
*mem_ctx
, const struct security_token
*ptoken
);
403 NTSTATUS
merge_nt_token(TALLOC_CTX
*mem_ctx
,
404 const struct security_token
*token_1
,
405 const struct security_token
*token_2
,
406 struct security_token
**token_out
);
407 bool token_sid_in_ace(const struct security_token
*token
, const struct security_ace
*ace
);
409 /* The following definitions come from lib/util_sec.c */
412 uid_t
sec_initial_uid(void);
413 gid_t
sec_initial_gid(void);
414 bool root_mode(void);
415 bool non_root_mode(void);
416 void gain_root_privilege(void);
417 void gain_root_group_privilege(void);
418 void set_effective_uid(uid_t uid
);
419 void set_effective_gid(gid_t gid
);
420 void save_re_uid(void);
421 void restore_re_uid_fromroot(void);
422 void restore_re_uid(void);
423 void save_re_gid(void);
424 void restore_re_gid(void);
425 int set_re_uid(void);
426 void become_user_permanently(uid_t uid
, gid_t gid
);
427 int set_thread_credentials(uid_t uid
,
430 const gid_t
*gidset
);
431 bool is_setuid_root(void) ;
433 /* The following definitions come from lib/util_sid.c */
435 char *sid_to_fstring(fstring sidstr_out
, const struct dom_sid
*sid
);
436 bool sid_linearize(uint8_t *outbuf
, size_t len
, const struct dom_sid
*sid
);
437 bool non_mappable_sid(struct dom_sid
*sid
);
438 char *sid_binstring_hex_talloc(TALLOC_CTX
*mem_ctx
, const struct dom_sid
*sid
);
439 struct netr_SamInfo3
;
440 NTSTATUS
sid_array_from_info3(TALLOC_CTX
*mem_ctx
,
441 const struct netr_SamInfo3
*info3
,
442 struct dom_sid
**user_sids
,
443 uint32_t *num_user_sids
,
444 bool include_user_group_rid
);
446 /* The following definitions come from lib/util_sock.c */
448 bool is_broadcast_addr(const struct sockaddr
*pss
);
449 bool is_loopback_ip_v4(struct in_addr ip
);
450 bool is_loopback_addr(const struct sockaddr
*pss
);
451 bool is_zero_addr(const struct sockaddr_storage
*pss
);
452 void zero_ip_v4(struct in_addr
*ip
);
453 void in_addr_to_sockaddr_storage(struct sockaddr_storage
*ss
,
455 bool same_net(const struct sockaddr
*ip1
,
456 const struct sockaddr
*ip2
,
457 const struct sockaddr
*mask
);
458 bool sockaddr_equal(const struct sockaddr
*ip1
,
459 const struct sockaddr
*ip2
);
460 bool is_address_any(const struct sockaddr
*psa
);
461 uint16_t get_sockaddr_port(const struct sockaddr_storage
*pss
);
462 char *print_sockaddr(char *dest
,
464 const struct sockaddr_storage
*psa
);
465 char *print_canonical_sockaddr(TALLOC_CTX
*ctx
,
466 const struct sockaddr_storage
*pss
);
467 bool is_a_socket(int fd
);
468 void set_socket_options(int fd
, const char *options
);
469 NTSTATUS
read_fd_with_timeout(int fd
, char *buf
,
470 size_t mincnt
, size_t maxcnt
,
471 unsigned int time_out
,
473 NTSTATUS
read_data_ntstatus(int fd
, char *buffer
, size_t N
);
475 NTSTATUS
read_smb_length_return_keepalive(int fd
, char *inbuf
,
476 unsigned int timeout
,
478 NTSTATUS
receive_smb_raw(int fd
,
481 unsigned int timeout
,
486 const struct sockaddr_storage
*paddr
,
489 NTSTATUS
open_socket_out(const struct sockaddr_storage
*pss
, uint16_t port
,
490 int timeout
, int *pfd
);
491 struct tevent_req
*open_socket_out_send(TALLOC_CTX
*mem_ctx
,
492 struct tevent_context
*ev
,
493 const struct sockaddr_storage
*pss
,
496 NTSTATUS
open_socket_out_recv(struct tevent_req
*req
, int *pfd
);
497 struct tevent_req
*open_socket_out_defer_send(TALLOC_CTX
*mem_ctx
,
498 struct tevent_context
*ev
,
499 struct timeval wait_time
,
500 const struct sockaddr_storage
*pss
,
503 NTSTATUS
open_socket_out_defer_recv(struct tevent_req
*req
, int *pfd
);
504 const char *get_peer_addr(int fd
, char *addr
, size_t addr_len
);
506 struct tsocket_address
;
508 int get_remote_hostname(const struct tsocket_address
*remote_address
,
510 TALLOC_CTX
*mem_ctx
);
512 int create_pipe_sock(const char *socket_dir
,
513 const char *socket_name
,
515 const char *get_mydnsfullname(void);
516 bool is_myname_or_ipaddr(const char *s
);
517 int poll_one_fd(int fd
, int events
, int timeout
, int *revents
);
518 int poll_intr_one_fd(int fd
, int events
, int timeout
, int *revents
);
520 /* The following definitions come from lib/util_str.c */
522 bool next_token(const char **ptr
, char *buff
, const char *sep
, size_t bufsize
);
523 bool strnequal(const char *s1
,const char *s2
,size_t n
);
524 bool strcsequal(const char *s1
,const char *s2
);
525 char *skip_string(const char *base
, size_t len
, char *buf
);
526 size_t str_charnum(const char *s
);
527 bool trim_char(char *s
,char cfront
,char cback
);
528 bool strhasupper(const char *s
);
529 bool strhaslower(const char *s
);
530 bool in_list(const char *s
, const char *list
, bool casesensitive
);
531 void fstring_sub(char *s
,const char *pattern
,const char *insert
);
532 char *realloc_string_sub2(char *string
,
535 bool remove_unsafe_characters
,
536 bool allow_trailing_dollar
);
537 char *realloc_string_sub(char *string
,
540 void all_string_sub(char *s
,const char *pattern
,const char *insert
, size_t len
);
541 char *octal_string(int i
);
542 char *string_truncate(char *s
, unsigned int length
);
543 char *strchr_m(const char *src
, char c
);
544 char *strrchr_m(const char *s
, char c
);
545 char *strnrchr_m(const char *s
, char c
, unsigned int n
);
546 char *strstr_m(const char *src
, const char *findstr
);
547 bool strlower_m(char *s
);
548 bool strupper_m(char *s
);
549 size_t strlen_m(const char *s
);
550 size_t strlen_m_term(const char *s
);
551 size_t strlen_m_term_null(const char *s
);
552 int fstr_sprintf(fstring s
, const char *fmt
, ...);
554 uint64_t STR_TO_SMB_BIG_UINT(const char *nptr
, const char **entptr
);
555 uint64_t conv_str_size(const char * str
);
556 char *talloc_asprintf_strupper_m(TALLOC_CTX
*t
, const char *fmt
, ...)
557 PRINTF_ATTRIBUTE(2,3);
558 char *talloc_asprintf_strlower_m(TALLOC_CTX
*t
, const char *fmt
, ...)
559 PRINTF_ATTRIBUTE(2,3);
560 bool validate_net_name( const char *name
,
561 const char *invalid_chars
,
563 char *escape_shell_string(const char *src
);
564 ssize_t
full_path_tos(const char *dir
, const char *name
,
565 char *tmpbuf
, size_t tmpbuf_len
,
566 char **pdst
, char **to_free
);
568 /* The following definitions come from lib/version.c */
570 const char *samba_version_string(void);
572 /* The following definitions come from lib/wins_srv.c */
574 bool wins_srv_is_dead(struct in_addr wins_ip
, struct in_addr src_ip
);
575 void wins_srv_alive(struct in_addr wins_ip
, struct in_addr src_ip
);
576 void wins_srv_died(struct in_addr wins_ip
, struct in_addr src_ip
);
577 unsigned wins_srv_count(void);
578 char **wins_srv_tags(void);
579 void wins_srv_tags_free(char **list
);
580 struct in_addr
wins_srv_ip_tag(const char *tag
, struct in_addr src_ip
);
581 bool wins_server_tag_ips(const char *tag
, TALLOC_CTX
*mem_ctx
,
582 struct in_addr
**pservers
, size_t *pnum_servers
);
583 unsigned wins_srv_count_tag(const char *tag
);
585 #ifndef ASN1_MAX_OIDS
586 #define ASN1_MAX_OIDS 20
588 bool spnego_parse_negTokenInit(TALLOC_CTX
*ctx
,
590 char *OIDs
[ASN1_MAX_OIDS
],
593 DATA_BLOB
spnego_gen_krb5_wrap(TALLOC_CTX
*ctx
, const DATA_BLOB ticket
, const uint8_t tok_id
[2]);
595 /* The following definitions come from libsmb/conncache.c */
597 NTSTATUS
check_negative_conn_cache( const char *domain
, const char *server
);
598 void add_failed_connection_entry(const char *domain
, const char *server
, NTSTATUS result
) ;
599 void flush_negative_conn_cache_for_domain(const char *domain
);
601 /* The following definitions come from libsmb/errormap.c */
603 NTSTATUS
dos_to_ntstatus(uint8_t eclass
, uint32_t ecode
);
605 /* The following definitions come from libsmb/namecache.c */
607 bool namecache_store(const char *name
,
610 struct samba_sockaddr
*sa_list
);
611 bool namecache_fetch(TALLOC_CTX
*ctx
,
614 struct samba_sockaddr
**sa_list
,
616 bool namecache_delete(const char *name
, int name_type
);
617 void namecache_flush(void);
618 bool namecache_status_store(const char *keyname
, int keyname_type
,
619 int name_type
, const struct sockaddr_storage
*keyip
,
620 const char *srvname
);
621 bool namecache_status_fetch(const char *keyname
,
624 const struct sockaddr_storage
*keyip
,
627 /* The following definitions come from libsmb/namequery_dc.c */
629 bool get_dc_name(const char *domain
,
632 struct sockaddr_storage
*ss_out
);
634 /* The following definitions come from libsmb/smberr.c */
636 const char *smb_dos_err_name(uint8_t e_class
, uint16_t num
);
637 const char *get_dos_error_msg(WERROR result
);
638 const char *smb_dos_err_class(uint8_t e_class
);
639 WERROR
map_werror_from_unix(int error
);
641 /* The following definitions come from libsmb/trusts_util.c */
643 struct netlogon_creds_cli_context
;
644 struct messaging_context
;
645 struct dcerpc_binding_handle
;
646 char *trust_pw_new_value(TALLOC_CTX
*mem_ctx
,
647 enum netr_SchannelType sec_channel_type
,
649 NTSTATUS
trust_pw_change(struct netlogon_creds_cli_context
*context
,
650 struct messaging_context
*msg_ctx
,
651 struct dcerpc_binding_handle
*b
,
656 /* The following definitions come from lib/sessionid_tdb.c */
658 NTSTATUS
sessionid_traverse_read(int (*fn
)(const char *key
,
659 struct sessionid
*session
,
663 /* The following definitions come from lib/avahi.c */
665 struct AvahiPoll
*tevent_avahi_poll(TALLOC_CTX
*mem_ctx
,
666 struct tevent_context
*ev
);
668 /* The following definitions come from libsmb/smbsock_connect.c */
670 struct tevent_req
*smbsock_connect_send(TALLOC_CTX
*mem_ctx
,
671 struct tevent_context
*ev
,
672 const struct sockaddr_storage
*addr
,
674 const char *called_name
,
676 const char *calling_name
,
678 NTSTATUS
smbsock_connect_recv(struct tevent_req
*req
, int *sock
,
680 NTSTATUS
smbsock_connect(const struct sockaddr_storage
*addr
, uint16_t port
,
681 const char *called_name
, int called_type
,
682 const char *calling_name
, int calling_type
,
683 int *pfd
, uint16_t *ret_port
, int sec_timeout
);
685 struct tevent_req
*smbsock_any_connect_send(TALLOC_CTX
*mem_ctx
,
686 struct tevent_context
*ev
,
687 const struct sockaddr_storage
*addrs
,
688 const char **called_names
,
690 const char **calling_names
,
692 size_t num_addrs
, uint16_t port
);
693 NTSTATUS
smbsock_any_connect_recv(struct tevent_req
*req
, int *pfd
,
694 size_t *chosen_index
, uint16_t *chosen_port
);
695 NTSTATUS
smbsock_any_connect(const struct sockaddr_storage
*addrs
,
696 const char **called_names
,
698 const char **calling_names
,
703 int *pfd
, size_t *chosen_index
,
704 uint16_t *chosen_port
);
706 /* The following definitions come from lib/util_wellknown.c */
708 bool sid_check_is_wellknown_domain(const struct dom_sid
*sid
, const char **name
);
709 bool sid_check_is_in_wellknown_domain(const struct dom_sid
*sid
);
710 bool lookup_wellknown_sid(TALLOC_CTX
*mem_ctx
, const struct dom_sid
*sid
,
711 const char **domain
, const char **name
);
712 bool lookup_wellknown_name(TALLOC_CTX
*mem_ctx
, const char *name
,
713 struct dom_sid
*sid
, const char **domain
);
715 /* The following definitions come from lib/filename_util.c */
717 NTSTATUS
get_full_smb_filename(TALLOC_CTX
*ctx
, const struct smb_filename
*smb_fname
,
719 struct smb_filename
*synthetic_smb_fname(TALLOC_CTX
*mem_ctx
,
720 const char *base_name
,
721 const char *stream_name
,
722 const SMB_STRUCT_STAT
*psbuf
,
725 NTSTATUS
filename_convert_dirfsp(
727 connection_struct
*conn
,
731 struct files_struct
**pdirfsp
,
732 struct smb_filename
**psmb_name_rel
);
733 struct smb_filename
*full_path_from_dirfsp_atname(
735 const struct files_struct
*dirfsp
,
736 const struct smb_filename
*atname
);
737 struct smb_filename
*synthetic_smb_fname_split(TALLOC_CTX
*ctx
,
740 const char *smb_fname_str_dbg(const struct smb_filename
*smb_fname
);
741 const char *fsp_str_dbg(const struct files_struct
*fsp
);
742 const char *fsp_fnum_dbg(const struct files_struct
*fsp
);
743 struct smb_filename
*cp_smb_filename(TALLOC_CTX
*mem_ctx
,
744 const struct smb_filename
*in
);
745 struct smb_filename
*cp_smb_filename_nostream(TALLOC_CTX
*mem_ctx
,
746 const struct smb_filename
*in
);
747 bool is_ntfs_stream_smb_fname(const struct smb_filename
*smb_fname
);
748 bool is_ntfs_default_stream_smb_fname(const struct smb_filename
*smb_fname
);
749 bool is_named_stream(const struct smb_filename
*smb_fname
);
750 bool is_invalid_windows_ea_name(const char *name
);
751 bool ea_list_has_invalid_name(struct ea_list
*ea_list
);
752 bool split_stream_filename(TALLOC_CTX
*ctx
,
753 const char *filename_in
,
755 char **streamname_out
);
757 /* The following definitions come from lib/dummyroot.c */
759 void become_root(void);
760 void unbecome_root(void);
762 /* The following definitions come from lib/smbd_shim.c */
764 int find_service(TALLOC_CTX
*ctx
, const char *service_in
, char **p_service_out
);
765 void send_stat_cache_delete_message(struct messaging_context
*msg_ctx
,
767 NTSTATUS
can_delete_directory_fsp(files_struct
*fsp
);
768 bool change_to_root_user(void);
769 bool become_authenticated_pipe_user(struct auth_session_info
*session_info
);
770 bool unbecome_authenticated_pipe_user(void);
772 void contend_level2_oplocks_begin(files_struct
*fsp
,
773 enum level2_contention_type type
);
774 void contend_level2_oplocks_end(files_struct
*fsp
,
775 enum level2_contention_type type
);
777 /* The following definitions come from lib/per_thread_cwd.c */
779 void per_thread_cwd_check(void);
780 bool per_thread_cwd_supported(void);
781 void per_thread_cwd_disable(void);
782 void per_thread_cwd_activate(void);
784 #endif /* _PROTO_H_ */