diff options
author | David Disseldorp <ddiss@samba.org> | 2014-10-30 01:37:50 +0100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2014-11-17 21:21:12 +0100 |
commit | bcd16d68ac1ccdd1158ff1e3c1d73fd6cfdfef6d (patch) | |
tree | d18ac97db1498183106506da6f5cb9fd63d274d0 /source3 | |
parent | 20f803ba0202f94dc357ac703174fd1bcc4b5a4f (diff) | |
download | samba-bcd16d68ac1ccdd1158ff1e3c1d73fd6cfdfef6d.tar.gz |
spoolss: fix jobid in level 3 EnumJobs response
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>
(cherry picked from commit 5e7ab3d2f4f7950099561eb22d6a9a1536297442)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/rpc_server/spoolss/srv_spoolss_nt.c | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index e00c85c9ef..47fcdc1a35 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -7320,41 +7320,51 @@ static WERROR enumjobs_level3(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); - - *count = num_queues; + if (info == NULL) { + result = WERR_NOMEM; + goto err_out; + } - for (i=0; i<*count; i++) { - const print_queue_struct *next_queue = NULL; + pdb = get_print_db_byname(pinfo2->sharename); + if (pdb == NULL) { + result = WERR_INVALID_PARAM; + goto err_info_free; + } - if (i+1 < *count) { - next_queue = &queue[i+1]; + 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; } - result = fill_job_info3(info, - &info[i].info3, - &queue[i], - next_queue, - i, - snum, - pinfo2); - if (!W_ERROR_IS_OK(result)) { - goto out; - } - } + info[num_filled].info3.job_id = jobid; + /* next_job_id is overwritten on next iteration */ + info[num_filled].info3.next_job_id = 0; + info[num_filled].info3.reserved = 0; - out: - if (!W_ERROR_IS_OK(result)) { - TALLOC_FREE(info); - *count = 0; - return result; + if (num_filled > 0) { + info[num_filled - 1].info3.next_job_id = jobid; + } + num_filled++; } + release_print_db(pdb); *info_p = info; + *count = num_filled; return WERR_OK; + +err_info_free: + TALLOC_FREE(info); +err_out: + *count = 0; + return result; } /**************************************************************** |