summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2000-08-04 20:32:34 +0000
committerGerald Carter <jerry@samba.org>2000-08-04 20:32:34 +0000
commit4fabc1ad0de4864f1c8d58875086c8ce28db5cc1 (patch)
tree01d8dc6a1e311caadf9477c05b8a4004c6529518 /source3
parentb3b512264d90f58a9a9c50cef33d9b860f54c51a (diff)
downloadsamba-4fabc1ad0de4864f1c8d58875086c8ce28db5cc1.tar.gz
samba-4fabc1ad0de4864f1c8d58875086c8ce28db5cc1.tar.bz2
samba-4fabc1ad0de4864f1c8d58875086c8ce28db5cc1.zip
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)
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_client/cli_spoolss.c48
-rw-r--r--source3/rpcclient/cmd_spoolss.c6
2 files changed, 28 insertions, 26 deletions
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;
}
/****************************************************************************
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 058c6db457..f79a7042d2 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -512,7 +512,6 @@ uint32 cmd_spoolss_addprinterex(struct client_info *info, int argc, char *argv[]
fstring srv_port_name;
BOOL valid_port = False;
TALLOC_CTX *mem_ctx = NULL;
- uint32 result;
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->dest_host);
@@ -620,8 +619,9 @@ uint32 cmd_spoolss_addprinterex(struct client_info *info, int argc, char *argv[]
/* if successful, spoolss_addprinterex() should return True and hnd
should be a valid handle to an open printer */
- if ((result = spoolss_addprinterex(&hnd, srv_name, &print_info_2)) == NT_STATUS_NOPROBLEMO)
+ if (spoolss_addprinterex(&hnd, srv_name, &print_info_2))
{
+ DEBUG(0,("cmd_spoolss_addprinterex: [%s] added successfully.\n", printer_name));
if (!spoolss_closeprinter( &hnd ))
{
report (out_hnd, "cmd_spoolss_addprinterex: spoolss_closeprinter FAILED!\n");
@@ -629,7 +629,7 @@ uint32 cmd_spoolss_addprinterex(struct client_info *info, int argc, char *argv[]
}
else
{
- report (out_hnd, "cmd_spoolss_addprinterex: spoolss_addprinterex FAILED! [%d]\n", result);
+ report (out_hnd, "cmd_spoolss_addprinterex: spoolss_addprinterex FAILED!\n");
}