summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorDavid O'Neill <dmo@samba.org>2001-01-17 22:55:02 +0000
committerDavid O'Neill <dmo@samba.org>2001-01-17 22:55:02 +0000
commit22363b9d7893998169ac7a777df466940fd0a000 (patch)
tree6ce4b12a4786a8299d1535277d8d124056f72cf1 /source3
parent0407ba8b1bad1da4e7d1064fb6632277b03a1afd (diff)
downloadsamba-22363b9d7893998169ac7a777df466940fd0a000.tar.gz
samba-22363b9d7893998169ac7a777df466940fd0a000.tar.bz2
samba-22363b9d7893998169ac7a777df466940fd0a000.zip
Changes from APPLIANCE_HEAD:
source/include/proto.h source/include/rpc_spoolss.h source/rpc_parse/parse_spoolss.c source/rpc_server/srv_spoolss.c source/rpc_server/srv_spoolss_nt.c - speedups in printer queue enumeration - still room for improvement. The construct_dev_mode() still creates and destroys a printer info_2 structure every time it is called. - fixed job->devmode memory leak - converted printer job notification routines to use tallocated memory rather than a fixed 2K buffer. This reduces the memory requirements of a 4500 job queue enumeration from 90MB to about 16MB. (This used to be commit 7853b27bc1765d48d5f06837f8aca71a3a0d1e5d)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h833
-rwxr-xr-xsource3/include/rpc_spoolss.h2
-rw-r--r--source3/rpc_parse/parse_spoolss.c30
-rwxr-xr-xsource3/rpc_server/srv_spoolss.c2
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c526
5 files changed, 874 insertions, 519 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 160131e610..8de5dfeb07 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -214,10 +214,362 @@ 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 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 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 +707,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 +790,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);
@@ -661,358 +1013,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);
@@ -1099,9 +1099,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);
@@ -1132,6 +1129,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);
@@ -1939,11 +1939,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
@@ -1976,6 +1971,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);
@@ -2189,6 +2189,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,
@@ -2202,6 +2213,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,
@@ -3349,7 +3366,8 @@ uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options,
const UNISTR2 *localmachine, uint32 printerlocal,
SPOOL_NOTIFY_OPTION *option);
uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change,
- SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info);
+ SPOOL_NOTIFY_OPTION *option, TALLOC_CTX *mem_ctx,
+ SPOOL_NOTIFY_INFO *info);
uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 level,
NEW_BUFFER *buffer, uint32 offered,
uint32 *needed, uint32 *returned);
@@ -3465,23 +3483,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
@@ -3988,6 +3989,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
@@ -4024,27 +4046,6 @@ BOOL vfswrap_fset_nt_acl(files_struct *fsp, int fd, uint32 security_info_sent, S
BOOL vfswrap_set_nt_acl(files_struct *fsp, char *name, uint32 security_info_sent, SEC_DESC *psd);
#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/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index 33541c12fe..94d5985688 100755
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -654,7 +654,7 @@ typedef struct spool_notify_info_data
struct
{
uint32 length;
- uint16 string[1024];
+ uint16 *string;
}
data;
}
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index a6f46285eb..868d90ae74 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -22,7 +22,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
#include "includes.h"
extern int DEBUGLEVEL;
@@ -384,9 +383,31 @@ BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data,
return False;
if (MARSHALLING(ps)) {
/* These are already in little endian format. Don't byte swap. */
- if(!prs_uint8s(True,"string",ps,depth,(uint8 *)data->notify_data.data.string,x*2))
- return False;
+ if (x == 1) {
+
+ /* No memory allocated for this string
+ therefore following the data.string
+ pointer is a bad idea. Use a pointer to
+ the uint32 length union member to
+ provide a source for a unicode NULL */
+
+ if(!prs_uint8s(True,"string",ps,depth, (uint8 *)&data->notify_data.data.length,x*2))
+ return False;
+ } else {
+ if(!prs_uint8s(True,"string",ps,depth,(uint8 *)data->notify_data.data.string,x*2))
+ return False;
+ }
} else {
+
+ /* Tallocate memory for string */
+
+ DEBUG(0, ("** tallocating memory\n"));
+
+ data->notify_data.data.string = (uint16 *)
+ talloc(ps->mem_ctx, x * 2);
+ if (!data->notify_data.data.string)
+ return False;
+
if(!prs_uint16s(True,"string",ps,depth,data->notify_data.data.string,x))
return False;
}
@@ -5753,10 +5774,7 @@ static JOB_INFO_2 *job2_dup(const JOB_INFO_2* from)
void free_job_info_2(JOB_INFO_2 *job)
{
if (job!=NULL)
- {
free_devmode(job->devmode);
- free(job);
- }
}
void free_job2_array(uint32 num_entries, JOB_INFO_2 **entries)
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index 72ce17fee1..8d7d238ad0 100755
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -277,7 +277,7 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p)
}
r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change,
- q_u.option, &r_u.info);
+ q_u.option, data->mem_ctx, &r_u.info);
safe_free(q_u.option);
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 0654eea6f4..24626d1a9a 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -273,7 +273,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd)
slprintf(command, sizeof(command), "%s \"%s\"", cmd,
Printer->dev.handlename);
dos_to_unix(command, True); /* Convert printername to unix-codepage */
- slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid);
+ slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid);
unlink(tmp_file);
DEBUG(10,("Running [%s > %s]\n", command,tmp_file));
@@ -1132,53 +1132,116 @@ uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options,
/*******************************************************************
* fill a notify_info_data with the servername
********************************************************************/
-static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue,
- NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_server_name(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- pstring temp_name;
+ pstring temp_name, temp;
+ uint32 len;
snprintf(temp_name, sizeof(temp_name)-1, "\\\\%s", global_myname);
- data->notify_data.data.length= (uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- temp_name, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16));
+ len = (uint32)dos_PutUniCode(temp, temp_name, sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with the printername (not including the servername).
********************************************************************/
-static void spoolss_notify_printer_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue,
- NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_printer_name(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
+ pstring temp;
+ uint32 len;
+
/* the notify name should not contain the \\server\ part */
char *p = strrchr(printer->info_2->printername, '\\');
+
if (!p) {
p = printer->info_2->printername;
} else {
p++;
}
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- p, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16));
+ len = (uint32)dos_PutUniCode(temp, p, sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with the servicename
********************************************************************/
-static void spoolss_notify_share_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_share_name(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- lp_servicename(snum), sizeof(data->notify_data.data.string),True) - sizeof(uint16))/sizeof(uint16));
+ pstring temp;
+ uint32 len;
+
+ len = (uint32)dos_PutUniCode(temp, lp_servicename(snum),
+ sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with the port name
********************************************************************/
-static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_port_name(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
+ pstring temp;
+ uint32 len;
+
/* even if it's strange, that's consistant in all the code */
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- printer->info_2->portname, sizeof(data->notify_data.data.string), True) - sizeof(uint16))/sizeof(uint16));
+ len = (uint32)dos_PutUniCode(temp, printer->info_2->portname,
+ sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
@@ -1186,23 +1249,57 @@ static void spoolss_notify_port_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, pri
* jfmxxxx: it's incorrect, should be lp_printerdrivername()
* but it doesn't exist, have to see what to do
********************************************************************/
-static void spoolss_notify_driver_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_driver_name(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- printer->info_2->drivername, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+ pstring temp;
+ uint32 len;
+
+ len = (uint32)dos_PutUniCode(temp, printer->info_2->drivername,
+ sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with the comment
********************************************************************/
-static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_comment(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
+ pstring temp;
+ uint32 len;
+
if (*printer->info_2->comment == '\0')
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- lp_comment(snum), sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+ len = (uint32)dos_PutUniCode(temp, lp_comment(snum),
+ sizeof(temp) - 2, True);
else
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- printer->info_2->comment, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+ len = (uint32)dos_PutUniCode(temp, printer->info_2->comment,
+ sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
@@ -1210,17 +1307,38 @@ static void spoolss_notify_comment(int snum, SPOOL_NOTIFY_INFO_DATA *data, print
* jfm:xxxx incorrect, have to create a new smb.conf option
* location = "Room 1, floor 2, building 3"
********************************************************************/
-static void spoolss_notify_location(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_location(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- printer->info_2->location, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+ pstring temp;
+ uint32 len;
+
+ len = (uint32)dos_PutUniCode(temp, printer->info_2->location,
+ sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with the device mode
* jfm:xxxx don't to it for know but that's a real problem !!!
********************************************************************/
-static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_devmode(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
}
@@ -1229,40 +1347,108 @@ static void spoolss_notify_devmode(int snum, SPOOL_NOTIFY_INFO_DATA *data, print
* jfm:xxxx just return no file could add an option to smb.conf
* separator file = "separator.txt"
********************************************************************/
-static void spoolss_notify_sepfile(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_sepfile(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- printer->info_2->sepfile, sizeof(data->notify_data.data.string)-1,True) - sizeof(uint16))/sizeof(uint16));
+ pstring temp;
+ uint32 len;
+
+ len = (uint32)dos_PutUniCode(temp, printer->info_2->sepfile,
+ sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with the print processor
* jfm:xxxx return always winprint to indicate we don't do anything to it
********************************************************************/
-static void spoolss_notify_print_processor(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_print_processor(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- printer->info_2->printprocessor, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+ pstring temp;
+ uint32 len;
+
+ len = (uint32)dos_PutUniCode(temp, printer->info_2->printprocessor,
+ sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with the print processor options
* jfm:xxxx send an empty string
********************************************************************/
-static void spoolss_notify_parameters(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_parameters(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- printer->info_2->parameters, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+ pstring temp;
+ uint32 len;
+
+ len = (uint32)dos_PutUniCode(temp, printer->info_2->parameters,
+ sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with the data type
* jfm:xxxx always send RAW as data type
********************************************************************/
-static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_datatype(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- printer->info_2->datatype, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+ pstring temp;
+ uint32 len;
+
+ len = (uint32)dos_PutUniCode(temp, printer->info_2->datatype,
+ sizeof(pstring) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
@@ -1270,7 +1456,11 @@ static void spoolss_notify_datatype(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin
* jfm:xxxx send an null pointer to say no security desc
* have to implement security before !
********************************************************************/
-static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_security_desc(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.data.length=0;
data->notify_data.data.string[0]=0x00;
@@ -1280,7 +1470,11 @@ static void spoolss_notify_security_desc(int snum, SPOOL_NOTIFY_INFO_DATA *data,
* fill a notify_info_data with the attributes
* jfm:xxxx a samba printer is always shared
********************************************************************/
-static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_attributes(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.value[0] = printer->info_2->attributes;
}
@@ -1288,7 +1482,11 @@ static void spoolss_notify_attributes(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr
/*******************************************************************
* fill a notify_info_data with the priority
********************************************************************/
-static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_priority(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.value[0] = printer->info_2->priority;
}
@@ -1296,7 +1494,11 @@ static void spoolss_notify_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin
/*******************************************************************
* fill a notify_info_data with the default priority
********************************************************************/
-static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_default_priority(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.value[0] = printer->info_2->default_priority;
}
@@ -1304,7 +1506,11 @@ static void spoolss_notify_default_priority(int snum, SPOOL_NOTIFY_INFO_DATA *da
/*******************************************************************
* fill a notify_info_data with the start time
********************************************************************/
-static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_start_time(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.value[0] = printer->info_2->starttime;
}
@@ -1312,7 +1518,11 @@ static void spoolss_notify_start_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr
/*******************************************************************
* fill a notify_info_data with the until time
********************************************************************/
-static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_until_time(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.value[0] = printer->info_2->untiltime;
}
@@ -1320,9 +1530,14 @@ static void spoolss_notify_until_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr
/*******************************************************************
* fill a notify_info_data with the status
********************************************************************/
-static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_status(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
int count;
+
print_queue_struct *q=NULL;
print_status_struct status;
@@ -1335,7 +1550,11 @@ static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_
/*******************************************************************
* fill a notify_info_data with the number of jobs queued
********************************************************************/
-static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_cjobs(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
print_queue_struct *q=NULL;
print_status_struct status;
@@ -1348,7 +1567,11 @@ static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_q
/*******************************************************************
* fill a notify_info_data with the average ppm
********************************************************************/
-static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_average_ppm(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
/* always respond 8 pages per minutes */
/* a little hard ! */
@@ -1358,16 +1581,37 @@ static void spoolss_notify_average_ppm(int snum, SPOOL_NOTIFY_INFO_DATA *data, p
/*******************************************************************
* fill a notify_info_data with username
********************************************************************/
-static void spoolss_notify_username(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_username(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- queue->user, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+ pstring temp;
+ uint32 len;
+
+ len = (uint32)dos_PutUniCode(temp, queue->user,
+ sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with job status
********************************************************************/
-static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_job_status(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.value[0]=nt_printj_status(queue->status);
}
@@ -1375,18 +1619,41 @@ static void spoolss_notify_job_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, pr
/*******************************************************************
* fill a notify_info_data with job name
********************************************************************/
-static void spoolss_notify_job_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_job_name(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- queue->file, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+ pstring temp;
+ uint32 len;
+
+ len = (uint32)dos_PutUniCode(temp, queue->file, sizeof(temp) - 2,
+ True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with job status
********************************************************************/
-static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_job_status_string(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
char *p = "unknown";
+ pstring temp;
+ uint32 len;
switch (queue->status) {
case LPQ_QUEUED:
@@ -1402,14 +1669,28 @@ static void spoolss_notify_job_status_string(int snum, SPOOL_NOTIFY_INFO_DATA *d
p = "Printing";
break;
}
- data->notify_data.data.length=(uint32)((dos_PutUniCode((char *)data->notify_data.data.string,
- p, sizeof(data->notify_data.data.string)-1, True) - sizeof(uint16))/sizeof(uint16));
+
+ len = (uint32)dos_PutUniCode(temp, p, sizeof(temp) - 2, True);
+
+ data->notify_data.data.length = len / 2 - 1;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
+ memcpy(data->notify_data.data.string, temp, len);
}
/*******************************************************************
* fill a notify_info_data with job time
********************************************************************/
-static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_job_time(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.value[0]=0x0;
}
@@ -1417,7 +1698,11 @@ static void spoolss_notify_job_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin
/*******************************************************************
* fill a notify_info_data with job size
********************************************************************/
-static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_job_size(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.value[0]=queue->size;
}
@@ -1425,7 +1710,11 @@ static void spoolss_notify_job_size(int snum, SPOOL_NOTIFY_INFO_DATA *data, prin
/*******************************************************************
* fill a notify_info_data with job position
********************************************************************/
-static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_job_position(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
data->notify_data.value[0]=queue->job;
}
@@ -1433,13 +1722,27 @@ static void spoolss_notify_job_position(int snum, SPOOL_NOTIFY_INFO_DATA *data,
/*******************************************************************
* fill a notify_info_data with submitted time
********************************************************************/
-static void spoolss_notify_submitted_time(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, NT_PRINTER_INFO_LEVEL *printer)
+static void spoolss_notify_submitted_time(int snum,
+ SPOOL_NOTIFY_INFO_DATA *data,
+ print_queue_struct *queue,
+ NT_PRINTER_INFO_LEVEL *printer,
+ TALLOC_CTX *mem_ctx)
{
struct tm *t;
+ uint32 len;
t=gmtime(&queue->time);
- data->notify_data.data.length = sizeof(SYSTEMTIME);
+ len = sizeof(SYSTEMTIME);
+
+ data->notify_data.data.length = len;
+ data->notify_data.data.string = (uint16 *)talloc(mem_ctx, len);
+
+ if (!data->notify_data.data.string) {
+ data->notify_data.data.length = 0;
+ return;
+ }
+
make_systemtime((SYSTEMTIME*)(data->notify_data.data.string), t);
}
@@ -1453,7 +1756,7 @@ struct s_notify_info_data_table
uint32 size;
void (*fn) (int snum, SPOOL_NOTIFY_INFO_DATA *data,
print_queue_struct *queue,
- NT_PRINTER_INFO_LEVEL *printer);
+ NT_PRINTER_INFO_LEVEL *printer, TALLOC_CTX *mem_ctx);
};
struct s_notify_info_data_table notify_info_data_table[] =
@@ -1595,7 +1898,10 @@ static void construct_info_data(SPOOL_NOTIFY_INFO_DATA *info_data, uint16 type,
* fill a notify_info struct with info asked
*
********************************************************************/
-static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id)
+static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int
+ snum, SPOOL_NOTIFY_OPTION_TYPE
+ *option_type, uint32 id,
+ TALLOC_CTX *mem_ctx)
{
int field_num,j;
uint16 type;
@@ -1631,7 +1937,8 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO
DEBUG(10,("construct_notify_printer_info: calling [%s] snum=%d printername=[%s])\n",
notify_info_data_table[j].name, snum, printer->info_2->printername ));
- notify_info_data_table[j].fn(snum, current_data, queue, printer);
+ notify_info_data_table[j].fn(snum, current_data, queue,
+ printer, mem_ctx);
info->count++;
}
@@ -1649,7 +1956,8 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue,
SPOOL_NOTIFY_INFO *info,
NT_PRINTER_INFO_LEVEL *printer,
int snum, SPOOL_NOTIFY_OPTION_TYPE
- *option_type, uint32 id)
+ *option_type, uint32 id,
+ TALLOC_CTX *mem_ctx)
{
int field_num,j;
uint16 type;
@@ -1678,7 +1986,8 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue,
current_data=&(info->data[info->count]);
construct_info_data(current_data, type, field, id);
- notify_info_data_table[j].fn(snum, current_data, queue, printer);
+ notify_info_data_table[j].fn(snum, current_data, queue,
+ printer, mem_ctx);
info->count++;
}
@@ -1716,7 +2025,9 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue,
* fill a notify_info struct with info asked
*
********************************************************************/
-static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info)
+static uint32 printserver_notify_info(const POLICY_HND *hnd,
+ SPOOL_NOTIFY_INFO *info,
+ TALLOC_CTX *mem_ctx)
{
int snum;
Printer_entry *Printer=find_printer_index_by_hnd(hnd);
@@ -1742,7 +2053,8 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *
for (snum=0; snum<n_services; snum++)
if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) )
- if (construct_notify_printer_info(info, snum, option_type, id))
+ if (construct_notify_printer_info
+ (info, snum, option_type, id, mem_ctx))
id++;
}
@@ -1769,7 +2081,8 @@ static uint32 printserver_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *
* fill a notify_info struct with info asked
*
********************************************************************/
-static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info)
+static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info,
+ TALLOC_CTX *mem_ctx)
{
int snum;
Printer_entry *Printer=find_printer_index_by_hnd(hnd);
@@ -1796,8 +2109,9 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info)
switch ( option_type->type ) {
case PRINTER_NOTIFY_TYPE:
- if(construct_notify_printer_info(info, snum,
- option_type, id))
+ if(construct_notify_printer_info(info, snum,
+ option_type, id,
+ mem_ctx))
id--;
break;
@@ -1815,11 +2129,12 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info)
construct_notify_jobs_info(&queue[j], info,
printer, snum,
option_type,
- queue[j].job);
+ queue[j].job,
+ mem_ctx);
}
free_a_printer(&printer, 2);
-
+
done:
safe_free(queue);
break;
@@ -1848,13 +2163,16 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info)
* spoolss_rfnpcnex
********************************************************************/
uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change,
- SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info)
+ SPOOL_NOTIFY_OPTION *option, TALLOC_CTX *mem_ctx,
+ SPOOL_NOTIFY_INFO *info)
{
Printer_entry *Printer=find_printer_index_by_hnd(handle);
+ uint32 result = ERROR_INVALID_HANDLE;
if (!OPEN_HANDLE(Printer)) {
- DEBUG(0,("_spoolss_rfnpcnex: Invalid handle (%s).\n",OUR_HANDLE(handle)));
- return ERROR_INVALID_HANDLE;
+ DEBUG(0,("_spoolss_rfnpcnex: Invalid handle (%s).\n",
+ OUR_HANDLE(handle)));
+ goto done;
}
DEBUG(4,("Printer type %x\n",Printer->printer_type));
@@ -1876,12 +2194,17 @@ uint32 _spoolss_rfnpcnex( POLICY_HND *handle, uint32 change,
switch (Printer->printer_type) {
case PRINTER_HANDLE_IS_PRINTSERVER:
- return printserver_notify_info(handle, info);
+ result = printserver_notify_info(handle, info,
+ mem_ctx);
+ break;
+
case PRINTER_HANDLE_IS_PRINTER:
- return printer_notify_info(handle, info);
+ result = printer_notify_info(handle, info, mem_ctx);
+ break;
}
-
- return ERROR_INVALID_HANDLE;
+
+ done:
+ return result;
}
/********************************************************************
@@ -4076,16 +4399,13 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue,
/****************************************************************************
****************************************************************************/
static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
- int position, int snum)
+ int position, int snum,
+ NT_PRINTER_INFO_LEVEL *ntprinter)
{
pstring temp_name;
- NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
pstring chaine;
struct tm *t;
- if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 )
- return False;
-
t=gmtime(&queue->time);
snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname);
@@ -4119,11 +4439,9 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
job_info->pagesprinted=0;
if((job_info->devmode = construct_dev_mode(snum)) == NULL) {
- free_a_printer(&ntprinter, 2);
return False;
}
- free_a_printer(&ntprinter, 2);
return (True);
}
@@ -4180,19 +4498,25 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum,
NEW_BUFFER *buffer, uint32 offered,
uint32 *needed, uint32 *returned)
{
+ NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
JOB_INFO_2 *info;
int i;
info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2));
if (info==NULL) {
- safe_free(queue);
*returned=0;
return ERROR_NOT_ENOUGH_MEMORY;
}
-
+
+ if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) {
+ *returned = 0;
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
for (i=0; i<*returned; i++)
- fill_job_info_2(&(info[i]), &queue[i], i, snum);
+ fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter);
+ free_a_printer(&ntprinter, 2);
safe_free(queue);
/* check the required size. */
@@ -4209,7 +4533,10 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum,
new_smb_io_job_info_2("", buffer, &info[i], 0);
/* clear memory */
- free_job_info_2(info);
+ for (i = 0; i < *returned; i++)
+ free_job_info_2(&info[i]);
+
+ free(info);
if (*needed > offered) {
*returned=0;
@@ -5763,6 +6090,8 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
int i=0;
BOOL found=False;
JOB_INFO_2 *info_2;
+ NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
+
info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2));
ZERO_STRUCTP(info_2);
@@ -5784,8 +6113,14 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
return NT_STATUS_NO_PROBLEMO;
}
- fill_job_info_2(info_2, &(queue[i-1]), i, snum);
+ if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0) {
+ safe_free(queue);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
+
+ fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter);
+ free_a_printer(&ntprinter, 2);
safe_free(queue);
*needed += spoolss_size_job_info_2(info_2);
@@ -5798,6 +6133,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
new_smb_io_job_info_2("", buffer, info_2, 0);
free_job_info_2(info_2);
+ free(info_2);
if (*needed > offered)
return ERROR_INSUFFICIENT_BUFFER;