diff options
author | Gerald Carter <jerry@samba.org> | 2000-07-21 20:03:18 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2000-07-21 20:03:18 +0000 |
commit | 74a9323bad6deb44ad634b6e0c563d9daa0f1c76 (patch) | |
tree | 10702ddadfef5d4bc7d6da54dfa6280042c968cf | |
parent | fe245e2a92b47567ae1c8a27158e27ef360e0efc (diff) | |
download | samba-74a9323bad6deb44ad634b6e0c563d9daa0f1c76.tar.gz samba-74a9323bad6deb44ad634b6e0c563d9daa0f1c76.tar.bz2 samba-74a9323bad6deb44ad634b6e0c563d9daa0f1c76.zip |
* Added EnumPorts()
* Fixed an off-by-one bug noticed by JF in GetPrinterDriverDirectory()
jerry
(This used to be commit a9522f560da64045d928dabedeacdef0a6c3db51)
-rw-r--r-- | source3/rpc_client/cli_spoolss.c | 70 | ||||
-rw-r--r-- | source3/rpc_client/msrpc_spoolss.c | 70 |
2 files changed, 137 insertions, 3 deletions
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 0f89399beb..d6156bf4ac 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -162,6 +162,70 @@ uint32 spoolss_enum_printers(uint32 flags, fstring srv_name, uint32 level, } /**************************************************************************** +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 ****************************************************************************/ uint32 spoolss_enum_jobs(const POLICY_HND *hnd, uint32 firstjob, uint32 numofjobs, @@ -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) ) { diff --git a/source3/rpc_client/msrpc_spoolss.c b/source3/rpc_client/msrpc_spoolss.c index 10582c01be..34e6d4404c 100644 --- a/source3/rpc_client/msrpc_spoolss.c +++ b/source3/rpc_client/msrpc_spoolss.c @@ -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 @@ -237,6 +253,54 @@ BOOL msrpc_spoolss_enum_printers(char* srv_name, uint32 flags, /**************************************************************************** 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 +****************************************************************************/ uint32 msrpc_spoolss_getprinterdata( const char* printer_name, const char* station, const char* user_name, @@ -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); |