summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h836
-rw-r--r--source3/printing/nt_printing.c105
-rw-r--r--source3/printing/printfsp.c4
-rw-r--r--source3/printing/printing.c13
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c87
-rw-r--r--source3/smbd/close.c4
-rw-r--r--source3/smbd/lanman.c2
-rw-r--r--source3/tdb/Makefile14
-rw-r--r--source3/tdb/tdb.c32
-rw-r--r--source3/tdb/tdbtool.c83
10 files changed, 672 insertions, 508 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 77a1898954..ffd6a8bfe5 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -214,10 +214,361 @@ void CatchChildLeaveStatus(void);
int vslprintf(char *str, int n, char *format, va_list ap);
+/*The following definitions come from libsmb/cliconnect.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);
+
+/*The following definitions come from libsmb/clidgram.c */
+
+int cli_send_mailslot(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 cli_get_response(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 libsmb/clientgen.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_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 libsmb/clierror.c */
+
+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 libsmb/clifile.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_nt_create_uni(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 libsmb/clilist.c */
+
+int cli_list(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 *));
+
+/*The following definitions come from libsmb/cli_lsarpc.c */
+
+struct cli_state *cli_lsa_initialise(struct cli_state *cli, char *system_name,
+ struct ntuser_creds *creds);
+void cli_lsa_shutdown(struct cli_state *cli);
+uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos,
+ uint32 des_access, POLICY_HND *pol);
+uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *pol);
+uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *pol,
+ int num_sids, DOM_SID *sids, char ***names,
+ uint32 **types, int *num_names);
+uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *pol,
+ int num_names, char **names, DOM_SID **sids,
+ uint32 **types, int *num_sids);
+uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *pol,
+ uint16 info_class, fstring domain_name,
+ DOM_SID * domain_sid);
+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, int pipe_name_len,
+ 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
+struct cli_state *cli_samr_initialise(struct cli_state *cli, char *system_name,
+ struct ntuser_creds *creds);
+void cli_samr_shutdown(struct cli_state *cli);
+uint32 cli_samr_connect(struct cli_state *cli, char *srv_name,
+ uint32 access_mask, POLICY_HND *connect_pol);
+uint32 cli_samr_close(struct cli_state *cli, POLICY_HND *connect_pol);
+uint32 cli_samr_open_domain(struct cli_state *cli, POLICY_HND *connect_pol,
+ uint32 access_mask, DOM_SID *domain_sid,
+ POLICY_HND *domain_pol);
+uint32 cli_samr_open_user(struct cli_state *cli, POLICY_HND *domain_pol,
+ uint32 access_mask, uint32 user_rid,
+ POLICY_HND *user_pol);
+uint32 cli_samr_open_group(struct cli_state *cli, POLICY_HND *domain_pol,
+ uint32 access_mask, uint32 group_rid,
+ POLICY_HND *group_pol);
+uint32 cli_samr_query_userinfo(struct cli_state *cli, POLICY_HND *user_pol,
+ uint16 switch_value, SAM_USERINFO_CTR *ctr);
+uint32 cli_samr_query_groupinfo(struct cli_state *cli, POLICY_HND *group_pol,
+ uint32 info_level, GROUP_INFO_CTR *ctr);
+uint32 cli_samr_query_usergroups(struct cli_state *cli, POLICY_HND *user_pol,
+ uint32 *num_groups, DOM_GID **gid);
+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,
+ char *system_name,
+ struct ntuser_creds *creds);
+void cli_spoolss_shutdown(struct cli_state *cli);
+uint32 cli_spoolss_open_printer_ex(struct cli_state *cli, char *printername,
+ char *datatype, uint32 access_required,
+ char *station, char *username,
+ POLICY_HND *pol);
+uint32 cli_spoolss_closeprinter(struct cli_state *cli, POLICY_HND *pol);
+uint32 cli_spoolss_enum_printers(struct cli_state *cli, uint32 flags,
+ uint32 level, int *returned,
+ PRINTER_INFO_CTR *ctr);
+uint32 cli_spoolss_enum_ports(struct cli_state *cli, uint32 level,
+ int *returned, PORT_INFO_CTR *ctr);
+uint32 cli_spoolss_getprinter(struct cli_state *cli, POLICY_HND *pol,
+ uint32 level, PRINTER_INFO_CTR *ctr);
+
+/*The following definitions come from libsmb/clitrans.c */
+
+BOOL cli_send_trans(struct cli_state *cli, int trans,
+ char *name, int pipe_name_len,
+ 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/credentials.c */
+
+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);
+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_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/smberr.c */
+
+char *smb_errstr(char *inbuf);
+
+/*The following definitions come from libsmb/unexpected.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);
+
/*The following definitions come from lib/snprintf.c */
@@ -355,6 +706,23 @@ 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_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.c */
char *tmpdir(void);
@@ -421,23 +789,6 @@ 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);
@@ -663,358 +1014,6 @@ 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 libsmb/cli_lsarpc.c */
-
-struct cli_state *cli_lsa_initialise(struct cli_state *cli, char *system_name,
- struct ntuser_creds *creds);
-void cli_lsa_shutdown(struct cli_state *cli);
-uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos,
- uint32 des_access, POLICY_HND *pol);
-uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *pol);
-uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *pol,
- int num_sids, DOM_SID *sids, char ***names,
- uint32 **types, int *num_names);
-uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *pol,
- int num_names, char **names, DOM_SID **sids,
- uint32 **types, int *num_sids);
-uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *pol,
- uint16 info_class, fstring domain_name,
- DOM_SID * domain_sid);
-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/cli_samr.c */
-
-#if NEW_NTDOMAIN
-struct cli_state *cli_samr_initialise(struct cli_state *cli, char *system_name,
- struct ntuser_creds *creds);
-void cli_samr_shutdown(struct cli_state *cli);
-uint32 cli_samr_connect(struct cli_state *cli, char *srv_name,
- uint32 access_mask, POLICY_HND *connect_pol);
-uint32 cli_samr_close(struct cli_state *cli, POLICY_HND *connect_pol);
-uint32 cli_samr_open_domain(struct cli_state *cli, POLICY_HND *connect_pol,
- uint32 access_mask, DOM_SID *domain_sid,
- POLICY_HND *domain_pol);
-uint32 cli_samr_open_user(struct cli_state *cli, POLICY_HND *domain_pol,
- uint32 access_mask, uint32 user_rid,
- POLICY_HND *user_pol);
-uint32 cli_samr_open_group(struct cli_state *cli, POLICY_HND *domain_pol,
- uint32 access_mask, uint32 group_rid,
- POLICY_HND *group_pol);
-uint32 cli_samr_query_userinfo(struct cli_state *cli, POLICY_HND *user_pol,
- uint16 switch_value, SAM_USERINFO_CTR *ctr);
-uint32 cli_samr_query_groupinfo(struct cli_state *cli, POLICY_HND *group_pol,
- uint32 info_level, GROUP_INFO_CTR *ctr);
-uint32 cli_samr_query_usergroups(struct cli_state *cli, POLICY_HND *user_pol,
- uint32 *num_groups, DOM_GID **gid);
-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/cli_spoolss.c */
-
-struct cli_state *cli_spoolss_initialise(struct cli_state *cli,
- char *system_name,
- struct ntuser_creds *creds);
-void cli_spoolss_shutdown(struct cli_state *cli);
-uint32 cli_spoolss_open_printer_ex(struct cli_state *cli, char *printername,
- char *datatype, uint32 access_required,
- char *station, char *username,
- POLICY_HND *pol);
-uint32 cli_spoolss_closeprinter(struct cli_state *cli, POLICY_HND *pol);
-uint32 cli_spoolss_enum_printers(struct cli_state *cli, uint32 flags,
- uint32 level, int *returned,
- PRINTER_INFO_CTR *ctr);
-uint32 cli_spoolss_enum_ports(struct cli_state *cli, uint32 level,
- int *returned, PORT_INFO_CTR *ctr);
-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 */
-
-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 libsmb/clidgram.c */
-
-int cli_send_mailslot(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 cli_get_response(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 libsmb/clientgen.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_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 libsmb/clierror.c */
-
-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 libsmb/clifile.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_nt_create_uni(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 libsmb/clilist.c */
-
-int cli_list(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 *));
-
-/*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, int pipe_name_len,
- 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/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/clitrans.c */
-
-BOOL cli_send_trans(struct cli_state *cli, int trans,
- char *name, int pipe_name_len,
- 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/credentials.c */
-
-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);
-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_resolve_bcast(const char *name, int name_type,
- struct in_addr **return_ip_list, int *return_count);
-BOOL is_ip_address(const char *name);
-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 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/smberr.c */
-
-char *smb_errstr(char *inbuf);
-
-/*The following definitions come from libsmb/unexpected.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);
-
/*The following definitions come from locking/brlock.c */
void brl_init(int read_only);
@@ -1101,9 +1100,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);
@@ -1134,6 +1130,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);
@@ -1930,6 +1929,7 @@ BOOL nt_printing_getsec(char *printername, SEC_DESC_BUF **secdesc_ctr);
void map_printer_permissions(SEC_DESC *sd);
BOOL print_access_check(struct current_user *user, int snum, int access_type);
BOOL print_time_access_check(int snum);
+uint32 printer_write_default_dev(int snum, const PRINTER_DEFAULT *printer_default);
#endif
/*The following definitions come from printing/pcap.c */
@@ -1942,16 +1942,11 @@ 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
files_struct *print_fsp_open(connection_struct *conn,char *jobname);
-void print_fsp_end(files_struct *fsp);
+void print_fsp_end(files_struct *fsp, BOOL normal_close);
#endif
/*The following definitions come from printing/printing.c */
@@ -1969,7 +1964,7 @@ BOOL print_job_pause(struct current_user *user, int jobid, int *errcode);
BOOL print_job_resume(struct current_user *user, int jobid, int *errcode);
int print_job_write(int jobid, const char *buf, int size);
int print_job_start(struct current_user *user, int snum, char *jobname);
-BOOL print_job_end(int jobid);
+BOOL print_job_end(int jobid, BOOL normal_close);
int print_queue_status(int snum,
print_queue_struct **queue,
print_status_struct *status);
@@ -1979,6 +1974,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);
@@ -2192,6 +2192,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,
@@ -2205,6 +2216,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,
@@ -3339,6 +3356,8 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername,
const PRINTER_DEFAULT *printer_default,
uint32 user_switch, SPOOL_USER_CTR user_ctr,
POLICY_HND *handle);
+BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode,
+ NT_DEVICEMODE **pp_nt_devmode);
uint32 _spoolss_closeprinter(POLICY_HND *handle);
uint32 _spoolss_deleteprinter(POLICY_HND *handle);
uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename,
@@ -3468,23 +3487,6 @@ uint32 lookup_user_rid(char *user_name, uint32 *rid);
BOOL api_wkssvc_rpc(pipes_struct *p);
#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
@@ -3994,6 +3996,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
@@ -4032,27 +4055,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/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index eb4b243f2e..ff24849f0b 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1722,8 +1722,6 @@ static uint32 update_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
char *buf;
int buflen, len, ret;
TDB_DATA kbuf, dbuf;
- NT_PRINTER_INFO_LEVEL_2 *old_printer = NULL;
- NT_DEVICEMODE *devmode = NULL;
/*
* in addprinter: no servername and the printer is the name
@@ -1779,20 +1777,7 @@ static uint32 update_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
info->datatype,
info->parameters);
- /* do not write a NULL devicemode if there was previously
- a valid one. Windows 2000 likes to send setprinter calls
- with NULL devicemodes (e.g. HP 4050 PCL6 driver) --jerry
-
- We need to get the previously saved information for
- this printer if the devicemode is NULL */
- devmode = info->devmode;
- if (!devmode && info->sharename)
- {
- get_a_printer_2(&old_printer, info->sharename);
- if (old_printer)
- devmode = old_printer->devmode;
- }
- len += pack_devicemode(devmode, buf+len, buflen-len);
+ len += pack_devicemode(info->devmode, buf+len, buflen-len);
len += pack_specifics(info->specific, buf+len, buflen-len);
@@ -1821,9 +1806,6 @@ static uint32 update_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
DEBUG(8,("packed printer [%s] with driver [%s] portname=[%s] len=%d\n",
info->sharename, info->drivername, info->portname, len));
- if (old_printer)
- free_nt_printer_info_level_2(&old_printer);
-
return ret;
}
@@ -1977,8 +1959,7 @@ NT_DEVICEMODE *construct_nt_devicemode(const fstring default_devicename)
nt_devmode->panningwidth = 0;
nt_devmode->panningheight = 0;
- nt_devmode->private=NULL;
-
+ nt_devmode->private = NULL;
return nt_devmode;
}
@@ -2110,7 +2091,7 @@ static int unpack_devicemode(NT_DEVICEMODE **nt_devmode, char *buf, int buflen)
if (devmode.private) {
/* the len in tdb_unpack is an int value and
- * devmoce.driverextra is only a short
+ * devmode.driverextra is only a short
*/
len += tdb_unpack(buf+len, buflen-len, "B", &extra_len, &devmode.private);
devmode.driverextra=(uint16)extra_len;
@@ -2198,8 +2179,18 @@ static uint32 get_a_printer_2_default(NT_PRINTER_INFO_LEVEL_2 **info_ptr, fstrin
info.default_priority = 1;
info.setuptime = (uint32)time(NULL);
+#if 1 /* JRA - NO NOT CHANGE ! */
+ info.devmode = NULL;
+#else
+ /*
+ * We should not return a default devicemode, as this causes
+ * Win2K to not send the correct one on PCL drivers. It needs to
+ * see a null devicemode so it can then overwrite the devicemode
+ * on OpenPrinterEx. Yes this *is* insane :-). JRA.
+ */
if ((info.devmode = construct_nt_devicemode(info.printername)) == NULL)
goto fail;
+#endif
if (!nt_printing_getsec(sharename, &info.secdesc_buf))
goto fail;
@@ -2421,9 +2412,13 @@ uint32 add_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
NTTIME time_nt;
time_t time_unix = time(NULL);
unix_to_nt_time(&time_nt, time_unix);
- printer.info_2->changeid=time_nt.low;
+ if (printer.info_2->changeid==time_nt.low)
+ printer.info_2->changeid++;
+ else
+ printer.info_2->changeid=time_nt.low;
printer.info_2->c_setprinter++;
+
result=update_a_printer_2(printer.info_2);
break;
}
@@ -3145,5 +3140,69 @@ BOOL print_time_access_check(int snum)
return ok;
}
+/****************************************************************************
+ Attempt to write a default device.
+*****************************************************************************/
+
+uint32 printer_write_default_dev(int snum, const PRINTER_DEFAULT *printer_default)
+{
+ NT_PRINTER_INFO_LEVEL *printer = NULL;
+
+ uint32 result = 0;
+
+ /*
+ * Don't bother if no default devicemode was sent.
+ */
+
+ if (printer_default->devmode_cont.devmode == NULL)
+ return 0;
+
+ if (get_a_printer(&printer, 2, lp_servicename(snum))!=0)
+ return ERROR_ACCESS_DENIED;
+
+ /*
+ * Just ignore it if we already have a devmode.
+ */
+
+ if (printer->info_2->devmode != NULL)
+ goto done;
+
+ /*
+ * We don't have a devicemode and we're trying to write
+ * one. Check we have the access needed.
+ */
+
+ if (!print_access_check(NULL, snum, PRINTER_ACCESS_ADMINISTER)) {
+ DEBUG(5,("printer_write_default_dev: Access denied for printer %s\n",
+ lp_servicename(snum) ));
+ result = ERROR_ACCESS_DENIED;
+ goto done;
+ }
+
+ /*
+ * Convert the on the wire devicemode format to the internal one.
+ */
+
+ if (!convert_devicemode(printer->info_2->printername,
+ printer_default->devmode_cont.devmode,
+ &printer->info_2->devmode)) {
+ result = ERROR_NOT_ENOUGH_MEMORY;
+ goto done;
+ }
+
+ /*
+ * Finally write back to the tdb.
+ */
+
+ if (add_a_printer(*printer, 2)!=0) {
+ result = ERROR_ACCESS_DENIED;
+ goto done;
+ }
+
+ done:
+
+ free_a_printer(&printer, 2);
+ return result;
+}
#undef OLD_NTDOMAIN
diff --git a/source3/printing/printfsp.c b/source3/printing/printfsp.c
index 9b5a4877ee..f6ab69fd93 100644
--- a/source3/printing/printfsp.c
+++ b/source3/printing/printfsp.c
@@ -82,9 +82,9 @@ files_struct *print_fsp_open(connection_struct *conn,char *jobname)
/****************************************************************************
print a file - called on closing the file
****************************************************************************/
-void print_fsp_end(files_struct *fsp)
+void print_fsp_end(files_struct *fsp, BOOL normal_close)
{
- print_job_end(fsp->print_jobid);
+ print_job_end(fsp->print_jobid, normal_close);
if (fsp->fsp_name) {
string_free(&fsp->fsp_name);
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 46d872df7c..4dbb01e839 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -950,9 +950,11 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
/****************************************************************************
Print a file - called on closing the file. This spools the job.
+ If normal close is false then we're tearing down the jobs - treat as an
+ error.
****************************************************************************/
-BOOL print_job_end(int jobid)
+BOOL print_job_end(int jobid, BOOL normal_close)
{
struct printjob *pjob = print_job_find(jobid);
int snum, ret;
@@ -970,12 +972,17 @@ BOOL print_job_end(int jobid)
snum = print_job_snum(jobid);
- if (sys_fstat(pjob->fd, &sbuf) == 0) {
+ if (normal_close && (sys_fstat(pjob->fd, &sbuf) == 0)) {
pjob->size = sbuf.st_size;
close(pjob->fd);
pjob->fd = -1;
} else {
- /* Couldn't stat the job file, so something has gone wrong. Cleanup */
+
+ /*
+ * Not a normal close or we couldn't stat the job file,
+ * so something has gone wrong. Cleanup.
+ */
+
unlink(pjob->filename);
tdb_delete(tdb, print_key(jobid));
return False;
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 0ffe172b0a..dabaca5d66 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -740,6 +740,22 @@ uint32 _spoolss_open_printer_ex( const UNISTR2 *printername,
result = ERROR_ACCESS_DENIED;
goto done;
}
+
+ /*
+ * If we have a default device pointer in the
+ * printer_default struct, then we need to get
+ * the printer info from the tdb and if there is
+ * no default devicemode there then we do a *SET*
+ * here ! This is insanity.... JRA.
+ */
+
+ if (printer_default->devmode_cont.devmode != NULL) {
+ result = printer_write_default_dev( snum, printer_default);
+ if (result != 0) {
+ close_printer_handle(handle);
+ goto done;
+ }
+ }
}
done:
@@ -781,15 +797,26 @@ static BOOL convert_printer_driver_info(const SPOOL_PRINTER_DRIVER_INFO_LEVEL *u
return True;
}
-static BOOL convert_devicemode(const DEVICEMODE *devmode, NT_DEVICEMODE *nt_devmode)
+BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode,
+ NT_DEVICEMODE **pp_nt_devmode)
{
+ NT_DEVICEMODE *nt_devmode = *pp_nt_devmode;
+
+ /*
+ * Ensure nt_devmode is a valid pointer
+ * as we will be overwriting it.
+ */
+
+ if (nt_devmode == NULL)
+ if ((nt_devmode = construct_nt_devicemode(printername)) == NULL)
+ return False;
+
unistr_to_dos(nt_devmode->devicename, (const char *)devmode->devicename.buffer, 31);
unistr_to_dos(nt_devmode->formname, (const char *)devmode->formname.buffer, 31);
nt_devmode->specversion=devmode->specversion;
nt_devmode->driverversion=devmode->driverversion;
nt_devmode->size=devmode->size;
- nt_devmode->driverextra=devmode->driverextra;
nt_devmode->fields=devmode->fields;
nt_devmode->orientation=devmode->orientation;
nt_devmode->papersize=devmode->papersize;
@@ -820,16 +847,20 @@ static BOOL convert_devicemode(const DEVICEMODE *devmode, NT_DEVICEMODE *nt_devm
nt_devmode->panningwidth=devmode->panningwidth;
nt_devmode->panningheight=devmode->panningheight;
- safe_free(nt_devmode->private);
- if (nt_devmode->driverextra != 0) {
- /* if we had a previous private delete it and make a new one */
+ /*
+ * Only change private and driverextra if the incoming devmode
+ * has a new one. JRA.
+ */
+
+ if ((devmode->driverextra != 0) && (devmode->private != NULL)) {
+ safe_free(nt_devmode->private);
+ nt_devmode->driverextra=devmode->driverextra;
if((nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8))) == NULL)
return False;
memcpy(nt_devmode->private, devmode->private, nt_devmode->driverextra);
}
- else {
- nt_devmode->private = NULL;
- }
+
+ *pp_nt_devmode = nt_devmode;
return True;
}
@@ -915,7 +946,7 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
return True;
}
- if (!strcmp(value, "DefaultSpoolDirectory")) {
+ if (!strcmp(value, "DefaultSpoolDirectory")) {
pstring string="You are using a Samba server";
*type = 0x1;
*needed = 2*(strlen(string)+1);
@@ -1045,7 +1076,7 @@ uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename,
if (handle_is_printserver(handle))
found=getprinterdata_printer_server(value, type, data, needed, *out_size);
else
- found=getprinterdata_printer(handle, value, type, data, needed, *out_size);
+ found= getprinterdata_printer(handle, value, type, data, needed, *out_size);
if (found==False) {
DEBUG(5, ("value not found, allocating %d\n", *out_size));
@@ -1063,8 +1094,9 @@ uint32 _spoolss_getprinterdata(POLICY_HND *handle, UNISTR2 *valuename,
if (*needed > *out_size)
return ERROR_MORE_DATA;
- else
+ else {
return NT_STATUS_NO_PROBLEMO;
+ }
}
/***************************************************************************
@@ -2299,11 +2331,11 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer, int snum)
printer->unknown13 = 0x0;
printer->unknown14 = 0x1;
printer->unknown15 = 0x024a; /* 586 Pentium ? */
- printer->unknown16 = 0x0;
+ printer->unknown16 = 0x0;
printer->change_id = ntprinter->info_2->changeid; /* ChangeID in milliseconds*/
- printer->unknown18 = 0x0;
+ printer->unknown18 = 0x0;
printer->status = nt_printq_status(status.status);
- printer->unknown20 = 0x0;
+ printer->unknown20 = 0x0;
printer->c_setprinter = ntprinter->info_2->c_setprinter; /* how many times setprinter has been called */
printer->unknown22 = 0x0;
printer->unknown23 = 0x6; /* 6 ???*/
@@ -3679,7 +3711,7 @@ uint32 _spoolss_enddocprinter(POLICY_HND *handle)
}
Printer->document_started=False;
- print_job_end(Printer->jobid);
+ print_job_end(Printer->jobid,True);
/* error codes unhandled so far ... */
return 0x0;
@@ -4230,21 +4262,12 @@ static uint32 update_printer(POLICY_HND *handle, uint32 level,
/* we have a valid devmode
convert it and link it*/
- /*
- * Ensure printer->info_2->devmode is a valid pointer
- * as we will be overwriting it in convert_devicemode().
- */
-
- if (printer->info_2->devmode == NULL)
- printer->info_2->devmode = construct_nt_devicemode(printer->info_2->printername);
-
DEBUGADD(8,("Converting the devicemode struct\n"));
- convert_devicemode(devmode, printer->info_2->devmode);
-
- } else {
- if (printer->info_2->devmode != NULL)
- free_nt_devicemode(&printer->info_2->devmode);
- printer->info_2->devmode=NULL;
+ if (!convert_devicemode(printer->info_2->printername, devmode,
+ &printer->info_2->devmode)) {
+ result = ERROR_NOT_ENOUGH_MEMORY;
+ goto done;
+ }
}
/* Do sanity check on the requested changes for Samba */
@@ -5673,10 +5696,10 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle,
convert_specific_param(&param, value , type, data, real_len);
- /* Check if we are making any changes or not. Return true if
+ /* Check if we are making any changes or not. Return true if
nothing is actually changing. */
-
- ZERO_STRUCT(old_param);
+
+ ZERO_STRUCT(old_param);
if (get_specific_param(*printer, 2, param->value, &old_param.data,
&old_param.type, (unsigned int *)&old_param.data_len)) {
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 62194f73a5..87bd313327 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -116,8 +116,8 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
if (close_filestruct(fsp) == -1)
err1 = -1;
- if (normal_close && fsp->print_file) {
- print_fsp_end(fsp);
+ if (fsp->print_file) {
+ print_fsp_end(fsp, normal_close);
file_free(fsp);
return 0;
}
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 23ce19f532..7dba0c06f3 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -736,7 +736,7 @@ static void fill_printq_info(connection_struct *conn, int snum, int uLevel,
PACKI(desc,"W",5); /* pad1 */
PACKS(desc,"z",""); /* pszSepFile */
PACKS(desc,"z","WinPrint"); /* pszPrProc */
- PACKS(desc,"z",""); /* pszParms */
+ PACKS(desc,"z",NULL); /* pszParms */
PACKS(desc,"z",NULL); /* pszComment - don't ask.... JRA */
/* "don't ask" that it's done this way to fix corrupted
Win9X/ME printer comments. */
diff --git a/source3/tdb/Makefile b/source3/tdb/Makefile
index 01de7d244b..196187eef1 100644
--- a/source3/tdb/Makefile
+++ b/source3/tdb/Makefile
@@ -4,18 +4,20 @@
CFLAGS = -DSTANDALONE -DTDB_DEBUG -g -DHAVE_MMAP=1
CC = gcc
+
PROGS = tdbtest tdbtool tdbtorture
+TDB_OBJ = tdb.o spinlock.o
default: $(PROGS)
-tdbtest: tdbtest.o tdb.o spinlock.o
- $(CC) $(CFLAGS) -o tdbtest tdbtest.o tdb.o spinlock.o -lgdbm
+tdbtest: tdbtest.o $(TDB_OBJ)
+ $(CC) $(CFLAGS) -o tdbtest tdbtest.o $(TDB_OBJ) -lgdbm
-tdbtool: tdbtool.o tdb.o spinlock.o
- $(CC) $(CFLAGS) -o tdbtool tdbtool.o tdb.o spinlock.o
+tdbtool: tdbtool.o $(TDB_OBJ)
+ $(CC) $(CFLAGS) -o tdbtool tdbtool.o $(TDB_OBJ)
-tdbtorture: tdbtorture.o tdb.o
- $(CC) $(CFLAGS) -o tdbtorture tdbtorture.o tdb.o spinlock.o
+tdbtorture: tdbtorture.o $(TDB_OBJ)
+ $(CC) $(CFLAGS) -o tdbtorture tdbtorture.o $(TDB_OBJ)
clean:
rm -f $(PROGS) *.o *~ *% core test.db test.tdb test.gdbm
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index 944a734ddc..39d061b0a8 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -84,10 +84,10 @@ static void *tdb_mmap(tdb_len size, int readonly, int fd)
void *ret = NULL;
#ifdef HAVE_MMAP
ret = mmap(NULL, size, PROT_READ | (readonly ? 0 : PROT_WRITE), MAP_SHARED|MAP_FILE, fd, 0);
-#endif
- if (ret == (void *)-1)
- ret = NULL;
+ if (ret == (void *)-1)
+ ret = NULL;
+#endif
return ret;
}
@@ -302,7 +302,8 @@ static int update_tailer(TDB_CONTEXT *tdb, tdb_off offset,
#ifdef TDB_DEBUG
void tdb_printfreelist(TDB_CONTEXT *tdb)
{
- tdb_off offset, rec_ptr, last_ptr;
+ long total_free = 0;
+ tdb_off offset, rec_ptr, last_ptr;
struct list_struct rec, lastrec, newrec;
tdb_lock(tdb, -1, F_WRLCK);
@@ -326,11 +327,13 @@ void tdb_printfreelist(TDB_CONTEXT *tdb)
return;
}
- printf("entry offset=[0x%08x], rec.rec_len = [0x%08x]\n", rec.next, rec.rec_len );
+ printf("entry offset=[0x%08x], rec.rec_len = [0x%08x (%d)]\n", rec.next, rec.rec_len, rec.rec_len );
+ total_free += rec.rec_len;
/* move to the next record */
rec_ptr = rec.next;
}
+ printf("total rec_len = [0x%08x (%d)]\n", total_free, total_free );
tdb_unlock(tdb, -1, F_WRLCK);
}
@@ -1013,6 +1016,17 @@ int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
coalescing with `allocated' block before it's updated. */
if (flag != TDB_INSERT) tdb_delete(tdb, key);
+ /* Copy key+value *before* allocating free space in case malloc
+ fails and we are left with a dead spot in the tdb. */
+
+ if (!(p = (char *)malloc(key.dsize + dbuf.dsize))) {
+ tdb->ecode = TDB_ERR_OOM;
+ goto fail;
+ }
+
+ memcpy(p, key.dptr, key.dsize);
+ memcpy(p+key.dsize, dbuf.dptr, dbuf.dsize);
+
/* now we're into insert / modify / replace of a record which
* we know could not be optimised by an in-place store (for
* various reasons). */
@@ -1027,18 +1041,12 @@ int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
rec.full_hash = hash;
rec.magic = TDB_MAGIC;
- if (!(p = (char *)malloc(key.dsize + dbuf.dsize))) {
- tdb->ecode = TDB_ERR_OOM;
- goto fail;
- }
-
- memcpy(p, key.dptr, key.dsize);
- memcpy(p+key.dsize, dbuf.dptr, dbuf.dsize);
/* write out and point the top of the hash chain at it */
if (rec_write(tdb, rec_ptr, &rec) == -1
|| tdb_write(tdb, rec_ptr+sizeof(rec), p, key.dsize+dbuf.dsize)==-1
|| ofs_write(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) {
fail:
+ /* Need to tdb_unallocate() here */
ret = -1;
}
out:
diff --git a/source3/tdb/tdbtool.c b/source3/tdb/tdbtool.c
index 508adc5d54..1b038226d0 100644
--- a/source3/tdb/tdbtool.c
+++ b/source3/tdb/tdbtool.c
@@ -12,6 +12,27 @@
/* a tdb tool for manipulating a tdb database */
+#define FSTRING_LEN 128
+typedef char fstring[FSTRING_LEN];
+
+typedef struct connections_key {
+ pid_t pid;
+ int cnum;
+ fstring name;
+} connections_key;
+
+typedef struct connections_data {
+ int magic;
+ pid_t pid;
+ int cnum;
+ uid_t uid;
+ gid_t gid;
+ char name[24];
+ char addr[24];
+ char machine[128];
+ time_t start;
+} connections_data;
+
static TDB_CONTEXT *tdb;
static int print_rec(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state);
@@ -180,13 +201,41 @@ static void delete_tdb(void)
}
}
+static int print_conn_key(TDB_DATA key)
+{
+ printf( "pid =%5d ", ((connections_key*)key.dptr)->pid);
+ printf( "cnum =%10d ", ((connections_key*)key.dptr)->cnum);
+ printf( "name =[%s]\n", ((connections_key*)key.dptr)->name);
+ return 0;
+}
+
+static int print_conn_data(TDB_DATA dbuf)
+{
+ printf( "pid =%5d ", ((connections_data*)dbuf.dptr)->pid);
+ printf( "cnum =%10d ", ((connections_data*)dbuf.dptr)->cnum);
+ printf( "name =[%s]\n", ((connections_data*)dbuf.dptr)->name);
+
+ printf( "uid =%5d ", ((connections_data*)dbuf.dptr)->uid);
+ printf( "addr =[%s]\n", ((connections_data*)dbuf.dptr)->addr);
+ printf( "gid =%5d ", ((connections_data*)dbuf.dptr)->gid);
+ printf( "machine=[%s]\n", ((connections_data*)dbuf.dptr)->machine);
+ printf( "start = %s\n", ctime(&((connections_data*)dbuf.dptr)->start));
+ return 0;
+}
+
static int print_rec(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
{
+#if 0
+ print_conn_key(key);
+ print_conn_data(dbuf);
+ return 0;
+#else
printf("\nkey %d bytes\n", key.dsize);
print_data(key.dptr, key.dsize);
printf("data %d bytes\n", dbuf.dsize);
print_data(dbuf.dptr, dbuf.dsize);
return 0;
+#endif
}
static int total_bytes;
@@ -240,13 +289,16 @@ static void next_record(TDB_CONTEXT *tdb, TDB_DATA *pkey)
*pkey = tdb_nextkey(tdb, *pkey);
dbuf = tdb_fetch(tdb, *pkey);
- if (!dbuf.dptr) terror("fetch failed");
- /* printf("%s : %*.*s\n", k, (int)dbuf.dsize, (int)dbuf.dsize, dbuf.dptr); */
- print_rec(tdb, *pkey, dbuf, NULL);
+ if (!dbuf.dptr)
+ terror("fetch failed");
+ else
+ /* printf("%s : %*.*s\n", k, (int)dbuf.dsize, (int)dbuf.dsize, dbuf.dptr); */
+ print_rec(tdb, *pkey, dbuf, NULL);
}
int main(int argc, char *argv[])
{
+ int bIterate = 0;
char *line;
char *tok;
TDB_DATA iterate_kbuf;
@@ -268,9 +320,12 @@ int main(int argc, char *argv[])
}
if ((tok = strtok(line," "))==NULL) {
- continue;
+ if (bIterate)
+ next_record(tdb, &iterate_kbuf);
+ continue;
}
if (strcmp(tok,"create") == 0) {
+ bIterate = 0;
create_tdb();
continue;
} else if (strcmp(tok,"open") == 0) {
@@ -280,31 +335,39 @@ int main(int argc, char *argv[])
/* all the rest require a open database */
if (!tdb) {
+ bIterate = 0;
terror("database not open");
help();
continue;
}
if (strcmp(tok,"insert") == 0) {
+ bIterate = 0;
insert_tdb();
} else if (strcmp(tok,"store") == 0) {
+ bIterate = 0;
store_tdb();
} else if (strcmp(tok,"show") == 0) {
+ bIterate = 0;
show_tdb();
} else if (strcmp(tok,"erase") == 0) {
+ bIterate = 0;
tdb_traverse(tdb, do_delete_fn, NULL);
} else if (strcmp(tok,"delete") == 0) {
+ bIterate = 0;
delete_tdb();
} else if (strcmp(tok,"dump") == 0) {
+ bIterate = 0;
tdb_traverse(tdb, print_rec, NULL);
} else if (strcmp(tok,"info") == 0) {
info_tdb();
- } else if (strcmp(tok, "free") == 0) {
- tdb_printfreelist(tdb);
- } else if (strcmp(tok, "first") == 0) {
- first_record(tdb, &iterate_kbuf);
- } else if (strcmp(tok, "next") == 0) {
- next_record(tdb, &iterate_kbuf);
+ } else if (strcmp(tok, "free") == 0) {
+ tdb_printfreelist(tdb);
+ } else if (strcmp(tok, "first") == 0) {
+ bIterate = 1;
+ first_record(tdb, &iterate_kbuf);
+ } else if (strcmp(tok, "next") == 0) {
+ next_record(tdb, &iterate_kbuf);
} else {
help();
}