mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
* Added EnumPorts()
* Fixed an off-by-one bug noticed by JF in GetPrinterDriverDirectory() jerry
This commit is contained in:
parent
a0e8a55c27
commit
a9522f560d
@ -161,6 +161,70 @@ uint32 spoolss_enum_printers(uint32 flags, fstring srv_name, uint32 level,
|
||||
return r_o.status;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
do a SPOOLSS Enum Ports
|
||||
****************************************************************************/
|
||||
uint32 spoolss_enum_ports(fstring srv_name, uint32 level,
|
||||
NEW_BUFFER *buffer, uint32 offered,
|
||||
uint32 *needed, uint32 *returned)
|
||||
{
|
||||
prs_struct rbuf;
|
||||
prs_struct buf;
|
||||
SPOOL_Q_ENUMPORTS q_o;
|
||||
SPOOL_R_ENUMPORTS r_o;
|
||||
|
||||
struct cli_connection *con = NULL;
|
||||
|
||||
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
|
||||
return False;
|
||||
|
||||
prs_init(&buf , MAX_PDU_FRAG_LEN, 4, MARSHALL);
|
||||
prs_init(&rbuf, 0, 4, UNMARSHALL);
|
||||
|
||||
/* create and send a MSRPC command with api SPOOLSS_ENUMPORTS */
|
||||
|
||||
DEBUG(5,("SPOOLSS Enum Ports (Server: %s level: %d)\n", srv_name, level));
|
||||
|
||||
make_spoolss_q_enumports(&q_o, "", level, buffer, offered);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
if (!spoolss_io_q_enumports("", &q_o, &buf, 0) ) {
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
cli_connection_unlink(con);
|
||||
}
|
||||
|
||||
if(!rpc_con_pipe_req(con, SPOOLSS_ENUMPORTS, &buf, &rbuf)) {
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
cli_connection_unlink(con);
|
||||
}
|
||||
|
||||
prs_mem_free(&buf );
|
||||
ZERO_STRUCT(r_o);
|
||||
|
||||
prs_switch_type(&buffer->prs, UNMARSHALL);
|
||||
prs_set_offset(&buffer->prs, 0);
|
||||
r_o.buffer=buffer;
|
||||
|
||||
if(!new_spoolss_io_r_enumports("", &r_o, &rbuf, 0)) {
|
||||
prs_mem_free(&rbuf);
|
||||
cli_connection_unlink(con);
|
||||
}
|
||||
|
||||
*needed=r_o.needed;
|
||||
*returned=r_o.returned;
|
||||
|
||||
prs_mem_free(&rbuf);
|
||||
prs_mem_free(&buf );
|
||||
|
||||
cli_connection_unlink(con);
|
||||
|
||||
return r_o.status;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
do a SPOOLSS Enum Jobs
|
||||
****************************************************************************/
|
||||
@ -585,9 +649,11 @@ uint32 spoolss_getprinterdriverdir(fstring srv_name, fstring env_name, uint32 le
|
||||
|
||||
/* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
|
||||
|
||||
DEBUG(5,("SPOOLSS GetPrinterDriverDir (Server: %s Env: %s level: %d)\n", srv_name, env_name, level));
|
||||
DEBUG(5,("SPOOLSS GetPrinterDriverDir (Server: %s Env: %s level: %d)\n",
|
||||
srv_name, env_name, level));
|
||||
|
||||
make_spoolss_q_getprinterdriverdir(&q_o, srv_name, env_name, level, buffer, offered);
|
||||
make_spoolss_q_getprinterdriverdir(&q_o, srv_name, env_name, level,
|
||||
buffer, offered);
|
||||
|
||||
/* turn parameters into data stream */
|
||||
if (!spoolss_io_q_getprinterdriverdir("", &q_o, &buf, 0) ) {
|
||||
|
@ -182,6 +182,22 @@ static void decode_printerdriverdir_info_1(NEW_BUFFER *buffer, DRIVER_DIRECTORY_
|
||||
}
|
||||
|
||||
|
||||
static void decode_port_info_2(NEW_BUFFER *buffer, uint32 returned,
|
||||
PORT_INFO_2 **info)
|
||||
{
|
||||
uint32 i;
|
||||
PORT_INFO_2 *inf;
|
||||
|
||||
inf=(PORT_INFO_2*)malloc(returned*sizeof(PORT_INFO_2));
|
||||
|
||||
prs_set_offset(&buffer->prs, 0);
|
||||
|
||||
for (i=0; i<returned; i++) {
|
||||
new_smb_io_port_info_2("", buffer, &(inf[i]), 0);
|
||||
}
|
||||
|
||||
*info=inf;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
nt spoolss query
|
||||
@ -234,6 +250,54 @@ BOOL msrpc_spoolss_enum_printers(char* srv_name, uint32 flags,
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
nt spoolss query
|
||||
****************************************************************************/
|
||||
BOOL msrpc_spoolss_enum_ports(char* srv_name,
|
||||
uint32 level, PORT_INFO_CTR *ctr)
|
||||
{
|
||||
uint32 status;
|
||||
NEW_BUFFER buffer;
|
||||
uint32 needed;
|
||||
uint32 returned;
|
||||
|
||||
init_buffer(&buffer, 0);
|
||||
|
||||
/* send a NULL buffer first */
|
||||
status=spoolss_enum_ports(srv_name, level, &buffer, 0,
|
||||
&needed, &returned);
|
||||
|
||||
if (status==ERROR_INSUFFICIENT_BUFFER) {
|
||||
init_buffer(&buffer, needed);
|
||||
status=spoolss_enum_ports(srv_name, level, &buffer,
|
||||
needed, &needed, &returned);
|
||||
}
|
||||
|
||||
report(out_hnd, "\tstatus:[%d (%x)]\n", status, status);
|
||||
|
||||
if (status!=NT_STATUS_NO_PROBLEMO)
|
||||
return False;
|
||||
|
||||
/* is there anything to process? */
|
||||
if (returned != 0)
|
||||
{
|
||||
switch (level) {
|
||||
case 2:
|
||||
decode_port_info_2(&buffer, returned, &ctr->port.info_2);
|
||||
break;
|
||||
default:
|
||||
DEBUG(0,("Unable to decode unknown PORT_INFO_%d\n", level));
|
||||
break;
|
||||
}
|
||||
|
||||
display_port_info_ctr(out_hnd, ACTION_HEADER , level, returned, ctr);
|
||||
display_port_info_ctr(out_hnd, ACTION_ENUMERATE, level, returned, ctr);
|
||||
display_port_info_ctr(out_hnd, ACTION_FOOTER , level, returned, ctr);
|
||||
}
|
||||
|
||||
return True;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
nt spoolss query
|
||||
****************************************************************************/
|
||||
@ -585,17 +649,21 @@ BOOL msrpc_spoolss_getprinterdriverdir(char* srv_name, char* env_name, uint32 le
|
||||
{
|
||||
uint32 status;
|
||||
NEW_BUFFER buffer;
|
||||
uint32 needed;
|
||||
uint32 needed = 502;
|
||||
|
||||
init_buffer(&buffer, 0);
|
||||
|
||||
#if 0 /* JERRY */
|
||||
/* send a NULL buffer first */
|
||||
status=spoolss_getprinterdriverdir(srv_name, env_name, level, &buffer, 0, &needed);
|
||||
|
||||
if (status==ERROR_INSUFFICIENT_BUFFER) {
|
||||
#endif
|
||||
init_buffer(&buffer, needed);
|
||||
status=spoolss_getprinterdriverdir(srv_name, env_name, level, &buffer, needed, &needed);
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
|
||||
report(out_hnd, "\tstatus:[%d (%x)]\n", status, status);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user