From: David Disseldorp Date: Thu, 30 Oct 2014 00:37:47 +0000 (+0100) Subject: spoolss: fix GetJob jobid lookups X-Git-Tag: samba-4.0.23~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b1a54b8340af6dc2067d5141b9a317df242c6ac;p=thirdparty%2Fsamba.git spoolss: fix GetJob jobid lookups Clients issue GetJob requests using the jobid assigned by the spoolss server. The corresponding printing backend (sysjob) identifier needs to be resolved to locate the correct print queue entry. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10905 Reported-by: Franz Pförtsch Signed-off-by: David Disseldorp Reviewed-by: Jeremy Allison (cherry picked from commit 3a28ae56977235d3c9e3abcd1f24b220e536c50d) --- diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index f0ae9fa1cb9..9acba9f2162 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -9310,13 +9310,14 @@ static WERROR getjob_level_1(TALLOC_CTX *mem_ctx, int count, int snum, struct spoolss_PrinterInfo2 *pinfo2, uint32_t jobid, + int sysjob, struct spoolss_JobInfo1 *r) { int i = 0; bool found = false; for (i=0; imem_ctx, get_session_info_system(), p->msg_ctx, - lp_const_servicename(snum), + svc_name, &pinfo2); if (!W_ERROR_IS_OK(result)) { return result; } + pdb = get_print_db_byname(svc_name); + if (pdb == NULL) { + DEBUG(3, ("failed to get print db for svc %s\n", svc_name)); + TALLOC_FREE(pinfo2); + return WERR_INVALID_PARAM; + } + + sysjob = jobid_to_sysjob_pdb(pdb, r->in.job_id); + release_print_db(pdb); + if (sysjob == -1) { + DEBUG(3, ("no sysjob for spoolss jobid %u\n", r->in.job_id)); + TALLOC_FREE(pinfo2); + return WERR_INVALID_PARAM; + } + count = print_queue_status(p->msg_ctx, snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], prt_status:[%d], [%s]\n", @@ -9435,12 +9460,14 @@ WERROR _spoolss_GetJob(struct pipes_struct *p, case 1: result = getjob_level_1(p->mem_ctx, queue, count, snum, pinfo2, - r->in.job_id, &r->out.info->info1); + r->in.job_id, sysjob, + &r->out.info->info1); break; case 2: result = getjob_level_2(p->mem_ctx, queue, count, snum, pinfo2, - r->in.job_id, &r->out.info->info2); + r->in.job_id, sysjob, + &r->out.info->info2); break; default: result = WERR_UNKNOWN_LEVEL;