From 95c9e4e0ba8f37f565aaf136f41eb76489441ff7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 10 Mar 2001 11:35:25 +0000 Subject: to use the same macros in the client and server rename the CLISTR_ macros to STR_ --- source/include/client.h | 7 - source/include/proto.h | 1578 ++++++++++++++++++++++---------------------- source/include/smb.h | 8 + source/libsmb/cliconnect.c | 24 +- source/libsmb/clifile.c | 22 +- source/libsmb/clilist.c | 32 +- source/libsmb/climessage.c | 4 +- source/libsmb/clirap.c | 6 +- source/libsmb/clistr.c | 56 +- source/libsmb/clitrans.c | 4 +- 10 files changed, 876 insertions(+), 865 deletions(-) (limited to 'source') diff --git a/source/include/client.h b/source/include/client.h index ddfc65db32e..bdc2383f8ef 100644 --- a/source/include/client.h +++ b/source/include/client.h @@ -30,13 +30,6 @@ #define CLI_BUFFER_SIZE (0xFFFF) -/* clistr flags - see clistr.c */ -#define CLISTR_TERMINATE 1 -#define CLISTR_CONVERT 2 -#define CLISTR_UPPER 4 -#define CLISTR_ASCII 8 -#define CLISTR_UNICODE 16 - /* * These definitions depend on smb.h */ diff --git a/source/include/proto.h b/source/include/proto.h index a532830ce1f..3a889ef7e9d 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -218,502 +218,93 @@ void CatchChildLeaveStatus(void); int vslprintf(char *str, int n, char *format, va_list ap); -/*The following definitions come from lib/smbrun.c */ - -int smbrun(char *cmd,char *outfile,BOOL shared); - -/*The following definitions come from lib/snprintf.c */ - - -/*The following definitions come from lib/substitute.c */ - -void standard_sub_basic(char *str); -void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, char *str); -void standard_sub_conn(connection_struct *conn, char *str); -void standard_sub_snum(int snum, char *str); -void standard_sub_vuser(char *str, user_struct *vuser); -void standard_sub_vsnum(char *str, user_struct *vuser, int snum); - -/*The following definitions come from lib/sysacls.c */ - -int sys_acl_get_entry( SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p); -int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p); -int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p); -void *sys_acl_get_qualifier( SMB_ACL_ENTRY_T entry_d); -SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type); -SMB_ACL_T sys_acl_get_fd(int fd); -int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset); -int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm); -int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm); -char *sys_acl_to_text( SMB_ACL_T the_acl, ssize_t *plen); -SMB_ACL_T sys_acl_init( int count); -int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry); -int sys_acl_set_tag_type( SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype); -int sys_acl_set_qualifier( SMB_ACL_ENTRY_T entry, void *qual); -int sys_acl_set_permset( SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset); -int sys_acl_valid( SMB_ACL_T theacl ); -int sys_acl_set_file( char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl); -int sys_acl_set_fd( int fd, SMB_ACL_T theacl); -int sys_acl_free_text(char *text); -int sys_acl_free_acl(SMB_ACL_T the_acl) ; -int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p); -int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p); -int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p); -void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d); -SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type); -SMB_ACL_T sys_acl_get_fd(int fd); -int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d); -int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); -int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); -char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p); -SMB_ACL_T sys_acl_init(int count); -int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p); -int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type); -int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p); -int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d); -int sys_acl_valid(SMB_ACL_T acl_d); -int sys_acl_set_file(char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d); -int sys_acl_set_fd(int fd, SMB_ACL_T acl_d); -int sys_acl_free_text(char *text); -int sys_acl_free_acl(SMB_ACL_T acl_d) ; -int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p); -int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p); -int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p); -void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d); -SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type); -SMB_ACL_T sys_acl_get_fd(int fd); -int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d); -int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); -int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); -char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p); -SMB_ACL_T sys_acl_init(int count); -int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p); -int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type); -int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p); -int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d); -int sys_acl_valid(SMB_ACL_T acl_d); -int sys_acl_set_file(char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d); -int sys_acl_set_fd(int fd, SMB_ACL_T acl_d); -int sys_acl_free_text(char *text); -int sys_acl_free_acl(SMB_ACL_T acl_d) ; -int sys_acl_get_entry( SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p); -int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p); -int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p); -void *sys_acl_get_qualifier( SMB_ACL_ENTRY_T entry_d); -SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type); -SMB_ACL_T sys_acl_get_fd(int fd); -int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset); -int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm); -int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm); -char *sys_acl_to_text( SMB_ACL_T the_acl, ssize_t *plen); -int sys_acl_free_text(char *text); -SMB_ACL_T sys_acl_init( int count); -int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry); -int sys_acl_set_tag_type( SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype); -int sys_acl_set_qualifier( SMB_ACL_ENTRY_T entry, void *qual); -int sys_acl_set_permset( SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset); -int sys_acl_valid( SMB_ACL_T theacl ); -int sys_acl_set_file( char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl); -int sys_acl_set_fd( int fd, SMB_ACL_T theacl); -int sys_acl_free_acl(SMB_ACL_T the_acl) ; - -/*The following definitions come from lib/system.c */ - -int sys_usleep(long usecs); -int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf); -int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf); -int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf); -int sys_ftruncate(int fd, SMB_OFF_T offset); -SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence); -int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence); -SMB_OFF_T sys_ftell(FILE *fp); -int sys_creat(const char *path, mode_t mode); -int sys_open(const char *path, int oflag, mode_t mode); -FILE *sys_fopen(const char *path, const char *type); -SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp); -int sys_waitpid(pid_t pid,int *status,int options); -char *sys_getwd(char *s); -int sys_chown(const char *fname,uid_t uid,gid_t gid); -int sys_chroot(const char *dname); -struct hostent *sys_gethostbyname(const char *name); -void oplock_set_capability(BOOL this_process, BOOL inherit); -long sys_random(void); -void sys_srandom(unsigned int seed); -int groups_max(void); -int sys_getgroups(int setlen, gid_t *gidset); -int sys_setgroups(int setlen, gid_t *gidset); -void sys_setpwent(void); -struct passwd *sys_getpwent(void); -void sys_endpwent(void); -struct passwd *sys_getpwnam(const char *name); -struct passwd *sys_getpwuid(uid_t uid); -int wsys_stat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf); -int wsys_lstat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf); -int wsys_creat(const smb_ucs2_t *wfname, mode_t mode); -int wsys_open(const smb_ucs2_t *wfname, int oflag, mode_t mode); -FILE *wsys_fopen(const smb_ucs2_t *wfname, const char *type); -DIR *wsys_opendir(const smb_ucs2_t *wfname); -smb_ucs2_t *wsys_getwd(smb_ucs2_t *s); -int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid); -int wsys_chroot(const smb_ucs2_t *wfname); -pid_t sys_fork(void); -pid_t sys_getpid(void); -int sys_popen(const char *command); -int sys_pclose(int fd); - -/*The following definitions come from lib/talloc.c */ - -TALLOC_CTX *talloc_init(void); -void *talloc(TALLOC_CTX *t, size_t size); -void talloc_destroy_pool(TALLOC_CTX *t); -void talloc_destroy(TALLOC_CTX *t); -size_t talloc_pool_size(TALLOC_CTX *t); -void *talloc_zero(TALLOC_CTX *t, size_t size); -void *talloc_memdup(TALLOC_CTX *t, void *p, size_t size); - -/*The following definitions come from lib/time.c */ - -void GetTimeOfDay(struct timeval *tval); -void TimeInit(void); -int TimeDiff(time_t t); -struct tm *LocalTime(time_t *t); -time_t nt_time_to_unix(NTTIME *nt); -time_t interpret_long_date(char *p); -void unix_to_nt_time(NTTIME *nt, time_t t); -void put_long_date(char *p,time_t t); -BOOL null_mtime(time_t mtime); -void put_dos_date(char *buf,int offset,time_t unixdate); -void put_dos_date2(char *buf,int offset,time_t unixdate); -void put_dos_date3(char *buf,int offset,time_t unixdate); -time_t make_unix_date(void *date_ptr); -time_t make_unix_date2(void *date_ptr); -time_t make_unix_date3(void *date_ptr); -char *http_timestring(time_t t); -char *timestring(BOOL hires); -time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs); - -/*The following definitions come from lib/ufc.c */ - -char *ufc_crypt(char *key,char *salt); - -/*The following definitions come from lib/username.c */ - -char *get_user_home_dir(char *user); -BOOL map_username(char *user); -struct passwd *Get_Pwnam(char *user,BOOL allow_change); -BOOL user_in_group_list(char *user,char *gname); -BOOL user_in_list(char *user,char *list); -struct passwd *smb_getpwnam(char *user, BOOL allow_change); - -/*The following definitions come from lib/util.c */ - -char *tmpdir(void); -BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups); -char *Atoic(char *p, int *n, char *c); -char *get_numlist(char *p, uint32 **num, int *count); -BOOL file_exist(char *fname,SMB_STRUCT_STAT *sbuf); -int file_rename(char *from, char *to); -time_t file_modtime(char *fname); -BOOL directory_exist(char *dname,SMB_STRUCT_STAT *st); -SMB_OFF_T get_file_size(char *file_name); -char *attrib_string(uint16 mode); -void show_msg(char *buf); -void smb_setlen(char *buf,int len); -int set_message(char *buf,int num_words,int num_bytes,BOOL zero); -void set_message_bcc(char *buf,int num_bytes); -void dos_clean_name(char *s); -void unix_clean_name(char *s); -void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date); -void close_low_fds(void); -int set_blocking(int fd, BOOL set); -SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n,char *header,int headlen,int align); -void msleep(int t); -void become_daemon(void); -BOOL yesno(char *p); -void *Realloc(void *p,size_t size); -void safe_free(void *p); -BOOL get_myname(char *my_name); -int interpret_protocol(char *str,int def); -BOOL is_ipaddress(const char *str); -uint32 interpret_addr(char *str); -struct in_addr *interpret_addr2(char *str); -BOOL zero_ip(struct in_addr ip); -BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask); -struct hostent *Get_Hostbyname(const char *name); -BOOL process_exists(pid_t pid); -char *uidtoname(uid_t uid); -char *gidtoname(gid_t gid); -uid_t nametouid(char *name); -gid_t nametogid(char *name); -void smb_panic(char *why); -char *readdirname(DIR *p); -BOOL is_in_path(char *name, name_compare_entry *namelist); -void set_namearray(name_compare_entry **ppname_array, char *namelist); -void free_namearray(name_compare_entry *name_array); -BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); -BOOL is_myname(char *s); -void set_remote_arch(enum remote_arch_types type); -enum remote_arch_types get_remote_arch(void); -void out_ascii(FILE *f, unsigned char *buf,int len); -void out_data(FILE *f,char *buf1,int len, int per_line); -void print_asc(int level, unsigned char *buf,int len); -void dump_data(int level,char *buf1,int len); -char *tab_depth(int depth); -int str_checksum(const char *s); -void zero_free(void *p, size_t size); -int set_maxfiles(int requested_max); -BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name); -char *smbd_mktemp(char *template); -void *memdup(void *p, size_t size); -char *myhostname(void); -char *lock_path(char *name); -char *parent_dirname(const char *path); -BOOL ms_has_wild(char *s); -BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive); -int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6); - -/*The following definitions come from lib/util_array.c */ - -void free_void_array(uint32 num_entries, void **entries, - void(free_item)(void*)); -void* add_copy_to_array(uint32 *len, void ***array, const void *item, - void*(item_dup)(const void*), BOOL alloc_anyway); -void* add_item_to_array(uint32 *len, void ***array, void *item); -void free_use_info_array(uint32 num_entries, struct use_info **entries); -struct use_info* add_use_info_to_array(uint32 *len, struct use_info ***array, - const struct use_info *name); -void free_char_array(uint32 num_entries, char **entries); -char* add_chars_to_array(uint32 *len, char ***array, const char *name); -void free_uint32_array(uint32 num_entries, uint32 **entries); -uint32* add_uint32s_to_array(uint32 *len, uint32 ***array, const uint32 *name); -void free_sid_array(uint32 num_entries, DOM_SID **entries); -DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid); - -/*The following definitions come from lib/util_file.c */ - -BOOL do_file_lock(int fd, int waitsecs, int type); -BOOL file_lock(int fd, int type, int secs, int *plock_depth); -BOOL file_unlock(int fd, int *plock_depth); -void *startfilepwent(char *pfile, char *s_readbuf, int bufsize, - int *file_lock_depth, BOOL update); -void endfilepwent(void *vp, int *file_lock_depth); -SMB_BIG_UINT getfilepwpos(void *vp); -BOOL setfilepwpos(void *vp, SMB_BIG_UINT tok); -int getfileline(void *vp, char *linebuf, int linebuf_size); -char *fgets_slash(char *s2,int maxlen,FILE *f); -char *file_pload(char *syscmd, size_t *size); -char *file_load(char *fname, size_t *size); -char **file_lines_load(char *fname, int *numlines, BOOL convert); -char **file_lines_pload(char *syscmd, int *numlines, BOOL convert); -void file_lines_free(char **lines); -void file_lines_slashcont(char **lines); - -/*The following definitions come from lib/util_list.c */ - -BOOL copy_policy_hnd (POLICY_HND *dest, const POLICY_HND *src); -BOOL compare_rpc_hnd_node(const RPC_HND_NODE *x, - const RPC_HND_NODE *y); -BOOL RpcHndList_set_connection(const POLICY_HND *hnd, - struct cli_connection *con); -BOOL RpcHndList_del_connection(const POLICY_HND *hnd); -struct cli_connection* RpcHndList_get_connection(const POLICY_HND *hnd); - -/*The following definitions come from lib/util_seaccess.c */ - -void se_map_generic(uint32 *access_mask, struct generic_mapping *mapping); -BOOL se_access_check(SEC_DESC *sd, struct current_user *user, - uint32 acc_desired, uint32 *acc_granted, uint32 *status); -SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr, - BOOL child_container); - -/*The following definitions come from lib/util_sec.c */ +/*The following definitions come from libsmb/cliconnect.c */ -void gain_root_privilege(void); -void gain_root_group_privilege(void); -void set_effective_uid(uid_t uid); -void set_effective_gid(gid_t gid); -void save_re_uid(void); -void restore_re_uid(void); -int set_re_uid(void); -void become_user_permanently(uid_t uid, gid_t gid); +BOOL cli_session_setup(struct cli_state *cli, + char *user, + char *pass, int passlen, + char *ntpass, int ntpasslen, + char *workgroup); +BOOL cli_ulogoff(struct cli_state *cli); +BOOL cli_send_tconX(struct cli_state *cli, + char *share, char *dev, char *pass, int passlen); +BOOL cli_tdis(struct cli_state *cli); +void cli_negprot_send(struct cli_state *cli); +BOOL cli_negprot(struct cli_state *cli); +BOOL cli_session_request(struct cli_state *cli, + struct nmb_name *calling, struct nmb_name *called); +BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip); +BOOL cli_reestablish_connection(struct cli_state *cli); +BOOL cli_establish_connection(struct cli_state *cli, + char *dest_host, struct in_addr *dest_ip, + struct nmb_name *calling, struct nmb_name *called, + char *service, char *service_type, + BOOL do_shutdown, BOOL do_tcon); +BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost, + struct in_addr *pdest_ip); -/*The following definitions come from lib/util_sid.c */ +/*The following definitions come from libsmb/clidgram.c */ -void generate_wellknown_sids(void); -BOOL map_domain_sid_to_name(DOM_SID *sid, char *nt_domain); -BOOL lookup_known_rid(DOM_SID *sid, uint32 rid, char *name, enum SID_NAME_USE *psid_name_use); -BOOL map_domain_name_to_sid(DOM_SID *sid, char *nt_domain); -void split_domain_name(const char *fullname, char *domain, char *name); -char *sid_to_string(fstring sidstr_out, DOM_SID *sid); -BOOL string_to_sid(DOM_SID *sidout, char *sidstr); -BOOL sid_append_rid(DOM_SID *sid, uint32 rid); -BOOL sid_split_rid(DOM_SID *sid, uint32 *rid); -void sid_copy(DOM_SID *dst, const DOM_SID *src); -DOM_SID *sid_dup(DOM_SID *src); -BOOL sid_linearize(char *outbuf, size_t len, DOM_SID *sid); -int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2); -BOOL sid_equal(const DOM_SID *sid1, const DOM_SID *sid2); -size_t sid_size(DOM_SID *sid); +int cli_send_mailslot(int dgram_sock, BOOL unique, char *mailslot, + char *buf, int len, + const char *srcname, int src_type, + const char *dstname, int dest_type, + struct in_addr dest_ip, struct in_addr src_ip, + int dest_port, int src_port); +int cli_get_response(int dgram_sock, BOOL unique, char *mailslot, char *buf, int bufsiz); +int cli_get_backup_list(const char *myname, const char *send_to_name); +int cli_get_backup_server(char *my_name, char *target, char *servername, int namesize); -/*The following definitions come from lib/util_sock.c */ +/*The following definitions come from libsmb/clientgen.c */ -BOOL is_a_socket(int fd); -void set_socket_options(int fd, char *options); -ssize_t read_udp_socket(int fd,char *buf,size_t len); -ssize_t read_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out); -BOOL send_keepalive(int client); -ssize_t read_data(int fd,char *buffer,size_t N); -ssize_t write_data(int fd,char *buffer,size_t N); -ssize_t write_socket_data(int fd,char *buffer,size_t N); -ssize_t write_socket(int fd,char *buf,size_t len); -ssize_t read_smb_length(int fd,char *inbuf,unsigned int timeout); -BOOL receive_smb(int fd,char *buffer, unsigned int timeout); -BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout); -BOOL send_null_session_msg(int fd); -BOOL send_smb(int fd,char *buffer); -BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type); -int open_socket_in(int type, int port, int dlevel,uint32 socket_addr, BOOL rebind); -int open_socket_out(int type, struct in_addr *addr, int port ,int timeout); -void reset_globals_after_fork(void); -void client_setfd(int fd); -char *client_name(void); -char *client_addr(void); -char *get_socket_name(int fd); -char *get_socket_addr(int fd); -int open_pipe_sock(char *path); -int create_pipe_socket(char *dir, int dir_perms, - char *path, int path_perms); +int cli_set_port(struct cli_state *cli, int port); +BOOL cli_receive_smb(struct cli_state *cli); +BOOL cli_send_smb(struct cli_state *cli); +void cli_setup_packet(struct cli_state *cli); +void cli_setup_bcc(struct cli_state *cli, void *p); +void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); +struct cli_state *cli_initialise(struct cli_state *cli); +void cli_shutdown(struct cli_state *cli); +void cli_sockopt(struct cli_state *cli, char *options); +uint16 cli_setpid(struct cli_state *cli, uint16 pid); -/*The following definitions come from lib/util_str.c */ +/*The following definitions come from libsmb/clierror.c */ -void set_first_token(char *ptr); -BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize); -char **toktocliplist(int *ctok, char *sep); -int StrCaseCmp(const char *s, const char *t); -int StrnCaseCmp(const char *s, const char *t, size_t n); -BOOL strequal(const char *s1, const char *s2); -BOOL strnequal(const char *s1,const char *s2,size_t n); -BOOL strcsequal(const char *s1,const char *s2); -int strwicmp(char *psz1, char *psz2); -void strlower(char *s); -void strupper(char *s); -void strnorm(char *s); -BOOL strisnormal(char *s); -void string_replace(char *s,char oldc,char newc); -char *skip_string(char *buf,size_t n); -size_t str_charnum(const char *s); -BOOL trim_string(char *s,const char *front,const char *back); -BOOL strhasupper(const char *s); -BOOL strhaslower(const char *s); -size_t count_chars(const char *s,char c); -BOOL str_is_all(const char *s,char c); -char *safe_strcpy(char *dest,const char *src, size_t maxlength); -char *safe_strcat(char *dest, const char *src, size_t maxlength); -char *alpha_strcpy(char *dest, const char *src, size_t maxlength); -char *StrnCpy(char *dest,const char *src,size_t n); -char *strncpyn(char *dest, const char *src,size_t n, char c); -size_t strhex_to_str(char *p, size_t len, const char *strhex); -BOOL in_list(char *s,char *list,BOOL casesensitive); -void string_free(char **s); -BOOL string_set(char **dest,const char *src); -void string_sub(char *s,const char *pattern,const char *insert, size_t len); -void fstring_sub(char *s,const char *pattern,const char *insert); -void pstring_sub(char *s,const char *pattern,const char *insert); -void all_string_sub(char *s,const char *pattern,const char *insert, size_t len); -void split_at_last_component(char *path, char *front, char sep, char *back); -char *octal_string(int i); -char *string_truncate(char *s, int length); -void parse_domain_user(char *domuser, fstring domain, fstring user); +char *cli_errstr(struct cli_state *cli); +int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error); -/*The following definitions come from lib/util_unistr.c */ +/*The following definitions come from libsmb/clifile.c */ -size_t dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate); -void unistr_to_dos(char *dest, const char *src, size_t len); -char *skip_unibuf(char *src, size_t len); -char *dos_unistrn2(uint16 *src, int len); -char *dos_unistr2(uint16 *src); -char *dos_unistr2_to_str(UNISTR2 *str); -void ascii_to_unistr(uint16 *dest, const char *src, int maxlen); -void unistr_to_ascii(char *dest, const uint16 *src, int len); -void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen); -uint32 buffer2_to_uint32(BUFFER2 *str); -char *dos_buffer2_to_str(BUFFER2 *str); -char *dos_buffer2_to_multistr(BUFFER2 *str); -size_t dos_struni2(char *dst, const char *src, size_t max_len); -char *dos_unistr(char *buf); -int unistrcpy(char *dst, char *src); -void default_unicode_map(smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp); -BOOL load_unicode_map(const char *codepage, smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp); -BOOL load_dos_unicode_map(int codepage); -BOOL load_unix_unicode_map(const char *unix_char_set); -smb_ucs2_t *multibyte_to_unicode(smb_ucs2_t *dst, const char *src, - size_t dst_len, smb_ucs2_t *cp_to_ucs2); -char *unicode_to_unix(char *dst, const smb_ucs2_t *src, size_t dst_len); -smb_ucs2_t *unix_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len); -char *unicode_to_dos(char *dst, const smb_ucs2_t *src, size_t dst_len); -size_t unicode_to_dos_char(char *dst, const smb_ucs2_t src); -smb_ucs2_t *dos_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len); -size_t strlen_w(const smb_ucs2_t *src); -smb_ucs2_t *safe_strcpy_w(smb_ucs2_t *dest,const smb_ucs2_t *src, size_t maxlength); -smb_ucs2_t *safe_strcat_w(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength); -int strcmp_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2); -int strncmp_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2, size_t len); -smb_ucs2_t *strstr_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2); -smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c); -smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c); -smb_ucs2_t *strtok_w(smb_ucs2_t *s1, const smb_ucs2_t *s2); -smb_ucs2_t *strdup_w(const smb_ucs2_t *s); -int isupper_w( smb_ucs2_t val); -int islower_w( smb_ucs2_t val); -int isdigit_w( smb_ucs2_t val); -int isxdigit_w( smb_ucs2_t val); -int isspace_w( smb_ucs2_t val); -smb_ucs2_t toupper_w( smb_ucs2_t val ); -smb_ucs2_t tolower_w( smb_ucs2_t val ); -void set_first_token_w(smb_ucs2_t *ptr); -BOOL next_token_w(smb_ucs2_t **ptr, smb_ucs2_t *buff, smb_ucs2_t *sep, size_t bufsize); -smb_ucs2_t **toktocliplist_w(int *ctok, smb_ucs2_t *sep); -int StrCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t); -int StrnCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t, size_t n); -BOOL strequal_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2); -BOOL strnequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2,size_t n); -BOOL strcsequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2); -void strlower_w(smb_ucs2_t *s); -void strupper_w(smb_ucs2_t *s); -void strnorm_w(smb_ucs2_t *s); -BOOL strisnormal_w(smb_ucs2_t *s); -void string_replace_w(smb_ucs2_t *s, smb_ucs2_t oldc, smb_ucs2_t newc); -smb_ucs2_t *skip_string_w(smb_ucs2_t *buf,size_t n); -size_t str_charnum_w(const smb_ucs2_t *s); -BOOL trim_string_w(smb_ucs2_t *s,const smb_ucs2_t *front,const smb_ucs2_t *back); -BOOL strhasupper_w(const smb_ucs2_t *s); -BOOL strhaslower_w(const smb_ucs2_t *s); -size_t count_chars_w(const smb_ucs2_t *s,smb_ucs2_t c); -BOOL str_is_all_w(const smb_ucs2_t *s,smb_ucs2_t c); -smb_ucs2_t *alpha_strcpy_w(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength); -smb_ucs2_t *StrnCpy_w(smb_ucs2_t *dest,const smb_ucs2_t *src,size_t n); -smb_ucs2_t *strncpyn_w(smb_ucs2_t *dest, const smb_ucs2_t *src,size_t n, smb_ucs2_t c); -size_t strhex_to_str_w(char *p, size_t len, const smb_ucs2_t *strhex); -BOOL in_list_w(smb_ucs2_t *s,smb_ucs2_t *list,BOOL casesensitive); -BOOL string_init_w(smb_ucs2_t **dest,const smb_ucs2_t *src); -void string_free_w(smb_ucs2_t **s); -BOOL string_set_w(smb_ucs2_t **dest,const smb_ucs2_t *src); -void string_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert, size_t len); -void fstring_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert); -void pstring_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,smb_ucs2_t *insert); -void all_string_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert, size_t len); -void split_at_last_component_w(smb_ucs2_t *path, smb_ucs2_t *front, smb_ucs2_t sep, smb_ucs2_t *back); -smb_ucs2_t *octal_string_w(int i); -smb_ucs2_t *string_truncate_w(smb_ucs2_t *s, size_t length); -smb_ucs2_t doscp2ucs2(int w); -int ucs2doscp(smb_ucs2_t w); +BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst); +BOOL cli_unlink(struct cli_state *cli, char *fname); +BOOL cli_mkdir(struct cli_state *cli, char *dname); +BOOL cli_rmdir(struct cli_state *cli, char *dname); +int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess); +int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode); +BOOL cli_close(struct cli_state *cli, int fnum); +BOOL cli_lock(struct cli_state *cli, int fnum, + uint32 offset, uint32 len, int timeout, enum brl_type lock_type); +BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len); +BOOL cli_lock64(struct cli_state *cli, int fnum, + SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type); +BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len); +BOOL cli_getattrE(struct cli_state *cli, int fd, + uint16 *attr, size_t *size, + time_t *c_time, time_t *a_time, time_t *m_time); +BOOL cli_getatr(struct cli_state *cli, char *fname, + uint16 *attr, size_t *size, time_t *t); +BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t); +BOOL cli_chkpath(struct cli_state *cli, char *path); +BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail); -/*The following definitions come from lib/wins_srv.c */ +/*The following definitions come from libsmb/clilist.c */ -BOOL wins_srv_load_list( char *src ); -struct in_addr wins_srv_ip( void ); -void wins_srv_died( struct in_addr boothill_ip ); -unsigned long wins_srv_count( void ); +int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *, void *), void *state); +int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *, void *), void *state); +int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, + void (*fn)(file_info *, const char *, void *), void *state); /*The following definitions come from libsmb/cli_lsarpc.c */ @@ -736,6 +327,60 @@ uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, POLICY_HND *pol, uint32 *enum_ctx, uint32 *num_domains, char ***domain_names, DOM_SID **domain_sids); +/*The following definitions come from libsmb/climessage.c */ + +BOOL cli_message_start(struct cli_state *cli, char *host, char *username, + int *grp); +BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp); +BOOL cli_message_end(struct cli_state *cli, int grp); + +/*The following definitions come from libsmb/cliprint.c */ + +int cli_print_queue(struct cli_state *cli, + void (*fn)(struct print_job_info *)); +int cli_printjob_del(struct cli_state *cli, int job); + +/*The following definitions come from libsmb/clirap.c */ + +BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, + uint16 *setup, uint32 setup_count, uint32 max_setup_count, + char *params, uint32 param_count, uint32 max_param_count, + char *data, uint32 data_count, uint32 max_data_count, + char **rparam, uint32 *rparam_count, + char **rdata, uint32 *rdata_count); +BOOL cli_api(struct cli_state *cli, + char *param, int prcnt, int mprcnt, + char *data, int drcnt, int mdrcnt, + char **rparam, int *rprcnt, + char **rdata, int *rdrcnt); +BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation); +int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state); +BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, + void (*fn)(const char *, uint32, const char *, void *), + void *state); +BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, + const char *old_password); +BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, + time_t *c_time, time_t *a_time, time_t *m_time, + size_t *size, uint16 *mode); +BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, + time_t *c_time, time_t *a_time, time_t *m_time, + time_t *w_time, size_t *size, uint16 *mode, + SMB_INO_T *ino); +BOOL cli_qfileinfo(struct cli_state *cli, int fnum, + uint16 *mode, size_t *size, + time_t *c_time, time_t *a_time, time_t *m_time, + time_t *w_time, SMB_INO_T *ino); + +/*The following definitions come from libsmb/clireadwrite.c */ + +size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size); +ssize_t cli_write(struct cli_state *cli, + int fnum, uint16 write_mode, + char *buf, off_t offset, size_t size); +ssize_t cli_smbwrite(struct cli_state *cli, + int fnum, char *buf, off_t offset, size_t size1); + /*The following definitions come from libsmb/cli_samr.c */ #if NEW_NTDOMAIN @@ -764,6 +409,11 @@ uint32 cli_samr_query_groupmem(struct cli_state *cli, POLICY_HND *group_pol, uint32 *num_mem, uint32 **rid, uint32 **attr); #endif +/*The following definitions come from libsmb/clisecdesc.c */ + +SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd); +BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd); + /*The following definitions come from libsmb/cli_spoolss.c */ struct cli_state *cli_spoolss_initialise(struct cli_state *cli, @@ -783,304 +433,655 @@ uint32 cli_spoolss_enum_ports(struct cli_state *cli, uint32 level, uint32 cli_spoolss_getprinter(struct cli_state *cli, POLICY_HND *pol, uint32 level, PRINTER_INFO_CTR *ctr); -/*The following definitions come from libsmb/cliconnect.c */ +/*The following definitions come from libsmb/clistr.c */ -BOOL cli_session_setup(struct cli_state *cli, - char *user, - char *pass, int passlen, - char *ntpass, int ntpasslen, - char *workgroup); -BOOL cli_ulogoff(struct cli_state *cli); -BOOL cli_send_tconX(struct cli_state *cli, - char *share, char *dev, char *pass, int passlen); -BOOL cli_tdis(struct cli_state *cli); -void cli_negprot_send(struct cli_state *cli); -BOOL cli_negprot(struct cli_state *cli); -BOOL cli_session_request(struct cli_state *cli, - struct nmb_name *calling, struct nmb_name *called); -BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip); -BOOL cli_reestablish_connection(struct cli_state *cli); -BOOL cli_establish_connection(struct cli_state *cli, - char *dest_host, struct in_addr *dest_ip, - struct nmb_name *calling, struct nmb_name *called, - char *service, char *service_type, - BOOL do_shutdown, BOOL do_tcon); -BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost, - struct in_addr *pdest_ip); +int clistr_push(struct cli_state *cli, void *dest, const char *src, int dest_len, int flags); +int clistr_push_size(struct cli_state *cli, const void *dest, const char *src, int dest_len, int flags); +int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len, int src_len, int flags); +int clistr_pull_size(struct cli_state *cli, const void *src, int src_len); +int clistr_align(struct cli_state *cli, int offset); -/*The following definitions come from libsmb/clidgram.c */ +/*The following definitions come from libsmb/clitrans.c */ -int cli_send_mailslot(int dgram_sock, BOOL unique, char *mailslot, - char *buf, int len, - const char *srcname, int src_type, - const char *dstname, int dest_type, - struct in_addr dest_ip, struct in_addr src_ip, - int dest_port, int src_port); -int cli_get_response(int dgram_sock, BOOL unique, char *mailslot, char *buf, int bufsiz); -int cli_get_backup_list(const char *myname, const char *send_to_name); -int cli_get_backup_server(char *my_name, char *target, char *servername, int namesize); +BOOL cli_send_trans(struct cli_state *cli, int trans, + char *pipe_name, + int fid, int flags, + uint16 *setup, int lsetup, int msetup, + char *param, int lparam, int mparam, + char *data, int ldata, int mdata); +BOOL cli_receive_trans(struct cli_state *cli,int trans, + char **param, int *param_len, + char **data, int *data_len); +BOOL cli_send_nt_trans(struct cli_state *cli, + int function, + int flags, + uint16 *setup, int lsetup, int msetup, + char *param, int lparam, int mparam, + char *data, int ldata, int mdata); +BOOL cli_receive_nt_trans(struct cli_state *cli, + char **param, int *param_len, + char **data, int *data_len); -/*The following definitions come from libsmb/clientgen.c */ +/*The following definitions come from libsmb/credentials.c */ -int cli_set_port(struct cli_state *cli, int port); -BOOL cli_receive_smb(struct cli_state *cli); -BOOL cli_send_smb(struct cli_state *cli); -void cli_setup_packet(struct cli_state *cli); -void cli_setup_bcc(struct cli_state *cli, void *p); -void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr); -struct cli_state *cli_initialise(struct cli_state *cli); -void cli_shutdown(struct cli_state *cli); -void cli_sockopt(struct cli_state *cli, char *options); -uint16 cli_setpid(struct cli_state *cli, uint16 pid); +char *credstr(uchar *cred); +void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass, + uchar session_key[8]); +void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp, + DOM_CHAL *cred); +int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred, + UTIME timestamp); +BOOL clnt_deal_with_creds(uchar sess_key[8], + DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred); +BOOL deal_with_creds(uchar sess_key[8], + DOM_CRED *sto_clnt_cred, + DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred); + +/*The following definitions come from libsmb/namequery.c */ + +struct node_status *name_status_query(int fd,struct nmb_name *name, + struct in_addr to_ip, int *num_names); +BOOL name_status_find(int type, struct in_addr to_ip, char *name); +BOOL name_register(int fd, const char *name, int name_type, + struct in_addr name_ip, int opcode, + BOOL bcast, + struct in_addr to_ip, int *count); +struct in_addr *name_query(int fd,const char *name,int name_type, + BOOL bcast,BOOL recurse, + struct in_addr to_ip, int *count); +FILE *startlmhosts(char *fname); +BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); +void endlmhosts(FILE *fp); +BOOL name_register_wins(const char *name, int name_type); +BOOL name_resolve_bcast(const char *name, int name_type, + struct in_addr **return_ip_list, int *return_count); +BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type); +BOOL resolve_srv_name(const char* srv_name, fstring dest_host, + struct in_addr *ip); +BOOL find_master_ip(char *group, struct in_addr *master_ip); +BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pdc_ip, char *ret_name); +BOOL get_dc_list(BOOL pdc_only, char *group, struct in_addr **ip_list, int *count); + +/*The following definitions come from libsmb/nmblib.c */ + +void debug_nmb_packet(struct packet_struct *p); +char *nmb_namestr(struct nmb_name *n); +struct packet_struct *copy_packet(struct packet_struct *packet); +void free_packet(struct packet_struct *packet); +struct packet_struct *parse_packet(char *buf,int length, + enum packet_type packet_type); +struct packet_struct *read_packet(int fd,enum packet_type packet_type); +void make_nmb_name( struct nmb_name *n, const char *name, int type); +BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2); +int build_packet(char *buf, struct packet_struct *p); +BOOL send_packet(struct packet_struct *p); +struct packet_struct *receive_packet(int fd,enum packet_type type,int t); +struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id); +struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name); +BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name); +void sort_query_replies(char *data, int n, struct in_addr ip); +char *dns_to_netbios_name(char *dns_name); +int name_mangle( char *In, char *Out, char name_type ); +int name_extract(char *buf,int ofs,char *name); +int name_len(char *s1); + +/*The following definitions come from libsmb/nterr.c */ + +BOOL get_safe_nt_error_msg(uint32 nt_code,char *msg, size_t len); +char *get_nt_error_msg(uint32 nt_code); + +/*The following definitions come from libsmb/passchange.c */ + +BOOL remote_password_change(const char *remote_machine, const char *user_name, + const char *old_passwd, const char *new_passwd, + char *err_str, size_t err_str_len); + +/*The following definitions come from libsmb/pwd_cache.c */ + +void pwd_init(struct pwd_info *pwd); +BOOL pwd_is_nullpwd(const struct pwd_info *pwd); +BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2); +void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt); +void pwd_set_nullpwd(struct pwd_info *pwd); +void pwd_set_cleartext(struct pwd_info *pwd, char *clr); +void pwd_get_cleartext(struct pwd_info *pwd, char *clr); +void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]); +void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]); +void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr); +void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8]); +void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24]); + +/*The following definitions come from lib/smbrun.c */ + +int smbrun(char *cmd,char *outfile,BOOL shared); + +/*The following definitions come from libsmb/smbdes.c */ + +void E_P16(unsigned char *p14,unsigned char *p16); +void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24); +void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out); +void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out); +void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key); +void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key); +void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw); +void SamOEMhash( unsigned char *data, unsigned char *key, int val); + +/*The following definitions come from libsmb/smbencrypt.c */ + +void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24); +void E_md4hash(uchar *passwd, uchar *p16); +void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]); +void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]); +void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]); +void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24); +BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode); +BOOL decode_pw_buffer(char buffer[516], char *new_pwrd, + int new_pwrd_size, uint32 *new_pw_len); -/*The following definitions come from libsmb/clierror.c */ +/*The following definitions come from libsmb/smberr.c */ -char *cli_errstr(struct cli_state *cli); -int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num, uint32 *nt_rpc_error); +char *smb_errstr(char *inbuf); -/*The following definitions come from libsmb/clifile.c */ +/*The following definitions come from libsmb/unexpected.c */ -BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst); -BOOL cli_unlink(struct cli_state *cli, char *fname); -BOOL cli_mkdir(struct cli_state *cli, char *dname); -BOOL cli_rmdir(struct cli_state *cli, char *dname); -int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess); -int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode); -BOOL cli_close(struct cli_state *cli, int fnum); -BOOL cli_lock(struct cli_state *cli, int fnum, - uint32 offset, uint32 len, int timeout, enum brl_type lock_type); -BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len); -BOOL cli_lock64(struct cli_state *cli, int fnum, - SMB_BIG_UINT offset, SMB_BIG_UINT len, int timeout, enum brl_type lock_type); -BOOL cli_unlock64(struct cli_state *cli, int fnum, SMB_BIG_UINT offset, SMB_BIG_UINT len); -BOOL cli_getattrE(struct cli_state *cli, int fd, - uint16 *attr, size_t *size, - time_t *c_time, time_t *a_time, time_t *m_time); -BOOL cli_getatr(struct cli_state *cli, char *fname, - uint16 *attr, size_t *size, time_t *t); -BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t); -BOOL cli_chkpath(struct cli_state *cli, char *path); -BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail); +void unexpected_packet(struct packet_struct *p); +void clear_unexpected(time_t t); +struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, + char *mailslot_name); -/*The following definitions come from libsmb/clilist.c */ +/*The following definitions come from lib/snprintf.c */ -int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *, void *), void *state); -int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *, void *), void *state); -int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute, - void (*fn)(file_info *, const char *, void *), void *state); -/*The following definitions come from libsmb/climessage.c */ +/*The following definitions come from lib/substitute.c */ -BOOL cli_message_start(struct cli_state *cli, char *host, char *username, - int *grp); -BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp); -BOOL cli_message_end(struct cli_state *cli, int grp); +void standard_sub_basic(char *str); +void standard_sub_advanced(int snum, char *user, char *connectpath, gid_t gid, char *str); +void standard_sub_conn(connection_struct *conn, char *str); +void standard_sub_snum(int snum, char *str); +void standard_sub_vuser(char *str, user_struct *vuser); +void standard_sub_vsnum(char *str, user_struct *vuser, int snum); -/*The following definitions come from libsmb/cliprint.c */ +/*The following definitions come from lib/sysacls.c */ -int cli_print_queue(struct cli_state *cli, - void (*fn)(struct print_job_info *)); -int cli_printjob_del(struct cli_state *cli, int job); +int sys_acl_get_entry( SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p); +int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p); +int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p); +void *sys_acl_get_qualifier( SMB_ACL_ENTRY_T entry_d); +SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type); +SMB_ACL_T sys_acl_get_fd(int fd); +int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset); +int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm); +int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm); +char *sys_acl_to_text( SMB_ACL_T the_acl, ssize_t *plen); +SMB_ACL_T sys_acl_init( int count); +int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry); +int sys_acl_set_tag_type( SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype); +int sys_acl_set_qualifier( SMB_ACL_ENTRY_T entry, void *qual); +int sys_acl_set_permset( SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset); +int sys_acl_valid( SMB_ACL_T theacl ); +int sys_acl_set_file( char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl); +int sys_acl_set_fd( int fd, SMB_ACL_T theacl); +int sys_acl_free_text(char *text); +int sys_acl_free_acl(SMB_ACL_T the_acl) ; +int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p); +int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p); +int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p); +void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d); +SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type); +SMB_ACL_T sys_acl_get_fd(int fd); +int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d); +int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); +int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); +char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p); +SMB_ACL_T sys_acl_init(int count); +int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p); +int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type); +int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p); +int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d); +int sys_acl_valid(SMB_ACL_T acl_d); +int sys_acl_set_file(char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d); +int sys_acl_set_fd(int fd, SMB_ACL_T acl_d); +int sys_acl_free_text(char *text); +int sys_acl_free_acl(SMB_ACL_T acl_d) ; +int sys_acl_get_entry(SMB_ACL_T acl_d, int entry_id, SMB_ACL_ENTRY_T *entry_p); +int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *type_p); +int sys_acl_get_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p); +void *sys_acl_get_qualifier(SMB_ACL_ENTRY_T entry_d); +SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type); +SMB_ACL_T sys_acl_get_fd(int fd); +int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset_d); +int sys_acl_add_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); +int sys_acl_get_perm(SMB_ACL_PERMSET_T permset_d, SMB_ACL_PERM_T perm); +char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p); +SMB_ACL_T sys_acl_init(int count); +int sys_acl_create_entry(SMB_ACL_T *acl_p, SMB_ACL_ENTRY_T *entry_p); +int sys_acl_set_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T tag_type); +int sys_acl_set_qualifier(SMB_ACL_ENTRY_T entry_d, void *qual_p); +int sys_acl_set_permset(SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T permset_d); +int sys_acl_valid(SMB_ACL_T acl_d); +int sys_acl_set_file(char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d); +int sys_acl_set_fd(int fd, SMB_ACL_T acl_d); +int sys_acl_free_text(char *text); +int sys_acl_free_acl(SMB_ACL_T acl_d) ; +int sys_acl_get_entry( SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p); +int sys_acl_get_tag_type( SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p); +int sys_acl_get_permset( SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p); +void *sys_acl_get_qualifier( SMB_ACL_ENTRY_T entry_d); +SMB_ACL_T sys_acl_get_file( const char *path_p, SMB_ACL_TYPE_T type); +SMB_ACL_T sys_acl_get_fd(int fd); +int sys_acl_clear_perms(SMB_ACL_PERMSET_T permset); +int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm); +int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm); +char *sys_acl_to_text( SMB_ACL_T the_acl, ssize_t *plen); +int sys_acl_free_text(char *text); +SMB_ACL_T sys_acl_init( int count); +int sys_acl_create_entry( SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry); +int sys_acl_set_tag_type( SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype); +int sys_acl_set_qualifier( SMB_ACL_ENTRY_T entry, void *qual); +int sys_acl_set_permset( SMB_ACL_ENTRY_T entry, SMB_ACL_PERMSET_T permset); +int sys_acl_valid( SMB_ACL_T theacl ); +int sys_acl_set_file( char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl); +int sys_acl_set_fd( int fd, SMB_ACL_T theacl); +int sys_acl_free_acl(SMB_ACL_T the_acl) ; -/*The following definitions come from libsmb/clirap.c */ +/*The following definitions come from lib/system.c */ -BOOL cli_api_pipe(struct cli_state *cli, char *pipe_name, - uint16 *setup, uint32 setup_count, uint32 max_setup_count, - char *params, uint32 param_count, uint32 max_param_count, - char *data, uint32 data_count, uint32 max_data_count, - char **rparam, uint32 *rparam_count, - char **rdata, uint32 *rdata_count); -BOOL cli_api(struct cli_state *cli, - char *param, int prcnt, int mprcnt, - char *data, int drcnt, int mdrcnt, - char **rparam, int *rprcnt, - char **rdata, int *rdrcnt); -BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation); -int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *, void *), void *state); -BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, - void (*fn)(const char *, uint32, const char *, void *), - void *state); -BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password, - const char *old_password); -BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, - time_t *c_time, time_t *a_time, time_t *m_time, - size_t *size, uint16 *mode); -BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, - time_t *c_time, time_t *a_time, time_t *m_time, - time_t *w_time, size_t *size, uint16 *mode, - SMB_INO_T *ino); -BOOL cli_qfileinfo(struct cli_state *cli, int fnum, - uint16 *mode, size_t *size, - time_t *c_time, time_t *a_time, time_t *m_time, - time_t *w_time, SMB_INO_T *ino); +int sys_usleep(long usecs); +int sys_stat(const char *fname,SMB_STRUCT_STAT *sbuf); +int sys_fstat(int fd,SMB_STRUCT_STAT *sbuf); +int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf); +int sys_ftruncate(int fd, SMB_OFF_T offset); +SMB_OFF_T sys_lseek(int fd, SMB_OFF_T offset, int whence); +int sys_fseek(FILE *fp, SMB_OFF_T offset, int whence); +SMB_OFF_T sys_ftell(FILE *fp); +int sys_creat(const char *path, mode_t mode); +int sys_open(const char *path, int oflag, mode_t mode); +FILE *sys_fopen(const char *path, const char *type); +SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp); +int sys_waitpid(pid_t pid,int *status,int options); +char *sys_getwd(char *s); +int sys_chown(const char *fname,uid_t uid,gid_t gid); +int sys_chroot(const char *dname); +struct hostent *sys_gethostbyname(const char *name); +void oplock_set_capability(BOOL this_process, BOOL inherit); +long sys_random(void); +void sys_srandom(unsigned int seed); +int groups_max(void); +int sys_getgroups(int setlen, gid_t *gidset); +int sys_setgroups(int setlen, gid_t *gidset); +void sys_setpwent(void); +struct passwd *sys_getpwent(void); +void sys_endpwent(void); +struct passwd *sys_getpwnam(const char *name); +struct passwd *sys_getpwuid(uid_t uid); +int wsys_stat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf); +int wsys_lstat(const smb_ucs2_t *wfname,SMB_STRUCT_STAT *sbuf); +int wsys_creat(const smb_ucs2_t *wfname, mode_t mode); +int wsys_open(const smb_ucs2_t *wfname, int oflag, mode_t mode); +FILE *wsys_fopen(const smb_ucs2_t *wfname, const char *type); +DIR *wsys_opendir(const smb_ucs2_t *wfname); +smb_ucs2_t *wsys_getwd(smb_ucs2_t *s); +int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid); +int wsys_chroot(const smb_ucs2_t *wfname); +pid_t sys_fork(void); +pid_t sys_getpid(void); +int sys_popen(const char *command); +int sys_pclose(int fd); -/*The following definitions come from libsmb/clireadwrite.c */ +/*The following definitions come from lib/talloc.c */ -size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size); -ssize_t cli_write(struct cli_state *cli, - int fnum, uint16 write_mode, - char *buf, off_t offset, size_t size); -ssize_t cli_smbwrite(struct cli_state *cli, - int fnum, char *buf, off_t offset, size_t size1); +TALLOC_CTX *talloc_init(void); +void *talloc(TALLOC_CTX *t, size_t size); +void talloc_destroy_pool(TALLOC_CTX *t); +void talloc_destroy(TALLOC_CTX *t); +size_t talloc_pool_size(TALLOC_CTX *t); +void *talloc_zero(TALLOC_CTX *t, size_t size); +void *talloc_memdup(TALLOC_CTX *t, void *p, size_t size); -/*The following definitions come from libsmb/clisecdesc.c */ +/*The following definitions come from lib/time.c */ -SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd); -BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd); +void GetTimeOfDay(struct timeval *tval); +void TimeInit(void); +int TimeDiff(time_t t); +struct tm *LocalTime(time_t *t); +time_t nt_time_to_unix(NTTIME *nt); +time_t interpret_long_date(char *p); +void unix_to_nt_time(NTTIME *nt, time_t t); +void put_long_date(char *p,time_t t); +BOOL null_mtime(time_t mtime); +void put_dos_date(char *buf,int offset,time_t unixdate); +void put_dos_date2(char *buf,int offset,time_t unixdate); +void put_dos_date3(char *buf,int offset,time_t unixdate); +time_t make_unix_date(void *date_ptr); +time_t make_unix_date2(void *date_ptr); +time_t make_unix_date3(void *date_ptr); +char *http_timestring(time_t t); +char *timestring(BOOL hires); +time_t get_create_time(SMB_STRUCT_STAT *st,BOOL fake_dirs); -/*The following definitions come from libsmb/clistr.c */ +/*The following definitions come from lib/ufc.c */ -int clistr_push(struct cli_state *cli, void *dest, const char *src, int dest_len, int flags); -int clistr_push_size(struct cli_state *cli, const void *dest, const char *src, int dest_len, int flags); -int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len, int src_len, int flags); -int clistr_pull_size(struct cli_state *cli, const void *src, int src_len); -int clistr_align(struct cli_state *cli, int offset); +char *ufc_crypt(char *key,char *salt); + +/*The following definitions come from lib/username.c */ -/*The following definitions come from libsmb/clitrans.c */ +char *get_user_home_dir(char *user); +BOOL map_username(char *user); +struct passwd *Get_Pwnam(char *user,BOOL allow_change); +BOOL user_in_group_list(char *user,char *gname); +BOOL user_in_list(char *user,char *list); +struct passwd *smb_getpwnam(char *user, BOOL allow_change); -BOOL cli_send_trans(struct cli_state *cli, int trans, - char *pipe_name, - int fid, int flags, - uint16 *setup, int lsetup, int msetup, - char *param, int lparam, int mparam, - char *data, int ldata, int mdata); -BOOL cli_receive_trans(struct cli_state *cli,int trans, - char **param, int *param_len, - char **data, int *data_len); -BOOL cli_send_nt_trans(struct cli_state *cli, - int function, - int flags, - uint16 *setup, int lsetup, int msetup, - char *param, int lparam, int mparam, - char *data, int ldata, int mdata); -BOOL cli_receive_nt_trans(struct cli_state *cli, - char **param, int *param_len, - char **data, int *data_len); +/*The following definitions come from lib/util_array.c */ -/*The following definitions come from libsmb/credentials.c */ +void free_void_array(uint32 num_entries, void **entries, + void(free_item)(void*)); +void* add_copy_to_array(uint32 *len, void ***array, const void *item, + void*(item_dup)(const void*), BOOL alloc_anyway); +void* add_item_to_array(uint32 *len, void ***array, void *item); +void free_use_info_array(uint32 num_entries, struct use_info **entries); +struct use_info* add_use_info_to_array(uint32 *len, struct use_info ***array, + const struct use_info *name); +void free_char_array(uint32 num_entries, char **entries); +char* add_chars_to_array(uint32 *len, char ***array, const char *name); +void free_uint32_array(uint32 num_entries, uint32 **entries); +uint32* add_uint32s_to_array(uint32 *len, uint32 ***array, const uint32 *name); +void free_sid_array(uint32 num_entries, DOM_SID **entries); +DOM_SID* add_sid_to_array(uint32 *len, DOM_SID ***array, const DOM_SID *sid); -char *credstr(uchar *cred); -void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass, - uchar session_key[8]); -void cred_create(uchar session_key[8], DOM_CHAL *stor_cred, UTIME timestamp, - DOM_CHAL *cred); -int cred_assert(DOM_CHAL *cred, uchar session_key[8], DOM_CHAL *stored_cred, - UTIME timestamp); -BOOL clnt_deal_with_creds(uchar sess_key[8], - DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_srv_cred); -BOOL deal_with_creds(uchar sess_key[8], - DOM_CRED *sto_clnt_cred, - DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred); +/*The following definitions come from lib/util.c */ -/*The following definitions come from libsmb/namequery.c */ +char *tmpdir(void); +BOOL in_group(gid_t group, gid_t current_gid, int ngroups, gid_t *groups); +char *Atoic(char *p, int *n, char *c); +char *get_numlist(char *p, uint32 **num, int *count); +BOOL file_exist(char *fname,SMB_STRUCT_STAT *sbuf); +int file_rename(char *from, char *to); +time_t file_modtime(char *fname); +BOOL directory_exist(char *dname,SMB_STRUCT_STAT *st); +SMB_OFF_T get_file_size(char *file_name); +char *attrib_string(uint16 mode); +void show_msg(char *buf); +void smb_setlen(char *buf,int len); +int set_message(char *buf,int num_words,int num_bytes,BOOL zero); +void set_message_bcc(char *buf,int num_bytes); +void set_message_end(void *outbuf,void *end_ptr); +void dos_clean_name(char *s); +void unix_clean_name(char *s); +void make_dir_struct(char *buf,char *mask,char *fname,SMB_OFF_T size,int mode,time_t date); +void close_low_fds(void); +int set_blocking(int fd, BOOL set); +SMB_OFF_T transfer_file(int infd,int outfd,SMB_OFF_T n,char *header,int headlen,int align); +void msleep(int t); +void become_daemon(void); +BOOL yesno(char *p); +void *Realloc(void *p,size_t size); +void safe_free(void *p); +BOOL get_myname(char *my_name); +int interpret_protocol(char *str,int def); +BOOL is_ipaddress(const char *str); +uint32 interpret_addr(char *str); +struct in_addr *interpret_addr2(char *str); +BOOL zero_ip(struct in_addr ip); +BOOL same_net(struct in_addr ip1,struct in_addr ip2,struct in_addr mask); +struct hostent *Get_Hostbyname(const char *name); +BOOL process_exists(pid_t pid); +char *uidtoname(uid_t uid); +char *gidtoname(gid_t gid); +uid_t nametouid(char *name); +gid_t nametogid(char *name); +void smb_panic(char *why); +char *readdirname(DIR *p); +BOOL is_in_path(char *name, name_compare_entry *namelist); +void set_namearray(name_compare_entry **ppname_array, char *namelist); +void free_namearray(name_compare_entry *name_array); +BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); +BOOL is_myname(char *s); +void set_remote_arch(enum remote_arch_types type); +enum remote_arch_types get_remote_arch(void); +void out_ascii(FILE *f, unsigned char *buf,int len); +void out_data(FILE *f,char *buf1,int len, int per_line); +void print_asc(int level, unsigned char *buf,int len); +void dump_data(int level,char *buf1,int len); +char *tab_depth(int depth); +int str_checksum(const char *s); +void zero_free(void *p, size_t size); +int set_maxfiles(int requested_max); +BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name); +char *smbd_mktemp(char *template); +void *memdup(void *p, size_t size); +char *myhostname(void); +char *lock_path(char *name); +char *parent_dirname(const char *path); +BOOL ms_has_wild(char *s); +BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive); +int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6); -struct node_status *name_status_query(int fd,struct nmb_name *name, - struct in_addr to_ip, int *num_names); -BOOL name_status_find(int type, struct in_addr to_ip, char *name); -BOOL name_register(int fd, const char *name, int name_type, - struct in_addr name_ip, int opcode, - BOOL bcast, - struct in_addr to_ip, int *count); -struct in_addr *name_query(int fd,const char *name,int name_type, - BOOL bcast,BOOL recurse, - struct in_addr to_ip, int *count); -FILE *startlmhosts(char *fname); -BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); -void endlmhosts(FILE *fp); -BOOL name_register_wins(const char *name, int name_type); -BOOL name_resolve_bcast(const char *name, int name_type, - struct in_addr **return_ip_list, int *return_count); -BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type); -BOOL resolve_srv_name(const char* srv_name, fstring dest_host, - struct in_addr *ip); -BOOL find_master_ip(char *group, struct in_addr *master_ip); -BOOL lookup_pdc_name(const char *srcname, const char *domain, struct in_addr *pdc_ip, char *ret_name); -BOOL get_dc_list(BOOL pdc_only, char *group, struct in_addr **ip_list, int *count); +/*The following definitions come from lib/util_file.c */ -/*The following definitions come from libsmb/nmblib.c */ +BOOL do_file_lock(int fd, int waitsecs, int type); +BOOL file_lock(int fd, int type, int secs, int *plock_depth); +BOOL file_unlock(int fd, int *plock_depth); +void *startfilepwent(char *pfile, char *s_readbuf, int bufsize, + int *file_lock_depth, BOOL update); +void endfilepwent(void *vp, int *file_lock_depth); +SMB_BIG_UINT getfilepwpos(void *vp); +BOOL setfilepwpos(void *vp, SMB_BIG_UINT tok); +int getfileline(void *vp, char *linebuf, int linebuf_size); +char *fgets_slash(char *s2,int maxlen,FILE *f); +char *file_pload(char *syscmd, size_t *size); +char *file_load(char *fname, size_t *size); +char **file_lines_load(char *fname, int *numlines, BOOL convert); +char **file_lines_pload(char *syscmd, int *numlines, BOOL convert); +void file_lines_free(char **lines); +void file_lines_slashcont(char **lines); -void debug_nmb_packet(struct packet_struct *p); -char *nmb_namestr(struct nmb_name *n); -struct packet_struct *copy_packet(struct packet_struct *packet); -void free_packet(struct packet_struct *packet); -struct packet_struct *parse_packet(char *buf,int length, - enum packet_type packet_type); -struct packet_struct *read_packet(int fd,enum packet_type packet_type); -void make_nmb_name( struct nmb_name *n, const char *name, int type); -BOOL nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2); -int build_packet(char *buf, struct packet_struct *p); -BOOL send_packet(struct packet_struct *p); -struct packet_struct *receive_packet(int fd,enum packet_type type,int t); -struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id); -struct packet_struct *receive_dgram_packet(int fd, int t, char *mailslot_name); -BOOL match_mailslot_name(struct packet_struct *p, char *mailslot_name); -void sort_query_replies(char *data, int n, struct in_addr ip); -char *dns_to_netbios_name(char *dns_name); -int name_mangle( char *In, char *Out, char name_type ); -int name_extract(char *buf,int ofs,char *name); -int name_len(char *s1); +/*The following definitions come from lib/util_list.c */ -/*The following definitions come from libsmb/nterr.c */ +BOOL copy_policy_hnd (POLICY_HND *dest, const POLICY_HND *src); +BOOL compare_rpc_hnd_node(const RPC_HND_NODE *x, + const RPC_HND_NODE *y); +BOOL RpcHndList_set_connection(const POLICY_HND *hnd, + struct cli_connection *con); +BOOL RpcHndList_del_connection(const POLICY_HND *hnd); +struct cli_connection* RpcHndList_get_connection(const POLICY_HND *hnd); -BOOL get_safe_nt_error_msg(uint32 nt_code,char *msg, size_t len); -char *get_nt_error_msg(uint32 nt_code); +/*The following definitions come from lib/util_seaccess.c */ -/*The following definitions come from libsmb/passchange.c */ +void se_map_generic(uint32 *access_mask, struct generic_mapping *mapping); +BOOL se_access_check(SEC_DESC *sd, struct current_user *user, + uint32 acc_desired, uint32 *acc_granted, uint32 *status); +SEC_DESC_BUF *se_create_child_secdesc(TALLOC_CTX *ctx, SEC_DESC *parent_ctr, + BOOL child_container); -BOOL remote_password_change(const char *remote_machine, const char *user_name, - const char *old_passwd, const char *new_passwd, - char *err_str, size_t err_str_len); +/*The following definitions come from lib/util_sec.c */ -/*The following definitions come from libsmb/pwd_cache.c */ +void gain_root_privilege(void); +void gain_root_group_privilege(void); +void set_effective_uid(uid_t uid); +void set_effective_gid(gid_t gid); +void save_re_uid(void); +void restore_re_uid(void); +int set_re_uid(void); +void become_user_permanently(uid_t uid, gid_t gid); -void pwd_init(struct pwd_info *pwd); -BOOL pwd_is_nullpwd(const struct pwd_info *pwd); -BOOL pwd_compare(struct pwd_info *pwd1, struct pwd_info *pwd2); -void pwd_read(struct pwd_info *pwd, char *passwd_report, BOOL do_encrypt); -void pwd_set_nullpwd(struct pwd_info *pwd); -void pwd_set_cleartext(struct pwd_info *pwd, char *clr); -void pwd_get_cleartext(struct pwd_info *pwd, char *clr); -void pwd_set_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]); -void pwd_get_lm_nt_16(struct pwd_info *pwd, uchar lm_pwd[16], uchar nt_pwd[16]); -void pwd_make_lm_nt_16(struct pwd_info *pwd, char *clr); -void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8]); -void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24], uchar nt_owf[24]); +/*The following definitions come from lib/util_sid.c */ -/*The following definitions come from libsmb/smbdes.c */ +void generate_wellknown_sids(void); +BOOL map_domain_sid_to_name(DOM_SID *sid, char *nt_domain); +BOOL lookup_known_rid(DOM_SID *sid, uint32 rid, char *name, enum SID_NAME_USE *psid_name_use); +BOOL map_domain_name_to_sid(DOM_SID *sid, char *nt_domain); +void split_domain_name(const char *fullname, char *domain, char *name); +char *sid_to_string(fstring sidstr_out, DOM_SID *sid); +BOOL string_to_sid(DOM_SID *sidout, char *sidstr); +BOOL sid_append_rid(DOM_SID *sid, uint32 rid); +BOOL sid_split_rid(DOM_SID *sid, uint32 *rid); +void sid_copy(DOM_SID *dst, const DOM_SID *src); +DOM_SID *sid_dup(DOM_SID *src); +BOOL sid_linearize(char *outbuf, size_t len, DOM_SID *sid); +int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2); +BOOL sid_equal(const DOM_SID *sid1, const DOM_SID *sid2); +size_t sid_size(DOM_SID *sid); -void E_P16(unsigned char *p14,unsigned char *p16); -void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24); -void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out); -void E_old_pw_hash( unsigned char *p14, unsigned char *in, unsigned char *out); -void cred_hash1(unsigned char *out,unsigned char *in,unsigned char *key); -void cred_hash2(unsigned char *out,unsigned char *in,unsigned char *key); -void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int forw); -void SamOEMhash( unsigned char *data, unsigned char *key, int val); +/*The following definitions come from lib/util_sock.c */ + +BOOL is_a_socket(int fd); +void set_socket_options(int fd, char *options); +ssize_t read_udp_socket(int fd,char *buf,size_t len); +ssize_t read_with_timeout(int fd,char *buf,size_t mincnt,size_t maxcnt,unsigned int time_out); +BOOL send_keepalive(int client); +ssize_t read_data(int fd,char *buffer,size_t N); +ssize_t write_data(int fd,char *buffer,size_t N); +ssize_t write_socket_data(int fd,char *buffer,size_t N); +ssize_t write_socket(int fd,char *buf,size_t len); +ssize_t read_smb_length(int fd,char *inbuf,unsigned int timeout); +BOOL receive_smb(int fd,char *buffer, unsigned int timeout); +BOOL client_receive_smb(int fd,char *buffer, unsigned int timeout); +BOOL send_null_session_msg(int fd); +BOOL send_smb(int fd,char *buffer); +BOOL send_one_packet(char *buf,int len,struct in_addr ip,int port,int type); +int open_socket_in(int type, int port, int dlevel,uint32 socket_addr, BOOL rebind); +int open_socket_out(int type, struct in_addr *addr, int port ,int timeout); +void reset_globals_after_fork(void); +void client_setfd(int fd); +char *client_name(void); +char *client_addr(void); +char *get_socket_name(int fd); +char *get_socket_addr(int fd); +int open_pipe_sock(char *path); +int create_pipe_socket(char *dir, int dir_perms, + char *path, int path_perms); -/*The following definitions come from libsmb/smbencrypt.c */ +/*The following definitions come from lib/util_str.c */ -void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24); -void E_md4hash(uchar *passwd, uchar *p16); -void nt_lm_owf_gen(char *pwd, uchar nt_p16[16], uchar p16[16]); -void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24]); -void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]); -void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24); -BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode); -BOOL decode_pw_buffer(char buffer[516], char *new_pwrd, - int new_pwrd_size, uint32 *new_pw_len); +void set_first_token(char *ptr); +BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize); +char **toktocliplist(int *ctok, char *sep); +int StrCaseCmp(const char *s, const char *t); +int StrnCaseCmp(const char *s, const char *t, size_t n); +BOOL strequal(const char *s1, const char *s2); +BOOL strnequal(const char *s1,const char *s2,size_t n); +BOOL strcsequal(const char *s1,const char *s2); +int strwicmp(char *psz1, char *psz2); +void strlower(char *s); +void strupper(char *s); +void strnorm(char *s); +BOOL strisnormal(char *s); +void string_replace(char *s,char oldc,char newc); +char *skip_string(char *buf,size_t n); +size_t str_charnum(const char *s); +BOOL trim_string(char *s,const char *front,const char *back); +BOOL strhasupper(const char *s); +BOOL strhaslower(const char *s); +size_t count_chars(const char *s,char c); +BOOL str_is_all(const char *s,char c); +char *safe_strcpy(char *dest,const char *src, size_t maxlength); +char *safe_strcat(char *dest, const char *src, size_t maxlength); +char *alpha_strcpy(char *dest, const char *src, size_t maxlength); +char *StrnCpy(char *dest,const char *src,size_t n); +char *strncpyn(char *dest, const char *src,size_t n, char c); +size_t strhex_to_str(char *p, size_t len, const char *strhex); +BOOL in_list(char *s,char *list,BOOL casesensitive); +void string_free(char **s); +BOOL string_set(char **dest,const char *src); +void string_sub(char *s,const char *pattern,const char *insert, size_t len); +void fstring_sub(char *s,const char *pattern,const char *insert); +void pstring_sub(char *s,const char *pattern,const char *insert); +void all_string_sub(char *s,const char *pattern,const char *insert, size_t len); +void split_at_last_component(char *path, char *front, char sep, char *back); +char *octal_string(int i); +char *string_truncate(char *s, int length); +void parse_domain_user(char *domuser, fstring domain, fstring user); -/*The following definitions come from libsmb/smberr.c */ +/*The following definitions come from lib/util_unistr.c */ -char *smb_errstr(char *inbuf); +size_t dos_PutUniCode(char *dst,const char *src, ssize_t len, BOOL null_terminate); +void unistr_to_dos(char *dest, const char *src, size_t len); +char *skip_unibuf(char *src, size_t len); +char *dos_unistrn2(uint16 *src, int len); +char *dos_unistr2(uint16 *src); +char *dos_unistr2_to_str(UNISTR2 *str); +void ascii_to_unistr(uint16 *dest, const char *src, int maxlen); +void unistr_to_ascii(char *dest, const uint16 *src, int len); +void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen); +uint32 buffer2_to_uint32(BUFFER2 *str); +char *dos_buffer2_to_str(BUFFER2 *str); +char *dos_buffer2_to_multistr(BUFFER2 *str); +size_t dos_struni2(char *dst, const char *src, size_t max_len); +char *dos_unistr(char *buf); +int unistrcpy(char *dst, char *src); +void default_unicode_map(smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp); +BOOL load_unicode_map(const char *codepage, smb_ucs2_t **pp_cp_to_ucs2, uint16 **pp_ucs2_to_cp); +BOOL load_dos_unicode_map(int codepage); +BOOL load_unix_unicode_map(const char *unix_char_set); +smb_ucs2_t *multibyte_to_unicode(smb_ucs2_t *dst, const char *src, + size_t dst_len, smb_ucs2_t *cp_to_ucs2); +char *unicode_to_unix(char *dst, const smb_ucs2_t *src, size_t dst_len); +smb_ucs2_t *unix_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len); +char *unicode_to_dos(char *dst, const smb_ucs2_t *src, size_t dst_len); +size_t unicode_to_dos_char(char *dst, const smb_ucs2_t src); +smb_ucs2_t *dos_to_unicode(smb_ucs2_t *dst, const char *src, size_t dst_len); +size_t strlen_w(const smb_ucs2_t *src); +smb_ucs2_t *safe_strcpy_w(smb_ucs2_t *dest,const smb_ucs2_t *src, size_t maxlength); +smb_ucs2_t *safe_strcat_w(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength); +int strcmp_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2); +int strncmp_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2, size_t len); +smb_ucs2_t *strstr_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2); +smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c); +smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c); +smb_ucs2_t *strtok_w(smb_ucs2_t *s1, const smb_ucs2_t *s2); +smb_ucs2_t *strdup_w(const smb_ucs2_t *s); +int isupper_w( smb_ucs2_t val); +int islower_w( smb_ucs2_t val); +int isdigit_w( smb_ucs2_t val); +int isxdigit_w( smb_ucs2_t val); +int isspace_w( smb_ucs2_t val); +smb_ucs2_t toupper_w( smb_ucs2_t val ); +smb_ucs2_t tolower_w( smb_ucs2_t val ); +void set_first_token_w(smb_ucs2_t *ptr); +BOOL next_token_w(smb_ucs2_t **ptr, smb_ucs2_t *buff, smb_ucs2_t *sep, size_t bufsize); +smb_ucs2_t **toktocliplist_w(int *ctok, smb_ucs2_t *sep); +int StrCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t); +int StrnCaseCmp_w(const smb_ucs2_t *s, const smb_ucs2_t *t, size_t n); +BOOL strequal_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2); +BOOL strnequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2,size_t n); +BOOL strcsequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2); +void strlower_w(smb_ucs2_t *s); +void strupper_w(smb_ucs2_t *s); +void strnorm_w(smb_ucs2_t *s); +BOOL strisnormal_w(smb_ucs2_t *s); +void string_replace_w(smb_ucs2_t *s, smb_ucs2_t oldc, smb_ucs2_t newc); +smb_ucs2_t *skip_string_w(smb_ucs2_t *buf,size_t n); +size_t str_charnum_w(const smb_ucs2_t *s); +BOOL trim_string_w(smb_ucs2_t *s,const smb_ucs2_t *front,const smb_ucs2_t *back); +BOOL strhasupper_w(const smb_ucs2_t *s); +BOOL strhaslower_w(const smb_ucs2_t *s); +size_t count_chars_w(const smb_ucs2_t *s,smb_ucs2_t c); +BOOL str_is_all_w(const smb_ucs2_t *s,smb_ucs2_t c); +smb_ucs2_t *alpha_strcpy_w(smb_ucs2_t *dest, const smb_ucs2_t *src, size_t maxlength); +smb_ucs2_t *StrnCpy_w(smb_ucs2_t *dest,const smb_ucs2_t *src,size_t n); +smb_ucs2_t *strncpyn_w(smb_ucs2_t *dest, const smb_ucs2_t *src,size_t n, smb_ucs2_t c); +size_t strhex_to_str_w(char *p, size_t len, const smb_ucs2_t *strhex); +BOOL in_list_w(smb_ucs2_t *s,smb_ucs2_t *list,BOOL casesensitive); +BOOL string_init_w(smb_ucs2_t **dest,const smb_ucs2_t *src); +void string_free_w(smb_ucs2_t **s); +BOOL string_set_w(smb_ucs2_t **dest,const smb_ucs2_t *src); +void string_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert, size_t len); +void fstring_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert); +void pstring_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,smb_ucs2_t *insert); +void all_string_sub_w(smb_ucs2_t *s,const smb_ucs2_t *pattern,const smb_ucs2_t *insert, size_t len); +void split_at_last_component_w(smb_ucs2_t *path, smb_ucs2_t *front, smb_ucs2_t sep, smb_ucs2_t *back); +smb_ucs2_t *octal_string_w(int i); +smb_ucs2_t *string_truncate_w(smb_ucs2_t *s, size_t length); +smb_ucs2_t doscp2ucs2(int w); +int ucs2doscp(smb_ucs2_t w); -/*The following definitions come from libsmb/unexpected.c */ +/*The following definitions come from lib/wins_srv.c */ -void unexpected_packet(struct packet_struct *p); -void clear_unexpected(time_t t); -struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, - char *mailslot_name); +BOOL wins_srv_load_list( char *src ); +struct in_addr wins_srv_ip( void ); +void wins_srv_died( struct in_addr boothill_ip ); +unsigned long wins_srv_count( void ); /*The following definitions come from locking/brlock.c */ @@ -1168,9 +1169,6 @@ BOOL queue_dns_query(struct packet_struct *p,struct nmb_name *question, struct name_record **n); void kill_async_dns_child(void); -/*The following definitions come from nmbd/nmbd.c */ - - /*The following definitions come from nmbd/nmbd_become_dmb.c */ void add_domain_names(time_t t); @@ -1201,6 +1199,9 @@ void announce_and_sync_with_domain_master_browser( struct subnet_record *subrec, void collect_all_workgroup_names_from_wins_server(time_t t); void sync_all_dmbs(time_t t); +/*The following definitions come from nmbd/nmbd.c */ + + /*The following definitions come from nmbd/nmbd_elections.c */ void check_master_browser_exists(time_t t); @@ -2013,11 +2014,6 @@ void pcap_printer_fn(void (*fn)(char *, char *)); void cups_printer_fn(void (*fn)(char *, char *)); int cups_printername_ok(char *name); -/*The following definitions come from printing/print_svid.c */ - -void sysv_printer_fn(void (*fn)(char *, char *)); -int sysv_printername_ok(char *name); - /*The following definitions come from printing/printfsp.c */ #if OLD_NTDOMAIN @@ -2050,6 +2046,11 @@ BOOL print_queue_resume(struct current_user *user, int snum, int *errcode); BOOL print_queue_purge(struct current_user *user, int snum, int *errcode); #endif +/*The following definitions come from printing/print_svid.c */ + +void sysv_printer_fn(void (*fn)(char *, char *)); +int sysv_printername_ok(char *name); + /*The following definitions come from profile/profile.c */ void profile_message(int msg_type, pid_t src, void *buf, size_t len); @@ -2262,6 +2263,17 @@ BOOL do_wks_query_info(struct cli_state *cli, char *server_name, uint32 switch_value, WKS_INFO_100 *wks100); +/*The following definitions come from rpcclient/cmd_lsarpc.c */ + + +/*The following definitions come from rpcclient/cmd_samr.c */ + +#if NEW_NTDOMAIN +#endif + +/*The following definitions come from rpcclient/cmd_spoolss.c */ + + /*The following definitions come from rpc_client/ncacn_np_use.c */ BOOL ncacn_np_use_del(const char *srv_name, const char *pipe_name, @@ -2275,6 +2287,12 @@ struct ncacn_np *ncacn_np_use_add(const char *pipe_name, const struct ntuser_creds *ntc, BOOL reuse, BOOL *is_new_connection); +/*The following definitions come from rpcclient/rpcclient.c */ + +void fetch_domain_sid(void); +void init_rpcclient_creds(struct ntuser_creds *creds); +void add_command_set(struct cmd_set *cmd_set); + /*The following definitions come from rpc_parse/parse_creds.c */ BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name, @@ -3493,23 +3511,6 @@ BOOL api_wkssvc_rpc(pipes_struct *p); uint32 _wks_query_info(pipes_struct *p, WKS_Q_QUERY_INFO *q_u, WKS_R_QUERY_INFO *r_u); #endif -/*The following definitions come from rpcclient/cmd_lsarpc.c */ - - -/*The following definitions come from rpcclient/cmd_samr.c */ - -#if NEW_NTDOMAIN -#endif - -/*The following definitions come from rpcclient/cmd_spoolss.c */ - - -/*The following definitions come from rpcclient/rpcclient.c */ - -void fetch_domain_sid(void); -void init_rpcclient_creds(struct ntuser_creds *creds); -void add_command_set(struct cmd_set *cmd_set); - /*The following definitions come from smbd/blocking.c */ #if OLD_NTDOMAIN @@ -3972,6 +3973,15 @@ connection_struct *make_connection(char *service,char *user,char *password, int void close_cnum(connection_struct *conn, uint16 vuid); #endif +/*The following definitions come from smbd/srvstr.c */ + +int srvstr_push(void *inbuf, void *outbuf, void *dest, const char *src, int dest_len, int flags); +int srvstr_push_size(void *inbuf, void *outbuf, + const void *dest, const char *src, int dest_len, int flags); +int srvstr_pull(void *inbuf, char *dest, const void *src, int dest_len, int src_len, int flags); +int srvstr_pull_size(void *inbuf, const void *src, int src_len); +int srvstr_align(void *inbuf, int offset); + /*The following definitions come from smbd/ssl.c */ int sslutil_init(int isServer); @@ -4019,6 +4029,27 @@ BOOL sid_to_uid(DOM_SID *psid, uid_t *puid, enum SID_NAME_USE *sidtype); BOOL sid_to_gid(DOM_SID *psid, gid_t *pgid, enum SID_NAME_USE *sidtype); #endif +/*The following definitions come from smbd/vfs.c */ + +#if OLD_NTDOMAIN +int vfs_init_default(connection_struct *conn); +BOOL vfs_init_custom(connection_struct *conn); +BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st); +int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode); +char *vfs_getwd(connection_struct *conn, char *unix_path); +BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf); +ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count); +ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N); +int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len); +SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp, + int out_fd, files_struct *out_fsp, + SMB_OFF_T n, char *header, int headlen, int align); +char *vfs_readdirname(connection_struct *conn, void *p); +int vfs_ChDir(connection_struct *conn, char *path); +char *vfs_GetWd(connection_struct *conn, char *path); +BOOL reduce_name(connection_struct *conn, char *s,char *dir,BOOL widelinks); +#endif + /*The following definitions come from smbd/vfs-wrap.c */ #if OLD_NTDOMAIN @@ -4057,27 +4088,6 @@ int vfswrap_chmod_acl(connection_struct *conn, char *name, mode_t mode); int vfswrap_fchmod_acl(files_struct *fsp, int fd, mode_t mode); #endif -/*The following definitions come from smbd/vfs.c */ - -#if OLD_NTDOMAIN -int vfs_init_default(connection_struct *conn); -BOOL vfs_init_custom(connection_struct *conn); -BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st); -int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode); -char *vfs_getwd(connection_struct *conn, char *unix_path); -BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf); -ssize_t vfs_read_data(files_struct *fsp, char *buf, size_t byte_count); -ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N); -int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len); -SMB_OFF_T vfs_transfer_file(int in_fd, files_struct *in_fsp, - int out_fd, files_struct *out_fsp, - SMB_OFF_T n, char *header, int headlen, int align); -char *vfs_readdirname(connection_struct *conn, void *p); -int vfs_ChDir(connection_struct *conn, char *path); -char *vfs_GetWd(connection_struct *conn, char *path); -BOOL reduce_name(connection_struct *conn, char *s,char *dir,BOOL widelinks); -#endif - /*The following definitions come from smbwrapper/realcalls.c */ int real_utime(const char *name, struct utimbuf *buf); diff --git a/source/include/smb.h b/source/include/smb.h index d4073a23146..d16c7661fec 100644 --- a/source/include/smb.h +++ b/source/include/smb.h @@ -52,6 +52,14 @@ typedef int BOOL; #define DEF_CREATE_MASK (0755) #endif +/* string manipulation flags - see clistr.c and srvstr.c */ +#define STR_TERMINATE 1 +#define STR_CONVERT 2 +#define STR_UPPER 4 +#define STR_ASCII 8 +#define STR_UNICODE 16 + + /* how long to wait for secondary SMB packets (milli-seconds) */ #define SMB_SECONDARY_WAIT (60*1000) diff --git a/source/libsmb/cliconnect.c b/source/libsmb/cliconnect.c index f2f9b89ea44..46a63dc5f19 100644 --- a/source/libsmb/cliconnect.c +++ b/source/libsmb/cliconnect.c @@ -104,7 +104,7 @@ BOOL cli_session_setup(struct cli_state *cli, /* * Plaintext mode needed, assume plaintext supplied. */ - passlen = clistr_push(cli, pword, pass, -1, CLISTR_CONVERT|CLISTR_TERMINATE); + passlen = clistr_push(cli, pword, pass, -1, STR_CONVERT|STR_TERMINATE); fstrcpy(ntpword, ""); ntpasslen = 0; } @@ -136,7 +136,7 @@ BOOL cli_session_setup(struct cli_state *cli, p = smb_buf(cli->outbuf); memcpy(p,pword,passlen); p += passlen; - p += clistr_push(cli, p, user, -1, CLISTR_CONVERT|CLISTR_UPPER|CLISTR_TERMINATE); + p += clistr_push(cli, p, user, -1, STR_CONVERT|STR_UPPER|STR_TERMINATE); cli_setup_bcc(cli, p); } else @@ -167,10 +167,10 @@ BOOL cli_session_setup(struct cli_state *cli, p += SVAL(cli->outbuf,smb_vwv7); memcpy(p,ntpword,ntpasslen); p += SVAL(cli->outbuf,smb_vwv8); - p += clistr_push(cli, p, user, -1, CLISTR_CONVERT|CLISTR_TERMINATE|CLISTR_UPPER); - p += clistr_push(cli, p, workgroup, -1, CLISTR_CONVERT|CLISTR_TERMINATE|CLISTR_UPPER); - p += clistr_push(cli, p, "Unix", -1, CLISTR_CONVERT|CLISTR_TERMINATE); - p += clistr_push(cli, p, "Samba", -1, CLISTR_CONVERT|CLISTR_TERMINATE); + p += clistr_push(cli, p, user, -1, STR_CONVERT|STR_TERMINATE|STR_UPPER); + p += clistr_push(cli, p, workgroup, -1, STR_CONVERT|STR_TERMINATE|STR_UPPER); + p += clistr_push(cli, p, "Unix", -1, STR_CONVERT|STR_TERMINATE); + p += clistr_push(cli, p, "Samba", -1, STR_CONVERT|STR_TERMINATE); cli_setup_bcc(cli, p); } @@ -193,9 +193,9 @@ BOOL cli_session_setup(struct cli_state *cli, * info. */ char *q = smb_buf(cli->inbuf); - q += clistr_pull(cli, cli->server_os, q, sizeof(fstring), -1, CLISTR_TERMINATE|CLISTR_CONVERT); - q += clistr_pull(cli, cli->server_type, q, sizeof(fstring), -1, CLISTR_TERMINATE|CLISTR_CONVERT); - q += clistr_pull(cli, cli->server_domain, q, sizeof(fstring), -1, CLISTR_TERMINATE|CLISTR_CONVERT); + q += clistr_pull(cli, cli->server_os, q, sizeof(fstring), -1, STR_TERMINATE|STR_CONVERT); + q += clistr_pull(cli, cli->server_type, q, sizeof(fstring), -1, STR_TERMINATE|STR_CONVERT); + q += clistr_pull(cli, cli->server_domain, q, sizeof(fstring), -1, STR_TERMINATE|STR_CONVERT); } fstrcpy(cli->user_name, user); @@ -255,7 +255,7 @@ BOOL cli_send_tconX(struct cli_state *cli, /* * Non-encrypted passwords - convert to DOS codepage before using. */ - passlen = clistr_push(cli, pword, pass, -1, CLISTR_CONVERT|CLISTR_TERMINATE); + passlen = clistr_push(cli, pword, pass, -1, STR_CONVERT|STR_TERMINATE); } else { memcpy(pword, pass, passlen); } @@ -276,7 +276,7 @@ BOOL cli_send_tconX(struct cli_state *cli, p = smb_buf(cli->outbuf); memcpy(p,pword,passlen); p += passlen; - p += clistr_push(cli, p, fullshare, -1, CLISTR_CONVERT | CLISTR_TERMINATE); + p += clistr_push(cli, p, fullshare, -1, STR_CONVERT | STR_TERMINATE); fstrcpy(p, dev); p += strlen(dev)+1; cli_setup_bcc(cli, p); @@ -294,7 +294,7 @@ BOOL cli_send_tconX(struct cli_state *cli, fstrcpy(cli->dev, "A:"); if (cli->protocol >= PROTOCOL_NT1) { - clistr_pull(cli, cli->dev, smb_buf(cli->inbuf), sizeof(fstring), -1, CLISTR_TERMINATE | CLISTR_CONVERT); + clistr_pull(cli, cli->dev, smb_buf(cli->inbuf), sizeof(fstring), -1, STR_TERMINATE | STR_CONVERT); } if (strcasecmp(share,"IPC$")==0) { diff --git a/source/libsmb/clifile.c b/source/libsmb/clifile.c index 3471ecdc679..8742a576cf3 100644 --- a/source/libsmb/clifile.c +++ b/source/libsmb/clifile.c @@ -44,10 +44,10 @@ BOOL cli_rename(struct cli_state *cli, char *fname_src, char *fname_dst) p = smb_buf(cli->outbuf); *p++ = 4; p += clistr_push(cli, p, fname_src, -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + STR_TERMINATE | STR_CONVERT); *p++ = 4; p += clistr_push(cli, p, fname_dst, -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + STR_TERMINATE | STR_CONVERT); cli_setup_bcc(cli, p); @@ -83,7 +83,7 @@ BOOL cli_unlink(struct cli_state *cli, char *fname) p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); + p += clistr_push(cli, p, fname, -1, STR_TERMINATE | STR_CONVERT); cli_setup_bcc(cli, p); cli_send_smb(cli); @@ -116,7 +116,7 @@ BOOL cli_mkdir(struct cli_state *cli, char *dname) p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, dname, -1, CLISTR_CONVERT|CLISTR_TERMINATE); + p += clistr_push(cli, p, dname, -1, STR_CONVERT|STR_TERMINATE); cli_setup_bcc(cli, p); @@ -150,7 +150,7 @@ BOOL cli_rmdir(struct cli_state *cli, char *dname) p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, dname, -1, CLISTR_TERMINATE|CLISTR_CONVERT); + p += clistr_push(cli, p, dname, -1, STR_TERMINATE|STR_CONVERT); cli_setup_bcc(cli, p); @@ -199,11 +199,11 @@ int cli_nt_create(struct cli_state *cli, char *fname, uint32 DesiredAccess) p = smb_buf(cli->outbuf); /* this alignment and termination is critical for netapp filers. Don't change */ p += clistr_align(cli, PTR_DIFF(p, cli->outbuf)); - len = clistr_push(cli, p, fname, -1, CLISTR_CONVERT); + len = clistr_push(cli, p, fname, -1, STR_CONVERT); p += len; SSVAL(cli->outbuf,smb_ntcreate_NameLength, len); /* sigh. this copes with broken netapp filer behaviour */ - p += clistr_push(cli, p, "", -1, CLISTR_TERMINATE); + p += clistr_push(cli, p, "", -1, STR_TERMINATE); cli_setup_bcc(cli, p); @@ -281,7 +281,7 @@ int cli_open(struct cli_state *cli, char *fname, int flags, int share_mode) } p = smb_buf(cli->outbuf); - p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); + p += clistr_push(cli, p, fname, -1, STR_TERMINATE | STR_CONVERT); cli_setup_bcc(cli, p); @@ -597,7 +597,7 @@ BOOL cli_getatr(struct cli_state *cli, char *fname, p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); + p += clistr_push(cli, p, fname, -1, STR_TERMINATE | STR_CONVERT); cli_setup_bcc(cli, p); @@ -648,7 +648,7 @@ BOOL cli_setatr(struct cli_state *cli, char *fname, uint16 attr, time_t t) p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, fname, -1, CLISTR_TERMINATE | CLISTR_CONVERT); + p += clistr_push(cli, p, fname, -1, STR_TERMINATE | STR_CONVERT); *p++ = 4; cli_setup_bcc(cli, p); @@ -685,7 +685,7 @@ BOOL cli_chkpath(struct cli_state *cli, char *path) cli_setup_packet(cli); p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, path2, -1, CLISTR_TERMINATE | CLISTR_CONVERT); + p += clistr_push(cli, p, path2, -1, STR_TERMINATE | STR_CONVERT); cli_setup_bcc(cli, p); diff --git a/source/libsmb/clilist.c b/source/libsmb/clilist.c index 175673d4fef..f0ca0d5f548 100644 --- a/source/libsmb/clilist.c +++ b/source/libsmb/clilist.c @@ -51,7 +51,7 @@ static int interpret_long_filename(struct cli_state *cli, clistr_pull(cli, finfo->name, p+27, sizeof(finfo->name), -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + STR_TERMINATE | STR_CONVERT); } return(28 + CVAL(p,26)); @@ -66,7 +66,7 @@ static int interpret_long_filename(struct cli_state *cli, clistr_pull(cli, finfo->name, p+31, sizeof(finfo->name), -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + STR_TERMINATE | STR_CONVERT); } return(32 + CVAL(p,30)); @@ -82,7 +82,7 @@ static int interpret_long_filename(struct cli_state *cli, clistr_pull(cli, finfo->name, p+33, sizeof(finfo->name), -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + STR_TERMINATE | STR_CONVERT); } return(SVAL(p,4)+4); @@ -97,7 +97,7 @@ static int interpret_long_filename(struct cli_state *cli, clistr_pull(cli, finfo->name, p+37, sizeof(finfo->name), -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + STR_TERMINATE | STR_CONVERT); } return(SVAL(p,4)+4); @@ -135,8 +135,8 @@ static int interpret_long_filename(struct cli_state *cli, p += 2; { /* stupid NT bugs. grr */ - int flags = CLISTR_CONVERT; - if (p[1] == 0 && namelen > 1) flags |= CLISTR_UNICODE; + int flags = STR_CONVERT; + if (p[1] == 0 && namelen > 1) flags |= STR_UNICODE; clistr_pull(cli, finfo->short_name, p, sizeof(finfo->short_name), 24, flags); @@ -145,7 +145,7 @@ static int interpret_long_filename(struct cli_state *cli, clistr_pull(cli, finfo->name, p, sizeof(finfo->name), namelen, - CLISTR_CONVERT); + STR_CONVERT); return(ret); } return(SVAL(p,0)); @@ -195,8 +195,8 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, } param_len = 12+clistr_push_size(cli, NULL, mask, -1, - CLISTR_TERMINATE | - CLISTR_CONVERT); + STR_TERMINATE | + STR_CONVERT); if (First) { setup = TRANSACT2_FINDFIRST; @@ -206,7 +206,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, SSVAL(param,6,info_level); SIVAL(param,8,0); clistr_push(cli, param+12, mask, -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + STR_TERMINATE | STR_CONVERT); } else { setup = TRANSACT2_FINDNEXT; SSVAL(param,0,ff_dir_handle); @@ -215,7 +215,7 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, SIVAL(param,6,0); /* ff_resume_key */ SSVAL(param,10,8+4+2); /* continue + resume required + close on end */ clistr_push(cli, param+12, mask, -1, - CLISTR_TERMINATE | CLISTR_CONVERT); + STR_TERMINATE | STR_CONVERT); } if (!cli_send_trans(cli, SMBtrans2, @@ -271,15 +271,15 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute, clistr_pull(cli, mask, p+ff_lastname, sizeof(mask), data_len-ff_lastname, - CLISTR_TERMINATE | - CLISTR_CONVERT); + STR_TERMINATE | + STR_CONVERT); break; case 1: clistr_pull(cli, mask, p+ff_lastname+1, sizeof(mask), -1, - CLISTR_TERMINATE | - CLISTR_CONVERT); + STR_TERMINATE | + STR_CONVERT); break; } } else { @@ -392,7 +392,7 @@ int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute, p = smb_buf(cli->outbuf); *p++ = 4; - p += clistr_push(cli, p, first?mask:"", -1, CLISTR_TERMINATE|CLISTR_CONVERT); + p += clistr_push(cli, p, first?mask:"", -1, STR_TERMINATE|STR_CONVERT); *p++ = 5; if (first) { SSVAL(p,0,0); diff --git a/source/libsmb/climessage.c b/source/libsmb/climessage.c index 47139dcfd61..87f81754599 100644 --- a/source/libsmb/climessage.c +++ b/source/libsmb/climessage.c @@ -42,10 +42,10 @@ BOOL cli_message_start(struct cli_state *cli, char *host, char *username, p = smb_buf(cli->outbuf); *p++ = 4; p += clistr_push(cli, p, username, -1, - CLISTR_TERMINATE|CLISTR_CONVERT); + STR_TERMINATE|STR_CONVERT); *p++ = 4; p += clistr_push(cli, p, host, -1, - CLISTR_TERMINATE|CLISTR_CONVERT); + STR_TERMINATE|STR_CONVERT); cli_setup_bcc(cli, p); diff --git a/source/libsmb/clirap.c b/source/libsmb/clirap.c index 3c87464495d..561d717e730 100644 --- a/source/libsmb/clirap.c +++ b/source/libsmb/clirap.c @@ -235,7 +235,7 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype, p += 4; p += clistr_push(cli, p, workgroup, -1, - CLISTR_TERMINATE | CLISTR_CONVERT | CLISTR_ASCII); + STR_TERMINATE | STR_CONVERT | STR_ASCII); if (cli_api(cli, param, PTR_DIFF(p,param), 8, /* params, length, max */ @@ -394,7 +394,7 @@ BOOL cli_qpathinfo(struct cli_state *cli, const char *fname, memset(p, 0, 6); SSVAL(p, 0, SMB_INFO_STANDARD); p += 6; - p += clistr_push(cli, p, fname, sizeof(pstring)-6, CLISTR_TERMINATE | CLISTR_CONVERT); + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE | STR_CONVERT); param_len = PTR_DIFF(p, param); @@ -470,7 +470,7 @@ BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname, memset(p, 0, 6); SSVAL(p, 0, SMB_QUERY_FILE_ALL_INFO); p += 6; - p += clistr_push(cli, p, fname, sizeof(pstring)-6, CLISTR_TERMINATE | CLISTR_CONVERT); + p += clistr_push(cli, p, fname, sizeof(pstring)-6, STR_TERMINATE | STR_CONVERT); param_len = PTR_DIFF(p, param); diff --git a/source/libsmb/clistr.c b/source/libsmb/clistr.c index 1835e159710..c0e7231d7a7 100644 --- a/source/libsmb/clistr.c +++ b/source/libsmb/clistr.c @@ -29,10 +29,10 @@ dos code page destination choosing unicode or ascii based on the cli->capabilities flag return the number of bytes occupied by the string in the destination flags can have: - CLISTR_TERMINATE means include the null termination - CLISTR_CONVERT means convert from unix to dos codepage - CLISTR_UPPER means uppercase in the destination - CLISTR_ASCII use ascii even with unicode servers + STR_TERMINATE means include the null termination + STR_CONVERT means convert from unix to dos codepage + STR_UPPER means uppercase in the destination + STR_ASCII use ascii even with unicode servers dest_len is the maximum length allowed in the destination. If dest_len is -1 then no maxiumum is used ****************************************************************************/ @@ -45,52 +45,52 @@ int clistr_push(struct cli_state *cli, void *dest, const char *src, int dest_len dest_len = sizeof(pstring); } - if (!(flags & CLISTR_ASCII) && clistr_align(cli, PTR_DIFF(dest, cli->outbuf))) { + if (!(flags & STR_ASCII) && clistr_align(cli, PTR_DIFF(dest, cli->outbuf))) { *(char *)dest = 0; dest++; dest_len--; len++; } - if ((flags & CLISTR_ASCII) || !(cli->capabilities & CAP_UNICODE)) { + if ((flags & STR_ASCII) || !(cli->capabilities & CAP_UNICODE)) { /* the server doesn't want unicode */ safe_strcpy(dest, src, dest_len); len = strlen(dest); - if (flags & CLISTR_TERMINATE) len++; - if (flags & CLISTR_CONVERT) unix_to_dos(dest,True); - if (flags & CLISTR_UPPER) strupper(dest); + if (flags & STR_TERMINATE) len++; + if (flags & STR_CONVERT) unix_to_dos(dest,True); + if (flags & STR_UPPER) strupper(dest); return len; } /* the server likes unicode. give it the works */ - if (flags & CLISTR_CONVERT) { - dos_PutUniCode(dest, src, dest_len, flags & CLISTR_TERMINATE); + if (flags & STR_CONVERT) { + dos_PutUniCode(dest, src, dest_len, flags & STR_TERMINATE); } else { ascii_to_unistr(dest, src, dest_len); } - if (flags & CLISTR_UPPER) { + if (flags & STR_UPPER) { strupper_w(dest); } len += strlen(src)*2; - if (flags & CLISTR_TERMINATE) len += 2; + if (flags & STR_TERMINATE) len += 2; return len; } /**************************************************************************** return the length that a string would occupy when copied with clistr_push() - CLISTR_TERMINATE means include the null termination - CLISTR_CONVERT means convert from unix to dos codepage - CLISTR_UPPER means uppercase in the destination + STR_TERMINATE means include the null termination + STR_CONVERT means convert from unix to dos codepage + STR_UPPER means uppercase in the destination note that dest is only used for alignment purposes. No data is written. ****************************************************************************/ int clistr_push_size(struct cli_state *cli, const void *dest, const char *src, int dest_len, int flags) { int len = strlen(src); - if (flags & CLISTR_TERMINATE) len++; - if (!(flags & CLISTR_ASCII) && (cli->capabilities & CAP_UNICODE)) len *= 2; + if (flags & STR_TERMINATE) len++; + if (!(flags & STR_ASCII) && (cli->capabilities & CAP_UNICODE)) len *= 2; - if (!(flags & CLISTR_ASCII) && dest && clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) { + if (!(flags & STR_ASCII) && dest && clistr_align(cli, PTR_DIFF(cli->outbuf, dest))) { len++; } @@ -101,10 +101,10 @@ int clistr_push_size(struct cli_state *cli, const void *dest, const char *src, i copy a string from a unicode or ascii source (depending on cli->capabilities) to a char* destination flags can have: - CLISTR_CONVERT means convert from dos to unix codepage - CLISTR_TERMINATE means the string in src is null terminated - CLISTR_UNICODE means to force as unicode -if CLISTR_TERMINATE is set then src_len is ignored + STR_CONVERT means convert from dos to unix codepage + STR_TERMINATE means the string in src is null terminated + STR_UNICODE means to force as unicode +if STR_TERMINATE is set then src_len is ignored src_len is the length of the source area in bytes return the number of bytes occupied by the string in src ****************************************************************************/ @@ -121,9 +121,9 @@ int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len if (src_len > 0) src_len--; } - if (!(flags & CLISTR_UNICODE) && !(cli->capabilities & CAP_UNICODE)) { + if (!(flags & STR_UNICODE) && !(cli->capabilities & CAP_UNICODE)) { /* the server doesn't want unicode */ - if (flags & CLISTR_TERMINATE) { + if (flags & STR_TERMINATE) { safe_strcpy(dest, src, dest_len); len = strlen(src)+1; } else { @@ -132,11 +132,11 @@ int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len memcpy(dest, src, len); dest[len] = 0; } - if (flags & CLISTR_CONVERT) dos_to_unix(dest,True); + if (flags & STR_CONVERT) dos_to_unix(dest,True); return len; } - if (flags & CLISTR_TERMINATE) { + if (flags & STR_TERMINATE) { unistr_to_ascii(dest, src, dest_len); len = strlen(dest)*2 + 2; } else { @@ -149,7 +149,7 @@ int clistr_pull(struct cli_state *cli, char *dest, const void *src, int dest_len *dest++ = 0; len = src_len; } - if (flags & CLISTR_CONVERT) dos_to_unix(dest,True); + if (flags & STR_CONVERT) dos_to_unix(dest,True); return len; } diff --git a/source/libsmb/clitrans.c b/source/libsmb/clitrans.c index 630e9f93c00..0bbe7c6dae8 100644 --- a/source/libsmb/clitrans.c +++ b/source/libsmb/clitrans.c @@ -53,7 +53,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, if (pipe_name) { pipe_name_len = clistr_push_size(cli, smb_buf(cli->outbuf), pipe_name, -1, - CLISTR_TERMINATE); + STR_TERMINATE); } outparam = smb_buf(cli->outbuf)+(trans==SMBtrans ? pipe_name_len : 3); @@ -76,7 +76,7 @@ BOOL cli_send_trans(struct cli_state *cli, int trans, SSVAL(cli->outbuf,smb_setup+i*2,setup[i]); p = smb_buf(cli->outbuf); if (trans==SMBtrans) { - clistr_push(cli, p, pipe_name, -1, CLISTR_TERMINATE); + clistr_push(cli, p, pipe_name, -1, STR_TERMINATE); } else { *p++ = 0; /* put in a null smb_name */ *p++ = 'D'; *p++ = ' '; /* observed in OS/2 */ -- cgit