[PATCH 1/2] printing: fix purge of all print jobs

David Disseldorp ddiss at samba.org
Wed May 21 13:55:58 MDT 2014


The incorrect (system) jobid is currently passed to the job deletion
function.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10612

Reported-by: Franz Pförtsch <franz.pfoertsch at brose.com>
Signed-off-by: David Disseldorp <ddiss at samba.org>
---
 source3/printing/printing.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 2c9eafa..fa4a2fc 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -3359,13 +3359,28 @@ WERROR print_queue_purge(const struct auth_session_info *server_info,
 	if ( can_job_admin )
 		become_root();
 
-	for (i=0;i<njobs;i++) {
-		bool owner = is_owner(server_info, lp_const_servicename(snum),
-				      queue[i].sysjob);
+	for (i = 0; i < njobs; i++) {
+		struct tdb_print_db *pdb;
+		int jobid;
+		bool owner;
+		pdb = get_print_db_byname(lp_const_servicename(snum));
+		if (pdb == NULL) {
+			DEBUG(1, ("failed to find printdb for %s\n",
+				  lp_const_servicename(snum)));
+			continue;
+		}
+		jobid = sysjob_to_jobid_pdb(pdb, queue[i].sysjob);
+		if (jobid == (uint32_t)-1) {
+			DEBUG(2, ("jobid for system job %d not found\n",
+				  queue[i].sysjob));
+			continue;	/* unix job */
+		}
+		owner = is_owner(server_info, lp_const_servicename(snum),
+				 jobid);
 
 		if (owner || can_job_admin) {
 			print_job_delete1(server_event_context(), msg_ctx,
-					  snum, queue[i].sysjob);
+					  snum, jobid);
 		}
 	}
 
-- 
1.8.4.5



More information about the samba-technical mailing list