summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-05 18:40:38 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-05 18:40:38 +0000
commit32dedee7f006351c505801dc207dbc46ca08044a (patch)
treee9761c6cd3341f3104fcfee714f64334558c8bc2 /source3
parent0d7f9837e282dc1b441c13d99eb7faf3d03ba1de (diff)
downloadsamba-32dedee7f006351c505801dc207dbc46ca08044a.tar.gz
samba-32dedee7f006351c505801dc207dbc46ca08044a.tar.bz2
samba-32dedee7f006351c505801dc207dbc46ca08044a.zip
experimental spoolss rpcclient commands
(This used to be commit c86edef90e7c96d5a99be29e2d2a3679ed26d97d)
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/include/proto.h52
-rwxr-xr-xsource3/include/rpc_spoolss.h3
-rw-r--r--source3/libsmb/clientgen.c6
-rw-r--r--source3/rpc_parse/parse_spoolss.c155
-rw-r--r--source3/rpcclient/rpcclient.c18
6 files changed, 196 insertions, 40 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 8de9d8f0e8..96e28e8eb2 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -158,6 +158,7 @@ RPC_CLIENT_OBJ = \
rpc_client/cli_pipe.o \
rpc_client/cli_lsarpc.o \
rpc_client/cli_wkssvc.o \
+ rpc_client/cli_spoolss.o \
rpc_client/cli_srvsvc.o \
rpc_client/cli_svcctl.o \
rpc_client/cli_samr.o \
@@ -249,6 +250,7 @@ SMBPASSWD_OBJ = utils/smbpasswd.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
RPCCLIENT_OBJ = rpcclient/rpcclient.o \
rpcclient/display.o \
rpcclient/cmd_lsarpc.o \
+ rpcclient/cmd_spoolss.o \
rpcclient/cmd_wkssvc.o \
rpcclient/cmd_samr.o \
rpcclient/cmd_reg.o \
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a1b82ab10d..e9880b55c3 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2035,6 +2035,15 @@ BOOL samr_query_dispinfo(struct cli_state *cli, uint16 fnum,
uint32 *num_entries,
SAM_DISPINFO_CTR *ctr);
+/*The following definitions come from rpc_client/cli_spoolss.c */
+
+BOOL spoolss_get_printer_data(struct cli_state *cli, uint16 fnum,
+ PRINTER_HND *hnd,
+ char *value_name, uint32 size);
+BOOL spoolss_get_printer(struct cli_state *cli, uint16 fnum,
+ PRINTER_HND *hnd, uint32 level,
+ uint32 buf_size);
+
/*The following definitions come from rpc_client/cli_srvsvc.c */
BOOL do_srv_net_srv_tprt_enum(struct cli_state *cli, uint16 fnum,
@@ -2816,12 +2825,12 @@ BOOL make_sam_user_info23A(SAM_USER_INFO_23 *usr,
char *full_name,
char *home_dir,
char *dir_drive,
- char *logon_script,
- char *profile_path,
- char *description,
- char *workstations,
- char *unknown_str,
- char *munged_dial,
+ char *log_scr,
+ char *prof_path,
+ char *desc,
+ char *wkstas,
+ char *unk_str,
+ char *mung_dial,
uint32 user_rid, /* 0x0000 0000 */
uint32 group_rid,
@@ -2846,12 +2855,12 @@ BOOL make_sam_user_info21(SAM_USER_INFO_21 *usr,
char *full_name,
char *home_dir,
char *dir_drive,
- char *logon_script,
- char *profile_path,
- char *description,
- char *workstations,
- char *unknown_str,
- char *munged_dial,
+ char *log_scr,
+ char *prof_path,
+ char *desc,
+ char *wkstas,
+ char *unk_str,
+ char *mung_dial,
uint32 user_rid,
uint32 group_rid,
@@ -2918,7 +2927,17 @@ BOOL make_systemtime(SYSTEMTIME *systime, struct tm *unixtime);
BOOL smb_io_notify_info_data_strings(char *desc,SPOOL_NOTIFY_INFO_DATA *data,
prs_struct *ps, int depth);
BOOL spoolss_io_r_open_printer(char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth);
+BOOL make_spoolss_io_q_open_printer(SPOOL_Q_OPEN_PRINTER *q_u,
+ uint32 unk_0,
+ char *printername,
+ uint32 unk_1, uint32 cbbuf, uint32 devmod, uint32 des_access,
+ char *station,
+ char *username);
BOOL spoolss_io_q_open_printer(char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth);
+BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
+ PRINTER_HND *handle,
+ char *valuename,
+ uint32 size);
BOOL spoolss_io_q_getprinterdata(char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth);
@@ -2956,6 +2975,10 @@ BOOL spoolss_io_r_enumprinters(char *desc,
BOOL spoolss_io_r_getprinter(char *desc,
SPOOL_R_GETPRINTER *r_u,
prs_struct *ps, int depth);
+BOOL make_spoolss_q_getprinter(SPOOL_Q_GETPRINTER *q_u,
+ PRINTER_HND *hnd,
+ uint32 level,
+ uint32 buf_size);
BOOL spoolss_io_q_getprinter(char *desc, SPOOL_Q_GETPRINTER *q_u,
prs_struct *ps, int depth);
BOOL spoolss_io_r_setprinter(char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth);
@@ -3389,6 +3412,11 @@ void cmd_sam_query_alias(struct client_info *info);
void cmd_sam_enum_aliases(struct client_info *info);
void cmd_sam_enum_groups(struct client_info *info);
+/*The following definitions come from rpcclient/cmd_spoolss.c */
+
+void cmd_spoolss_getprinterdata(struct client_info *info);
+void cmd_spoolss_getprinter(struct client_info *info);
+
/*The following definitions come from rpcclient/cmd_srvsvc.c */
BOOL net_srv_get_info(struct client_info *info,
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index a8f934fc47..e48d114dd1 100755
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -830,7 +830,9 @@ typedef struct spool_q_getprinter
{
PRINTER_HND handle;
uint32 level;
+ uint8* buffer;
uint32 offered;
+
} SPOOL_Q_GETPRINTER;
typedef struct spool_r_getprinter
@@ -845,6 +847,7 @@ typedef struct spool_r_getprinter
PRINTER_INFO_0 *info0;
PRINTER_INFO_1 *info1;
PRINTER_INFO_2 *info2;
+ void *info;
} printer;
} SPOOL_R_GETPRINTER;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 4bffb5aa3e..b153654591 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -998,6 +998,7 @@ static BOOL cli_calc_session_pwds(struct cli_state *cli,
uchar *srv_key = (uchar *)cli->cryptkey;
uchar nt_owf[16];
uchar kr[16];
+ HMACMD5Context ctx;
SMBgenclientchals(cli->lm_cli_chal,
cli->nt_cli_chal,
@@ -1023,6 +1024,11 @@ static BOOL cli_calc_session_pwds(struct cli_state *cli,
cli->nt_cli_chal, cli->nt_cli_chal_len,
&ntpword[cli->nt_cli_chal_len]);
*ntpasslen = cli->nt_cli_chal_len + 16;
+
+ hmac_md5_init_limK_to_64(kr, 16, &ctx);
+ hmac_md5_update(cli->nt_cli_chal, cli->nt_cli_chal_len, &ctx);
+ hmac_md5_final(cli->sess_key, &ctx);
+
}
else
{
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index c11c1ed43c..c1d8e54afb 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -413,6 +413,54 @@ BOOL spoolss_io_r_open_printer(char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct
return True;
}
+#if 0
+/*******************************************************************
+ * make a structure.
+ ********************************************************************/
+BOOL make_spoolss_io_q_open_printer(SPOOL_Q_OPEN_PRINTER *q_u,
+ uint32 unk_0,
+ char *printername,
+ uint32 unk_1, uint32 cbbuf, uint32 devmod, uint32 des_access,
+ char *station,
+ char *username)
+{
+ int len_name = printername != NULL ? strlen(printername) : 0;
+
+ if (q_u == NULL) return False;
+
+ DEBUG(5,("make_spoolss_io_q_open_printer\n"));
+
+ q_u->unknown0 = unk_0;
+ make_unistr2(&(q_u->uni_domain), dom_name, len_name);
+
+
+ prs_uint32("unknown1", ps, depth, &(q_u->unknown1));
+ prs_uint32("cbbuf", ps, depth, &(q_u->cbbuf));
+ prs_uint32("devmod", ps, depth, &(q_u->devmod));
+ prs_uint32("access required", ps, depth, &(q_u->access_required));
+
+ /* don't care to decode end of packet by now */
+ /* but when acl will be implemented, it will be useful */
+
+ prs_uint32("unknown2", ps, depth, &(q_u->unknown2));
+ prs_uint32("unknown3", ps, depth, &(q_u->unknown3));
+ prs_uint32("unknown4", ps, depth, &(q_u->unknown4));
+ prs_uint32("unknown5", ps, depth, &(q_u->unknown5));
+ prs_uint32("unknown6", ps, depth, &(q_u->unknown6));
+ prs_uint32("unknown7", ps, depth, &(q_u->unknown7));
+ prs_uint32("unknown8", ps, depth, &(q_u->unknown8));
+ prs_uint32("unknown9", ps, depth, &(q_u->unknown9));
+ prs_uint32("unknown10", ps, depth, &(q_u->unknown10));
+ prs_uint32("unknown11", ps, depth, &(q_u->unknown11));
+
+ smb_io_unistr2("", &(q_u->station),True,ps,depth);
+ prs_align(ps);
+ smb_io_unistr2("", &(q_u->username),True,ps,depth);
+
+ return True;
+}
+#endif
+
/*******************************************************************
* read a structure.
* called from spoolss_q_open_printer (srv_spoolss.c)
@@ -458,6 +506,27 @@ BOOL spoolss_io_q_open_printer(char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct
}
/*******************************************************************
+ * make a structure.
+ ********************************************************************/
+BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
+ PRINTER_HND *handle,
+ char *valuename,
+ uint32 size)
+{
+ int len_name = valuename != NULL ? strlen(valuename) : 0;
+
+ if (q_u == NULL) return False;
+
+ DEBUG(5,("make_spoolss_q_getprinterdata\n"));
+
+ memcpy(&(q_u->handle), handle, sizeof(q_u->handle));
+ make_unistr2(&(q_u->valuename), valuename, len_name);
+ q_u->size = size;
+
+ return True;
+}
+
+/*******************************************************************
* read a structure.
* called from spoolss_q_getprinterdata (srv_spoolss.c)
********************************************************************/
@@ -1719,11 +1788,17 @@ BOOL spoolss_io_r_getprinterdriver2(char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u,
}
}
+ if (ps->io)
+ {
+ /* reading */
+ r_u->offered = bufsize_required;
+ }
+
DEBUG(4,("spoolss_io_r_getprinterdriver2, size needed: %d\n",bufsize_required));
DEBUG(4,("spoolss_io_r_getprinterdriver2, size offered: %d\n",r_u->offered));
/* check if the buffer is big enough for the datas */
- if (r_u->offered<bufsize_required)
+ if (r_u->offered < bufsize_required)
{
/* it's too small */
r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */
@@ -1973,11 +2048,11 @@ BOOL spoolss_io_r_getprinter(char *desc,
DEBUG(4,("spoolss_io_r_getprinter, size offered: %d\n",r_u->offered));
/* check if the buffer is big enough for the datas */
- if (r_u->offered<bufsize_required)
+ if (r_u->offered < bufsize_required)
{
/* it's too small */
- r_u->status=ERROR_INSUFFICIENT_BUFFER; /* say so */
- r_u->offered=0; /* don't send back the buffer */
+ r_u->status = ERROR_INSUFFICIENT_BUFFER; /* say so */
+ r_u->offered = 0; /* don't send back the buffer */
DEBUG(4,("spoolss_io_r_getprinter, buffer too small\n"));
@@ -1990,6 +2065,16 @@ BOOL spoolss_io_r_getprinter(char *desc,
DEBUG(4,("spoolss_io_r_getprinter, buffer large enough\n"));
prs_uint32("size of buffer", ps, depth, &(r_u->offered));
+ }
+
+ if (ps->io)
+ {
+ /* reading */
+ r_u->printer.info = Realloc(NULL, r_u->offered);
+ }
+
+ if (bufsize_required <= r_u->offered)
+ {
beginning=ps->offset;
start_offset=ps->offset;
end_offset=start_offset+r_u->offered;
@@ -2046,7 +2131,6 @@ BOOL spoolss_io_r_getprinter(char *desc,
prs_uint32("size of buffer needed", ps, depth, &(bufsize_required));
prs_uint32("status", ps, depth, &(r_u->status));
-
return True;
}
@@ -2061,27 +2145,35 @@ BOOL spoolss_io_r_getprinter(char *desc,
********************************************************************/
static BOOL spoolss_io_read_buffer8(char *desc, prs_struct *ps, uint8 **buffer, uint32 *size,int depth)
{
- uint32 useless_ptr;
-
prs_debug(ps, depth, desc, "spoolss_io_read_buffer8");
depth++;
prs_align(ps);
- prs_uint32("buffer pointer", ps, depth, &useless_ptr);
+ prs_uint32("buffer size", ps, depth, size);
+ *buffer = (uint8 *)Realloc(NULL, (*size) * sizeof(uint8) );
+ prs_uint8s(True,"buffer",ps,depth,*buffer,*size);
+ prs_align(ps);
+
+ return True;
+}
+
+/*******************************************************************
+ * make a structure.
+ * called from spoolss_getprinter (srv_spoolss.c)
+ ********************************************************************/
+BOOL make_spoolss_q_getprinter(SPOOL_Q_GETPRINTER *q_u,
+ PRINTER_HND *hnd,
+ uint32 level,
+ uint32 buf_size)
+{
+ if (q_u == NULL) return False;
+
+ memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
- if (useless_ptr != 0x0000)
- {
- prs_uint32("buffer size", ps, depth, size);
- *buffer=(uint8 *)malloc( (*size) * sizeof(uint8) );
- prs_uint8s(True,"buffer",ps,depth,*buffer,*size);
- prs_align(ps);
- }
- else
- {
- *buffer=0x0000;
- *size=0x0000;
- }
+ q_u->level = level;
+ q_u->buffer = (uint8 *)Realloc(NULL, (buf_size) * sizeof(uint8) );
+ q_u->offered = buf_size;
return True;
}
@@ -2093,8 +2185,8 @@ static BOOL spoolss_io_read_buffer8(char *desc, prs_struct *ps, uint8 **buffer,
BOOL spoolss_io_q_getprinter(char *desc, SPOOL_Q_GETPRINTER *q_u,
prs_struct *ps, int depth)
{
- uint32 count;
- uint8 *buffer;
+ uint32 count = 0;
+ uint32 buf_ptr = q_u->buffer != NULL ? 1 : 0;
prs_debug(ps, depth, desc, "spoolss_io_q_getprinter");
depth++;
@@ -2104,15 +2196,24 @@ BOOL spoolss_io_q_getprinter(char *desc, SPOOL_Q_GETPRINTER *q_u,
prs_uint32("level", ps, depth, &(q_u->level));
- spoolss_io_read_buffer8("",ps, &buffer, &count,depth);
- if (buffer != 0x0000)
+ if (!ps->io)
{
- free(buffer);
+ /* writing */
+ buf_ptr = q_u->buffer != NULL ? 1 : 0;
+ }
+ prs_uint32("buffer pointer", ps, depth, &buf_ptr);
+
+ if (buf_ptr != 0)
+ {
+ spoolss_io_read_buffer8("",ps, &q_u->buffer, &count,depth);
+ }
+ if (q_u->buffer != NULL)
+ {
+ free(q_u->buffer);
}
-
prs_uint32("buffer size", ps, depth, &(q_u->offered));
- return True;
+ return count == q_u->offered;
}
/*******************************************************************
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index f5b23c018b..cb6ea0529d 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -232,6 +232,23 @@ commands[] =
},
/*
+ * printer testing
+ */
+
+ {
+ "spoolgetprinterdata",
+ cmd_spoolss_getprinterdata,
+ "Spool Printer Data Test",
+ {COMPL_NONE, COMPL_NONE}
+ },
+ {
+ "spoolgetprinter",
+ cmd_spoolss_getprinter,
+ "Spool Printer Test",
+ {COMPL_NONE, COMPL_NONE}
+ },
+
+ /*
* server
*/
{
@@ -240,7 +257,6 @@ commands[] =
"Display remote time",
{COMPL_NONE, COMPL_NONE}
},
-
{
"wksinfo",
cmd_wks_query_info,