From 4fabc1ad0de4864f1c8d58875086c8ce28db5cc1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 4 Aug 2000 20:32:34 +0000 Subject: spoolss_addprinterex() was adding the printer and returning the correct handle, but was deleting the connection to the server. Doh!! --jerry (This used to be commit 8e5e929561a1ae954bd60f7bd745d697438f835c) --- source3/rpc_client/cli_spoolss.c | 48 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'source3/rpc_client') diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 902f6e2bfe..21e87b5799 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -545,17 +545,16 @@ BOOL spoolss_open_printer_ex( const char *printername, do a SPOOLSS AddPrinterEx() **ALWAYS** uses as PRINTER_INFO level 2 struct ****************************************************************************/ -uint32 spoolss_addprinterex(POLICY_HND *hnd,const char* srv_name, PRINTER_INFO_2 *info2) +BOOL spoolss_addprinterex(POLICY_HND *hnd, const char* srv_name, PRINTER_INFO_2 *info2) { prs_struct rbuf; prs_struct buf; SPOOL_Q_ADDPRINTEREX q_o; SPOOL_R_ADDPRINTEREX r_o; - BOOL valid_pol = False; - char *s = NULL; struct cli_connection *con = NULL; TALLOC_CTX *mem_ctx = NULL; fstring client_name; + BOOL valid_pol = True; @@ -587,35 +586,38 @@ uint32 spoolss_addprinterex(POLICY_HND *hnd,const char* srv_name, PRINTER_INFO_2 make_spoolss_q_addprinterex(&q_o, srv_name, client_name, "Administrator", 2, info2); - /* turn parameters into data stream */ - if (!spoolss_io_q_addprinterex("", &q_o, &buf, 0) ) { - prs_mem_free(&rbuf); - prs_mem_free(&buf ); - - cli_connection_unlink(con); - } + /* turn parameters into data stream and send the request */ + if (spoolss_io_q_addprinterex("", &q_o, &buf, 0) && + rpc_con_pipe_req(con, SPOOLSS_ADDPRINTEREX, &buf, &rbuf)) + { + ZERO_STRUCT(r_o); - if(!rpc_con_pipe_req(con, SPOOLSS_ADDPRINTEREX, &buf, &rbuf)) { - prs_mem_free(&rbuf); - prs_mem_free(&buf ); + if(!spoolss_io_r_addprinterex("", &r_o, &rbuf, 0)) + { + /* report error code */ + DEBUG(5,("SPOOLSS_ADDPRINTEREX: %s\n", get_nt_error_msg(r_o.status))); + valid_pol = False; + } + + if (valid_pol) + { + /* ok, at last: we're happy. return the policy handle */ + copy_policy_hnd( hnd, &r_o.handle); - cli_connection_unlink(con); + /* associate the handle returned with the current + state of the clienjt connection */ + RpcHndList_set_connection(hnd, con); + } } - prs_mem_free(&buf ); - ZERO_STRUCT(r_o); - - if(!spoolss_io_r_addprinterex("", &r_o, &rbuf, 0)) { - prs_mem_free(&rbuf); - cli_connection_unlink(con); - } prs_mem_free(&rbuf); prs_mem_free(&buf ); - cli_connection_unlink(con); + if (mem_ctx) + talloc_destroy(mem_ctx); - return r_o.status; + return valid_pol; } /**************************************************************************** -- cgit