summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-01-15 12:06:09 +0100
committerAndreas Schneider <asn@samba.org>2011-01-21 13:14:49 +0100
commit7a2fa9fc1cf5b26419c9cd915e85030c7f14e764 (patch)
treed9f621bbf601fa380ca7a38d41ecc37f392ce8a4
parent1f8332526102e879c8a8f847d6b43efaf69d03ba (diff)
downloadsamba-7a2fa9fc1cf5b26419c9cd915e85030c7f14e764.tar.gz
samba-7a2fa9fc1cf5b26419c9cd915e85030c7f14e764.tar.bz2
samba-7a2fa9fc1cf5b26419c9cd915e85030c7f14e764.zip
s3:printing: use dcerpc_spoolss_X() functions
metze Signed-off-by: Andreas Schneider <asn@samba.org> Autobuild-User: Andreas Schneider <asn@samba.org> Autobuild-Date: Fri Jan 21 13:14:49 CET 2011 on sn-devel-104
-rw-r--r--source3/printing/nt_printing_migrate.c107
-rw-r--r--source3/printing/printspoolss.c24
2 files changed, 84 insertions, 47 deletions
diff --git a/source3/printing/nt_printing_migrate.c b/source3/printing/nt_printing_migrate.c
index c6466767e5..61fb9a602b 100644
--- a/source3/printing/nt_printing_migrate.c
+++ b/source3/printing/nt_printing_migrate.c
@@ -22,7 +22,7 @@
#include "printing/nt_printing_migrate.h"
#include "librpc/gen_ndr/ndr_ntprinting.h"
-#include "librpc/gen_ndr/cli_spoolss.h"
+#include "librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_client/cli_spoolss.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "rpc_server/rpc_ncacn_np.h"
@@ -38,6 +38,7 @@ static NTSTATUS migrate_form(TALLOC_CTX *mem_ctx,
unsigned char *data,
size_t length)
{
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
struct spoolss_DevmodeContainer devmode_ctr;
struct policy_handle hnd;
enum ndr_err_code ndr_err;
@@ -76,7 +77,7 @@ static NTSTATUS migrate_form(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(devmode_ctr);
- status = rpccli_spoolss_OpenPrinter(pipe_hnd,
+ status = dcerpc_spoolss_OpenPrinter(b,
mem_ctx,
srv_name_slash,
NULL,
@@ -85,13 +86,16 @@ static NTSTATUS migrate_form(TALLOC_CTX *mem_ctx,
&hnd,
&result);
if (!NT_STATUS_IS_OK(status)) {
- if (!W_ERROR_IS_OK(result)) {
- status = werror_to_ntstatus(result);
- }
- DEBUG(2, ("OpenPrinter(%s) failed: %s\n",
+ DEBUG(2, ("dcerpc_spoolss_OpenPrinter(%s) failed: %s\n",
srv_name_slash, nt_errstr(status)));
return status;
}
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(2, ("OpenPrinter(%s) failed: %s\n",
+ srv_name_slash, win_errstr(result)));
+ status = werror_to_ntstatus(result);
+ return status;
+ }
f1.form_name = key_name;
f1.flags = r.flag;
@@ -106,18 +110,22 @@ static NTSTATUS migrate_form(TALLOC_CTX *mem_ctx,
f.info1 = &f1;
- status = rpccli_spoolss_AddForm(pipe_hnd,
+ status = dcerpc_spoolss_AddForm(b,
mem_ctx,
&hnd,
1,
f,
&result);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(2, ("AddForm(%s) refused -- %s.\n",
+ DEBUG(2, ("dcerpc_spoolss_AddForm(%s) refused -- %s.\n",
f.info1->form_name, nt_errstr(status)));
+ } else if (!W_ERROR_IS_OK(result)) {
+ DEBUG(2, ("AddForm(%s) refused -- %s.\n",
+ f.info1->form_name, win_errstr(result)));
+ status = werror_to_ntstatus(result);
}
- rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
+ dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &result);
return status;
}
@@ -128,6 +136,7 @@ static NTSTATUS migrate_driver(TALLOC_CTX *mem_ctx,
unsigned char *data,
size_t length)
{
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
const char *srv_name_slash;
enum ndr_err_code ndr_err;
struct ntprinting_driver r;
@@ -176,17 +185,18 @@ static NTSTATUS migrate_driver(TALLOC_CTX *mem_ctx,
d.level = 3;
d.info.info3 = &d3;
- status = rpccli_spoolss_AddPrinterDriver(pipe_hnd,
+ status = dcerpc_spoolss_AddPrinterDriver(b,
mem_ctx,
srv_name_slash,
&d,
&result);
if (!NT_STATUS_IS_OK(status)) {
- if (!W_ERROR_IS_OK(result)) {
- status = werror_to_ntstatus(result);
- }
- DEBUG(2, ("AddPrinterDriver(%s) refused -- %s.\n",
+ DEBUG(2, ("dcerpc_spoolss_AddPrinterDriver(%s) refused -- %s.\n",
d3.driver_name, nt_errstr(status)));
+ } else if (!W_ERROR_IS_OK(result)) {
+ DEBUG(2, ("AddPrinterDriver(%s) refused -- %s.\n",
+ d3.driver_name, win_errstr(result)));
+ status = werror_to_ntstatus(result);
}
return status;
@@ -198,6 +208,7 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
unsigned char *data,
size_t length)
{
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
struct policy_handle hnd;
enum ndr_err_code ndr_err;
struct ntprinting_printer r;
@@ -231,7 +242,7 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(devmode_ctr);
- status = rpccli_spoolss_OpenPrinter(pipe_hnd,
+ status = dcerpc_spoolss_OpenPrinter(b,
mem_ctx,
key_name,
NULL,
@@ -240,11 +251,14 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
&hnd,
&result);
if (!NT_STATUS_IS_OK(status)) {
- if (!W_ERROR_IS_OK(result)) {
- status = werror_to_ntstatus(result);
- }
+ DEBUG(2, ("dcerpc_spoolss_OpenPrinter(%s) failed: %s\n",
+ key_name, nt_errstr(status)));
+ return status;
+ }
+ if (!W_ERROR_IS_OK(result)) {
DEBUG(2, ("OpenPrinter(%s) failed: %s\n",
key_name, win_errstr(result)));
+ status = werror_to_ntstatus(result);
return status;
}
@@ -320,7 +334,7 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
info_ctr.info.info2 = &info2;
info_ctr.level = 2;
- status = rpccli_spoolss_SetPrinter(pipe_hnd,
+ status = dcerpc_spoolss_SetPrinter(b,
mem_ctx,
&hnd,
&info_ctr,
@@ -329,10 +343,16 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
0, /* command */
&result);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(2, ("SetPrinter(%s) level 2 refused -- %s.\n",
+ DEBUG(2, ("dcerpc_spoolss_SetPrinter(%s) level 2 refused -- %s.\n",
key_name, nt_errstr(status)));
goto done;
}
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(2, ("SetPrinter(%s) level 2 refused -- %s.\n",
+ key_name, win_errstr(result)));
+ status = werror_to_ntstatus(result);
+ goto done;
+ }
/* migrate printerdata */
for (j = 0; j < r.count; j++) {
@@ -352,7 +372,7 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
valuename++;
}
- status = rpccli_spoolss_SetPrinterDataEx(pipe_hnd,
+ status = dcerpc_spoolss_SetPrinterDataEx(b,
mem_ctx,
&hnd,
keyname,
@@ -362,16 +382,25 @@ static NTSTATUS migrate_printer(TALLOC_CTX *mem_ctx,
r.printer_data[j].data.length,
&result);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(2, ("SetPrinterDataEx: printer [%s], keyname [%s], "
+ DEBUG(2, ("dcerpc_spoolss_SetPrinterDataEx: "
+ "printer [%s], keyname [%s], "
"valuename [%s] refused -- %s.\n",
key_name, keyname, valuename,
nt_errstr(status)));
break;
}
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(2, ("SetPrinterDataEx: printer [%s], keyname [%s], "
+ "valuename [%s] refused -- %s.\n",
+ key_name, keyname, valuename,
+ win_errstr(result)));
+ status = werror_to_ntstatus(result);
+ break;
+ }
}
done:
- rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
+ dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &result);
return status;
}
@@ -382,6 +411,7 @@ static NTSTATUS migrate_secdesc(TALLOC_CTX *mem_ctx,
unsigned char *data,
size_t length)
{
+ struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
struct policy_handle hnd;
enum ndr_err_code ndr_err;
struct sec_desc_buf secdesc_ctr;
@@ -412,7 +442,7 @@ static NTSTATUS migrate_secdesc(TALLOC_CTX *mem_ctx,
ZERO_STRUCT(devmode_ctr);
- status = rpccli_spoolss_OpenPrinter(pipe_hnd,
+ status = dcerpc_spoolss_OpenPrinter(b,
mem_ctx,
key_name,
NULL,
@@ -421,17 +451,20 @@ static NTSTATUS migrate_secdesc(TALLOC_CTX *mem_ctx,
&hnd,
&result);
if (!NT_STATUS_IS_OK(status)) {
- if (W_ERROR_EQUAL(WERR_INVALID_PRINTER_NAME, result)) {
- DEBUG(3, ("Ignoring missing printer %s\n", key_name));
- return NT_STATUS_OK;
- }
- if (!W_ERROR_IS_OK(result)) {
- status = werror_to_ntstatus(result);
- }
- DEBUG(2, ("OpenPrinter(%s) failed: %s\n",
+ DEBUG(2, ("dcerpc_spoolss_OpenPrinter(%s) failed: %s\n",
key_name, nt_errstr(status)));
return status;
}
+ if (W_ERROR_EQUAL(WERR_INVALID_PRINTER_NAME, result)) {
+ DEBUG(3, ("Ignoring missing printer %s\n", key_name));
+ return NT_STATUS_OK;
+ }
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(2, ("OpenPrinter(%s) failed: %s\n",
+ key_name, win_errstr(result)));
+ status = werror_to_ntstatus(result);
+ return status;
+ }
ZERO_STRUCT(devmode_ctr);
@@ -440,7 +473,7 @@ static NTSTATUS migrate_secdesc(TALLOC_CTX *mem_ctx,
info_ctr.info.info3 = &info3;
info_ctr.level = 3;
- status = rpccli_spoolss_SetPrinter(pipe_hnd,
+ status = dcerpc_spoolss_SetPrinter(b,
mem_ctx,
&hnd,
&info_ctr,
@@ -449,11 +482,15 @@ static NTSTATUS migrate_secdesc(TALLOC_CTX *mem_ctx,
0, /* command */
&result);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(2, ("SetPrinter(%s) level 3 refused -- %s.\n",
+ DEBUG(2, ("dcerpc_spoolss_SetPrinter(%s) level 3 refused -- %s.\n",
key_name, nt_errstr(status)));
+ } else if (!W_ERROR_IS_OK(result)) {
+ DEBUG(2, ("SetPrinter(%s) level 3 refused -- %s.\n",
+ key_name, win_errstr(result)));
+ status = werror_to_ntstatus(result);
}
- rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
+ dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &result);
return status;
}
diff --git a/source3/printing/printspoolss.c b/source3/printing/printspoolss.c
index 8effb6ec48..9b06ece307 100644
--- a/source3/printing/printspoolss.c
+++ b/source3/printing/printspoolss.c
@@ -19,7 +19,7 @@
#include "includes.h"
#include "printing.h"
-#include "../librpc/gen_ndr/cli_spoolss.h"
+#include "../librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_server/rpc_ncacn_np.h"
#include "smbd/globals.h"
#include "../libcli/security/security.h"
@@ -43,7 +43,7 @@ NTSTATUS print_spool_open(files_struct *fsp,
NTSTATUS status;
TALLOC_CTX *tmp_ctx;
struct print_file_data *pf;
- struct rpc_pipe_client *cli;
+ struct dcerpc_binding_handle *b = NULL;
struct spoolss_DevmodeContainer devmode_ctr;
union spoolss_DocumentInfo info;
int fd = -1;
@@ -132,11 +132,11 @@ NTSTATUS print_spool_open(files_struct *fsp,
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- cli = fsp->conn->spoolss_pipe;
+ b = fsp->conn->spoolss_pipe->binding_handle;
ZERO_STRUCT(devmode_ctr);
- status = rpccli_spoolss_OpenPrinter(cli, pf, pf->svcname,
+ status = dcerpc_spoolss_OpenPrinter(b, pf, pf->svcname,
"RAW", devmode_ctr,
SEC_FLAG_MAXIMUM_ALLOWED,
&pf->handle, &werr);
@@ -157,7 +157,7 @@ NTSTATUS print_spool_open(files_struct *fsp,
info.info1->output_file = pf->filename;
info.info1->datatype = "RAW";
- status = rpccli_spoolss_StartDocPrinter(cli, tmp_ctx, &pf->handle,
+ status = dcerpc_spoolss_StartDocPrinter(b, tmp_ctx, &pf->handle,
1, info, &pf->jobid, &werr);
if (!NT_STATUS_IS_OK(status)) {
goto done;
@@ -272,9 +272,9 @@ int print_spool_write(files_struct *fsp,
void print_spool_end(files_struct *fsp, enum file_close_type close_type)
{
- struct rpc_pipe_client *cli;
NTSTATUS status;
WERROR werr;
+ struct dcerpc_binding_handle *b = NULL;
status = rpc_pipe_open_interface(fsp->conn,
&ndr_table_spoolss.syntax_id,
@@ -288,13 +288,13 @@ void print_spool_end(files_struct *fsp, enum file_close_type close_type)
nt_errstr(status)));
return;
}
- cli = fsp->conn->spoolss_pipe;
+ b = fsp->conn->spoolss_pipe->binding_handle;
switch (close_type) {
case NORMAL_CLOSE:
case SHUTDOWN_CLOSE:
/* this also automatically calls spoolss_EndDocPrinter */
- status = rpccli_spoolss_ClosePrinter(cli, fsp->print_file,
+ status = dcerpc_spoolss_ClosePrinter(b, fsp->print_file,
&fsp->print_file->handle,
&werr);
if (!NT_STATUS_IS_OK(status) ||
@@ -313,9 +313,9 @@ void print_spool_end(files_struct *fsp, enum file_close_type close_type)
void print_spool_terminate(struct connection_struct *conn,
struct print_file_data *print_file)
{
- struct rpc_pipe_client *cli;
NTSTATUS status;
WERROR werr;
+ struct dcerpc_binding_handle *b = NULL;
rap_jobid_delete(print_file->svcname, print_file->jobid);
@@ -331,9 +331,9 @@ void print_spool_terminate(struct connection_struct *conn,
nt_errstr(status)));
return;
}
- cli = conn->spoolss_pipe;
+ b = conn->spoolss_pipe->binding_handle;
- status = rpccli_spoolss_SetJob(cli, print_file,
+ status = dcerpc_spoolss_SetJob(b, print_file,
&print_file->handle,
print_file->jobid,
NULL, SPOOLSS_JOB_CONTROL_DELETE,
@@ -344,7 +344,7 @@ void print_spool_terminate(struct connection_struct *conn,
print_file->jobid, nt_errstr(status)));
return;
}
- status = rpccli_spoolss_ClosePrinter(cli, print_file,
+ status = dcerpc_spoolss_ClosePrinter(b, print_file,
&print_file->handle,
&werr);
if (!NT_STATUS_IS_OK(status) ||