+++ /dev/null
-#
-# Fixes removal of print jobs by ensuring that we always
-# know what the Unix job id is and can therefore issue
-# an the 'lprm command'
-#
-diff --exclude-from=diff.excludes -ruBN samba-3.0.20b/source/include/printing.h samba-3.0.20b-new/source/include/printing.h
---- samba-3.0.20b/source/include/printing.h 2005-10-12 12:03:38.000000000 -0500
-+++ samba-3.0.20b-new/source/include/printing.h 2005-10-20 06:11:17.000000000 -0500
-@@ -57,7 +57,7 @@
- print_status_struct *status);
- int (*queue_pause)(int snum);
- int (*queue_resume)(int snum);
-- int (*job_delete)(int snum, struct printjob *pjob);
-+ int (*job_delete)(const char *sharename, const char *lprm_command, struct printjob *pjob);
- int (*job_pause)(int snum, struct printjob *pjob);
- int (*job_resume)(int snum, struct printjob *pjob);
- int (*job_submit)(int snum, struct printjob *pjob);
-diff --exclude-from=diff.excludes -ruBN samba-3.0.20b/source/printing/print_cups.c samba-3.0.20b-new/source/printing/print_cups.c
---- samba-3.0.20b/source/printing/print_cups.c 2005-10-12 12:03:27.000000000 -0500
-+++ samba-3.0.20b-new/source/printing/print_cups.c 2005-10-20 06:11:17.000000000 -0500
-@@ -265,7 +265,7 @@
- * 'cups_job_delete()' - Delete a job.
- */
-
--static int cups_job_delete(int snum, struct printjob *pjob)
-+static int cups_job_delete(const char *sharename, const char *lprm_command, struct printjob *pjob)
- {
- int ret = 1; /* Return value */
- http_t *http = NULL; /* HTTP connection to server */
-@@ -275,7 +275,7 @@
- char uri[HTTP_MAX_URI]; /* printer-uri attribute */
-
-
-- DEBUG(5,("cups_job_delete(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
-+ DEBUG(5,("cups_job_delete(%s, %p (%d))\n", sharename, pjob, pjob->sysjob));
-
- /*
- * Make sure we don't ask for passwords...
-diff --exclude-from=diff.excludes -ruBN samba-3.0.20b/source/printing/print_generic.c samba-3.0.20b-new/source/printing/print_generic.c
---- samba-3.0.20b/source/printing/print_generic.c 2005-10-12 12:03:27.000000000 -0500
-+++ samba-3.0.20b-new/source/printing/print_generic.c 2005-10-20 06:11:17.000000000 -0500
-@@ -68,14 +68,13 @@
- /****************************************************************************
- delete a print job
- ****************************************************************************/
--static int generic_job_delete(int snum, struct printjob *pjob)
-+static int generic_job_delete( const char *sharename, const char *lprm_command, struct printjob *pjob)
- {
- fstring jobstr;
-
- /* need to delete the spooled entry */
- slprintf(jobstr, sizeof(jobstr)-1, "%d", pjob->sysjob);
-- return print_run_command(snum, PRINTERNAME(snum), True,
-- lp_lprmcommand(snum), NULL,
-+ return print_run_command( -1, sharename, False, lprm_command, NULL,
- "%j", jobstr,
- "%T", http_timestring(pjob->starttime),
- NULL);
-diff --exclude-from=diff.excludes -ruBN samba-3.0.20b/source/printing/printing.c samba-3.0.20b-new/source/printing/printing.c
---- samba-3.0.20b/source/printing/printing.c 2005-10-12 12:03:27.000000000 -0500
-+++ samba-3.0.20b-new/source/printing/printing.c 2005-10-20 06:11:17.000000000 -0500
-@@ -685,6 +685,8 @@
- int qcount, snum, maxcount, total_jobs;
- const char *sharename;
- time_t lpq_time;
-+ const char *lprm_command;
-+ struct printif *print_if;
- };
-
- /****************************************************************************
-@@ -744,9 +746,39 @@
-
- if ( pjob.smbjob ) {
- for (i=0;i<ts->qcount;i++) {
-- uint32 curr_jobid = print_parse_jobid(ts->queue[i].fs_file);
-- if (jobid == curr_jobid)
-+
-+ uint32 curr_jobid;
-+
-+ if ( pjob.status == LPQ_DELETED )
-+ continue;
-+
-+ curr_jobid = print_parse_jobid(ts->queue[i].fs_file);
-+
-+ if (jobid == curr_jobid) {
-+
-+ /* try to clean up any jobs that need to be deleted */
-+
-+ if ( pjob.status == LPQ_DELETING ) {
-+ int result;
-+
-+ result = (*(ts->print_if->job_delete))(
-+ ts->sharename, ts->lprm_command, &pjob );
-+
-+ if ( result != 0 ) {
-+ /* if we can't delete, then reset the job status */
-+ pjob.status = LPQ_QUEUED;
-+ pjob_store(ts->sharename, jobid, &pjob);
-+ }
-+ else {
-+ /* if we deleted the job, the remove the tdb record */
-+ pjob_delete(ts->sharename, jobid);
-+ pjob.status = LPQ_DELETED;
-+ }
-+
-+ }
-+
- break;
-+ }
- }
- }
-
-@@ -773,9 +805,10 @@
- return 0;
- }
-
-- /* Save the pjob attributes we will store. */
-- /* FIXME!!! This is the only place where queue->job
-+ /* Save the pjob attributes we will store.
-+ FIXME!!! This is the only place where queue->job
- represents the SMB jobid --jerry */
-+
- ts->queue[i].job = jobid;
- ts->queue[i].size = pjob.size;
- ts->queue[i].page_count = pjob.page_count;
-@@ -904,6 +937,7 @@
-
- /****************************************************************************
- Store the sorted queue representation for later portmon retrieval.
-+ Skip deleted jobs
- ****************************************************************************/
-
- static void store_queue_struct(struct tdb_print_db *pdb, struct traverse_struct *pts)
-@@ -917,13 +951,17 @@
-
- if (max_reported_jobs && (max_reported_jobs < pts->qcount))
- pts->qcount = max_reported_jobs;
-- qcount = pts->qcount;
-+ qcount = 0;
-
- /* Work out the size. */
- data.dsize = 0;
- data.dsize += tdb_pack(NULL, 0, "d", qcount);
-
- for (i = 0; i < pts->qcount; i++) {
-+ if ( queue[i].status == LPQ_DELETED )
-+ continue;
-+
-+ qcount++;
- data.dsize += tdb_pack(NULL, 0, "ddddddff",
- (uint32)queue[i].job,
- (uint32)queue[i].size,
-@@ -941,6 +979,9 @@
- len = 0;
- len += tdb_pack(data.dptr + len, data.dsize - len, "d", qcount);
- for (i = 0; i < pts->qcount; i++) {
-+ if ( queue[i].status == LPQ_DELETED )
-+ continue;
-+
- len += tdb_pack(data.dptr + len, data.dsize - len, "ddddddff",
- (uint32)queue[i].job,
- (uint32)queue[i].size,
-@@ -1057,7 +1098,7 @@
-
- static void print_queue_update_internal( const char *sharename,
- struct printif *current_printif,
-- char *lpq_command )
-+ char *lpq_command, char *lprm_command )
- {
- int i, qcount;
- print_queue_struct *queue = NULL;
-@@ -1135,8 +1176,14 @@
- }
-
- pjob->sysjob = queue[i].job;
-- pjob->status = queue[i].status;
-+
-+ /* don't reset the status on jobs to be deleted */
-+
-+ if ( pjob->status != LPQ_DELETING )
-+ pjob->status = queue[i].status;
-+
- pjob_store(sharename, jobid, pjob);
-+
- check_job_changed(sharename, jcdata, jobid);
- }
-
-@@ -1150,6 +1197,8 @@
- tstruct.total_jobs = 0;
- tstruct.lpq_time = time(NULL);
- tstruct.sharename = sharename;
-+ tstruct.lprm_command = lprm_command;
-+ tstruct.print_if = current_printif;
-
- tdb_traverse(pdb->tdb, traverse_fn_delete, (void *)&tstruct);
-
-@@ -1210,7 +1259,7 @@
-
- static void print_queue_update_with_lock( const char *sharename,
- struct printif *current_printif,
-- char *lpq_command )
-+ char *lpq_command, char *lprm_command )
- {
- fstring keystr;
- struct tdb_print_db *pdb;
-@@ -1277,7 +1326,8 @@
-
- /* do the main work now */
-
-- print_queue_update_internal( sharename, current_printif, lpq_command );
-+ print_queue_update_internal( sharename, current_printif,
-+ lpq_command, lprm_command );
-
- /* Delete our pid from the db. */
- set_updating_pid(sharename, False);
-@@ -1290,14 +1340,15 @@
- static void print_queue_receive(int msg_type, pid_t src, void *buf, size_t msglen)
- {
- fstring sharename;
-- pstring lpqcommand;
-+ pstring lpqcommand, lprmcommand;
- int printing_type;
- size_t len;
-
-- len = tdb_unpack( buf, msglen, "fdP",
-+ len = tdb_unpack( buf, msglen, "fdPP",
- sharename,
- &printing_type,
-- lpqcommand );
-+ lpqcommand,
-+ lprmcommand );
-
- if ( len == -1 ) {
- DEBUG(0,("print_queue_receive: Got invalid print queue update message\n"));
-@@ -1306,7 +1357,7 @@
-
- print_queue_update_with_lock(sharename,
- get_printer_fns_from_type(printing_type),
-- lpqcommand );
-+ lpqcommand, lprmcommand );
-
- return;
- }
-@@ -1376,7 +1427,7 @@
- {
- fstring key;
- fstring sharename;
-- pstring lpqcommand;
-+ pstring lpqcommand, lprmcommand;
- char *buffer = NULL;
- size_t len = 0;
- size_t newlen;
-@@ -1392,6 +1443,10 @@
- string_sub2( lpqcommand, "%p", PRINTERNAME(snum), sizeof(lpqcommand), False, False );
- standard_sub_snum( snum, lpqcommand, sizeof(lpqcommand) );
-
-+ pstrcpy( lprmcommand, lp_lprmcommand(snum));
-+ string_sub2( lprmcommand, "%p", PRINTERNAME(snum), sizeof(lprmcommand), False, False );
-+ standard_sub_snum( snum, lprmcommand, sizeof(lprmcommand) );
-+
- /*
- * Make sure that the background queue process exists.
- * Otherwise just do the update ourselves
-@@ -1400,7 +1455,7 @@
- if ( force || background_lpq_updater_pid == -1 ) {
- DEBUG(4,("print_queue_update: updating queue [%s] myself\n", sharename));
- current_printif = get_printer_fns( snum );
-- print_queue_update_with_lock( sharename, current_printif, lpqcommand );
-+ print_queue_update_with_lock( sharename, current_printif, lpqcommand, lprmcommand );
-
- return;
- }
-@@ -1409,23 +1464,26 @@
-
- /* get the length */
-
-- len = tdb_pack( buffer, len, "fdP",
-+ len = tdb_pack( buffer, len, "fdPP",
- sharename,
- type,
-- lpqcommand );
-+ lpqcommand,
-+ lprmcommand );
-
- buffer = SMB_XMALLOC_ARRAY( char, len );
-
- /* now pack the buffer */
-- newlen = tdb_pack( buffer, len, "fdP",
-+ newlen = tdb_pack( buffer, len, "fdPP",
- sharename,
- type,
-- lpqcommand );
-+ lpqcommand,
-+ lprmcommand );
-
- SMB_ASSERT( newlen == len );
-
- DEBUG(10,("print_queue_update: Sending message -> printer = %s, "
-- "type = %d, lpq command = [%s]\n", sharename, type, lpqcommand ));
-+ "type = %d, lpq command = [%s] lprm command = [%s]\n",
-+ sharename, type, lpqcommand, lprmcommand ));
-
- /* here we set a msg pending record for other smbd processes
- to throttle the number of duplicate print_queue_update msgs
-@@ -1800,8 +1858,6 @@
- int result = 0;
- struct printif *current_printif = get_printer_fns( snum );
-
-- pjob = print_job_find(sharename, jobid);
--
- if (!pjob)
- return False;
-
-@@ -1813,7 +1869,9 @@
- return True;
-
- /* Hrm - we need to be able to cope with deleting a job before it
-- has reached the spooler. */
-+ has reached the spooler. Just mark it as LPQ_DELETING and
-+ let the print_queue_update() code rmeove the record */
-+
-
- if (pjob->sysjob == -1) {
- DEBUG(5, ("attempt to delete job %u not seen by lpr\n", (unsigned int)jobid));
-@@ -1824,24 +1882,31 @@
- pjob->status = LPQ_DELETING;
- pjob_store(sharename, jobid, pjob);
-
-- if (pjob->spooled && pjob->sysjob != -1)
-- result = (*(current_printif->job_delete))(snum, pjob);
--
-- /* Delete the tdb entry if the delete succeeded or the job hasn't
-- been spooled. */
--
-- if (result == 0) {
-- struct tdb_print_db *pdb = get_print_db_byname(sharename);
-- int njobs = 1;
-+ if (pjob->spooled && pjob->sysjob != -1)
-+ {
-+ result = (*(current_printif->job_delete))(
-+ PRINTERNAME(snum),
-+ lp_lprmcommand(snum),
-+ pjob);
-+
-+ /* Delete the tdb entry if the delete succeeded or the job hasn't
-+ been spooled. */
-+
-+ if (result == 0) {
-+ struct tdb_print_db *pdb = get_print_db_byname(sharename);
-+ int njobs = 1;
-
-- if (!pdb)
-- return False;
-- pjob_delete(sharename, jobid);
-- /* Ensure we keep a rough count of the number of total jobs... */
-- tdb_change_int32_atomic(pdb->tdb, "INFO/total_jobs", &njobs, -1);
-- release_print_db(pdb);
-+ if (!pdb)
-+ return False;
-+ pjob_delete(sharename, jobid);
-+ /* Ensure we keep a rough count of the number of total jobs... */
-+ tdb_change_int32_atomic(pdb->tdb, "INFO/total_jobs", &njobs, -1);
-+ release_print_db(pdb);
-+ }
- }
-
-+ remove_from_jobs_changed( sharename, jobid );
-+
- return (result == 0);
- }
-
-@@ -1871,6 +1936,7 @@
- BOOL print_job_delete(struct current_user *user, int snum, uint32 jobid, WERROR *errcode)
- {
- const char* sharename = lp_const_servicename( snum );
-+ struct printjob *pjob;
- BOOL owner, deleted;
- char *fname;
-
-@@ -1923,11 +1989,11 @@
-
- print_queue_update(snum, True);
-
-- deleted = !print_job_exists(sharename, jobid);
-- if ( !deleted )
-+ pjob = print_job_find(sharename, jobid);
-+ if ( pjob && (pjob->status != LPQ_DELETING) )
- *errcode = WERR_ACCESS_DENIED;
-
-- return deleted;
-+ return (pjob == NULL );
- }
-
- /****************************************************************************