summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>2000-04-07 05:48:55 +0000
committerLuke Leighton <lkcl@samba.org>2000-04-07 05:48:55 +0000
commit8f6b89d9540c6303030eb452d869587950eaaeb5 (patch)
treefa615be899029581c4a4fd2ad4db6980a5c047ef
parent47c3d6ea5140c5fbdc0dfe61e52b6387c2c8b644 (diff)
downloadsamba-8f6b89d9540c6303030eb452d869587950eaaeb5.tar.gz
spoolss from cvs main
-rw-r--r--source/Makefile.in17
-rw-r--r--source/include/lib_smb_proto.h231
-rw-r--r--source/include/proto.h1439
-rw-r--r--source/include/rpc_parse_proto.h2
-rw-r--r--source/printing/nt_printing.c62
-rw-r--r--source/printing/printing.c71
-rw-r--r--source/rpc_parse/parse_spoolss.c35
-rwxr-xr-xsource/script/installcp.sh2
-rwxr-xr-xsource/spoolssd/srv_spoolss_nt.c428
9 files changed, 1187 insertions, 1100 deletions
diff --git a/source/Makefile.in b/source/Makefile.in
index cf792ca656d..94868619b81 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -75,7 +75,7 @@ LOCKDIR = @lockdir@
CODEPAGEDIR = $(LIBDIR)/codepages
# The current codepage definition list.
-CODEPAGELIST= 437 737 850 852 861 932 866 949 950 936
+CODEPAGELIST= 437 737 775 850 852 861 932 866 949 950 936 1251 ISO8859-1 ISO8859-2 ISO8859-5 ISO8859-7 KOI-R
# where you are going to have the smbrun binary. This defaults to the
# install directory. This binary is needed for correct printing
@@ -113,7 +113,7 @@ SPROGS = bin/smbd bin/lsarpcd bin/svcctld bin/spoolssd bin/samrd \
bin/srvsvcd bin/wkssvcd bin/browserd bin/netlogond bin/winregd \
bin/nmbd bin/swat
PROGS1 = bin/smbclient bin/testparm bin/testprns bin/smbrun bin/smbstatus
-PROGS2 = bin/rpcclient bin/smbpasswd bin/make_smbcodepage bin/debug2html
+PROGS2 = bin/rpcclient bin/smbpasswd bin/make_smbcodepage bin/make_unicodemap
PROGS3 = bin/regedit bin/samedit bin/net bin/svccontrol bin/cmdat bin/ntspool
PROGS4 = @WRAP@ @WRAP32@
#MPROGS = @MPROGS@
@@ -466,6 +466,8 @@ SMBSH_OBJ = smbwrapper/smbsh.o smbwrapper/shared.o
MAKE_SMBCODEPAGE_OBJ = utils/make_smbcodepage.o
+MAKE_UNICODEMAP_OBJ = utils/make_unicodemap.o
+
MAKE_PRINTERDEF_OBJ = utils/make_printerdef.o
STATUS_OBJ = utils/status.o $(LIBSTATUS_OBJ) $(LOCKING_OBJ) \
@@ -785,6 +787,7 @@ MAKEDIR = || exec false; \
@MAINT@ @if (: >> .deps/$@ || : > .deps/$@) >/dev/null 2>&1; then :; \
@MAINT@ else dir=.deps/`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` \
@MAINT@ $(MAKEDIR); fi; rm -f .deps/$@ .deps/$@d
+@BROKEN_CC@ -mv `echo $@ | sed 's%^.*/%%g'` $@
@echo Compiling $< with libtool
@$(LIBTOOL) --mode=compile \
$(CC) -I. -I$(srcdir) $(FLAGS) -c $< \
@@ -813,6 +816,7 @@ MAKEDIR = || exec false; \
dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
@MAINT@ @if (: >> .deps/$@ || : > .deps/$@) >/dev/null 2>&1; then :; \
@MAINT@ else dir=.deps/`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` \
+@BROKEN_CC@ -mv `echo $@ | sed -e 's%^.*/%%g' -e 's%\.po$$%.o%'` $@.o
@MAINT@ $(MAKEDIR); fi; rm -f .deps/$@ .deps/$@d
@echo Compiling $*.c with @PICFLAG@ and -32
@$(CC) -32 -I. -I$(srcdir) $(FLAGS) @PICFLAG@ -c $< \
@@ -828,6 +832,7 @@ bin/.dummy:
@: >> $@ || : > $@ # what a fancy emoticon!
bin/libsurs.la: $(LIBSURS_LTOBJS) bin/.dummy
+@BROKEN_CC@ -mv `echo $@ | sed -e 's%^.*/%%g' -e 's%\.po32$$%.o%'` $@.o
@echo Linking shared library $@
@$(LINK) -o $@ -rpath $(LIBDIR) -version-info 0:1:0 \
$(LIBSURS_LTOBJS)
@@ -1029,6 +1034,10 @@ bin/make_smbcodepage: $(SAMBALIB) $(MAKE_SMBCODEPAGE_OBJ) bin/.dummy
@echo Linking $@
@$(LINK) -o $@ $(MAKE_SMBCODEPAGE_OBJ) $(SAMBALIB) $(LIBS)
+bin/make_unicodemap: $(SAMBALIB) $(MAKE_UNICODEMAP_OBJ) bin/.dummy
+ @echo Linking $@
+ @$(LINK) -o $@ $(MAKE_UNICODEMAP_OBJ) $(SAMBALIB) $(LIBS)
+
bin/nmblookup: $(SAMBALIB) $(NMBLIB) $(NMBLOOKUP_OBJ) bin/.dummy
@echo Linking $@
@$(LINK) -o $@ $(NMBLOOKUP_OBJ) $(NMBLIB) $(SAMBALIB) $(LIBS)
@@ -1216,10 +1225,10 @@ AUTOHEADER=@AUTOHEADER@
# when configure.in is updated, reconfigure
$(srcdir)/configure: @MAINT@ $(srcdir)/configure.in $(srcdir)/aclocal.m4
- cd $(srcdir) && $(AUTOCONF)
+ echo "WARNING: you need to rerun configure"
config.status: $(srcdir)/configure
- $(SHELL) ./config.status --recheck
+ echo "WARNING: you need to run ./config.status --recheck"
Makefile: $(srcdir)/Makefile.in config.status \
include/stamp-h # just to ensure that config.h is up-to-date
diff --git a/source/include/lib_smb_proto.h b/source/include/lib_smb_proto.h
index 96ed9486109..4082fe77de4 100644
--- a/source/include/lib_smb_proto.h
+++ b/source/include/lib_smb_proto.h
@@ -23,74 +23,6 @@ void MD5Update(struct MD5Context *ctx, uchar const *buf, unsigned len);
void MD5Final(uchar digest[16], struct MD5Context *ctx);
void MD5Transform(uint32 buf[4], const uchar inext[64]);
-/*The following definitions come from lib/util_hnd.c */
-
-struct policy_cache *get_global_hnd_cache(void);
-struct policy_cache *init_policy_cache(int num_pol_hnds);
-void free_policy_cache(struct policy_cache *cache);
-BOOL policy_hnd_set_name(struct policy_cache *cache,
- POLICY_HND *hnd, const char *name);
-const char *policy_hnd_get_name(struct policy_cache *cache,
- const POLICY_HND *hnd);
-BOOL dup_policy_hnd(struct policy_cache *cache,
- POLICY_HND *hnd,
- const POLICY_HND *from);
-BOOL register_policy_hnd(struct policy_cache *cache,
- const vuser_key *key,
- POLICY_HND *hnd,
- uint32 access_mask);
-BOOL open_policy_hnd(struct policy_cache *cache,
- const vuser_key *key,
- POLICY_HND *hnd,
- uint32 access_mask);
-BOOL open_policy_hnd_link(struct policy_cache *cache,
- const POLICY_HND *parent_hnd,
- POLICY_HND *hnd,
- uint32 access_mask);
-int find_policy_by_hnd(struct policy_cache *cache, const POLICY_HND *hnd);
-BOOL set_policy_state(struct policy_cache *cache, POLICY_HND *hnd,
- void(*fn)(void*), void *dev);
-void *get_policy_state_info(struct policy_cache *cache, const POLICY_HND *hnd);
-BOOL policy_hnd_set_state_type(struct policy_cache *cache,
- POLICY_HND *hnd, int type);
-int policy_hnd_get_state_type(struct policy_cache *cache,
- const POLICY_HND *hnd);
-BOOL policy_hnd_check_state_type(struct policy_cache *cache,
- const POLICY_HND *hnd, int type);
-BOOL close_policy_hnd(struct policy_cache *cache, POLICY_HND *hnd);
-BOOL policy_link_key(struct policy_cache *cache, const POLICY_HND *hnd,
- POLICY_HND *to);
-const vuser_key *get_policy_vuser_key(struct policy_cache *cache,
- const POLICY_HND *hnd);
-BOOL pol_get_usr_sesskey(struct policy_cache *cache, const POLICY_HND *hnd,
- uchar usr_sess_key[16]);
-
-/*The following definitions come from lib/vuser.c */
-
-BOOL is_valid_user_struct(const vuser_key * key);
-user_struct *get_valid_user_struct(const vuser_key * key);
-void invalidate_vuid(vuser_key * key);
-BOOL validated_username(vuser_key * key, char *name, size_t len);
-uint16 create_vuid(pid_t pid,
- uid_t uid, gid_t gid,
- int n_groups, gid_t * groups,
- const char *unix_name,
- const char *requested_name,
- const char *real_name,
- BOOL guest, const NET_USER_INFO_3 * info3);
-uint16 register_vuid(pid_t pid, uid_t uid, gid_t gid,
- const char *unix_name,
- const char *requested_name,
- BOOL guest, const NET_USER_INFO_3 * info3);
-BOOL check_vuser_ok(struct uid_cache *cache, user_struct * vuser, int snum);
-
-/*The following definitions come from lib/vuser_db.c */
-
-BOOL tdb_delete_vuid( const vuser_key *uk);
-BOOL tdb_lookup_vuid( const vuser_key *uk, user_struct **usr);
-BOOL tdb_store_vuid( const vuser_key *uk, user_struct *usr);
-BOOL vuid_init_db(void);
-
/*The following definitions come from libsmb/clientgen.c */
int cli_set_port(struct cli_state *cli, int port);
@@ -304,6 +236,74 @@ BOOL smb_safe_err_msg(uint8 class, uint32 num, char *ret, size_t len);
BOOL smb_safe_errstr(char *inbuf, char *msg, size_t len);
char *smb_errstr(char *inbuf);
+/*The following definitions come from lib/util_hnd.c */
+
+struct policy_cache *get_global_hnd_cache(void);
+struct policy_cache *init_policy_cache(int num_pol_hnds);
+void free_policy_cache(struct policy_cache *cache);
+BOOL policy_hnd_set_name(struct policy_cache *cache,
+ POLICY_HND *hnd, const char *name);
+const char *policy_hnd_get_name(struct policy_cache *cache,
+ const POLICY_HND *hnd);
+BOOL dup_policy_hnd(struct policy_cache *cache,
+ POLICY_HND *hnd,
+ const POLICY_HND *from);
+BOOL register_policy_hnd(struct policy_cache *cache,
+ const vuser_key *key,
+ POLICY_HND *hnd,
+ uint32 access_mask);
+BOOL open_policy_hnd(struct policy_cache *cache,
+ const vuser_key *key,
+ POLICY_HND *hnd,
+ uint32 access_mask);
+BOOL open_policy_hnd_link(struct policy_cache *cache,
+ const POLICY_HND *parent_hnd,
+ POLICY_HND *hnd,
+ uint32 access_mask);
+int find_policy_by_hnd(struct policy_cache *cache, const POLICY_HND *hnd);
+BOOL set_policy_state(struct policy_cache *cache, POLICY_HND *hnd,
+ void(*fn)(void*), void *dev);
+void *get_policy_state_info(struct policy_cache *cache, const POLICY_HND *hnd);
+BOOL policy_hnd_set_state_type(struct policy_cache *cache,
+ POLICY_HND *hnd, int type);
+int policy_hnd_get_state_type(struct policy_cache *cache,
+ const POLICY_HND *hnd);
+BOOL policy_hnd_check_state_type(struct policy_cache *cache,
+ const POLICY_HND *hnd, int type);
+BOOL close_policy_hnd(struct policy_cache *cache, POLICY_HND *hnd);
+BOOL policy_link_key(struct policy_cache *cache, const POLICY_HND *hnd,
+ POLICY_HND *to);
+const vuser_key *get_policy_vuser_key(struct policy_cache *cache,
+ const POLICY_HND *hnd);
+BOOL pol_get_usr_sesskey(struct policy_cache *cache, const POLICY_HND *hnd,
+ uchar usr_sess_key[16]);
+
+/*The following definitions come from lib/vuser.c */
+
+BOOL is_valid_user_struct(const vuser_key * key);
+user_struct *get_valid_user_struct(const vuser_key * key);
+void invalidate_vuid(vuser_key * key);
+BOOL validated_username(vuser_key * key, char *name, size_t len);
+uint16 create_vuid(pid_t pid,
+ uid_t uid, gid_t gid,
+ int n_groups, gid_t * groups,
+ const char *unix_name,
+ const char *requested_name,
+ const char *real_name,
+ BOOL guest, const NET_USER_INFO_3 * info3);
+uint16 register_vuid(pid_t pid, uid_t uid, gid_t gid,
+ const char *unix_name,
+ const char *requested_name,
+ BOOL guest, const NET_USER_INFO_3 * info3);
+BOOL check_vuser_ok(struct uid_cache *cache, user_struct * vuser, int snum);
+
+/*The following definitions come from lib/vuser_db.c */
+
+BOOL tdb_delete_vuid( const vuser_key *uk);
+BOOL tdb_lookup_vuid( const vuser_key *uk, user_struct **usr);
+BOOL tdb_store_vuid( const vuser_key *uk, user_struct *usr);
+BOOL vuid_init_db(void);
+
/*The following definitions come from rpc_parse/parse_creds.c */
BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name,
@@ -608,68 +608,67 @@ BOOL smb_io_rpc_auth_ntlmssp_chk(char *desc, RPC_AUTH_NTLMSSP_CHK * chk,
/*The following definitions come from rpc_parse/parse_prs.c */
-void prs_debug(prs_struct * ps, int depth, const char *desc,
+void prs_debug(prs_struct *ps, int depth, const char *desc,
const char *fn_name);
-void prs_debug_out(const prs_struct * ps, char *msg, int level);
-BOOL prs_init(prs_struct * ps, uint32 size, uint8 align, BOOL io);
-void prs_set_packtype(prs_struct * ps, const uint8 * pack_type);
-void prs_create(prs_struct * ps, char *data, uint32 size, uint8 align,
- BOOL io);
-BOOL prs_copy(prs_struct * ps, const prs_struct * from);
-BOOL prs_alloc_data(prs_struct * buf, int size);
-BOOL prs_buf_copy(char *copy_into, const prs_struct * buf,
+void prs_debug_out(const prs_struct *ps, char *msg, int level);
+BOOL prs_init(prs_struct *ps, uint32 size, uint8 align, BOOL io);
+void prs_set_packtype(prs_struct *ps, const uint8 *pack_type);
+void prs_create(prs_struct *ps, char *data, uint32 size, uint8 align, BOOL io);
+BOOL prs_copy(prs_struct *ps, const prs_struct *from);
+BOOL prs_alloc_data(prs_struct *buf, int size);
+BOOL prs_buf_copy(char *copy_into, const prs_struct *buf,
uint32 offset, uint32 len);
-void prs_struct_free(prs_struct ** buf);
-void prs_free_data(prs_struct * buf);
-BOOL prs_realloc_data(prs_struct * buf, size_t new_size);
-BOOL prs_grow_data(prs_struct * buf, BOOL io, int new_size, BOOL force_grow);
-uint32 prs_buf_len(const prs_struct * buf);
-char *prs_data(const prs_struct * buf, uint32 offset);
-void prs_link(prs_struct * prev, prs_struct * ps, prs_struct * next);
-BOOL prs_align(prs_struct * ps);
-BOOL prs_grow(prs_struct * ps, uint32 new_size);
-BOOL prs_append_data(prs_struct * ps, const char *data, int len);
-BOOL prs_add_data(prs_struct * ps, const char *data, int len);
+void prs_struct_free(prs_struct **buf);
+void prs_free_data(prs_struct *buf);
+BOOL prs_realloc_data(prs_struct *buf, size_t new_size);
+BOOL prs_grow_data(prs_struct *buf, BOOL io, int new_size, BOOL force_grow);
+uint32 prs_buf_len(const prs_struct *buf);
+char *prs_data(const prs_struct *buf, uint32 offset);
+void prs_link(prs_struct *prev, prs_struct *ps, prs_struct *next);
+BOOL prs_align(prs_struct *ps);
+BOOL prs_grow(prs_struct *ps, uint32 new_size);
+BOOL prs_append_data(prs_struct *ps, const char *data, int len);
+BOOL prs_add_data(prs_struct *ps, const char *data, int len);
void prs_switch_type(prs_struct *ps, BOOL io);
void prs_force_dynamic(prs_struct *ps);
uint32 prs_data_size(prs_struct *ps);
uint32 prs_offset(prs_struct *ps);
BOOL prs_set_offset(prs_struct *ps, uint32 offset);
void prs_mem_free(prs_struct *ps);
-BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start, uint32 len);
-BOOL _prs_uint8(char *name, prs_struct * ps, int depth, uint8 * data8);
-BOOL _prs_uint16(char *name, prs_struct * ps, int depth, uint16 * data16);
-BOOL _prs_hash1(prs_struct * ps, uint32 offset, uint8 sess_key[16]);
-BOOL _prs_uint32(char *name, prs_struct * ps, int depth, uint32 * data32);
-BOOL _prs_uint8s(BOOL charmode, char *name, prs_struct * ps, int depth,
- uint8 * data8s, int len);
-BOOL _prs_uint16s(BOOL charmode, char *name, prs_struct * ps, int depth,
- uint16 * data16s, int len);
-BOOL _prs_uint32s(BOOL charmode, char *name, prs_struct * ps, int depth,
- uint32 * data32s, int len);
-BOOL _prs_buffer2(BOOL charmode, char *name, prs_struct * ps, int depth,
+BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start,
+ uint32 len);
+BOOL _prs_uint8(char *name, prs_struct *ps, int depth, uint8 *data8);
+BOOL _prs_uint16(char *name, prs_struct *ps, int depth, uint16 *data16);
+BOOL _prs_hash1(prs_struct *ps, uint32 offset, uint8 sess_key[16]);
+BOOL _prs_uint32(char *name, prs_struct *ps, int depth, uint32 *data32);
+BOOL _prs_uint8s(BOOL charmode, char *name, prs_struct *ps, int depth,
+ uint8 *data8s, int len);
+BOOL _prs_uint16s(BOOL charmode, char *name, prs_struct *ps, int depth,
+ uint16 *data16s, int len);
+BOOL _prs_uint32s(BOOL charmode, char *name, prs_struct *ps, int depth,
+ uint32 *data32s, int len);
+BOOL _prs_buffer2(BOOL charmode, char *name, prs_struct *ps, int depth,
BUFFER2 * str);
-BOOL _prs_string2(BOOL charmode, char *name, prs_struct * ps, int depth,
+BOOL _prs_string2(BOOL charmode, char *name, prs_struct *ps, int depth,
STRING2 * str);
-BOOL _prs_unistr2(BOOL charmode, char *name, prs_struct * ps, int depth,
- UNISTR2 * str);
-BOOL _prs_unistr3(BOOL charmode, char *name, UNISTR3 * str, prs_struct * ps,
+BOOL _prs_unistr2(BOOL charmode, char *name, prs_struct *ps, int depth,
+ UNISTR2 *str);
+BOOL _prs_unistr3(BOOL charmode, char *name, UNISTR3 * str, prs_struct *ps,
int depth);
-BOOL _prs_unistr(char *name, prs_struct * ps, int depth, UNISTR * str);
-BOOL _prs_string(char *name, prs_struct * ps, int depth, char *str,
+BOOL _prs_unistr(char *name, prs_struct *ps, int depth, UNISTR * str);
+BOOL _prs_string(char *name, prs_struct *ps, int depth, char *str,
uint16 len, uint16 max_buf_size);
-BOOL _prs_uint16_pre(char *name, prs_struct * ps, int depth, uint16 * data16,
- uint32 * offset);
-BOOL _prs_uint16_post(char *name, prs_struct * ps, int depth, uint16 * data16,
+BOOL _prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16,
+ uint32 *offset);
+BOOL _prs_uint16_post(char *name, prs_struct *ps, int depth, uint16 *data16,
uint32 ptr_uint16, uint32 start_offset);
-BOOL _prs_uint32_pre(char *name, prs_struct * ps, int depth, uint32 * data32,
- uint32 * offset);
-BOOL _prs_uint32_post(char *name, prs_struct * ps, int depth, uint32 * data32,
+BOOL _prs_uint32_pre(char *name, prs_struct *ps, int depth, uint32 *data32,
+ uint32 *offset);
+BOOL _prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32,
uint32 ptr_uint32, uint32 data_size);
-int prs_tdb_delete(TDB_CONTEXT * tdb, prs_struct * pk);
-int prs_tdb_store(TDB_CONTEXT * tdb, int flgs, prs_struct * pk,
- prs_struct * pd);
-void prs_tdb_fetch(TDB_CONTEXT * tdb, prs_struct * pk, prs_struct * pd);
+int prs_tdb_delete(TDB_CONTEXT * tdb, prs_struct *pk);
+int prs_tdb_store(TDB_CONTEXT * tdb, int flgs, prs_struct *pk, prs_struct *pd);
+void prs_tdb_fetch(TDB_CONTEXT * tdb, prs_struct *pk, prs_struct *pd);
/*The following definitions come from rpc_parse/parse_vuid.c */
diff --git a/source/include/proto.h b/source/include/proto.h
index 04edcef28c4..8cc84bc16e0 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -411,10 +411,278 @@ void CatchChildLeaveStatus(void);
int vslprintf(char *str, int n, char *format, va_list ap);
+/*The following definitions come from libsmb/clientgen.c */
+
+int cli_set_port(struct cli_state *cli, int port);
+char *cli_errstr(struct cli_state *cli);
+void cli_safe_smb_errstr(struct cli_state *cli, char *msg, size_t len);
+BOOL get_safe_rap_errstr(int rap_error, char *err_msg, size_t msglen);
+void cli_safe_errstr(struct cli_state *cli, char *err_msg, size_t msglen);
+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_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);
+BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *));
+BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
+ void (*fn)(const char *, uint32, const char *));
+BOOL cli_session_setup_x(struct cli_state *cli,
+ char *user,
+ char *pass, int passlen,
+ char *ntpass, int ntpasslen,
+ char *user_domain);
+BOOL cli_session_setup(struct cli_state *cli,
+ char *user,
+ char *pass, int passlen,
+ char *ntpass, int ntpasslen,
+ char *user_domain);
+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);
+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, const char *fname);
+int cli_open(struct cli_state *cli, const 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);
+BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout);
+size_t cli_read_one(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
+size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size, BOOL overlap);
+ssize_t cli_write(struct cli_state *cli,
+ int fnum, uint16 write_mode,
+ char *buf, off_t offset, size_t size, size_t bytes_left);
+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_qpathinfo(struct cli_state *cli, const char *fname,
+ time_t *c_time, time_t *a_time, time_t *m_time,
+ size_t *size, uint16 *mode);
+BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
+ time_t *c_time, time_t *a_time, time_t *m_time,
+ time_t *w_time, size_t *size, uint16 *mode,
+ SMB_INO_T *ino);
+BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
+ uint16 *mode, size_t *size,
+ time_t *c_time, time_t *a_time, time_t *m_time,
+ time_t *w_time, SMB_INO_T *ino);
+int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
+ void (*fn)(file_info *, const char *));
+BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
+ const char *old_password);
+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);
+void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr);
+struct cli_state *cli_initialise(struct cli_state *cli);
+void cli_close_socket(struct cli_state *cli);
+void cli_shutdown(struct cli_state *cli);
+int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num);
+void cli_sockopt(struct cli_state *cli, char *options);
+uint16 cli_setpid(struct cli_state *cli, uint16 pid);
+BOOL cli_reestablish_connection(struct cli_state *cli);
+BOOL cli_establish_connection(struct cli_state *cli,
+ const 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 cli_connect_auth(struct cli_state *cli,
+ const char* desthost,
+ struct in_addr *dest_ip,
+ const struct ntuser_creds *usr);
+BOOL cli_connect_servers_auth(struct cli_state *cli,
+ char *p,
+ const struct ntuser_creds *usr);
+BOOL cli_connect_serverlist(struct cli_state *cli, char *p);
+int cli_printjob_del(struct cli_state *cli, int job);
+int cli_print_queue(struct cli_state *cli,
+ void (*fn)(struct print_job_info *));
+BOOL cli_chkpath(struct cli_state *cli, char *path);
+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);
+BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
+BOOL get_any_dc_name(const char *domain, char *srv_name);
+
+/*The following definitions come from libsmb/credentials.c */
+
+char *credstr(const uchar *cred);
+void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, const 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(const 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,
+ const DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred);
+
+/*The following definitions come from libsmb/namequery.c */
+
+BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
+ struct in_addr to_ip,char *master,char *rname);
+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 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(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);
+void nmb_safe_namestr(struct nmb_name *n, char *str, size_t len);
+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);
+const 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(const struct pwd_info *pwd1, const 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,
+ const uchar lm_pwd[16], const uchar nt_pwd[16]);
+void pwd_get_lm_nt_16(const 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_owf2(struct pwd_info *pwd, const uchar srv_key[8],
+ const char *user, const char *server,
+ const char *domain, uchar sess_key[16]);
+void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8],
+ uchar sess_key[16]);
+void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24],
+ uchar * nt_owf, size_t * nt_owf_len);
+
/*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 smbhash(uchar *out, const uchar *in, const uchar *key, int forw);
+void E_P16(uchar *p14,uchar *p16);
+void E_P24(const uchar *p21, const uchar *c8, uchar *p24);
+void D_P16(const uchar *p14, const uchar *in, uchar *out);
+void E_old_pw_hash( const uchar *p14, const uchar *in, uchar *out);
+void cred_hash1(uchar *out, const uchar *in, const uchar *key);
+void cred_hash2(uchar *out,uchar *in,uchar *key);
+void cred_hash3(uchar *out, const uchar *in,uchar *key, int forw);
+void SamOEMhash( uchar *data, const uchar *key, int val);
+void sam_pwd_hash(unsigned int rid, const uchar *in, uchar *out, int forw);
+
+/*The following definitions come from libsmb/smbencrypt.c */
+
+void SMBencrypt(uchar * pwrd, uchar * c8, uchar * p24);
+void E_md4hash(uchar * pwrd, uchar * p16);
+void lm_owf_gen(const char *pwd, uchar p16[16]);
+void nt_owf_gen(const char *pwd, uchar nt_p16[16]);
+void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar lm_p16[16]);
+void SMBOWFencrypt(const uchar pwrd[16], const uchar * c8, uchar p24[24]);
+void NTLMSSPOWFencrypt(const uchar pwrd[8], const uchar * ntlmchalresp,
+ uchar p24[24]);
+void SMBNTencrypt(uchar * pwrd, uchar * c8, uchar * p24);
+BOOL make_oem_passwd_hash(uchar data[516],
+ const char *pwrd, int new_pw_len,
+ const uchar old_pw_hash[16], BOOL unicode);
+void SMBOWFencrypt_ntv2(const uchar kr[16],
+ const uchar * srv_chal, int srv_chal_len,
+ const uchar * cli_chal, int cli_chal_len,
+ char resp_buf[16]);
+void SMBsesskeygen_ntv2(const uchar kr[16],
+ const uchar * nt_resp, char sess_key[16]);
+void SMBsesskeygen_ntv1(const uchar kr[16],
+ const uchar * nt_resp, char sess_key[16]);
+void SMBgenclientchals(char *lm_cli_chal,
+ char *nt_cli_chal, int *nt_cli_chal_len,
+ const char *srv, const char *dom);
+void ntv2_owf_gen(const uchar owf[16],
+ const char *user_n, const char *domain_n, uchar kr_buf[16]);
+void lm_owf_genW(const UNISTR2 *pwd, uchar p16[16]);
+void nt_owf_genW(const UNISTR2 *pwd, uchar nt_p16[16]);
+void nt_lm_owf_genW(const UNISTR2 *pwd, uchar nt_p16[16], uchar lm_p16[16]);
+BOOL nt_encrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key);
+BOOL nt_decrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key);
+BOOL decode_pw_buffer(const char buffer[516], char *new_pwrd,
+ int new_pwrd_size, uint32 *new_pw_len);
+BOOL encode_pw_buffer(char buffer[516], const char *new_pass,
+ int new_pw_len, BOOL nt_pass_set);
+
+/*The following definitions come from libsmb/smberr.c */
+
+char *smb_err_msg(uint8 class, uint32 num);
+BOOL smb_safe_err_msg(uint8 class, uint32 num, char *ret, size_t len);
+BOOL smb_safe_errstr(char *inbuf, char *msg, size_t len);
+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 */
@@ -424,11 +692,6 @@ void become_root(BOOL save_dir);
void unbecome_root(BOOL restore_dir);
const vuser_key *get_sec_ctx(void);
-/*The following definitions come from lib/surs.c */
-
-BOOL surs_sam_sid_to_unixid(DOM_SID *sid, POSIX_ID *id, BOOL create);
-BOOL surs_unixid_to_sam_sid(POSIX_ID *id, DOM_SID *sid, BOOL create);
-
/*The following definitions come from lib/sursalgdomonly.c */
BOOL surs_algdomonly_sam_sid_to_unixid(DOM_SID *sid, POSIX_ID *id,
@@ -443,6 +706,11 @@ BOOL surs_nt5ldap_sam_sid_to_unixid(LDAPDB *hds, DOM_SID * sid, uint32 type,
BOOL surs_nt5ldap_unixid_to_sam_sid(LDAPDB *hds, uint32 id, uint32 type,
DOM_SID * sid, BOOL create);
+/*The following definitions come from lib/surs.c */
+
+BOOL surs_sam_sid_to_unixid(DOM_SID *sid, POSIX_ID *id, BOOL create);
+BOOL surs_unixid_to_sam_sid(POSIX_ID *id, DOM_SID *sid, BOOL create);
+
/*The following definitions come from lib/surstdb.c */
BOOL surs_tdb_sam_sid_to_unixid(DOM_SID * sid, uint32 type, uint32 * id,
@@ -535,6 +803,25 @@ const struct passwd *Get_Pwnam(char *user,BOOL allow_change);
BOOL user_ok(char *user,int snum);
BOOL user_in_list(char *user,char *list);
+/*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_unistr_array(uint32 num_entries, UNISTR2 **entries);
+UNISTR2* add_unistr_to_array(uint32 *len, UNISTR2 ***array, UNISTR2 *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 */
BOOL init_myworkgroup(void);
@@ -636,25 +923,6 @@ char *lock_path(char *name);
char *parent_dirname(const char *path);
const char *get_sid_name_use_str(uint32 sid_name_use);
-/*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_unistr_array(uint32 num_entries, UNISTR2 **entries);
-UNISTR2* add_unistr_to_array(uint32 *len, UNISTR2 ***array, UNISTR2 *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);
@@ -976,274 +1244,6 @@ BOOL tdb_lookup_vuid( const vuser_key *uk, user_struct **usr);
BOOL tdb_store_vuid( const vuser_key *uk, user_struct *usr);
BOOL vuid_init_db(void);
-/*The following definitions come from libsmb/clientgen.c */
-
-int cli_set_port(struct cli_state *cli, int port);
-char *cli_errstr(struct cli_state *cli);
-void cli_safe_smb_errstr(struct cli_state *cli, char *msg, size_t len);
-BOOL get_safe_rap_errstr(int rap_error, char *err_msg, size_t msglen);
-void cli_safe_errstr(struct cli_state *cli, char *err_msg, size_t msglen);
-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_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);
-BOOL cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, const char *));
-BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
- void (*fn)(const char *, uint32, const char *));
-BOOL cli_session_setup_x(struct cli_state *cli,
- char *user,
- char *pass, int passlen,
- char *ntpass, int ntpasslen,
- char *user_domain);
-BOOL cli_session_setup(struct cli_state *cli,
- char *user,
- char *pass, int passlen,
- char *ntpass, int ntpasslen,
- char *user_domain);
-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);
-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, const char *fname);
-int cli_open(struct cli_state *cli, const 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);
-BOOL cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len, int timeout);
-size_t cli_read_one(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
-size_t cli_read(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size, BOOL overlap);
-ssize_t cli_write(struct cli_state *cli,
- int fnum, uint16 write_mode,
- char *buf, off_t offset, size_t size, size_t bytes_left);
-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_qpathinfo(struct cli_state *cli, const char *fname,
- time_t *c_time, time_t *a_time, time_t *m_time,
- size_t *size, uint16 *mode);
-BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
- time_t *c_time, time_t *a_time, time_t *m_time,
- time_t *w_time, size_t *size, uint16 *mode,
- SMB_INO_T *ino);
-BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
- uint16 *mode, size_t *size,
- time_t *c_time, time_t *a_time, time_t *m_time,
- time_t *w_time, SMB_INO_T *ino);
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
- void (*fn)(file_info *, const char *));
-BOOL cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
- const char *old_password);
-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);
-void cli_init_creds(struct cli_state *cli, const struct ntuser_creds *usr);
-struct cli_state *cli_initialise(struct cli_state *cli);
-void cli_close_socket(struct cli_state *cli);
-void cli_shutdown(struct cli_state *cli);
-int cli_error(struct cli_state *cli, uint8 *eclass, uint32 *num);
-void cli_sockopt(struct cli_state *cli, char *options);
-uint16 cli_setpid(struct cli_state *cli, uint16 pid);
-BOOL cli_reestablish_connection(struct cli_state *cli);
-BOOL cli_establish_connection(struct cli_state *cli,
- const 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 cli_connect_auth(struct cli_state *cli,
- const char* desthost,
- struct in_addr *dest_ip,
- const struct ntuser_creds *usr);
-BOOL cli_connect_servers_auth(struct cli_state *cli,
- char *p,
- const struct ntuser_creds *usr);
-BOOL cli_connect_serverlist(struct cli_state *cli, char *p);
-int cli_printjob_del(struct cli_state *cli, int job);
-int cli_print_queue(struct cli_state *cli,
- void (*fn)(struct print_job_info *));
-BOOL cli_chkpath(struct cli_state *cli, char *path);
-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);
-BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
-BOOL get_any_dc_name(const char *domain, char *srv_name);
-
-/*The following definitions come from libsmb/credentials.c */
-
-char *credstr(const uchar *cred);
-void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, const 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(const 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,
- const DOM_CRED *rcv_clnt_cred, DOM_CRED *rtn_srv_cred);
-
-/*The following definitions come from libsmb/namequery.c */
-
-BOOL name_status(int fd,char *name,int name_type,BOOL recurse,
- struct in_addr to_ip,char *master,char *rname);
-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 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(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);
-void nmb_safe_namestr(struct nmb_name *n, char *str, size_t len);
-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);
-const 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(const struct pwd_info *pwd1, const 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,
- const uchar lm_pwd[16], const uchar nt_pwd[16]);
-void pwd_get_lm_nt_16(const 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_owf2(struct pwd_info *pwd, const uchar srv_key[8],
- const char *user, const char *server,
- const char *domain, uchar sess_key[16]);
-void pwd_make_lm_nt_owf(struct pwd_info *pwd, uchar cryptkey[8],
- uchar sess_key[16]);
-void pwd_get_lm_nt_owf(struct pwd_info *pwd, uchar lm_owf[24],
- uchar * nt_owf, size_t * nt_owf_len);
-
-/*The following definitions come from libsmb/smbdes.c */
-
-void smbhash(uchar *out, const uchar *in, const uchar *key, int forw);
-void E_P16(uchar *p14,uchar *p16);
-void E_P24(const uchar *p21, const uchar *c8, uchar *p24);
-void D_P16(const uchar *p14, const uchar *in, uchar *out);
-void E_old_pw_hash( const uchar *p14, const uchar *in, uchar *out);
-void cred_hash1(uchar *out, const uchar *in, const uchar *key);
-void cred_hash2(uchar *out,uchar *in,uchar *key);
-void cred_hash3(uchar *out, const uchar *in,uchar *key, int forw);
-void SamOEMhash( uchar *data, const uchar *key, int val);
-void sam_pwd_hash(unsigned int rid, const uchar *in, uchar *out, int forw);
-
-/*The following definitions come from libsmb/smbencrypt.c */
-
-void SMBencrypt(uchar * pwrd, uchar * c8, uchar * p24);
-void E_md4hash(uchar * pwrd, uchar * p16);
-void lm_owf_gen(const char *pwd, uchar p16[16]);
-void nt_owf_gen(const char *pwd, uchar nt_p16[16]);
-void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar lm_p16[16]);
-void SMBOWFencrypt(const uchar pwrd[16], const uchar * c8, uchar p24[24]);
-void NTLMSSPOWFencrypt(const uchar pwrd[8], const uchar * ntlmchalresp,
- uchar p24[24]);
-void SMBNTencrypt(uchar * pwrd, uchar * c8, uchar * p24);
-BOOL make_oem_passwd_hash(uchar data[516],
- const char *pwrd, int new_pw_len,
- const uchar old_pw_hash[16], BOOL unicode);
-void SMBOWFencrypt_ntv2(const uchar kr[16],
- const uchar * srv_chal, int srv_chal_len,
- const uchar * cli_chal, int cli_chal_len,
- char resp_buf[16]);
-void SMBsesskeygen_ntv2(const uchar kr[16],
- const uchar * nt_resp, char sess_key[16]);
-void SMBsesskeygen_ntv1(const uchar kr[16],
- const uchar * nt_resp, char sess_key[16]);
-void SMBgenclientchals(char *lm_cli_chal,
- char *nt_cli_chal, int *nt_cli_chal_len,
- const char *srv, const char *dom);
-void ntv2_owf_gen(const uchar owf[16],
- const char *user_n, const char *domain_n, uchar kr_buf[16]);
-void lm_owf_genW(const UNISTR2 *pwd, uchar p16[16]);
-void nt_owf_genW(const UNISTR2 *pwd, uchar nt_p16[16]);
-void nt_lm_owf_genW(const UNISTR2 *pwd, uchar nt_p16[16], uchar lm_p16[16]);
-BOOL nt_encrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key);
-BOOL nt_decrypt_string2(STRING2 * out, const STRING2 * in, const uchar * key);
-BOOL decode_pw_buffer(const char buffer[516], char *new_pwrd,
- int new_pwrd_size, uint32 *new_pw_len);
-BOOL encode_pw_buffer(char buffer[516], const char *new_pass,
- int new_pw_len, BOOL nt_pass_set);
-
-/*The following definitions come from libsmb/smberr.c */
-
-char *smb_err_msg(uint8 class, uint32 num);
-BOOL smb_safe_err_msg(uint8 class, uint32 num, char *ret, size_t len);
-BOOL smb_safe_errstr(char *inbuf, char *msg, size_t len);
-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);
@@ -1457,9 +1457,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);
@@ -1490,6 +1487,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);
@@ -2276,7 +2276,7 @@ struct passgrp_ops *unix_initialise_password_grp(void);
int get_ntforms(nt_forms_struct **list);
int write_ntforms(nt_forms_struct **list, int number);
-void add_a_form(nt_forms_struct **list, const FORM *form, int *count);
+BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count);
void update_a_form(nt_forms_struct **list, const FORM *form, int count);
int get_ntdrivers(fstring **list, char *architecture);
void get_short_archi(char *short_archi, char *long_archi);
@@ -2306,29 +2306,25 @@ 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/printing.c */
void lpq_reset(int snum);
-void print_file(connection_struct *conn, const vuser_key *key,
- int snum, files_struct *file);
-int get_printqueue(int snum, connection_struct *conn, const vuser_key *key,
- print_queue_struct **queue,
+void print_file(connection_struct *conn, files_struct *file);
+int get_printqueue(int snum,
+ connection_struct *conn,print_queue_struct **queue,
print_status_struct *status);
-void del_printqueue(connection_struct *conn,const vuser_key *key,
- int snum,int jobid);
-void status_printjob(connection_struct *conn,const vuser_key *key,
- int snum,int jobid,int status);
+void del_printqueue(connection_struct *conn,int snum,int jobid);
+void status_printjob(connection_struct *conn,int snum,int jobid,int status);
int printjob_encode(int snum, int job);
void printjob_decode(int jobid, int *snum, int *job);
-uint32 status_printqueue(connection_struct *conn,const vuser_key *key,
- int snum,int status);
+void status_printqueue(connection_struct *conn,int snum,int status);
void load_printers(void);
+/*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 */
BOOL profile_setup(BOOL rdonly);
@@ -2802,6 +2798,309 @@ void cli_use_wait_keyboard(void);
BOOL wks_query_info( char *srv_name, uint32 switch_value,
WKS_INFO_100 *wks100);
+/*The following definitions come from rpcclient/cmdat.c */
+
+
+/*The following definitions come from rpcclient/cmdat_cmds.c */
+
+void add_at_commands(void);
+
+/*The following definitions come from rpcclient/cmd_atsvc.c */
+
+void cmd_at(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_brs.c */
+
+void cmd_brs_query_info(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_dfs.c */
+
+void cmd_dfs_add(struct client_info *info, int argc, char *argv[]);
+void cmd_dfs_remove(struct client_info *info, int argc, char *argv[]);
+void cmd_dfs_enum(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_eventlog.c */
+
+void cmd_eventlog(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_lsarpc.c */
+
+void cmd_lsa_enum_trust_dom(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_query_info(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_lookup_names(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_lookup_sids(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_set_secret(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_create_secret(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_query_secret_secobj(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_query_secret(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_netlogon.c */
+
+void cmd_netlogon_pwset(struct client_info *info, int argc, char *argv[]);
+void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]);
+void cmd_netlogon_domain_test(struct client_info *info, int argc,
+ char *argv[]);
+void cmd_sam_sync(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_reg.c */
+
+void split_server_keyname(char *srv_name, char *key, const char* arg);
+BOOL msrpc_reg_enum_key(const char* srv_name, const char* full_keyname,
+ REG_FN(reg_fn),
+ REG_KEY_FN(reg_key_fn),
+ REG_VAL_FN(reg_val_fn));
+void cmd_reg_enum(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_query_info(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_query_key(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_create_val(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_create_key(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_samr.c */
+
+void cmd_sam_ntchange_pwd(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_test(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_lookup_domain(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_lookup_names(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_lookup_rids(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_delete_dom_alias(struct client_info *info, int argc,
+ char *argv[]);
+void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_create_dom_trusting(struct client_info *info, int argc,
+ char *argv[]);
+void cmd_sam_create_dom_user(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_create_dom_alias(struct client_info *info, int argc,
+ char *argv[]);
+void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_delete_dom_user(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_delete_dom_group(struct client_info *info, int argc,
+ char *argv[]);
+void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_create_dom_group(struct client_info *info, int argc,
+ char *argv[]);
+void cmd_sam_enum_users(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_groupmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_group(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_sec_obj(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_user(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_dispinfo(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_dominfo(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_aliasmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_alias(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_enum_aliases(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_enum_groups(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_enum_domains(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_spoolss.c */
+
+BOOL msrpc_spoolss_enum_printers(char* srv_name, uint32 flags, uint32 level, PRINTER_INFO_CTR ctr);
+void cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[]);
+void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[]);
+BOOL msrpc_spoolss_enum_jobs( const char* printer_name,
+ const char* station, const char* user_name,
+ uint32 level,
+ void ***ctr, JOB_INFO_FN(fn));
+void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[]);
+BOOL msrpc_spoolss_enum_printerdata( const char* printer_name, const char* station, const char* user_name );
+void cmd_spoolss_enum_printerdata(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_srvsvc.c */
+
+BOOL net_srv_get_info(struct client_info *info,
+ uint32 info_level, SRV_INFO_CTR * ctr);
+void cmd_srv_query_info(struct client_info *info, int argc, char *argv[]);
+BOOL msrpc_srv_enum_tprt(const char *dest_srv,
+ uint32 info_level,
+ SRV_TPRT_INFO_CTR * ctr, TPRT_INFO_FN(tprt_fn));
+void cmd_srv_enum_tprt(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_enum_conn(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_enum_shares(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_share_get_info(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_share_del(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_enum_sess(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_enum_files(struct client_info *info, int argc, char *argv[]);
+void cmd_time(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_svcctl.c */
+
+void svc_display_query_svc_cfg(const QUERY_SERVICE_CONFIG *cfg);
+BOOL svc_query_service( POLICY_HND *pol_scm,
+ const char *svc_name,
+ SVC_QUERY_FN(svc_query_fn));
+void cmd_svc_info(struct client_info *info, int argc, char *argv[]);
+BOOL msrpc_svc_enum(const char* srv_name,
+ ENUM_SRVC_STATUS **svcs,
+ uint32 *num_svcs,
+ SVC_INFO_FN(info_fn),
+ SVC_QUERY_FN(query_fn));
+void cmd_svc_enum(struct client_info *info, int argc, char *argv[]);
+void cmd_svc_stop(struct client_info *info, int argc, char *argv[]);
+void cmd_svc_start(struct client_info *info, int argc, char *argv[]);
+void cmd_svc_set(struct client_info *info, int argc, char *argv[]);
+void cmd_svc_unk3(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/cmd_wkssvc.c */
+
+void cmd_wks_query_info(struct client_info *info, int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/dfs_cmds.c */
+
+void add_dfs_commands(void);
+
+/*The following definitions come from rpcclient/display_at.c */
+
+void display_at_enum_info(FILE *out_hnd, enum action_type action,
+ uint32 num_jobs, const AT_ENUM_INFO *const jobs,
+ char *const *const commands);
+void display_at_job_info(FILE *out_hnd, enum action_type action,
+ AT_JOB_INFO *const job, fstring command);
+
+/*The following definitions come from rpcclient/display_dfs.c */
+
+void display_dfs_enum_1(FILE *hnd, DFS_INFO_CTR *ctr);
+void display_dfs_enum_2(FILE *hnd, DFS_INFO_CTR *ctr);
+void display_dfs_enum_3_storages(FILE *hnd, DFS_INFO_3 *info3);
+void display_dfs_enum_3(FILE *hnd, DFS_INFO_CTR *ctr);
+void display_dfs_enum(FILE *hnd, char *srv_name, DFS_INFO_CTR *ctr);
+
+/*The following definitions come from rpcclient/display_event.c */
+
+void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *const ev);
+
+/*The following definitions come from rpcclient/display_reg.c */
+
+char *get_reg_val_type_str(uint32 type);
+void display_reg_value_info(FILE *out_hnd, enum action_type action,
+ const char *val_name,
+ uint32 val_type, const BUFFER2 *value);
+void display_reg_key_info(FILE *out_hnd, enum action_type action,
+ const char *key_name, time_t key_mod_time);
+
+/*The following definitions come from rpcclient/display_sam.c */
+
+void display_alias_members(FILE *out_hnd, enum action_type action,
+ uint32 num_mem, char *const *const sid_mem,
+ uint32 *const type);
+void display_alias_rid_info(FILE *out_hnd, enum action_type action,
+ DOM_SID *const sid,
+ uint32 num_rids, uint32 *const rid);
+void display_group_members(FILE *out_hnd, enum action_type action,
+ uint32 num_mem, char *const *const name, uint32 *const type);
+void display_group_info_ctr(FILE *out_hnd, enum action_type action,
+ GROUP_INFO_CTR *const ctr);
+void display_group_rid_info(FILE *out_hnd, enum action_type action,
+ uint32 num_gids, DOM_GID *const gid);
+void display_alias_name_info(FILE *out_hnd, enum action_type action,
+ uint32 num_aliases, fstring *const alias_name, const uint32 *const num_als_usrs);
+void display_alias_info_ctr(FILE *out_hnd, enum action_type action,
+ ALIAS_INFO_CTR *const ctr);
+void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *const usr);
+void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
+ uint32 switch_value, SAM_UNK_CTR *const ctr);
+void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action,
+ uint16 level, uint32 count,
+ SAM_DISPINFO_CTR *const ctr);
+
+/*The following definitions come from rpcclient/display_sec.c */
+
+void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const sec);
+
+/*The following definitions come from rpcclient/display_spool.c */
+
+void display_printer_info_ctr(FILE *out_hnd, enum action_type action, uint32 level,
+ uint32 count, PRINTER_INFO_CTR ctr);
+void display_printer_enumdata(FILE *out_hnd, enum action_type action, uint32 idx,
+ uint32 valuelen, uint16 *value, uint32 rvaluelen,
+ uint32 type,
+ uint32 datalen, uint8 *data, uint32 rdatalen);
+void display_job_info_2(FILE *out_hnd, enum action_type action,
+ JOB_INFO_2 *const i2);
+void display_job_info_1(FILE *out_hnd, enum action_type action,
+ JOB_INFO_1 *const i1);
+void display_job_info_2_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, JOB_INFO_2 *const *const ctr);
+void display_job_info_1_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, JOB_INFO_1 *const *const ctr);
+void display_job_info_ctr(FILE *out_hnd, enum action_type action,
+ uint32 level, uint32 count,
+ void *const *const ctr);
+
+/*The following definitions come from rpcclient/display_srv.c */
+
+char *get_file_oplock_str(uint32 op_type);
+void display_srv_info_ctr(FILE * out_hnd, enum action_type action,
+ const SRV_INFO_CTR * ctr);
+void display_srv_conn_info_ctr(FILE * out_hnd, enum action_type action,
+ SRV_CONN_INFO_CTR * const ctr);
+void display_tprt_info_0(FILE * out_hnd, enum action_type action,
+ TPRT_INFO_0 * const info0,
+ TPRT_INFO_0_STR * const str0);
+void display_srv_tprt_info_0_ctr(FILE * out_hnd, enum action_type action,
+ const SRV_TPRT_INFO_0 * const ctr);
+void display_srv_tprt_info_ctr(FILE * out_hnd, enum action_type action,
+ const SRV_TPRT_INFO_CTR * const ctr);
+void display_srv_share_info_ctr(FILE * out_hnd, enum action_type action,
+ SRV_SHARE_INFO_CTR * const ctr);
+void display_share_info_ctr(FILE * out_hnd, enum action_type action,
+ SHARE_INFO_CTR * const ctr);
+void display_srv_file_info_ctr(FILE * out_hnd, enum action_type action,
+ SRV_FILE_INFO_CTR * const ctr);
+void display_srv_sess_info_0_ctr(FILE * out_hnd, enum action_type action,
+ SRV_SESS_INFO_0 * const ctr);
+void display_srv_sess_info_1_ctr(FILE * out_hnd, enum action_type action,
+ SRV_SESS_INFO_1 * const ctr);
+void display_srv_sess_info_ctr(FILE * out_hnd, enum action_type action,
+ SRV_SESS_INFO_CTR * const ctr);
+void display_server(FILE * out_hnd, enum action_type action,
+ char *const sname, uint32 type, char *const comment);
+void display_share(FILE * out_hnd, enum action_type action,
+ char *const sname, uint32 type, char *const comment);
+void display_share2(FILE * out_hnd, enum action_type action,
+ char *const sname, uint32 type, char *const comment,
+ uint32 perms, uint32 max_uses, uint32 num_uses,
+ char *const path, char *const password);
+void display_name(FILE * out_hnd, enum action_type action, char *const sname);
+
+/*The following definitions come from rpcclient/display_svc.c */
+
+char *get_svc_start_type_str(uint32 type);
+void display_query_svc_cfg(FILE *out_hnd, enum action_type action,
+ const QUERY_SERVICE_CONFIG *const cfg);
+void display_svc_info(FILE *out_hnd, enum action_type action,
+ const ENUM_SRVC_STATUS *const svc);
+
+/*The following definitions come from rpcclient/display_sync.c */
+
+void display_sam_sync_ctr(FILE *out_hnd, enum action_type action,
+ SAM_DELTA_HDR *const delta,
+ SAM_DELTA_CTR *const ctr);
+void display_sam_sync(FILE *out_hnd, enum action_type action,
+ SAM_DELTA_HDR *const deltas,
+ SAM_DELTA_CTR *const ctr,
+ uint32 num);
+
+/*The following definitions come from rpcclient/eventlog.c */
+
+int main(int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/eventlog_cmds.c */
+
+void add_evt_commands(void);
+
+/*The following definitions come from rpcclient/lsa.c */
+
+
+/*The following definitions come from rpcclient/lsa_cmds.c */
+
+void add_lsa_commands(void);
+
/*The following definitions come from rpc_client/msrpc_lsarpc.c */
uint32 lookup_lsa_names(const char *srv_name,
@@ -3058,6 +3357,51 @@ BOOL ncalrpc_l_use_del(const char *pipe_name,
void ncalrpc_l_use_enum(uint32 * num_cons, struct use_info ***use);
void ncalrpc_use_wait_keyboard(void);
+/*The following definitions come from rpcclient/net.c */
+
+
+/*The following definitions come from rpcclient/net_cmds.c */
+
+void add_net_commands(void);
+
+/*The following definitions come from rpcclient/netlogon_cmds.c */
+
+void add_ntl_commands(void);
+
+/*The following definitions come from rpcclient/regedit.c */
+
+
+/*The following definitions come from rpcclient/regedit_cmds.c */
+
+void add_reg_commands(void);
+
+/*The following definitions come from rpcclient/rpcclient.c */
+
+
+/*The following definitions come from rpcclient/samedit.c */
+
+
+/*The following definitions come from rpcclient/samedit_cmds.c */
+
+void add_sam_commands(void);
+
+/*The following definitions come from rpcclient/spoolss.c */
+
+int main(int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/spoolss_cmds.c */
+
+void add_spl_commands(void);
+
+/*The following definitions come from rpcclient/svcctrl.c */
+
+int main(int argc, char *argv[]);
+
+/*The following definitions come from rpcclient/svcctrl_cmds.c */
+
+char *complete_svcenum(char *text, int state);
+void add_svc_commands(void);
+
/*The following definitions come from rpc_parse/parse_creds.c */
BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name,
@@ -3440,68 +3784,67 @@ BOOL smb_io_rpc_auth_ntlmssp_chk(char *desc, RPC_AUTH_NTLMSSP_CHK * chk,
/*The following definitions come from rpc_parse/parse_prs.c */
-void prs_debug(prs_struct * ps, int depth, const char *desc,
+void prs_debug(prs_struct *ps, int depth, const char *desc,
const char *fn_name);
-void prs_debug_out(const prs_struct * ps, char *msg, int level);
-BOOL prs_init(prs_struct * ps, uint32 size, uint8 align, BOOL io);
-void prs_set_packtype(prs_struct * ps, const uint8 * pack_type);
-void prs_create(prs_struct * ps, char *data, uint32 size, uint8 align,
- BOOL io);
-BOOL prs_copy(prs_struct * ps, const prs_struct * from);
-BOOL prs_alloc_data(prs_struct * buf, int size);
-BOOL prs_buf_copy(char *copy_into, const prs_struct * buf,
+void prs_debug_out(const prs_struct *ps, char *msg, int level);
+BOOL prs_init(prs_struct *ps, uint32 size, uint8 align, BOOL io);
+void prs_set_packtype(prs_struct *ps, const uint8 *pack_type);
+void prs_create(prs_struct *ps, char *data, uint32 size, uint8 align, BOOL io);
+BOOL prs_copy(prs_struct *ps, const prs_struct *from);
+BOOL prs_alloc_data(prs_struct *buf, int size);
+BOOL prs_buf_copy(char *copy_into, const prs_struct *buf,
uint32 offset, uint32 len);
-void prs_struct_free(prs_struct ** buf);
-void prs_free_data(prs_struct * buf);
-BOOL prs_realloc_data(prs_struct * buf, size_t new_size);
-BOOL prs_grow_data(prs_struct * buf, BOOL io, int new_size, BOOL force_grow);
-uint32 prs_buf_len(const prs_struct * buf);
-char *prs_data(const prs_struct * buf, uint32 offset);
-void prs_link(prs_struct * prev, prs_struct * ps, prs_struct * next);
-BOOL prs_align(prs_struct * ps);
-BOOL prs_grow(prs_struct * ps, uint32 new_size);
-BOOL prs_append_data(prs_struct * ps, const char *data, int len);
-BOOL prs_add_data(prs_struct * ps, const char *data, int len);
+void prs_struct_free(prs_struct **buf);
+void prs_free_data(prs_struct *buf);
+BOOL prs_realloc_data(prs_struct *buf, size_t new_size);
+BOOL prs_grow_data(prs_struct *buf, BOOL io, int new_size, BOOL force_grow);
+uint32 prs_buf_len(const prs_struct *buf);
+char *prs_data(const prs_struct *buf, uint32 offset);
+void prs_link(prs_struct *prev, prs_struct *ps, prs_struct *next);
+BOOL prs_align(prs_struct *ps);
+BOOL prs_grow(prs_struct *ps, uint32 new_size);
+BOOL prs_append_data(prs_struct *ps, const char *data, int len);
+BOOL prs_add_data(prs_struct *ps, const char *data, int len);
void prs_switch_type(prs_struct *ps, BOOL io);
void prs_force_dynamic(prs_struct *ps);
uint32 prs_data_size(prs_struct *ps);
uint32 prs_offset(prs_struct *ps);
BOOL prs_set_offset(prs_struct *ps, uint32 offset);
void prs_mem_free(prs_struct *ps);
-BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start, uint32 len);
-BOOL _prs_uint8(char *name, prs_struct * ps, int depth, uint8 * data8);
-BOOL _prs_uint16(char *name, prs_struct * ps, int depth, uint16 * data16);
-BOOL _prs_hash1(prs_struct * ps, uint32 offset, uint8 sess_key[16]);
-BOOL _prs_uint32(char *name, prs_struct * ps, int depth, uint32 * data32);
-BOOL _prs_uint8s(BOOL charmode, char *name, prs_struct * ps, int depth,
- uint8 * data8s, int len);
-BOOL _prs_uint16s(BOOL charmode, char *name, prs_struct * ps, int depth,
- uint16 * data16s, int len);
-BOOL _prs_uint32s(BOOL charmode, char *name, prs_struct * ps, int depth,
- uint32 * data32s, int len);
-BOOL _prs_buffer2(BOOL charmode, char *name, prs_struct * ps, int depth,
+BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start,
+ uint32 len);
+BOOL _prs_uint8(char *name, prs_struct *ps, int depth, uint8 *data8);
+BOOL _prs_uint16(char *name, prs_struct *ps, int depth, uint16 *data16);
+BOOL _prs_hash1(prs_struct *ps, uint32 offset, uint8 sess_key[16]);
+BOOL _prs_uint32(char *name, prs_struct *ps, int depth, uint32 *data32);
+BOOL _prs_uint8s(BOOL charmode, char *name, prs_struct *ps, int depth,
+ uint8 *data8s, int len);
+BOOL _prs_uint16s(BOOL charmode, char *name, prs_struct *ps, int depth,
+ uint16 *data16s, int len);
+BOOL _prs_uint32s(BOOL charmode, char *name, prs_struct *ps, int depth,
+ uint32 *data32s, int len);
+BOOL _prs_buffer2(BOOL charmode, char *name, prs_struct *ps, int depth,
BUFFER2 * str);
-BOOL _prs_string2(BOOL charmode, char *name, prs_struct * ps, int depth,
+BOOL _prs_string2(BOOL charmode, char *name, prs_struct *ps, int depth,
STRING2 * str);
-BOOL _prs_unistr2(BOOL charmode, char *name, prs_struct * ps, int depth,
- UNISTR2 * str);
-BOOL _prs_unistr3(BOOL charmode, char *name, UNISTR3 * str, prs_struct * ps,
+BOOL _prs_unistr2(BOOL charmode, char *name, prs_struct *ps, int depth,
+ UNISTR2 *str);
+BOOL _prs_unistr3(BOOL charmode, char *name, UNISTR3 * str, prs_struct *ps,
int depth);
-BOOL _prs_unistr(char *name, prs_struct * ps, int depth, UNISTR * str);
-BOOL _prs_string(char *name, prs_struct * ps, int depth, char *str,
+BOOL _prs_unistr(char *name, prs_struct *ps, int depth, UNISTR * str);
+BOOL _prs_string(char *name, prs_struct *ps, int depth, char *str,
uint16 len, uint16 max_buf_size);
-BOOL _prs_uint16_pre(char *name, prs_struct * ps, int depth, uint16 * data16,
- uint32 * offset);
-BOOL _prs_uint16_post(char *name, prs_struct * ps, int depth, uint16 * data16,
+BOOL _prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16,
+ uint32 *offset);
+BOOL _prs_uint16_post(char *name, prs_struct *ps, int depth, uint16 *data16,
uint32 ptr_uint16, uint32 start_offset);
-BOOL _prs_uint32_pre(char *name, prs_struct * ps, int depth, uint32 * data32,
- uint32 * offset);
-BOOL _prs_uint32_post(char *name, prs_struct * ps, int depth, uint32 * data32,
+BOOL _prs_uint32_pre(char *name, prs_struct *ps, int depth, uint32 *data32,
+ uint32 *offset);
+BOOL _prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32,
uint32 ptr_uint32, uint32 data_size);
-int prs_tdb_delete(TDB_CONTEXT * tdb, prs_struct * pk);
-int prs_tdb_store(TDB_CONTEXT * tdb, int flgs, prs_struct * pk,
- prs_struct * pd);
-void prs_tdb_fetch(TDB_CONTEXT * tdb, prs_struct * pk, prs_struct * pd);
+int prs_tdb_delete(TDB_CONTEXT * tdb, prs_struct *pk);
+int prs_tdb_store(TDB_CONTEXT * tdb, int flgs, prs_struct *pk, prs_struct *pd);
+void prs_tdb_fetch(TDB_CONTEXT * tdb, prs_struct *pk, prs_struct *pd);
/*The following definitions come from rpc_parse/parse_rpc.c */
@@ -3667,362 +4010,14 @@ BOOL api_svcctl_rpc(rpcsrv_struct * p);
BOOL api_wkssvc_rpc(rpcsrv_struct * p);
-/*The following definitions come from rpcclient/cmd_atsvc.c */
-
-void cmd_at(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_brs.c */
-
-void cmd_brs_query_info(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_dfs.c */
-
-void cmd_dfs_add(struct client_info *info, int argc, char *argv[]);
-void cmd_dfs_remove(struct client_info *info, int argc, char *argv[]);
-void cmd_dfs_enum(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_eventlog.c */
-
-void cmd_eventlog(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_lsarpc.c */
-
-void cmd_lsa_enum_trust_dom(struct client_info *info, int argc, char *argv[]);
-void cmd_lsa_query_info(struct client_info *info, int argc, char *argv[]);
-void cmd_lsa_lookup_names(struct client_info *info, int argc, char *argv[]);
-void cmd_lsa_lookup_sids(struct client_info *info, int argc, char *argv[]);
-void cmd_lsa_set_secret(struct client_info *info, int argc, char *argv[]);
-void cmd_lsa_create_secret(struct client_info *info, int argc, char *argv[]);
-void cmd_lsa_query_secret_secobj(struct client_info *info, int argc, char *argv[]);
-void cmd_lsa_query_secret(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_netlogon.c */
-
-void cmd_netlogon_pwset(struct client_info *info, int argc, char *argv[]);
-void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]);
-void cmd_netlogon_domain_test(struct client_info *info, int argc,
- char *argv[]);
-void cmd_sam_sync(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_reg.c */
-
-void split_server_keyname(char *srv_name, char *key, const char* arg);
-BOOL msrpc_reg_enum_key(const char* srv_name, const char* full_keyname,
- REG_FN(reg_fn),
- REG_KEY_FN(reg_key_fn),
- REG_VAL_FN(reg_val_fn));
-void cmd_reg_enum(struct client_info *info, int argc, char *argv[]);
-void cmd_reg_query_info(struct client_info *info, int argc, char *argv[]);
-void cmd_reg_query_key(struct client_info *info, int argc, char *argv[]);
-void cmd_reg_create_val(struct client_info *info, int argc, char *argv[]);
-void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[]);
-void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[]);
-void cmd_reg_create_key(struct client_info *info, int argc, char *argv[]);
-void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[]);
-void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[]);
-void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_samr.c */
-
-void cmd_sam_ntchange_pwd(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_test(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_lookup_domain(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_lookup_names(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_lookup_rids(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_delete_dom_alias(struct client_info *info, int argc,
- char *argv[]);
-void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_create_dom_trusting(struct client_info *info, int argc,
- char *argv[]);
-void cmd_sam_create_dom_user(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_create_dom_alias(struct client_info *info, int argc,
- char *argv[]);
-void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_delete_dom_user(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_delete_dom_group(struct client_info *info, int argc,
- char *argv[]);
-void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_create_dom_group(struct client_info *info, int argc,
- char *argv[]);
-void cmd_sam_enum_users(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_query_groupmem(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_query_group(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_query_sec_obj(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_query_user(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_query_dispinfo(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_query_dominfo(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_query_aliasmem(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_query_alias(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_enum_aliases(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_enum_groups(struct client_info *info, int argc, char *argv[]);
-void cmd_sam_enum_domains(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_spoolss.c */
-
-BOOL msrpc_spoolss_enum_printers(char* srv_name, uint32 flags, uint32 level, PRINTER_INFO_CTR ctr);
-void cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[]);
-void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[]);
-BOOL msrpc_spoolss_enum_jobs( const char* printer_name,
- const char* station, const char* user_name,
- uint32 level,
- void ***ctr, JOB_INFO_FN(fn));
-void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[]);
-BOOL msrpc_spoolss_enum_printerdata( const char* printer_name, const char* station, const char* user_name );
-void cmd_spoolss_enum_printerdata(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_srvsvc.c */
-
-BOOL net_srv_get_info(struct client_info *info,
- uint32 info_level, SRV_INFO_CTR * ctr);
-void cmd_srv_query_info(struct client_info *info, int argc, char *argv[]);
-BOOL msrpc_srv_enum_tprt(const char *dest_srv,
- uint32 info_level,
- SRV_TPRT_INFO_CTR * ctr, TPRT_INFO_FN(tprt_fn));
-void cmd_srv_enum_tprt(struct client_info *info, int argc, char *argv[]);
-void cmd_srv_enum_conn(struct client_info *info, int argc, char *argv[]);
-void cmd_srv_enum_shares(struct client_info *info, int argc, char *argv[]);
-void cmd_srv_share_get_info(struct client_info *info, int argc, char *argv[]);
-void cmd_srv_share_del(struct client_info *info, int argc, char *argv[]);
-void cmd_srv_enum_sess(struct client_info *info, int argc, char *argv[]);
-void cmd_srv_enum_files(struct client_info *info, int argc, char *argv[]);
-void cmd_time(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_svcctl.c */
-
-void svc_display_query_svc_cfg(const QUERY_SERVICE_CONFIG *cfg);
-BOOL svc_query_service( POLICY_HND *pol_scm,
- const char *svc_name,
- SVC_QUERY_FN(svc_query_fn));
-void cmd_svc_info(struct client_info *info, int argc, char *argv[]);
-BOOL msrpc_svc_enum(const char* srv_name,
- ENUM_SRVC_STATUS **svcs,
- uint32 *num_svcs,
- SVC_INFO_FN(info_fn),
- SVC_QUERY_FN(query_fn));
-void cmd_svc_enum(struct client_info *info, int argc, char *argv[]);
-void cmd_svc_stop(struct client_info *info, int argc, char *argv[]);
-void cmd_svc_start(struct client_info *info, int argc, char *argv[]);
-void cmd_svc_set(struct client_info *info, int argc, char *argv[]);
-void cmd_svc_unk3(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmd_wkssvc.c */
-
-void cmd_wks_query_info(struct client_info *info, int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/cmdat.c */
-
-
-/*The following definitions come from rpcclient/cmdat_cmds.c */
-
-void add_at_commands(void);
-
-/*The following definitions come from rpcclient/dfs_cmds.c */
-
-void add_dfs_commands(void);
-
-/*The following definitions come from rpcclient/display_at.c */
-
-void display_at_enum_info(FILE *out_hnd, enum action_type action,
- uint32 num_jobs, const AT_ENUM_INFO *const jobs,
- char *const *const commands);
-void display_at_job_info(FILE *out_hnd, enum action_type action,
- AT_JOB_INFO *const job, fstring command);
-
-/*The following definitions come from rpcclient/display_dfs.c */
-
-void display_dfs_enum_1(FILE *hnd, DFS_INFO_CTR *ctr);
-void display_dfs_enum_2(FILE *hnd, DFS_INFO_CTR *ctr);
-void display_dfs_enum_3_storages(FILE *hnd, DFS_INFO_3 *info3);
-void display_dfs_enum_3(FILE *hnd, DFS_INFO_CTR *ctr);
-void display_dfs_enum(FILE *hnd, char *srv_name, DFS_INFO_CTR *ctr);
-
-/*The following definitions come from rpcclient/display_event.c */
-
-void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *const ev);
-
-/*The following definitions come from rpcclient/display_reg.c */
-
-char *get_reg_val_type_str(uint32 type);
-void display_reg_value_info(FILE *out_hnd, enum action_type action,
- const char *val_name,
- uint32 val_type, const BUFFER2 *value);
-void display_reg_key_info(FILE *out_hnd, enum action_type action,
- const char *key_name, time_t key_mod_time);
-
-/*The following definitions come from rpcclient/display_sam.c */
-
-void display_alias_members(FILE *out_hnd, enum action_type action,
- uint32 num_mem, char *const *const sid_mem,
- uint32 *const type);
-void display_alias_rid_info(FILE *out_hnd, enum action_type action,
- DOM_SID *const sid,
- uint32 num_rids, uint32 *const rid);
-void display_group_members(FILE *out_hnd, enum action_type action,
- uint32 num_mem, char *const *const name, uint32 *const type);
-void display_group_info_ctr(FILE *out_hnd, enum action_type action,
- GROUP_INFO_CTR *const ctr);
-void display_group_rid_info(FILE *out_hnd, enum action_type action,
- uint32 num_gids, DOM_GID *const gid);
-void display_alias_name_info(FILE *out_hnd, enum action_type action,
- uint32 num_aliases, fstring *const alias_name, const uint32 *const num_als_usrs);
-void display_alias_info_ctr(FILE *out_hnd, enum action_type action,
- ALIAS_INFO_CTR *const ctr);
-void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_INFO_21 *const usr);
-void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
- uint32 switch_value, SAM_UNK_CTR *const ctr);
-void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action,
- uint16 level, uint32 count,
- SAM_DISPINFO_CTR *const ctr);
-
-/*The following definitions come from rpcclient/display_sec.c */
-
-void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const sec);
-
-/*The following definitions come from rpcclient/display_spool.c */
-
-void display_printer_info_ctr(FILE *out_hnd, enum action_type action, uint32 level,
- uint32 count, PRINTER_INFO_CTR ctr);
-void display_printer_enumdata(FILE *out_hnd, enum action_type action, uint32 idx,
- uint32 valuelen, uint16 *value, uint32 rvaluelen,
- uint32 type,
- uint32 datalen, uint8 *data, uint32 rdatalen);
-void display_job_info_2(FILE *out_hnd, enum action_type action,
- JOB_INFO_2 *const i2);
-void display_job_info_1(FILE *out_hnd, enum action_type action,
- JOB_INFO_1 *const i1);
-void display_job_info_2_ctr(FILE *out_hnd, enum action_type action,
- uint32 count, JOB_INFO_2 *const *const ctr);
-void display_job_info_1_ctr(FILE *out_hnd, enum action_type action,
- uint32 count, JOB_INFO_1 *const *const ctr);
-void display_job_info_ctr(FILE *out_hnd, enum action_type action,
- uint32 level, uint32 count,
- void *const *const ctr);
-
-/*The following definitions come from rpcclient/display_srv.c */
-
-char *get_file_oplock_str(uint32 op_type);
-void display_srv_info_ctr(FILE * out_hnd, enum action_type action,
- const SRV_INFO_CTR * ctr);
-void display_srv_conn_info_ctr(FILE * out_hnd, enum action_type action,
- SRV_CONN_INFO_CTR * const ctr);
-void display_tprt_info_0(FILE * out_hnd, enum action_type action,
- TPRT_INFO_0 * const info0,
- TPRT_INFO_0_STR * const str0);
-void display_srv_tprt_info_0_ctr(FILE * out_hnd, enum action_type action,
- const SRV_TPRT_INFO_0 * const ctr);
-void display_srv_tprt_info_ctr(FILE * out_hnd, enum action_type action,
- const SRV_TPRT_INFO_CTR * const ctr);
-void display_srv_share_info_ctr(FILE * out_hnd, enum action_type action,
- SRV_SHARE_INFO_CTR * const ctr);
-void display_share_info_ctr(FILE * out_hnd, enum action_type action,
- SHARE_INFO_CTR * const ctr);
-void display_srv_file_info_ctr(FILE * out_hnd, enum action_type action,
- SRV_FILE_INFO_CTR * const ctr);
-void display_srv_sess_info_0_ctr(FILE * out_hnd, enum action_type action,
- SRV_SESS_INFO_0 * const ctr);
-void display_srv_sess_info_1_ctr(FILE * out_hnd, enum action_type action,
- SRV_SESS_INFO_1 * const ctr);
-void display_srv_sess_info_ctr(FILE * out_hnd, enum action_type action,
- SRV_SESS_INFO_CTR * const ctr);
-void display_server(FILE * out_hnd, enum action_type action,
- char *const sname, uint32 type, char *const comment);
-void display_share(FILE * out_hnd, enum action_type action,
- char *const sname, uint32 type, char *const comment);
-void display_share2(FILE * out_hnd, enum action_type action,
- char *const sname, uint32 type, char *const comment,
- uint32 perms, uint32 max_uses, uint32 num_uses,
- char *const path, char *const password);
-void display_name(FILE * out_hnd, enum action_type action, char *const sname);
-
-/*The following definitions come from rpcclient/display_svc.c */
-
-char *get_svc_start_type_str(uint32 type);
-void display_query_svc_cfg(FILE *out_hnd, enum action_type action,
- const QUERY_SERVICE_CONFIG *const cfg);
-void display_svc_info(FILE *out_hnd, enum action_type action,
- const ENUM_SRVC_STATUS *const svc);
-
-/*The following definitions come from rpcclient/display_sync.c */
-
-void display_sam_sync_ctr(FILE *out_hnd, enum action_type action,
- SAM_DELTA_HDR *const delta,
- SAM_DELTA_CTR *const ctr);
-void display_sam_sync(FILE *out_hnd, enum action_type action,
- SAM_DELTA_HDR *const deltas,
- SAM_DELTA_CTR *const ctr,
- uint32 num);
-
-/*The following definitions come from rpcclient/eventlog.c */
-
-int main(int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/eventlog_cmds.c */
-
-void add_evt_commands(void);
-
-/*The following definitions come from rpcclient/lsa.c */
-
-
-/*The following definitions come from rpcclient/lsa_cmds.c */
-
-void add_lsa_commands(void);
-
-/*The following definitions come from rpcclient/net.c */
-
-
-/*The following definitions come from rpcclient/net_cmds.c */
-
-void add_net_commands(void);
-
-/*The following definitions come from rpcclient/netlogon_cmds.c */
-
-void add_ntl_commands(void);
-
-/*The following definitions come from rpcclient/regedit.c */
-
-
-/*The following definitions come from rpcclient/regedit_cmds.c */
-
-void add_reg_commands(void);
-
-/*The following definitions come from rpcclient/rpcclient.c */
-
-
-/*The following definitions come from rpcclient/samedit.c */
-
-
-/*The following definitions come from rpcclient/samedit_cmds.c */
-
-void add_sam_commands(void);
-
-/*The following definitions come from rpcclient/spoolss.c */
-
-int main(int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/spoolss_cmds.c */
-
-void add_spl_commands(void);
-
-/*The following definitions come from rpcclient/svcctrl.c */
-
-int main(int argc, char *argv[]);
-
-/*The following definitions come from rpcclient/svcctrl_cmds.c */
+/*The following definitions come from samrd/samrd.c */
-char *complete_svcenum(char *text, int state);
-void add_svc_commands(void);
+msrpc_service_fns *get_service_fns(void);
/*The following definitions come from samrd/samr_util.c */
uint32 samr_make_usr_obj_sd(SEC_DESC_BUF *buf, DOM_SID *usr_sid);
-/*The following definitions come from samrd/samrd.c */
-
-msrpc_service_fns *get_service_fns(void);
-
/*The following definitions come from samrd/srv_samr_als_tdb.c */
uint32 _samr_add_aliasmem(const POLICY_HND *alias_pol, const DOM_SID *sid);
@@ -4836,6 +4831,19 @@ BOOL become_user(connection_struct *conn, uint16 vuid);
BOOL become_userk(connection_struct *conn, const vuser_key *key);
BOOL unbecome_user(void );
+/*The following definitions come from smbd/vfs.c */
+
+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);
+BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf);
+ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N);
+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);
+
/*The following definitions come from smbd/vfs-wrap.c */
int vfswrap_dummy_connect(struct vfs_connection_struct *conn, char *service,
@@ -4863,19 +4871,6 @@ int vfswrap_unlink(char *path);
int vfswrap_chmod(char *path, mode_t mode);
int vfswrap_utime(char *path, struct utimbuf *times);
-/*The following definitions come from smbd/vfs.c */
-
-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);
-BOOL vfs_file_exist(connection_struct *conn,char *fname,SMB_STRUCT_STAT *sbuf);
-ssize_t vfs_write_data(files_struct *fsp,char *buffer,size_t N);
-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);
-
/*The following definitions come from smbwrapper/realcalls.c */
int real_utime(const char *name, struct utimbuf *buf);
diff --git a/source/include/rpc_parse_proto.h b/source/include/rpc_parse_proto.h
index 7496210fcc3..c6415b119c7 100644
--- a/source/include/rpc_parse_proto.h
+++ b/source/include/rpc_parse_proto.h
@@ -973,7 +973,7 @@ BOOL new_smb_io_job_info_1(char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int
BOOL new_smb_io_job_info_2(char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth);
BOOL new_smb_io_form_1(char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth);
void new_spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest);
-void new_spoolss_allocate_buffer(NEW_BUFFER **buffer);
+BOOL new_spoolss_allocate_buffer(NEW_BUFFER **buffer);
void new_spoolss_free_buffer(NEW_BUFFER *buffer);
uint32 new_get_buffer_size(NEW_BUFFER *buffer);
BOOL new_smb_io_driverdir_1(char *desc, NEW_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth);
diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c
index 180154218ce..39a44bdcf2d 100644
--- a/source/printing/nt_printing.c
+++ b/source/printing/nt_printing.c
@@ -148,7 +148,7 @@ int write_ntforms(nt_forms_struct **list, int number)
/****************************************************************************
add a form struct at the end of the list
****************************************************************************/
-void add_a_form(nt_forms_struct **list, const FORM *form, int *count)
+BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count)
{
int n=0;
BOOL update;
@@ -174,7 +174,8 @@ void add_a_form(nt_forms_struct **list, const FORM *form, int *count)
if (update==False)
{
- *list=Realloc(*list, (n+1)*sizeof(nt_forms_struct));
+ if((*list=Realloc(*list, (n+1)*sizeof(nt_forms_struct))) == NULL)
+ return False;
unistr2_to_ascii((*list)[n].name, &(form->name), sizeof((*list)[n].name)-1);
(*count)++;
}
@@ -186,6 +187,8 @@ void add_a_form(nt_forms_struct **list, const FORM *form, int *count)
(*list)[n].top=form->top;
(*list)[n].right=form->right;
(*list)[n].bottom=form->bottom;
+
+ return True;
}
/****************************************************************************
@@ -254,7 +257,10 @@ int get_ntdrivers(fstring **list, char *architecture)
fstrcpy(driver_name, dpname+match_len);
all_string_sub(driver_name, "#", "/", 0);
- *list = Realloc(*list, sizeof(fstring)*(total+1));
+
+ if((*list = Realloc(*list, sizeof(fstring)*(total+1))) == NULL)
+ return -1;
+
StrnCpy((*list)[total], driver_name, strlen(driver_name));
DEBUGADD(106,("Added: [%s]\n", driver_name));
total++;
@@ -278,12 +284,12 @@ void get_short_archi(char *short_archi, char *long_archi)
struct table archi_table[]=
{
- {"Windows 4.0", "" },
- {"Windows NT x86", "W32X86" },
- {"Windows NT R4000", "" },
- {"Windows NT Alpha_AXP", "" },
- {"Windows NT PowerPC", "" },
- {NULL, "" }
+ {"Windows 4.0", "WIN40" },
+ {"Windows NT x86", "W32X86" },
+ {"Windows NT R4000", "W32mips" },
+ {"Windows NT Alpha_AXP", "W32alpha" },
+ {"Windows NT PowerPC", "W32ppc" },
+ {NULL, "" }
};
int i=-1;
@@ -832,6 +838,8 @@ static void free_nt_printer_param(NT_PRINTER_PARAM **param_ptr)
if(param == NULL)
return;
+ DEBUG(106,("free_nt_printer_param: deleting param [%s]\n", param->value));
+
if(param->data)
free(param->data);
@@ -850,6 +858,8 @@ static void free_nt_devicemode(NT_DEVICEMODE **devmode_ptr)
if(nt_devmode == NULL)
return;
+ DEBUG(106,("free_nt_devicemode: deleting DEVMODE\n"));
+
if(nt_devmode->private)
free(nt_devmode->private);
@@ -869,6 +879,8 @@ static void free_nt_printer_info_level_2(NT_PRINTER_INFO_LEVEL_2 **info_ptr)
if(info == NULL)
return;
+ DEBUG(106,("free_nt_printer_info_level_2: deleting info\n"));
+
free_nt_devicemode(&info->devmode);
for(param_ptr = info->specific; param_ptr; ) {
@@ -1223,6 +1235,8 @@ uint32 get_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level, fstring share
{
uint32 success;
+ DEBUG(10,("get_a_printer: [%s] level %u\n", sharename, (unsigned int)level));
+
switch (level)
{
case 2:
@@ -1237,6 +1251,9 @@ uint32 get_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level, fstring share
}
dump_a_printer(*printer, level);
+
+ DEBUG(10,("get_a_printer: [%s] level %u returning %u\n", sharename, (unsigned int)level, (unsigned int)success));
+
return (success);
}
@@ -1253,32 +1270,7 @@ uint32 free_a_printer(NT_PRINTER_INFO_LEVEL printer, uint32 level)
{
if (printer.info_2 != NULL)
{
- if ((printer.info_2)->devmode != NULL)
- {
- DEBUG(106,("deleting DEVMODE\n"));
- if ((printer.info_2)->devmode->private !=NULL )
- free((printer.info_2)->devmode->private);
- free((printer.info_2)->devmode);
- }
-
- if ((printer.info_2)->specific != NULL)
- {
- NT_PRINTER_PARAM *param;
- NT_PRINTER_PARAM *next_param;
-
- param=(printer.info_2)->specific;
-
- while ( param != NULL)
- {
- next_param=param->next;
- DEBUG(106,("deleting param [%s]\n", param->value));
- free(param->data);
- free(param);
- param=next_param;
- }
- }
-
- free(printer.info_2);
+ free_nt_printer_info_level_2(&printer.info_2);
success=0;
}
else
diff --git a/source/printing/printing.c b/source/printing/printing.c
index c33b7b3010b..e4768582a8e 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -20,8 +20,6 @@
*/
#include "includes.h"
-#include "nterr.h"
-
extern int DEBUGLEVEL;
static BOOL * lpq_cache_reset=NULL;
@@ -51,11 +49,11 @@ Build the print command in the supplied buffer. This means getting the
print command for the service and inserting the printer name and the
print file name. Return NULL on error, else the passed buffer pointer.
****************************************************************************/
-static char *build_print_command(connection_struct *conn, const vuser_key *key,
- int snum,
+static char *build_print_command(connection_struct *conn,
char *command,
char *syscmd, char *filename)
{
+ int snum = SNUM(conn);
char *tstr;
/* get the print command for the service. */
@@ -74,7 +72,7 @@ static char *build_print_command(connection_struct *conn, const vuser_key *key,
DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum)));
}
- pstring_sub(syscmd, "%s", filename);
+ pstring_sub(syscmd, "%s", filename);
pstring_sub(syscmd, "%f", filename);
/* Does the service have a printername? If not, make a fake
@@ -89,12 +87,8 @@ static char *build_print_command(connection_struct *conn, const vuser_key *key,
pstring_sub(syscmd, "%p", tstr);
- {
- user_struct *vuser = get_valid_user_struct(key);
- standard_sub(conn, vuser, syscmd);
- vuid_free_user_struct(vuser);
- }
-
+ standard_sub(conn,syscmd);
+
return (syscmd);
}
@@ -102,10 +96,10 @@ static char *build_print_command(connection_struct *conn, const vuser_key *key,
/****************************************************************************
print a file - called on closing the file
****************************************************************************/
-void print_file(connection_struct *conn, const vuser_key *key,
- int snum, files_struct *file)
+void print_file(connection_struct *conn, files_struct *file)
{
pstring syscmd;
+ int snum = SNUM(conn);
char *tempstr;
*syscmd = 0;
@@ -116,7 +110,7 @@ void print_file(connection_struct *conn, const vuser_key *key,
return;
}
- tempstr = build_print_command(conn, key, snum,
+ tempstr = build_print_command(conn,
PRINTCOMMAND(snum),
syscmd, file->fsp_name);
if (tempstr != NULL) {
@@ -623,7 +617,7 @@ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
* the printer name in case we have a dash in that.
* Patch from Dom.Mitchell@palmerharvey.co.uk.
*/
-
+
/*
* Move to the first space.
*/
@@ -658,8 +652,7 @@ static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
fstring tmp;
fstrcpy(tmp,p+1);
fstrcpy(tok[2],tmp);
- }
-
+ }
buf->job = atoi(tok[1]);
buf->size = atoi(tok[3]);
@@ -992,8 +985,8 @@ static BOOL parse_lpq_entry(int snum,char *line,
/****************************************************************************
get a printer queue
****************************************************************************/
-int get_printqueue(int snum, connection_struct *conn, const vuser_key *key,
- print_queue_struct **queue,
+int get_printqueue(int snum,
+ connection_struct *conn,print_queue_struct **queue,
print_status_struct *status)
{
char *lpq_command = lp_lpqcommand(snum);
@@ -1024,11 +1017,7 @@ int get_printqueue(int snum, connection_struct *conn, const vuser_key *key,
pstrcpy(syscmd,lpq_command);
pstring_sub(syscmd,"%p",printername);
- {
- user_struct *vuser = get_valid_user_struct(key);
- standard_sub(conn, vuser, syscmd);
- vuid_free_user_struct(vuser);
- }
+ standard_sub(conn,syscmd);
slprintf(outfile,sizeof(outfile)-1, "%s/lpq.%08x",tmpdir(),str_checksum(syscmd));
@@ -1091,8 +1080,7 @@ int get_printqueue(int snum, connection_struct *conn, const vuser_key *key,
/****************************************************************************
delete a printer queue entry
****************************************************************************/
-void del_printqueue(connection_struct *conn,const vuser_key *key,
- int snum,int jobid)
+void del_printqueue(connection_struct *conn,int snum,int jobid)
{
char *lprm_command = lp_lprmcommand(snum);
char *printername = PRINTERNAME(snum);
@@ -1118,11 +1106,7 @@ void del_printqueue(connection_struct *conn,const vuser_key *key,
pstrcpy(syscmd,lprm_command);
pstring_sub(syscmd,"%p",printername);
pstring_sub(syscmd,"%j",jobstr);
- {
- user_struct *vuser = get_valid_user_struct(key);
- standard_sub(conn, vuser, syscmd);
- vuid_free_user_struct(vuser);
- }
+ standard_sub(conn,syscmd);
ret = smbrun(syscmd,NULL,False);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
@@ -1132,8 +1116,7 @@ void del_printqueue(connection_struct *conn,const vuser_key *key,
/****************************************************************************
change status of a printer queue entry
****************************************************************************/
-void status_printjob(connection_struct *conn,const vuser_key *key,
- int snum,int jobid,int status)
+void status_printjob(connection_struct *conn,int snum,int jobid,int status)
{
char *lpstatus_command =
(status==LPQ_PAUSED?lp_lppausecommand(snum):lp_lpresumecommand(snum));
@@ -1161,11 +1144,7 @@ void status_printjob(connection_struct *conn,const vuser_key *key,
pstrcpy(syscmd,lpstatus_command);
pstring_sub(syscmd,"%p",printername);
pstring_sub(syscmd,"%j",jobstr);
- {
- user_struct *vuser = get_valid_user_struct(key);
- standard_sub(conn, vuser, syscmd);
- vuid_free_user_struct(vuser);
- }
+ standard_sub(conn,syscmd);
ret = smbrun(syscmd,NULL,False);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
@@ -1197,8 +1176,8 @@ void printjob_decode(int jobid, int *snum, int *job)
/****************************************************************************
Change status of a printer queue
****************************************************************************/
-uint32 status_printqueue(connection_struct *conn,const vuser_key *key,
- int snum,int status)
+
+void status_printqueue(connection_struct *conn,int snum,int status)
{
char *queuestatus_command = (status==LPSTAT_STOPPED ?
lp_queuepausecommand(snum):lp_queueresumecommand(snum));
@@ -1215,20 +1194,12 @@ uint32 status_printqueue(connection_struct *conn,const vuser_key *key,
if (!queuestatus_command || !(*queuestatus_command)) {
DEBUG(5,("No queuestatus command to %s job\n",
(status==LPSTAT_STOPPED?"pause":"resume")));
- return NT_STATUS_INVALID_PARAMETER;
+ return;
}
pstrcpy(syscmd,queuestatus_command);
pstring_sub(syscmd,"%p",printername);
- {
- user_struct *vuser = get_valid_user_struct(key);
- standard_sub(conn, vuser, syscmd);
- vuid_free_user_struct(vuser);
- }
-
- return ret == 0 ? 0x0 : NT_STATUS_INVALID_PARAMETER;
-
-
+ standard_sub(conn,syscmd);
ret = smbrun(syscmd,NULL,False);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
diff --git a/source/rpc_parse/parse_spoolss.c b/source/rpc_parse/parse_spoolss.c
index 57853d6c152..d051c233a93 100644
--- a/source/rpc_parse/parse_spoolss.c
+++ b/source/rpc_parse/parse_spoolss.c
@@ -274,7 +274,8 @@ static BOOL smb_io_notify_option_type_ctr(char *desc, SPOOL_NOTIFY_OPTION_TYPE_C
/* reading */
if (UNMARSHALLING(ps))
- ctr->type=(SPOOL_NOTIFY_OPTION_TYPE *)malloc(ctr->count*sizeof(SPOOL_NOTIFY_OPTION_TYPE));
+ if((ctr->type=(SPOOL_NOTIFY_OPTION_TYPE *)malloc(ctr->count*sizeof(SPOOL_NOTIFY_OPTION_TYPE))) == NULL)
+ return False;
/* the option type struct */
for(i=0;i<ctr->count;i++)
@@ -389,7 +390,7 @@ BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data,
uint32 x;
BOOL isvalue;
- prs_debug(ps, depth, desc, "smb_io_notify_info_data");
+ prs_debug(ps, depth, desc, "smb_io_notify_info_data_strings");
depth++;
if(!prs_align(ps))
@@ -1143,7 +1144,8 @@ BOOL spoolss_io_q_rffpcnex(char *desc, SPOOL_Q_RFFPCNEX *q_u, prs_struct *ps, in
if (q_u->option_ptr!=0) {
if (UNMARSHALLING(ps))
- q_u->option=(SPOOL_NOTIFY_OPTION *)malloc(sizeof(SPOOL_NOTIFY_OPTION));
+ if((q_u->option=(SPOOL_NOTIFY_OPTION *)malloc(sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
+ return False;
if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
return False;
@@ -1191,7 +1193,8 @@ BOOL spoolss_io_q_rfnpcnex(char *desc, SPOOL_Q_RFNPCNEX *q_u, prs_struct *ps, in
if (q_u->option_ptr!=0) {
if (UNMARSHALLING(ps))
- q_u->option=(SPOOL_NOTIFY_OPTION *)malloc(sizeof(SPOOL_NOTIFY_OPTION));
+ if((q_u->option=(SPOOL_NOTIFY_OPTION *)malloc(sizeof(SPOOL_NOTIFY_OPTION))) == NULL)
+ return False;
if(!smb_io_notify_option("notify option", q_u->option, ps, depth))
return False;
@@ -1431,7 +1434,8 @@ static BOOL new_smb_io_relarraystr(char *desc, NEW_BUFFER *buffer, int depth, ui
return False;
l_chaine=str_len_uni(&chaine);
- chaine2=(uint16 *)Realloc(chaine2, (l_chaine2+l_chaine+1)*sizeof(uint16));
+ if((chaine2=(uint16 *)Realloc(chaine2, (l_chaine2+l_chaine+1)*sizeof(uint16))) == NULL)
+ return False;
memcpy(chaine2+l_chaine2, chaine.buffer, (l_chaine+1)*sizeof(uint16));
l_chaine2+=l_chaine+1;
@@ -1485,7 +1489,8 @@ static BOOL new_smb_io_reldevmode(char *desc, NEW_BUFFER *buffer, int depth, DEV
prs_set_offset(ps, buffer->string_at_end + buffer->struct_start);
/* read the string */
- *devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE));
+ if((*devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL)
+ return False;
if (!spoolss_io_devmode(desc, ps, depth, *devmode))
return False;
@@ -1986,16 +1991,21 @@ void new_spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest)
/*******************************************************************
create a BUFFER struct.
********************************************************************/
-void new_spoolss_allocate_buffer(NEW_BUFFER **buffer)
+BOOL new_spoolss_allocate_buffer(NEW_BUFFER **buffer)
{
if (buffer==NULL)
- return;
+ return False;
- *buffer=(NEW_BUFFER *)malloc(sizeof(NEW_BUFFER));
+ if((*buffer=(NEW_BUFFER *)malloc(sizeof(NEW_BUFFER))) == NULL) {
+ DEBUG(0,("new_spoolss_allocate_buffer: malloc fail for size %u.\n",
+ (unsigned int)sizeof(NEW_BUFFER) ));
+ return False;
+ }
(*buffer)->ptr=0x0;
(*buffer)->size=0;
(*buffer)->string_at_end=0;
+ return True;
}
/*******************************************************************
@@ -2315,8 +2325,11 @@ uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info)
for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++);
- size+=2*i;
- size+=6;
+ i=i+2; /* to count all chars including the leading zero */
+ i=2*i; /* because we need the value in bytes */
+ i=i+4; /* the offset pointer size */
+
+ size+=i;
return size;
}
diff --git a/source/script/installcp.sh b/source/script/installcp.sh
index 87b0ef1a8ab..5dbaae33d68 100755
--- a/source/script/installcp.sh
+++ b/source/script/installcp.sh
@@ -23,6 +23,8 @@ done
for p in $*; do
echo Creating codepage file $CODEPAGEDIR/codepage.$p
$BINDIR/make_smbcodepage c $p ${srcdir}/codepages/codepage_def.$p $CODEPAGEDIR/codepage.$p
+ echo Creating unicode codepage file $CODEPAGEDIR/unicode_map.$p
+ $BINDIR/make_unicodemap $p ${srcdir}/codepages/CP$p.TXT $CODEPAGEDIR/unicode_map.$p
done
diff --git a/source/spoolssd/srv_spoolss_nt.c b/source/spoolssd/srv_spoolss_nt.c
index e99c7307625..242412dc8b6 100755
--- a/source/spoolssd/srv_spoolss_nt.c
+++ b/source/spoolssd/srv_spoolss_nt.c
@@ -234,7 +234,9 @@ static BOOL open_printer_hnd(POLICY_HND *hnd)
{
Printer_entry *new_printer;
- new_printer=(Printer_entry *)malloc(sizeof(Printer_entry));
+ if((new_printer=(Printer_entry *)malloc(sizeof(Printer_entry))) == NULL)
+ return False;
+
ZERO_STRUCTP(new_printer);
new_printer->open = True;
@@ -312,8 +314,7 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
char *aprinter;
BOOL found=False;
- if (!OPEN_HANDLE(Printer))
- {
+ if (!OPEN_HANDLE(Printer)) {
DEBUG(0,("Error setting printer name=%s\n", printername));
return False;
}
@@ -351,6 +352,9 @@ static BOOL set_printer_hnd_printername(POLICY_HND *hnd, char *printername)
if (get_a_printer(&printer, 2, lp_servicename(snum))!=0)
continue;
+ DEBUG(10,("set_printer_hnd_printername: printername [%s], aprinter [%s]\n",
+ printer.info_2->printername, aprinter ));
+
if ( strlen(printer.info_2->printername) != strlen(aprinter) ) {
free_a_printer(printer, 2);
continue;
@@ -559,7 +563,8 @@ static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode)
/* if we had a previous private delete it and make a new one */
if (nt_devmode->private != NULL)
free(nt_devmode->private);
- nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8));
+ if((nt_devmode->private=(uint8 *)malloc(nt_devmode->driverextra * sizeof(uint8))) == NULL)
+ return False;
memcpy(nt_devmode->private, devmode.private, nt_devmode->driverextra);
}
@@ -572,7 +577,7 @@ static BOOL convert_devicemode(DEVICEMODE devmode, NT_DEVICEMODE *nt_devmode)
uint32 _spoolss_closeprinter(POLICY_HND *handle)
{
if (!close_printer_handle(handle))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
return NT_STATUS_NO_PROBLEMO;
}
@@ -589,7 +594,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
if (!strcmp(value, "BeepEnabled"))
{
*type = 0x4;
- *data = (uint8 *)malloc( 4*sizeof(uint8) );
+ if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL)
+ return False;
SIVAL(*data, 0, 0x01);
*needed = 0x4;
return True;
@@ -598,7 +604,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
if (!strcmp(value, "EventLog"))
{
*type = 0x4;
- *data = (uint8 *)malloc( 4*sizeof(uint8) );
+ if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL)
+ return False;
SIVAL(*data, 0, 0x1B);
*needed = 0x4;
return True;
@@ -607,7 +614,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
if (!strcmp(value, "NetPopup"))
{
*type = 0x4;
- *data = (uint8 *)malloc( 4*sizeof(uint8) );
+ if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL)
+ return False;
SIVAL(*data, 0, 0x01);
*needed = 0x4;
return True;
@@ -616,7 +624,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
if (!strcmp(value, "MajorVersion"))
{
*type = 0x4;
- *data = (uint8 *)malloc( 4*sizeof(uint8) );
+ if((*data = (uint8 *)malloc( 4*sizeof(uint8) )) == NULL)
+ return False;
SIVAL(*data, 0, 0x02);
*needed = 0x4;
return True;
@@ -627,7 +636,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
pstring string="You are using a Samba server";
*type = 0x1;
*needed = 2*(strlen(string)+1);
- *data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8));
+ if((*data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL)
+ return False;
memset(*data, 0, (*needed > in_size) ? *needed:in_size);
/* it's done by hand ready to go on the wire */
@@ -644,7 +654,8 @@ static BOOL getprinterdata_printer_server(fstring value, uint32 *type, uint8 **d
pstring string="Windows NT x86";
*type = 0x1;
*needed = 2*(strlen(string)+1);
- *data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8));
+ if((*data = (uint8 *)malloc( ((*needed > in_size) ? *needed:in_size) *sizeof(uint8))) == NULL)
+ return False;
memset(*data, 0, (*needed > in_size) ? *needed:in_size);
for (i=0; i<strlen(string); i++)
{
@@ -675,8 +686,11 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle,
if (!OPEN_HANDLE(Printer))
return False;
- get_printer_snum(handle, &snum);
- get_a_printer(&printer, 2, lp_servicename(snum));
+ if(!get_printer_snum(handle, &snum))
+ return False;
+
+ if(get_a_printer(&printer, 2, lp_servicename(snum)) != 0)
+ return False;
if (!get_specific_param(printer, 2, value, &idata, type, &len)) {
free_a_printer(printer, 2);
@@ -685,7 +699,11 @@ static BOOL getprinterdata_printer(const POLICY_HND *handle,
DEBUG(5,("getprinterdata_printer:allocating %d\n", in_size));
- *data = (uint8 *)malloc( in_size *sizeof(uint8) );
+ if((*data = (uint8 *)malloc( in_size *sizeof(uint8) )) == NULL) {
+ free_a_printer(printer, 2);
+ return False;
+ }
+
memset(*data, 0, in_size *sizeof(uint8));
/* copy the min(in_size, len) */
memcpy(*data, idata, (len>in_size)?in_size:len *sizeof(uint8));
@@ -730,8 +748,9 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename,
DEBUG(4,("_spoolss_getprinterdata\n"));
if (!OPEN_HANDLE(Printer)) {
- *data=(uint8 *)malloc(4*sizeof(uint8));
- return NT_STATUS_INVALID_HANDLE;
+ if((*data=(uint8 *)malloc(4*sizeof(uint8))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
+ return ERROR_INVALID_HANDLE;
}
unistr2_to_ascii(value, valuename, sizeof(value)-1);
@@ -744,7 +763,8 @@ uint32 _spoolss_getprinterdata(const POLICY_HND *handle, UNISTR2 *valuename,
if (found==False) {
DEBUG(5, ("value not found, allocating %d\n", *out_size));
/* reply this param doesn't exist */
- *data=(uint8 *)malloc(*out_size*sizeof(uint8));
+ if((*data=(uint8 *)malloc(*out_size*sizeof(uint8))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
memset(*data, 0x0, *out_size*sizeof(uint8));
return ERROR_INVALID_PARAMETER;
}
@@ -775,7 +795,7 @@ uint32 _spoolss_rffpcnex(const POLICY_HND *handle, uint32 flags, uint32 options,
Printer_entry *Printer=find_printer_index_by_hnd(handle);
if (!OPEN_HANDLE(Printer))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
Printer->notify.flags=flags;
Printer->notify.options=options;
@@ -997,7 +1017,7 @@ static void spoolss_notify_status(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_
print_status_struct status;
memset(&status, 0, sizeof(status));
- count=get_printqueue(snum, NULL, UID_FIELD_INVALID, &q, &status);
+ count=get_printqueue(snum, NULL, &q, &status);
data->notify_data.value[0]=(uint32) status.status;
safe_free(q);
}
@@ -1011,7 +1031,7 @@ static void spoolss_notify_cjobs(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_q
print_status_struct status;
memset(&status, 0, sizeof(status));
- data->notify_data.value[0]=get_printqueue(snum, NULL, UID_FIELD_INVALID, &q, &status);
+ data->notify_data.value[0]=get_printqueue(snum, NULL, &q, &status);
safe_free(q);
}
@@ -1258,7 +1278,10 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO
if (!search_notify(type, field, &j) )
continue;
- info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA));
+ if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) {
+ free_a_printer(printer, 2);
+ return False;
+ }
current_data=&(info->data[info->count]);
construct_info_data(current_data, type, field, id);
@@ -1305,7 +1328,11 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I
if (!search_notify(type, field, &j) )
continue;
- info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA));
+ if((info->data=Realloc(info->data, (info->count+1)*sizeof(SPOOL_NOTIFY_INFO_DATA))) == NULL) {
+ free_a_printer(printer, 2);
+ return False;
+ }
+
current_data=&(info->data[info->count]);
construct_info_data(current_data, type, field, id);
@@ -1419,7 +1446,7 @@ static uint32 printer_notify_info(const POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info
DEBUG(4,("printer_notify_info\n"));
option=Printer->notify.option;
- id=1;
+ id=0xffffffff;
info->version=2;
info->data=NULL;
info->count=0;
@@ -1433,15 +1460,14 @@ static uint32 printer_notify_info(const 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))
- id++;
+ id--;
break;
case JOB_NOTIFY_TYPE:
memset(&status, 0, sizeof(status));
- count=get_printqueue(snum, NULL, UID_FIELD_INVALID, &queue, &status);
+ count=get_printqueue(snum, NULL, &queue, &status);
for (j=0; j<count; j++)
- if (construct_notify_jobs_info(&(queue[j]), info, snum, option_type, id))
- id++;
+ construct_notify_jobs_info(&(queue[j]), info, snum, option_type, queue[j].job);
safe_free(queue);
break;
}
@@ -1474,7 +1500,7 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change,
Printer_entry *Printer=find_printer_index_by_hnd(handle);
if (!OPEN_HANDLE(Printer))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
DEBUG(4,("Printer type %x\n",Printer->printer_type));
@@ -1504,7 +1530,7 @@ uint32 _spoolss_rfnpcnex( const POLICY_HND *handle, uint32 change,
break;
}
- return NT_STATUS_INVALID_INFO_CLASS;
+ return ERROR_INVALID_HANDLE;
}
/********************************************************************
@@ -1528,7 +1554,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s
if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) != 0)
return False;
- count=get_printqueue(snum, NULL, UID_FIELD_INVALID, &queue, &status);
+ count=get_printqueue(snum, NULL, &queue, &status);
/* check if we already have a counter for this printer */
session_counter = (counter_printer_0 *)ubi_dlFirst(&counter_list);
@@ -1540,7 +1566,8 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s
/* it's the first time, add it to the list */
if (session_counter==NULL) {
- session_counter=(counter_printer_0 *)malloc(sizeof(counter_printer_0));
+ if((session_counter=(counter_printer_0 *)malloc(sizeof(counter_printer_0))) == NULL)
+ return False;
ZERO_STRUCTP(session_counter);
session_counter->snum=snum;
session_counter->counter=0;
@@ -1585,7 +1612,7 @@ static BOOL construct_printer_info_0(PRINTER_INFO_0 *printer,int snum, pstring s
printer->build_version = 0x0565; /* build 1381 */
printer->unknown7 = 0x1;
printer->unknown8 = 0x0;
- printer->unknown9 = 0x2;
+ printer->unknown9 = 0x0;
printer->session_counter = session_counter->counter;
printer->unknown11 = 0x0;
printer->printer_errors = 0x0; /* number of print failure */
@@ -1644,7 +1671,7 @@ static BOOL construct_printer_info_1(fstring server, uint32 flags, PRINTER_INFO_
/****************************************************************************
****************************************************************************/
-static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername)
+static BOOL construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername)
{
char adevice[32];
char aform[32];
@@ -1695,11 +1722,16 @@ static void construct_dev_mode(DEVICEMODE *devmode, int snum, char *servername)
if (ntdevmode->private != NULL)
{
- devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8));
+ if((devmode->private=(uint8 *)malloc(devmode->driverextra*sizeof(uint8))) == NULL) {
+ free_a_printer(printer, 2);
+ return False;
+ }
memcpy(devmode->private, ntdevmode->private, devmode->driverextra);
}
free_a_printer(printer, 2);
+
+ return True;
}
/********************************************************************
@@ -1722,8 +1754,8 @@ static BOOL construct_printer_info_2(pstring servername, PRINTER_INFO_2 *printer
if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 )
return False;
- ZERO_STRUCT(status);
- count=get_printqueue(snum, NULL, UID_FIELD_INVALID, &queue, &status);
+ memset(&status, 0, sizeof(status));
+ count=get_printqueue(snum, NULL, &queue, &status);
snprintf(chaine, sizeof(chaine)-1, "%s", servername);
@@ -1758,14 +1790,25 @@ static BOOL construct_printer_info_2(pstring servername, PRINTER_INFO_2 *printer
printer->cjobs = count; /* jobs */
printer->averageppm = ntprinter.info_2->averageppm; /* average pages per minute */
- devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE));
+ if((devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL)
+ goto err;
+
ZERO_STRUCTP(devmode);
- construct_dev_mode(devmode, snum, servername);
+
+ if(!construct_dev_mode(devmode, snum, servername))
+ goto err;
+
printer->devmode=devmode;
safe_free(queue);
free_a_printer(ntprinter, 2);
return True;
+
+ err:
+
+ safe_free(queue);
+ free_a_printer(ntprinter, 2);
+ return False;
}
/********************************************************************
@@ -1786,7 +1829,10 @@ static BOOL enum_all_printers_info_1(fstring server, uint32 flags, NEW_BUFFER *b
DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
if (construct_printer_info_1(server, flags, &current_prt, snum)) {
- printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1));
+ if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_1))) == NULL) {
+ *returned=0;
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *returned));
memcpy(&(printers[*returned]), &current_prt, sizeof(PRINTER_INFO_1));
(*returned)++;
@@ -1873,7 +1919,8 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui
* We should have a TDB here. The registration is done thru an undocumented RPC call.
*/
- printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1));
+ if((printer=(PRINTER_INFO_1 *)malloc(sizeof(PRINTER_INFO_1))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
*returned=1;
@@ -1940,7 +1987,8 @@ static BOOL enum_all_printers_info_2(fstring servername, NEW_BUFFER *buffer, uin
DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
if (construct_printer_info_2(servername, &current_prt, snum)) {
- printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2));
+ if((printers=Realloc(printers, (*returned +1)*sizeof(PRINTER_INFO_2))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *returned));
memcpy(&(printers[*returned]), &current_prt, sizeof(PRINTER_INFO_2));
(*returned)++;
@@ -2092,7 +2140,7 @@ uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 le
case 3:
case 4:
default:
- return NT_STATUS_INVALID_LEVEL;
+ return ERROR_INVALID_LEVEL;
break;
}
}
@@ -2103,7 +2151,9 @@ static uint32 getprinter_level_0(pstring servername, int snum, NEW_BUFFER *buffe
{
PRINTER_INFO_0 *printer=NULL;
- printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0));
+ if((printer=(PRINTER_INFO_0*)malloc(sizeof(PRINTER_INFO_0))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
+
construct_printer_info_0(printer, snum, servername);
/* check the required size. */
@@ -2133,7 +2183,9 @@ static uint32 getprinter_level_1(pstring servername, int snum, NEW_BUFFER *buffe
{
PRINTER_INFO_1 *printer=NULL;
- printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1));
+ if((printer=(PRINTER_INFO_1*)malloc(sizeof(PRINTER_INFO_1))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
+
construct_printer_info_1(servername, PRINTER_ENUM_ICON8, printer, snum);
/* check the required size. */
@@ -2164,7 +2216,8 @@ static uint32 getprinter_level_2(pstring servername, int snum, NEW_BUFFER *buffe
PRINTER_INFO_2 *printer=NULL;
fstring temp;
- printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2));
+ if((printer=(PRINTER_INFO_2*)malloc(sizeof(PRINTER_INFO_2)))==NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
fstrcpy(temp, "\\\\");
fstrcat(temp, servername);
@@ -2206,7 +2259,7 @@ uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level,
pstrcpy(servername, global_myname);
if (!get_printer_snum(handle, &snum))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
switch (level) {
case 0:
@@ -2322,7 +2375,10 @@ static void init_unistr_array(uint16 **uni_array, char **char_array, char *where
for (v=char_array[i]; *v!='\0'; v=char_array[i]) {
snprintf(line, sizeof(line)-1, "%s%s", where, v);
DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line)));
- *uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16));
+ if((*uni_array=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) {
+ DEBUG(0,("init_unistr_array: Realloc error\n" ));
+ return;
+ }
ascii_to_unistr( *uni_array+j, line , strlen(line));
j+=strlen(line)+1;
i++;
@@ -2401,7 +2457,8 @@ static uint32 getprinterdriver2_level1(pstring servername, pstring architecture,
{
DRIVER_INFO_1 *info=NULL;
- info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1));
+ if((info=(DRIVER_INFO_1 *)malloc(sizeof(DRIVER_INFO_1))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
construct_printer_driver_info_1(info, snum, servername, architecture);
@@ -2431,7 +2488,8 @@ static uint32 getprinterdriver2_level2(pstring servername, pstring architecture,
{
DRIVER_INFO_2 *info=NULL;
- info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2));
+ if((info=(DRIVER_INFO_2 *)malloc(sizeof(DRIVER_INFO_2))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
construct_printer_driver_info_2(info, snum, servername, architecture);
@@ -2461,7 +2519,8 @@ static uint32 getprinterdriver2_level3(pstring servername, pstring architecture,
{
DRIVER_INFO_3 *info=NULL;
- info=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3));
+ if((info=(DRIVER_INFO_3 *)malloc(sizeof(DRIVER_INFO_3)))==NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
construct_printer_driver_info_3(info, snum, servername, architecture);
@@ -2507,7 +2566,7 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a
unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1);
if (!get_printer_snum(handle, &snum))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
switch (level) {
case 1:
@@ -2520,7 +2579,7 @@ uint32 _spoolss_getprinterdriver2(const POLICY_HND *handle, const UNISTR2 *uni_a
return getprinterdriver2_level3(servername, architecture, snum, buffer, offered, needed);
break;
default:
- return NT_STATUS_INVALID_LEVEL;
+ return ERROR_INVALID_LEVEL;
break;
}
}
@@ -2538,7 +2597,7 @@ uint32 _spoolss_startpageprinter(const POLICY_HND *handle)
}
DEBUG(3,("Error in startpageprinter printer handle\n"));
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
}
/****************************************************************************
@@ -2550,7 +2609,7 @@ uint32 _spoolss_endpageprinter(const POLICY_HND *handle)
if (!OPEN_HANDLE(Printer))
{
DEBUG(3,("Error in endpageprinter printer handle\n"));
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
}
Printer->page_started=False;
@@ -2578,7 +2637,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level,
if (!OPEN_HANDLE(Printer))
{
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
}
/*
@@ -2606,7 +2665,7 @@ uint32 _spoolss_startdocprinter( const POLICY_HND *handle, uint32 level,
/* get the share number of the printer */
if (!get_printer_snum(handle, &snum))
{
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
}
/* Create a temporary file in the printer spool directory
@@ -2651,7 +2710,7 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle)
if (!OPEN_HANDLE(Printer))
{
DEBUG(3,("Error in enddocprinter handle\n"));
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
}
Printer->document_started=False;
@@ -2663,7 +2722,7 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle)
if (!get_printer_snum(handle,&snum))
{
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
}
/* copy the command into the buffer for extensive meddling. */
@@ -2689,8 +2748,7 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle)
*/
tstr = lp_printername(snum);
- if (tstr == NULL || tstr[0] == '\0')
- {
+ if (tstr == NULL || tstr[0] == '\0') {
DEBUG(3,( "No printer name - using %s.\n", SERVICE(snum)));
tstr = SERVICE(snum);
}
@@ -2700,21 +2758,18 @@ uint32 _spoolss_enddocprinter(const POLICY_HND *handle)
/* If the lpr command support the 'Job' option replace here */
pstring_sub(syscmd, "%j", job_name);
- if ( *syscmd != '\0')
- {
+ if ( *syscmd != '\0') {
int ret = smbrun(syscmd, NULL, False);
DEBUG(3,("Running the command `%s' gave %d\n", syscmd, ret));
- if (ret < 0)
- {
+ if (ret < 0) {
lpq_reset(snum);
- return NT_STATUS_ACCESS_DENIED;
+ return ERROR_ACCESS_DENIED;
}
}
- else
- {
+ else {
DEBUG(0,("Null print command?\n"));
lpq_reset(snum);
- return NT_STATUS_ACCESS_DENIED;
+ return ERROR_ACCESS_DENIED;
}
lpq_reset(snum);
@@ -2735,7 +2790,7 @@ uint32 _spoolss_writeprinter( const POLICY_HND *handle,
if (!OPEN_HANDLE(Printer))
{
DEBUG(3,("Error in writeprinter handle\n"));
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
}
fd = Printer->document_fd;
@@ -2756,21 +2811,21 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command)
Printer_entry *Printer = find_printer_index_by_hnd(handle);
if (!OPEN_HANDLE(Printer))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
if (!get_printer_snum(handle, &snum) )
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
switch (command) {
case PRINTER_CONTROL_PAUSE:
/* pause the printer here */
- status_printqueue(NULL, UID_FIELD_INVALID, snum, LPSTAT_STOPPED);
+ status_printqueue(NULL, snum, LPSTAT_STOPPED);
return 0x0;
break;
case PRINTER_CONTROL_RESUME:
case PRINTER_CONTROL_UNPAUSE:
/* UN-pause the printer here */
- status_printqueue(NULL, UID_FIELD_INVALID, snum, LPSTAT_OK);
+ status_printqueue(NULL, snum, LPSTAT_OK);
return 0x0;
break;
case PRINTER_CONTROL_PURGE:
@@ -2785,7 +2840,7 @@ static uint32 control_printer(const POLICY_HND *handle, uint32 command)
break;
}
- return NT_STATUS_INVALID_INFO_CLASS;
+ return ERROR_INVALID_FUNCTION;
}
/********************************************************************
@@ -2808,14 +2863,14 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level,
if (level!=2) {
DEBUG(0,("Send a mail to jfm@samba.org\n"));
DEBUGADD(0,("with the following message: update_printer: level!=2\n"));
- return NT_STATUS_INVALID_INFO_CLASS;
+ return ERROR_INVALID_LEVEL;
}
if (!OPEN_HANDLE(Printer))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
if (!get_printer_snum(handle, &snum) )
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
get_a_printer(&printer, 2, lp_servicename(snum));
@@ -2848,7 +2903,7 @@ static uint32 update_printer(const POLICY_HND *handle, uint32 level,
free_a_printer(printer, 2);
/* I don't really know what to return here !!! */
- return NT_STATUS_INVALID_INFO_CLASS;
+ return ERROR_ACCESS_DENIED;
}
free_a_printer(printer, 2);
@@ -2866,7 +2921,7 @@ uint32 _spoolss_setprinter(const POLICY_HND *handle, uint32 level,
Printer_entry *Printer = find_printer_index_by_hnd(handle);
if (!OPEN_HANDLE(Printer))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
/* check the level */
switch (level) {
@@ -2889,7 +2944,7 @@ uint32 _spoolss_fcpn(const POLICY_HND *handle)
Printer_entry *Printer= find_printer_index_by_hnd(handle);
if (!OPEN_HANDLE(Printer))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
Printer->notify.flags=0;
Printer->notify.options=0;
@@ -2952,9 +3007,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
time_t unixdate = time(NULL);
if (get_a_printer(&ntprinter, 2, lp_servicename(snum)) !=0 )
- {
- return (False);
- }
+ return False;
t=gmtime(&unixdate);
snprintf(temp_name, sizeof(temp_name), "\\\\%s", global_myname);
@@ -2986,9 +3039,16 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue,
job_info->timeelapsed=0;
job_info->pagesprinted=0;
- devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE));
+ if((devmode=(DEVICEMODE *)malloc(sizeof(DEVICEMODE))) == NULL) {
+ free_a_printer(ntprinter, 2);
+ return False;
+ }
+
ZERO_STRUCTP(devmode);
- construct_dev_mode(devmode, snum, global_myname);
+ if(!construct_dev_mode(devmode, snum, global_myname)) {
+ free_a_printer(ntprinter, 2);
+ return False;
+ }
job_info->devmode=devmode;
free_a_printer(ntprinter, 2);
@@ -3006,25 +3066,31 @@ static uint32 enumjobs_level1(print_queue_struct *queue, int snum,
int i;
info=(JOB_INFO_1 *)malloc(*returned*sizeof(JOB_INFO_1));
+ if (info==NULL) {
+ safe_free(queue);
+ *returned=0;
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
for (i=0; i<*returned; i++)
- {
fill_job_info_1(&(info[i]), &(queue[i]), i, snum);
- }
+
+ safe_free(queue);
/* check the required size. */
for (i=0; i<*returned; i++)
(*needed) += spoolss_size_job_info_1(&(info[i]));
- if (!alloc_buffer_size(buffer, *needed))
+ if (!alloc_buffer_size(buffer, *needed)) {
+ safe_free(info);
return ERROR_INSUFFICIENT_BUFFER;
+ }
/* fill the buffer with the structures */
for (i=0; i<*returned; i++)
new_smb_io_job_info_1("", buffer, &(info[i]), 0);
/* clear memory */
- safe_free(queue);
safe_free(info);
if (*needed > offered) {
@@ -3046,25 +3112,31 @@ static uint32 enumjobs_level2(print_queue_struct *queue, int snum,
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;
+ }
for (i=0; i<*returned; i++)
- {
fill_job_info_2(&(info[i]), &(queue[i]), i, snum);
- }
+
+ safe_free(queue);
/* check the required size. */
for (i=0; i<*returned; i++)
(*needed) += spoolss_size_job_info_2(&(info[i]));
- if (!alloc_buffer_size(buffer, *needed))
+ if (!alloc_buffer_size(buffer, *needed)) {
+ safe_free(info);
return ERROR_INSUFFICIENT_BUFFER;
+ }
/* fill the buffer with the structures */
for (i=0; i<*returned; i++)
new_smb_io_job_info_2("", buffer, &(info[i]), 0);
/* clear memory */
- safe_free(queue);
safe_free(info);
if (*needed > offered) {
@@ -3094,11 +3166,9 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs,
*returned=0;
if (!get_printer_snum(handle, &snum))
- {
- return NT_STATUS_INVALID_HANDLE;
- }
+ return ERROR_INVALID_HANDLE;
- *returned = get_printqueue(snum, NULL, UID_FIELD_INVALID, &queue, &prt_status);
+ *returned = get_printqueue(snum, NULL, &queue, &prt_status);
DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message));
switch (level) {
@@ -3109,7 +3179,9 @@ uint32 _spoolss_enumjobs( POLICY_HND *handle, uint32 firstjob, uint32 numofjobs,
return enumjobs_level2(queue, snum, buffer, offered, needed, returned);
break;
default:
- return NT_STATUS_INVALID_LEVEL;
+ safe_free(queue);
+ *returned=0;
+ return ERROR_INVALID_LEVEL;
break;
}
}
@@ -3141,49 +3213,47 @@ uint32 _spoolss_setjob( const POLICY_HND *handle,
memset(&prt_status, 0, sizeof(prt_status));
- if (!get_printer_snum(handle, &snum))
- {
- return NT_STATUS_INVALID_HANDLE;
+ if (!get_printer_snum(handle, &snum)) {
+ return ERROR_INVALID_HANDLE;
}
- count=get_printqueue(snum, NULL, UID_FIELD_INVALID, &queue, &prt_status);
+ count=get_printqueue(snum, NULL, &queue, &prt_status);
- while ( (i<count) && found==False )
- {
+ while ( (i<count) && found==False ) {
if ( jobid == queue[i].job )
- {
found=True;
- }
i++;
}
- if (found==True)
- {
- switch (command)
- {
+ if (found==True) {
+ switch (command) {
+
case JOB_CONTROL_CANCEL:
case JOB_CONTROL_DELETE:
{
- del_printqueue(NULL, UID_FIELD_INVALID, snum, jobid);
+ del_printqueue(NULL, snum, jobid);
safe_free(queue);
return 0x0;
}
case JOB_CONTROL_PAUSE:
{
- status_printjob(NULL, UID_FIELD_INVALID, snum, jobid, LPQ_PAUSED);
+ status_printjob(NULL, snum, jobid, LPQ_PAUSED);
safe_free(queue);
return 0x0;
}
case JOB_CONTROL_RESUME:
{
- status_printjob(NULL, UID_FIELD_INVALID, snum, jobid, LPQ_QUEUED);
+ status_printjob(NULL, snum, jobid, LPQ_QUEUED);
safe_free(queue);
return 0x0;
}
}
}
safe_free(queue);
- return NT_STATUS_INVALID_INFO_CLASS;
+
+ /* I really don't know what to return ! */
+ /* need to add code in rpcclient */
+ return ERROR_INVALID_PRINTER_NAME;
}
@@ -3195,7 +3265,9 @@ static uint32 enumprinterdrivers_level1(fstring *list, fstring servername, fstri
int i;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
DRIVER_INFO_1 *driver_info_1=NULL;
- driver_info_1=(DRIVER_INFO_1 *)malloc(*returned * sizeof(DRIVER_INFO_1));
+
+ if((driver_info_1=(DRIVER_INFO_1 *)malloc(*returned * sizeof(DRIVER_INFO_1))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
for (i=0; i<*returned; i++) {
get_a_printer_driver(&driver, 3, list[i], architecture);
@@ -3240,7 +3312,9 @@ static uint32 enumprinterdrivers_level2(fstring *list, fstring servername, fstri
int i;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
DRIVER_INFO_2 *driver_info_2=NULL;
- driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2));
+
+ if((driver_info_2=(DRIVER_INFO_2 *)malloc(*returned * sizeof(DRIVER_INFO_2))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
for (i=0; i<*returned; i++) {
get_a_printer_driver(&driver, 3, list[i], architecture);
@@ -3285,7 +3359,9 @@ static uint32 enumprinterdrivers_level3(fstring *list, fstring servername, fstri
int i;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
DRIVER_INFO_3 *driver_info_3=NULL;
- driver_info_3=(DRIVER_INFO_3 *)malloc((*returned)*sizeof(DRIVER_INFO_3));
+
+ if((driver_info_3=(DRIVER_INFO_3 *)malloc((*returned)*sizeof(DRIVER_INFO_3))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
for (i=0; i<*returned; i++) {
get_a_printer_driver(&driver, 3, list[i], architecture);
@@ -3346,6 +3422,9 @@ uint32 _spoolss_enumprinterdrivers( UNISTR2 *name, UNISTR2 *environment, uint32
*returned=get_ntdrivers(&list, architecture);
DEBUGADD(4,("we have: [%d] drivers in environment [%s]\n", *returned, architecture));
+ if(*returned == -1)
+ return ERROR_NOT_ENOUGH_MEMORY;
+
for (i=0; i<*returned; i++)
DEBUGADD(5,("driver: [%s]\n", list[i]));
@@ -3399,7 +3478,10 @@ uint32 _new_spoolss_enumforms( const POLICY_HND *handle, uint32 level,
switch (level) {
case 1:
- forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1));
+ if((forms_1=(FORM_1 *)malloc(*numofforms * sizeof(FORM_1))) == NULL) {
+ *numofforms=0;
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
/* construct the list of form structures */
for (i=0; i<*numofforms; i++) {
@@ -3478,7 +3560,8 @@ static uint32 enumports_level_1(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) )
(*returned)++;
- ports=(PORT_INFO_1 *)malloc( (*returned+1) * sizeof(PORT_INFO_1) );
+ if((ports=(PORT_INFO_1 *)malloc( (*returned+1) * sizeof(PORT_INFO_1) )) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
for (snum=0; snum<n_services; snum++) {
if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
@@ -3531,7 +3614,8 @@ static uint32 enumports_level_2(NEW_BUFFER *buffer, uint32 offered, uint32 *need
if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) )
(*returned)++;
- ports=(PORT_INFO_2 *)malloc( (*returned+1) * sizeof(PORT_INFO_2) );
+ if((ports=(PORT_INFO_2 *)malloc( (*returned+1) * sizeof(PORT_INFO_2) )) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
for (snum=0; snum<n_services; snum++) {
if ( lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
@@ -3588,7 +3672,7 @@ uint32 _spoolss_enumports( UNISTR2 *name, uint32 level,
return enumports_level_2(buffer, offered, needed, returned);
break;
default:
- return NT_STATUS_INVALID_INFO_CLASS;
+ return ERROR_INVALID_LEVEL;
break;
}
}
@@ -3651,6 +3735,7 @@ uint32 _spoolss_addprinterex( const UNISTR2 *uni_srv_name, uint32 level,
case 1:
/* we don't handle yet */
/* but I know what to do ... */
+ return ERROR_INVALID_LEVEL;
break;
case 2:
return spoolss_addprinterex_level_2(uni_srv_name, info,
@@ -3675,7 +3760,7 @@ uint32 _spoolss_addprinterdriver( const UNISTR2 *server_name,
convert_printer_driver_info(info, &driver, level);
if (add_a_printer_driver(driver, level)!=0)
- return NT_STATUS_ACCESS_DENIED;
+ return ERROR_ACCESS_DENIED;
return NT_STATUS_NO_PROBLEMO;
}
@@ -3696,7 +3781,8 @@ static uint32 getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen
pstring short_archi;
DRIVER_DIRECTORY_1 *info=NULL;
- info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1));
+ if((info=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
unistr2_to_ascii(long_archi, uni_environment, sizeof(long_archi)-1);
get_short_archi(short_archi, long_archi);
@@ -3780,13 +3866,13 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx,
DEBUG(5,("spoolss_enumprinterdata\n"));
if (!OPEN_HANDLE(Printer))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
if (!get_printer_snum(handle, &snum))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
if (get_a_printer(&printer, 2, lp_servicename(snum)) != 0x0)
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
/*
* The NT machine wants to know the biggest size of value and data
@@ -3827,6 +3913,7 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx,
if (!get_specific_param_by_index(printer, 2, idx, value, &data, &type, &data_len)) {
free_a_printer(printer, 2);
+ safe_free(data);
return ERROR_NO_MORE_ITEMS;
}
@@ -3840,7 +3927,11 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx,
*/
*out_max_value_len=in_value_len/2;
- *out_value=(uint16 *)malloc(in_value_len*sizeof(uint8));
+ if((*out_value=(uint16 *)malloc(in_value_len*sizeof(uint8))) == NULL) {
+ free_a_printer(printer, 2);
+ safe_free(data);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
ascii_to_unistr(*out_value, value, *out_max_value_len);
*out_value_len=2*(1+strlen(value));
@@ -3848,7 +3939,11 @@ uint32 _spoolss_enumprinterdata(const POLICY_HND *handle, uint32 idx,
/* the data is counted in bytes */
*out_max_data_len=in_data_len;
- *data_out=(uint8 *)malloc(in_data_len*sizeof(uint8));
+ if((*data_out=(uint8 *)malloc(in_data_len*sizeof(uint8))) == NULL) {
+ free_a_printer(printer, 2);
+ safe_free(data);
+ return ERROR_NOT_ENOUGH_MEMORY;
+ }
memcpy(*data_out, data, data_len);
*out_data_len=data_len;
@@ -3879,26 +3974,23 @@ uint32 _spoolss_setprinterdata( const POLICY_HND *handle,
if (!OPEN_HANDLE(Printer))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
if (!get_printer_snum(handle, &snum))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
status = get_a_printer(&printer, 2, lp_servicename(snum));
if (status != 0x0)
- return status;
+ return ERROR_INVALID_NAME;
convert_specific_param(&param, value , type, data, real_len);
unlink_specific_param_if_exist(printer.info_2, param);
if (!add_a_specific_param(printer.info_2, param))
- {
- status = NT_STATUS_INVALID_PARAMETER;
- }
+ status = ERROR_INVALID_PARAMETER;
else
- {
status = add_a_printer(printer, 2);
- }
+
free_a_printer(printer, 2);
return status;
@@ -3917,10 +4009,11 @@ uint32 _spoolss_addform( const POLICY_HND *handle,
DEBUG(5,("spoolss_addform\n"));
if (!OPEN_HANDLE(Printer))
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
count=get_ntforms(&list);
- add_a_form(&list, form, &count);
+ if(!add_a_form(&list, form, &count))
+ return ERROR_NOT_ENOUGH_MEMORY;
write_ntforms(&list, count);
safe_free(list);
@@ -3943,7 +4036,7 @@ uint32 _spoolss_setform( const POLICY_HND *handle,
if (!OPEN_HANDLE(Printer))
{
- return NT_STATUS_INVALID_HANDLE;
+ return ERROR_INVALID_HANDLE;
}
count=get_ntforms(&list);
update_a_form(&list, form, count);
@@ -3961,7 +4054,9 @@ static uint32 enumprintprocessors_level_1(NEW_BUFFER *buffer, uint32 offered, ui
{
PRINTPROCESSOR_1 *info_1=NULL;
- info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1));
+ if((info_1 = (PRINTPROCESSOR_1 *)malloc(sizeof(PRINTPROCESSOR_1))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
+
(*returned) = 0x1;
init_unistr(&(info_1->name), "winprint");
@@ -4006,7 +4101,7 @@ uint32 _spoolss_enumprintprocessors(UNISTR2 *name, UNISTR2 *environment, uint32
return enumprintprocessors_level_1(buffer, offered, needed, returned);
break;
default:
- return NT_STATUS_INVALID_INFO_CLASS;
+ return ERROR_INVALID_LEVEL;
break;
}
}
@@ -4018,7 +4113,9 @@ static uint32 enumprintprocdatatypes_level_1(NEW_BUFFER *buffer, uint32 offered,
{
PRINTPROCDATATYPE_1 *info_1=NULL;
- info_1 = (PRINTPROCDATATYPE_1 *)malloc(sizeof(PRINTPROCDATATYPE_1));
+ if((info_1 = (PRINTPROCDATATYPE_1 *)malloc(sizeof(PRINTPROCDATATYPE_1))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
+
(*returned) = 0x1;
init_unistr(&(info_1->name), "RAW");
@@ -4056,7 +4153,7 @@ uint32 _spoolss_enumprintprocdatatypes(UNISTR2 *name, UNISTR2 *processor, uint32
return enumprintprocdatatypes_level_1(buffer, offered, needed, returned);
break;
default:
- return NT_STATUS_INVALID_INFO_CLASS;
+ return ERROR_INVALID_LEVEL;
break;
}
}
@@ -4068,7 +4165,9 @@ static uint32 enumprintmonitors_level_1(NEW_BUFFER *buffer, uint32 offered, uint
{
PRINTMONITOR_1 *info_1=NULL;
- info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1));
+ if((info_1 = (PRINTMONITOR_1 *)malloc(sizeof(PRINTMONITOR_1))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
+
(*returned) = 0x1;
init_unistr(&(info_1->name), "Local Port");
@@ -4097,7 +4196,9 @@ static uint32 enumprintmonitors_level_2(NEW_BUFFER *buffer, uint32 offered, uint
{
PRINTMONITOR_2 *info_2=NULL;
- info_2 = (PRINTMONITOR_2 *)malloc(sizeof(PRINTMONITOR_2));
+ if((info_2 = (PRINTMONITOR_2 *)malloc(sizeof(PRINTMONITOR_2))) == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY;
+
(*returned) = 0x1;
init_unistr(&(info_2->name), "Local Port");
@@ -4147,7 +4248,7 @@ uint32 _spoolss_enumprintmonitors(UNISTR2 *name,uint32 level,
return enumprintmonitors_level_2(buffer, offered, needed, returned);
break;
default:
- return NT_STATUS_INVALID_INFO_CLASS;
+ return ERROR_INVALID_LEVEL;
break;
}
}
@@ -4163,7 +4264,7 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin
if (info_1 == NULL) {
safe_free(queue);
- return NT_STATUS_NO_MEMORY;
+ return ERROR_NOT_ENOUGH_MEMORY;
}
for (i=0; i<count && found==False; i++) {
@@ -4173,16 +4274,21 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin
if (found==False) {
safe_free(queue);
+ safe_free(info_1);
/* I shoud reply something else ... I can't find the good one */
return NT_STATUS_NO_PROBLEMO;
}
- fill_job_info_1(info_1, &(queue[i]), i, snum);
+ fill_job_info_1(info_1, &(queue[i-1]), i, snum);
+
+ safe_free(queue);
*needed += spoolss_size_job_info_1(info_1);
- if (!alloc_buffer_size(buffer, *needed))
+ if (!alloc_buffer_size(buffer, *needed)) {
+ safe_free(info_1);
return ERROR_INSUFFICIENT_BUFFER;
+ }
new_smb_io_job_info_1("", buffer, info_1, 0);
@@ -4197,8 +4303,6 @@ static uint32 getjob_level_1(print_queue_struct *queue, int count, int snum, uin
/****************************************************************************
****************************************************************************/
-#if 0
-... Not yet used...
static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uint32 jobid, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
int i=0;
@@ -4208,7 +4312,7 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
if (info_2 == NULL) {
safe_free(queue);
- return NT_STATUS_NO_MEMORY;
+ return ERROR_NOT_ENOUGH_MEMORY;
}
for (i=0; i<count && found==False; i++) {
@@ -4218,16 +4322,21 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
if (found==False) {
safe_free(queue);
+ safe_free(info_2);
/* I shoud reply something else ... I can't find the good one */
return NT_STATUS_NO_PROBLEMO;
}
- fill_job_info_2(info_2, &(queue[i]), i, snum);
+ fill_job_info_2(info_2, &(queue[i-1]), i, snum);
+
+ safe_free(queue);
*needed += spoolss_size_job_info_2(info_2);
- if (!alloc_buffer_size(buffer, *needed))
+ if (!alloc_buffer_size(buffer, *needed)) {
+ safe_free(info_2);
return ERROR_INSUFFICIENT_BUFFER;
+ }
new_smb_io_job_info_2("", buffer, info_2, 0);
@@ -4238,7 +4347,6 @@ static uint32 getjob_level_2(print_queue_struct *queue, int count, int snum, uin
else
return NT_STATUS_NO_PROBLEMO;
}
-#endif
/****************************************************************************
****************************************************************************/
@@ -4258,11 +4366,9 @@ uint32 _spoolss_getjob( POLICY_HND *handle, uint32 jobid, uint32 level,
*needed=0;
if (!get_printer_snum(handle, &snum))
- {
- return NT_STATUS_INVALID_HANDLE;
- }
+ return ERROR_INVALID_HANDLE;
- count=get_printqueue(snum, NULL, UID_FIELD_INVALID, &queue, &prt_status);
+ count=get_printqueue(snum, NULL, &queue, &prt_status);
DEBUGADD(4,("count:[%d], prt_status:[%d], [%s]\n",
count, prt_status.status, prt_status.message));
@@ -4272,11 +4378,11 @@ uint32 _spoolss_getjob( POLICY_HND *handle, uint32 jobid, uint32 level,
return getjob_level_1(queue, count, snum, jobid, buffer, offered, needed);
break;
case 2:
- return getjob_level_1(queue, count, snum, jobid, buffer, offered, needed);
+ return getjob_level_2(queue, count, snum, jobid, buffer, offered, needed);
break;
default:
safe_free(queue);
- return NT_STATUS_INVALID_INFO_CLASS;
+ return ERROR_INVALID_LEVEL;
break;
}
}