diff options
author | Simo Sorce <idra@samba.org> | 2010-05-01 17:42:52 -0400 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2010-07-27 10:27:13 -0400 |
commit | 94ee35f9cc0880c267bee14047d559948eb14ede (patch) | |
tree | 61302ba298a2bfa4358f9ae445c2c9267a4f1a4a /source3/rpc_server | |
parent | 4761498c9e40d8b00060d2949bfcff32c6cf7f99 (diff) | |
download | samba-94ee35f9cc0880c267bee14047d559948eb14ede.tar.gz samba-94ee35f9cc0880c267bee14047d559948eb14ede.tar.bz2 samba-94ee35f9cc0880c267bee14047d559948eb14ede.zip |
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 <jmcd@samba.org>
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 19 |
1 files changed, 14 insertions, 5 deletions
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; } |