Bug 10898 - spoolss EnumJobs(level=4) returns WERR_OK with 0 jobs and WERR_UNKNOWN_LEVEL with > 0 jobs
Summary: spoolss EnumJobs(level=4) returns WERR_OK with 0 jobs and WERR_UNKNOWN_LEVEL ...
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Printing (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-27 15:18 UTC by David Disseldorp
Modified: 2014-11-10 20:33 UTC (History)
3 users (show)

See Also:


Attachments
cherry-pick against 3.6-test branch (1.79 KB, patch)
2014-10-28 11:06 UTC, David Disseldorp
no flags Details
fix cherry-picked for v4-0-test branch (1.79 KB, patch)
2014-10-28 11:08 UTC, David Disseldorp
jra: review+
asn: review+
Details
fix cherry-picked for v4-1-test branch (1.79 KB, patch)
2014-10-28 11:08 UTC, David Disseldorp
jra: review+
asn: review+
Details
fix cherry-picked for v4-2-test branch (1.79 KB, patch)
2014-10-28 11:09 UTC, David Disseldorp
jra: review+
asn: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Disseldorp 2014-10-27 15:18:09 UTC
The following code leads to inconsistent spoolss EnumJobs responses, as described in the summary:

 7325 WERROR _spoolss_EnumJobs(struct pipes_struct *p,
 7326                          struct spoolss_EnumJobs *r)
 7327 {
...
 7362         count = print_queue_status(p->msg_ctx, snum, &queue, &prt_status);
 7363         DEBUGADD(4,("count:[%d], status:[%d], [%s]\n",
 7364                 count, prt_status.status, prt_status.message));
 7365 
 7366         if (count == 0) {
 7367                 SAFE_FREE(queue);
 7368                 TALLOC_FREE(pinfo2);
 7369                 return WERR_OK;
 7370         }
 7371 
 7372         switch (r->in.level) {
 7373         case 1:
 7374                 result = enumjobs_level1(p->mem_ctx, queue, count, snum,
 7375                                          pinfo2, r->out.info, r->out.count);
 7376                 break;
 7377         case 2:
 7378                 result = enumjobs_level2(p->mem_ctx, queue, count, snum,
 7379                                          pinfo2, r->out.info, r->out.count);
 7380                 break;
 7381         case 3:
 7382                 result = enumjobs_level3(p->mem_ctx, queue, count, snum,
 7383                                          pinfo2, r->out.info, r->out.count);
 7384                 break;
 7385         default:
 7386                 result = WERR_UNKNOWN_LEVEL;
 7387                 break;
 7388         }

We should check for an unsupported EnumJobs level prior to the "if (count == 0) {" response fast-path.

The fix is quite simple, but will take a little longer, as I'd also like to add a corresponding smbtorture test.
Comment 1 David Disseldorp 2014-10-28 11:06:34 UTC
Created attachment 10370 [details]
cherry-pick against 3.6-test branch
Comment 2 David Disseldorp 2014-10-28 11:08:09 UTC
Created attachment 10371 [details]
fix cherry-picked for v4-0-test branch
Comment 3 David Disseldorp 2014-10-28 11:08:39 UTC
Created attachment 10372 [details]
fix cherry-picked for v4-1-test branch
Comment 4 David Disseldorp 2014-10-28 11:09:24 UTC
Created attachment 10373 [details]
fix cherry-picked for v4-2-test branch
Comment 5 Andreas Schneider 2014-10-28 13:29:44 UTC
Karolin, please add the patches to the branches. Thanks!
Comment 6 Karolin Seeger 2014-10-29 20:16:32 UTC
Pushed to autobuild-v4-[0|1|2]-test.
Comment 7 Karolin Seeger 2014-11-10 20:33:48 UTC
Pushed to all branches.
Closing out bug report.

Thanks!