diff options
author | David Disseldorp <ddiss@samba.org> | 2014-10-30 01:37:48 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-10-30 06:52:04 +0100 |
commit | 4d7f5d2af6ef6960dccaccf89c6e88947e2591bf (patch) | |
tree | a565973f3d88e050f726e28e8fa51232dceaf180 | |
parent | 3a28ae56977235d3c9e3abcd1f24b220e536c50d (diff) | |
download | samba-4d7f5d2af6ef6960dccaccf89c6e88947e2591bf.tar.gz |
spoolss: fix jobid in level 1 GetJob and EnumJobs responses
Until now, these responses have incorrectly carried the printing backend
job identifier (sysjob), rather than the one allocated and returned by
Samba on job submission.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10905
Reported-by: Franz Pförtsch <franz.pfoertsch@brose.com>
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r-- | source3/rpc_server/spoolss/srv_spoolss_nt.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index 3675fc1e5d1..8c601590092 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -7057,6 +7057,7 @@ fill_job_info1 static WERROR fill_job_info1(TALLOC_CTX *mem_ctx, struct spoolss_JobInfo1 *r, const print_queue_struct *queue, + uint32_t jobid, int position, int snum, struct spoolss_PrinterInfo2 *pinfo2) { @@ -7064,7 +7065,7 @@ static WERROR fill_job_info1(TALLOC_CTX *mem_ctx, t = gmtime(&queue->time); - r->job_id = queue->sysjob; + r->job_id = jobid; r->printer_name = lp_servicename(mem_ctx, snum); W_ERROR_HAVE_NO_MEMORY(r->printer_name); @@ -7182,34 +7183,56 @@ static WERROR enumjobs_level1(TALLOC_CTX *mem_ctx, union spoolss_JobInfo *info; int i; WERROR result = WERR_OK; + uint32_t num_filled; + struct tdb_print_db *pdb; info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues); - W_ERROR_HAVE_NO_MEMORY(info); + if (info == NULL) { + result = WERR_NOMEM; + goto err_out; + } - *count = num_queues; + pdb = get_print_db_byname(pinfo2->sharename); + if (pdb == NULL) { + result = WERR_INVALID_PARAM; + goto err_info_free; + } + + num_filled = 0; + for (i = 0; i < num_queues; i++) { + uint32_t jobid = sysjob_to_jobid_pdb(pdb, queue[i].sysjob); + if (jobid == (uint32_t)-1) { + DEBUG(4, ("skipping sysjob %d\n", queue[i].sysjob)); + continue; + } - for (i=0; i<*count; i++) { result = fill_job_info1(info, - &info[i].info1, + &info[num_filled].info1, &queue[i], + jobid, i, snum, pinfo2); if (!W_ERROR_IS_OK(result)) { - goto out; + goto err_pdb_drop; } - } - out: - if (!W_ERROR_IS_OK(result)) { - TALLOC_FREE(info); - *count = 0; - return result; + num_filled++; } + release_print_db(pdb); *info_p = info; + *count = num_filled; return WERR_OK; + +err_pdb_drop: + release_print_db(pdb); +err_info_free: + TALLOC_FREE(info); +err_out: + *count = 0; + return result; } /**************************************************************************** @@ -9368,6 +9391,7 @@ static WERROR getjob_level_1(TALLOC_CTX *mem_ctx, return fill_job_info1(mem_ctx, r, &queue[i], + jobid, i, snum, pinfo2); |