From 94ee35f9cc0880c267bee14047d559948eb14ede Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 1 May 2010 17:42:52 -0400 Subject: s3-printing: Made print_job_start more robust. Explicitly return ntstatus errors instead of relying on elusive errno. Split the function to make it easier to follow. Signed-off-by: Jim McDonough --- source3/rpc_server/srv_spoolss_nt.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server/srv_spoolss_nt.c') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 86dffafb73..24d1716d42 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -5121,6 +5121,7 @@ WERROR _spoolss_StartDocPrinter(pipes_struct *p, struct spoolss_DocumentInfo1 *info_1; int snum; Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); + WERROR werr; if (!Printer) { DEBUG(2,("_spoolss_StartDocPrinter: " @@ -5129,6 +5130,13 @@ WERROR _spoolss_StartDocPrinter(pipes_struct *p, return WERR_BADFID; } + if (Printer->jobid) { + DEBUG(2, ("_spoolss_StartDocPrinter: " + "StartDocPrinter called twice! " + "(existing jobid = %d)\n", Printer->jobid)); + return WERR_INVALID_HANDLE; + } + if (r->in.level != 1) { return WERR_UNKNOWN_LEVEL; } @@ -5155,15 +5163,15 @@ WERROR _spoolss_StartDocPrinter(pipes_struct *p, return WERR_BADFID; } - Printer->jobid = print_job_start(p->server_info, snum, - info_1->document_name, - Printer->devmode); + werr = print_job_start(p->server_info, snum, + info_1->document_name, info_1->output_file, + Printer->devmode, &Printer->jobid); /* An error occured in print_job_start() so return an appropriate NT error code. */ - if (Printer->jobid == -1) { - return map_werror_from_unix(errno); + if (!W_ERROR_IS_OK(werr)) { + return werr; } Printer->document_started = true; @@ -5196,6 +5204,7 @@ WERROR _spoolss_EndDocPrinter(pipes_struct *p, print_job_end(snum, Printer->jobid, NORMAL_CLOSE); /* error codes unhandled so far ... */ + Printer->jobid = 0; return WERR_OK; } -- cgit