[SCM] Samba Shared Repository - branch v3-6-test updated

Karolin Seeger kseeger at samba.org
Tue Jul 24 12:55:21 MDT 2012


The branch, v3-6-test has been updated
       via  7ea0c96 s3-printing: fix broken print_job_get_name() return
       via  e0e0f30 s3-torture: Use static printer for smbd spooler test
       via  3258434 s3-printing: use euid for vlp job tracking
       via  76c101c s3-printing: fill print_generic sysjob id on job submission
       via  7531533 s3-printing: pass lpq command to job_submit
       via  f831a9b s3-printing: remove unused print_job_fname()
       via  9ec5b7b s3-printing: pass a talloc ctx to unpack_pjob
       via  9d481ce s3-printing: return talloced print jobs
       via  7ba7b36 s3-printing: clean up print_job_pause/resume interface
       via  41d9357 s3-printing: fix potential print db refcount leak
       via  df9a97b s3-spoolss: remove duplicate "." in smbd spooler path
       via  bb3b489 s3-printing: remove print_parse_jobid()
       via  bf00b21 s3-printing: remove redundant variable set
       via  dd1a076 s3-printing: remove print_parse_jobid() calls from printing.c
       via  5aeda94 s3-printing: rename queue->job sysjob
       via  4dea77d s3-printing: remove print_parse_jobid() from print_cups.c
       via  994da02 s3-printing: store print jobid as part of struct printjob
       via  8b25aa4 torture: add test for smbd print job spooling
      from  8ce2065 s3:smb2_server: implement credit granting similar to windows

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 7ea0c96fe47f3d1b753b5f6cf9591e70eacf502b
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Jun 27 01:23:57 2012 +0200

    s3-printing: fix broken print_job_get_name() return
    
    The last 18 patches address bug #8719 - printing fails in function
    cups_job_submit.

commit e0e0f30958f9cd4dbc8faba901216869bb6601e5
Author: David Disseldorp <ddiss at samba.org>
Date:   Fri Jun 22 18:49:50 2012 +0200

    s3-torture: Use static printer for smbd spooler test

commit 32584347e93e5ff219cce4dd8e13bf8b2868072c
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Jun 21 15:49:55 2012 +0200

    s3-printing: use euid for vlp job tracking
    
    vlp can be called by print_run_command as root with euids set
    appropriately, vlp should use this to track the job owner.

commit 76c101c151303c6063623f5f72073e3af50c3eeb
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Feb 9 12:08:27 2012 +0100

    s3-printing: fill print_generic sysjob id on job submission
    
    Change the generic print backend to fill the printing backend job
    identifier (sysjob) on submission of a new job.
    This is needed to ensure correct mapping of spoolss jobs and entries in
    the backend print queue.
    
    This and the last 13 commits attempt to address bug 8719.

commit 7531533e797a2421b5b1a7b383fbddc70ccad34b
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Feb 8 18:47:11 2012 +0100

    s3-printing: pass lpq command to job_submit
    
    Currently the generic print backend does not fill the printing backend
    job identifier (sysjob) on submission of a new job. The sysjob
    identifier is required to correctly map jobs in the printer queue to
    corresponding spoolss print jobs.
    
    Passing the lpq command to job_submit allows the generic print backend
    to check the printer queue for the new job following submission. This
    behaviour will come in a later commit.

commit f831a9bdbdddd77c3e7ea7e5ae1653567ee12ceb
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Feb 8 17:03:06 2012 +0100

    s3-printing: remove unused print_job_fname()

commit 9ec5b7b9e2d8ac42e4172cbabb7a3b57c1f7ba39
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Feb 8 17:57:02 2012 +0100

    s3-printing: pass a talloc ctx to unpack_pjob
    
    Rather than allocating the devicemode on a null context.

commit 9d481ce29b1f47ffda2696862109eebfe942097c
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Feb 8 16:55:40 2012 +0100

    s3-printing: return talloced print jobs
    
    print_job_find() currently returns print jobs to callers via a
    statically allocated variable, this is particularly messy as the
    device mode is talloced under the static variable.
    
    This change adds or passes a talloc context to all callers, giving them
    ownership of the returned print job.

commit 7ba7b3678cd505dc4ccef25b6fc4db7bd4cc3442
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Feb 8 15:01:15 2012 +0100

    s3-printing: clean up print_job_pause/resume interface
    
    Currently both return a bool and sometimes set a werr pointer argument,
    always return werror instead.

commit 41d935744a03435337a90ab1477a7a54f96ca972
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Feb 8 13:45:40 2012 +0100

    s3-printing: fix potential print db refcount leak

commit df9a97b81f2a5520ed0ef79d9aeb3a014799e89c
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Feb 1 13:21:04 2012 +0100

    s3-spoolss: remove duplicate "." in smbd spooler path

commit bb3b4890c77bcf1c50f4f27f10e5f5812ae24a76
Author: David Disseldorp <ddiss at samba.org>
Date:   Mon Jan 30 17:35:28 2012 +0100

    s3-printing: remove print_parse_jobid()
    
    With all callers fixed, it is now safe to remove.

commit bf00b2155bc3e42946a3b2c6b9f88606b77f4bc8
Author: David Disseldorp <ddiss at samba.org>
Date:   Mon Jan 30 16:05:21 2012 +0100

    s3-printing: remove redundant variable set

commit dd1a076efe8c2118827c04d8f276b85893888be7
Author: David Disseldorp <ddiss at samba.org>
Date:   Mon Jan 30 13:35:21 2012 +0100

    s3-printing: remove print_parse_jobid() calls from printing.c
    
    In all cases the spoolss layer job id can be determinded from the
    printing subsystem allocated job identifier (sysjob).

commit 5aeda94f201ce8794d09f16a314b4044c5370f07
Author: David Disseldorp <ddiss at samba.org>
Date:   Fri Jan 27 12:33:27 2012 +0100

    s3-printing: rename queue->job sysjob
    
    Print jobs maintain two job identifiers, the jobid allocated by the
    spoolss layer (pj->jobid), and the job identifier defined by the
    printing backend (pj->sysjob).
    
    Printer job queues currently only contain a single job identifier
    variable (queue->job), the variable is sometimes representative of the
    spoolss layer job identifier, and more often representative of the
    printing backend id.
    
    This change renames the queue job identifier from queue->job to
    queue->sysjob, in preparation for a change to only store the printing
    backend identifier.

commit 4dea77df91c418633a2a411fd5be2cc9bb3a8eea
Author: David Disseldorp <ddiss at samba.org>
Date:   Mon Jan 30 13:44:33 2012 +0100

    s3-printing: remove print_parse_jobid() from print_cups.c
    
    The spoolss print job identifier is now passed to the cups layer via
    struct printjob, therefore it is no longer necessary to parse the job
    filename to determine it.

commit 994da027ee96811e2d5a025b667d8c6f85442ada
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Jan 26 15:28:34 2012 +0100

    s3-printing: store print jobid as part of struct printjob
    
    Printing code in some places relies upon the spool-file format to
    retrieve the print jobid. By storing the jobid as part of struct
    printjob, and hence in the printing TDB, we can move away from this ugly
    behaviour.

commit 8b25aa4feb00c6b9a1a7e5fdd61ffffa9fc4d1f5
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Jun 21 17:12:23 2012 +0200

    torture: add test for smbd print job spooling
    
    Clients can print by performing file IO on a printer share, rather than
    issuing spoolss RPCs.
    This commit attempts to reproduce bug 8719.

-----------------------------------------------------------------------

Summary of changes:
 source3/include/printing.h                  |   23 +-
 source3/printing/lpq_parse.c                |   41 +--
 source3/printing/print_cups.c               |   18 +-
 source3/printing/print_generic.c            |  149 +++++---
 source3/printing/print_iprint.c             |    6 +-
 source3/printing/printing.c                 |  504 +++++++++++++++++----------
 source3/printing/printspoolss.c             |   11 +-
 source3/printing/tests/vlp.c                |    3 +-
 source3/rpc_server/spoolss/srv_spoolss_nt.c |   30 +-
 source4/torture/rpc/spoolss.c               |   80 +++++
 10 files changed, 545 insertions(+), 320 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/printing.h b/source3/include/printing.h
index bba7d53..c511fa2 100644
--- a/source3/include/printing.h
+++ b/source3/include/printing.h
@@ -46,7 +46,7 @@ enum {
 };
 
 typedef struct _print_queue_struct {
-	int job;		/* normally the UNIX jobid -- see note in
+	int sysjob;		/* normally the UNIX jobid -- see note in
 				   printing.c:traverse_fn_delete() */
 	int size;
 	int page_count;
@@ -68,6 +68,7 @@ typedef struct {
 /* Information for print jobs */
 struct printjob {
 	pid_t pid; /* which process launched the job */
+	uint32_t jobid; /* the spoolss print job identifier */
 	int sysjob; /* the system (lp) job number */
 	int fd; /* file descriptor of open file if open */
 	time_t starttime; /* when the job started spooling */
@@ -100,7 +101,9 @@ struct printif
   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);
+  int (*job_submit)(int snum, struct printjob *pjob,
+		    enum printing_types printing_type,
+		    char *lpq_command);
 };
 
 extern struct printif	generic_printif;
@@ -123,7 +126,7 @@ extern struct printif	iprint_printif;
 #ifndef PRINT_SPOOL_PREFIX
 #define PRINT_SPOOL_PREFIX "smbprn."
 #endif
-#define PRINT_DATABASE_VERSION 7
+#define PRINT_DATABASE_VERSION 8
 
 #ifdef AIX
 #define DEFAULT_PRINTING PRINT_AIX
@@ -194,8 +197,9 @@ uint32 sysjob_to_jobid(int unix_jobid);
 bool print_notify_register_pid(int snum);
 bool print_notify_deregister_pid(int snum);
 bool print_job_exists(const char* sharename, uint32 jobid);
-char *print_job_fname(const char* sharename, uint32 jobid);
-struct spoolss_DeviceMode *print_job_devmode(const char* sharename, uint32 jobid);
+struct spoolss_DeviceMode *print_job_devmode(TALLOC_CTX *mem_ctx,
+					     const char *sharename,
+					     uint32 jobid);
 bool print_job_set_name(struct tevent_context *ev,
 			struct messaging_context *msg_ctx,
 			const char *sharename, uint32 jobid, const char *name);
@@ -203,12 +207,12 @@ bool print_job_get_name(TALLOC_CTX *mem_ctx, const char *sharename, uint32_t job
 WERROR print_job_delete(const struct auth_serversupplied_info *server_info,
 			struct messaging_context *msg_ctx,
 			int snum, uint32_t jobid);
-bool print_job_pause(const struct auth_serversupplied_info *server_info,
+WERROR print_job_pause(const struct auth_serversupplied_info *server_info,
 		     struct messaging_context *msg_ctx,
-		     int snum, uint32 jobid, WERROR *errcode);
-bool print_job_resume(const struct auth_serversupplied_info *server_info,
+		     int snum, uint32 jobid);
+WERROR print_job_resume(const struct auth_serversupplied_info *server_info,
 		      struct messaging_context *msg_ctx,
-		      int snum, uint32 jobid, WERROR *errcode);
+		      int snum, uint32 jobid);
 ssize_t print_job_write(struct tevent_context *ev,
 			struct messaging_context *msg_ctx,
 			int snum, uint32 jobid, const char *buf, size_t size);
@@ -245,7 +249,6 @@ void printing_end(void);
 bool parse_lpq_entry(enum printing_types printing_type,char *line,
 		     print_queue_struct *buf,
 		     print_status_struct *status,bool first);
-uint32_t print_parse_jobid(const char *fname);
 
 /* The following definitions come from printing/printing_db.c  */
 
diff --git a/source3/printing/lpq_parse.c b/source3/printing/lpq_parse.c
index 16b9b09..06790d8 100644
--- a/source3/printing/lpq_parse.c
+++ b/source3/printing/lpq_parse.c
@@ -164,7 +164,7 @@ static bool parse_lpq_bsd(char *line,print_queue_struct *buf,bool first)
 		return False;
 	}
 
-	buf->job = atoi(tok[JOBTOK]);
+	buf->sysjob = atoi(tok[JOBTOK]);
 	buf->size = atoi(tok[TOTALTOK]);
 	buf->status = strequal(tok[RANKTOK],"active")?LPQ_PRINTING:LPQ_QUEUED;
 	buf->time = time(NULL);
@@ -281,7 +281,7 @@ static bool parse_lpq_lprng(char *line,print_queue_struct *buf,bool first)
 		return False;
 	}
 
-	buf->job  = atoi(tokarr[LPRNG_JOBTOK]);
+	buf->sysjob = atoi(tokarr[LPRNG_JOBTOK]);
 	buf->size = atoi(tokarr[LPRNG_TOTALTOK]);
 
 	if (strequal(tokarr[LPRNG_RANKTOK],"active")) {
@@ -384,7 +384,7 @@ static bool parse_lpq_aix(char *line,print_queue_struct *buf,bool first)
 				}
 			}
 
-			buf->job = atoi(tok[1]);
+			buf->sysjob = atoi(tok[1]);
 			buf->status = strequal(tok[0],"HELD")?LPQ_PAUSED:LPQ_QUEUED;
 			buf->priority = 0;
 			buf->time = time(NULL);
@@ -420,7 +420,7 @@ static bool parse_lpq_aix(char *line,print_queue_struct *buf,bool first)
 			}
 		}
 
-		buf->job = atoi(tok[3]);
+		buf->sysjob = atoi(tok[3]);
 		buf->status = strequal(tok[2],"RUNNING")?LPQ_PRINTING:LPQ_QUEUED;
 		buf->priority = 0;
 		buf->time = time(NULL);
@@ -511,7 +511,7 @@ static bool parse_lpq_hpux(char *line, print_queue_struct *buf, bool first)
 
 		/* fill things from header line */
 		buf->time = jobtime;
-		buf->job = jobid;
+		buf->sysjob = jobid;
 		buf->status = jobstat;
 		buf->priority = jobprio;
 		if (jobuser) {
@@ -651,7 +651,7 @@ static bool parse_lpq_sysv(char *line,print_queue_struct *buf,bool first)
 		tok[2] = p+1;
 	}
 
-	buf->job = atoi(tok[1]);
+	buf->sysjob = atoi(tok[1]);
 	buf->size = atoi(tok[3]);
 	if (count > 7 && strequal(tok[7],"on")) {
 		buf->status = LPQ_PRINTING;
@@ -726,7 +726,7 @@ static bool parse_lpq_qnx(char *line,print_queue_struct *buf,bool first)
 		}
 	}
 
-	buf->job = atoi(tok[2]);
+	buf->sysjob = atoi(tok[2]);
 	buf->size = atoi(tok[4]);
 	buf->status = strequal(tok[3],"active")?LPQ_PRINTING:LPQ_QUEUED;
 	buf->priority = 0;
@@ -806,7 +806,7 @@ static bool parse_lpq_plp(char *line,print_queue_struct *buf,bool first)
 		}
 	}
 
-	buf->job = atoi(tok[4]);
+	buf->sysjob = atoi(tok[4]);
 
 	buf->size = atoi(tok[7]);
 	if (strchr_m(tok[7],'K')) {
@@ -896,7 +896,7 @@ static bool parse_lpq_nt(char *line,print_queue_struct *buf,bool first)
 	parse_line->space3 = '\0';
 	trim_char(parse_line->jobname, '\0', ' ');
 
-	buf->job = atoi(parse_line->jobid);
+	buf->sysjob = atoi(parse_line->jobid);
 	buf->priority = 0;
 	buf->size = atoi(parse_line->size);
 	buf->time = time(NULL);
@@ -957,7 +957,7 @@ static bool parse_lpq_os2(char *line,print_queue_struct *buf,bool first)
 	}
 
 	/* Get the jobid */
-	buf->job = atoi(parse_line->jobid);
+	buf->sysjob = atoi(parse_line->jobid);
 
 	/* Get the job name */
 	parse_line->space2[0] = '\0';
@@ -1023,7 +1023,7 @@ static bool parse_lpq_vlp(char *line,print_queue_struct *buf,bool first)
 	while(next_token_talloc(frame, &cline, &tok, NULL)) {
 		switch (toknum) {
 		case 0:
-			buf->job = atoi(tok);
+			buf->sysjob = atoi(tok);
 			break;
 		case 1:
 			buf->size = atoi(tok);
@@ -1152,22 +1152,3 @@ bool parse_lpq_entry(enum printing_types printing_type,char *line,
 	return ret;
 }
 
-/****************************************************************************
- Parse a file name from the system spooler to generate a jobid.
-****************************************************************************/
-
-uint32_t print_parse_jobid(const char *fname)
-{
-	int jobid;
-	const char *p = strstr_m(fname,PRINT_SPOOL_PREFIX);
-
-	if (!p) {
-		return (uint32_t)-1;
-	}
-	p += strlen(PRINT_SPOOL_PREFIX);
-	jobid = atoi(p);
-	if (jobid <= 0) {
-		return (uint32_t)-1;
-	}
-	return (uint32_t)jobid;
-}
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index ff19de2..9f23866 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -852,7 +852,9 @@ static int cups_job_resume(int snum, struct printjob *pjob)
  * 'cups_job_submit()' - Submit a job for printing.
  */
 
-static int cups_job_submit(int snum, struct printjob *pjob)
+static int cups_job_submit(int snum, struct printjob *pjob,
+			   enum printing_types printing_type,
+			   char *lpq_cmd)
 {
 	TALLOC_CTX *frame = talloc_stackframe();
 	int		ret = 1;		/* Return value */
@@ -871,7 +873,6 @@ static int cups_job_submit(int snum, struct printjob *pjob)
 	char *cupsoptions = NULL;
 	char *filename = NULL;
 	size_t size;
-	uint32_t jobid = (uint32_t)-1;
 
 	DEBUG(5,("cups_job_submit(%d, %p)\n", snum, pjob));
 
@@ -933,21 +934,12 @@ static int cups_job_submit(int snum, struct printjob *pjob)
 	             "job-originating-host-name", NULL,
 		     pjob->clientmachine);
 
-	/* Get the jobid from the filename. */
-	jobid = print_parse_jobid(pjob->filename);
-	if (jobid == (uint32_t)-1) {
-		DEBUG(0,("cups_job_submit: failed to parse jobid from name %s\n",
-				pjob->filename ));
-		jobid = 0;
-	}
-
 	if (!push_utf8_talloc(frame, &jobname, pjob->jobname, &size)) {
 		goto out;
 	}
 	new_jobname = talloc_asprintf(frame,
 			"%s%.8u %s", PRINT_SPOOL_PREFIX,
-			(unsigned int)jobid,
-			jobname);
+			pjob->jobid, jobname);
 	if (new_jobname == NULL) {
 		goto out;
 	}
@@ -1253,7 +1245,7 @@ static int cups_queue_get(const char *sharename,
 				continue;
 		}
 
-		temp->job      = job_id;
+		temp->sysjob   = job_id;
 		temp->size     = job_k_octets * 1024;
 		temp->status   = job_status == IPP_JOB_PENDING ? LPQ_QUEUED :
 				 job_status == IPP_JOB_STOPPED ? LPQ_PAUSED :
diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c
index b925bed..aac3892 100644
--- a/source3/printing/print_generic.c
+++ b/source3/printing/print_generic.c
@@ -139,10 +139,68 @@ static int generic_job_resume(int snum, struct printjob *pjob)
 }
 
 /****************************************************************************
+get the current list of queued jobs
+****************************************************************************/
+static int generic_queue_get(const char *printer_name,
+                             enum printing_types printing_type,
+                             char *lpq_command,
+                             print_queue_struct **q,
+                             print_status_struct *status)
+{
+	char **qlines;
+	int fd;
+	int numlines, i, qcount;
+	print_queue_struct *queue = NULL;
+
+	/* never do substitution when running the 'lpq command' since we can't
+	   get it rigt when using the background update daemon.  Make the caller
+	   do it before passing off the command string to us here. */
+
+	print_run_command(-1, printer_name, False, lpq_command, &fd, NULL);
+
+	if (fd == -1) {
+		DEBUG(5,("generic_queue_get: Can't read print queue status for printer %s\n",
+			printer_name ));
+		return 0;
+	}
+
+	numlines = 0;
+	qlines = fd_lines_load(fd, &numlines,0,NULL);
+	close(fd);
+
+	/* turn the lpq output into a series of job structures */
+	qcount = 0;
+	ZERO_STRUCTP(status);
+	if (numlines && qlines) {
+		queue = SMB_MALLOC_ARRAY(print_queue_struct, numlines+1);
+		if (!queue) {
+			TALLOC_FREE(qlines);
+			*q = NULL;
+			return 0;
+		}
+		memset(queue, '\0', sizeof(print_queue_struct)*(numlines+1));
+
+		for (i=0; i<numlines; i++) {
+			/* parse the line */
+			if (parse_lpq_entry(printing_type,qlines[i],
+					    &queue[qcount],status,qcount==0)) {
+				qcount++;
+			}
+		}
+	}
+
+	TALLOC_FREE(qlines);
+        *q = queue;
+	return qcount;
+}
+
+/****************************************************************************
  Submit a file for printing - called from print_job_end()
 ****************************************************************************/
 
-static int generic_job_submit(int snum, struct printjob *pjob)
+static int generic_job_submit(int snum, struct printjob *pjob,
+			      enum printing_types printing_type,
+			      char *lpq_cmd)
 {
 	int ret = -1;
 	char *current_directory = NULL;
@@ -152,6 +210,8 @@ static int generic_job_submit(int snum, struct printjob *pjob)
 	char *jobname = NULL;
 	TALLOC_CTX *ctx = talloc_tos();
 	fstring job_page_count, job_size;
+	print_queue_struct *q;
+	print_status_struct status;
 
 	/* we print from the directory path to give the best chance of
            parsing the lpq output */
@@ -202,6 +262,36 @@ static int generic_job_submit(int snum, struct printjob *pjob)
 			"%z", job_size,
 			"%c", job_page_count,
 			NULL);
+	if (ret != 0) {
+		ret = -1;
+		goto out;
+	}
+
+	/*
+	 * check the queue for the newly submitted job, this allows us to
+	 * determine the backend job identifier (sysjob).
+	 */
+	pjob->sysjob = -1;
+	ret = generic_queue_get(lp_printername(snum), printing_type, lpq_cmd,
+				&q, &status);
+	if (ret > 0) {
+		int i;
+		for (i = 0; i < ret; i++) {
+			if (strcmp(q[i].fs_file, p) == 0) {
+				pjob->sysjob = q[i].sysjob;
+				DEBUG(5, ("new job %u (%s) matches sysjob %d\n",
+					  pjob->jobid, jobname, pjob->sysjob));
+				break;
+			}
+		}
+		SAFE_FREE(q);
+		ret = 0;
+	}
+	if (pjob->sysjob == -1) {
+		DEBUG(0, ("failed to get sysjob for job %u (%s), tracking as "
+			  "Unix job\n", pjob->jobid, jobname));
+	}
+
 
  out:
 
@@ -212,63 +302,6 @@ static int generic_job_submit(int snum, struct printjob *pjob)
         return ret;
 }
 
-
-/****************************************************************************
-get the current list of queued jobs
-****************************************************************************/
-static int generic_queue_get(const char *printer_name, 
-                             enum printing_types printing_type,
-                             char *lpq_command,
-                             print_queue_struct **q, 
-                             print_status_struct *status)
-{
-	char **qlines;
-	int fd;
-	int numlines, i, qcount;
-	print_queue_struct *queue = NULL;
-	
-	/* never do substitution when running the 'lpq command' since we can't
-	   get it rigt when using the background update daemon.  Make the caller 
-	   do it before passing off the command string to us here. */
-
-	print_run_command(-1, printer_name, False, lpq_command, &fd, NULL);
-
-	if (fd == -1) {
-		DEBUG(5,("generic_queue_get: Can't read print queue status for printer %s\n",
-			printer_name ));
-		return 0;
-	}
-	
-	numlines = 0;
-	qlines = fd_lines_load(fd, &numlines,0,NULL);
-	close(fd);
-
-	/* turn the lpq output into a series of job structures */
-	qcount = 0;
-	ZERO_STRUCTP(status);
-	if (numlines && qlines) {
-		queue = SMB_MALLOC_ARRAY(print_queue_struct, numlines+1);
-		if (!queue) {
-			TALLOC_FREE(qlines);
-			*q = NULL;
-			return 0;
-		}
-		memset(queue, '\0', sizeof(print_queue_struct)*(numlines+1));
-
-		for (i=0; i<numlines; i++) {
-			/* parse the line */
-			if (parse_lpq_entry(printing_type,qlines[i],
-					    &queue[qcount],status,qcount==0)) {
-				qcount++;
-			}
-		}		
-	}
-
-	TALLOC_FREE(qlines);
-        *q = queue;
-	return qcount;
-}
-
 /****************************************************************************
  pause a queue
 ****************************************************************************/
diff --git a/source3/printing/print_iprint.c b/source3/printing/print_iprint.c
index 1392cba..5ca77f9 100644
--- a/source3/printing/print_iprint.c
+++ b/source3/printing/print_iprint.c
@@ -722,7 +722,9 @@ static int iprint_job_resume(int snum, struct printjob *pjob)
  * 'iprint_job_submit()' - Submit a job for printing.
  */
 
-static int iprint_job_submit(int snum, struct printjob *pjob)
+static int iprint_job_submit(int snum, struct printjob *pjob,
+			     enum printing_types printing_type,
+			     char *lpq_cmd)
 {
 	int		ret = 1;		/* Return value */
 	http_t		*http = NULL;		/* HTTP connection to server */
@@ -1162,7 +1164,7 @@ static int iprint_queue_get(const char *sharename,
 				continue;
 		}
 
-		temp->job      = job_id;
+		temp->sysjob   = job_id;
 		temp->size     = job_k_octets * 1024;
 		temp->status   = job_status == IPP_JOB_PENDING ? LPQ_QUEUED :
 		                 job_status == IPP_JOB_STOPPED ? LPQ_PAUSED :
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index f15bd4f..aa5b41d 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -373,18 +373,21 @@ done:
  unpack a pjob from a tdb buffer
 ***********************************************************************/
 
-static int unpack_pjob( uint8 *buf, int buflen, struct printjob *pjob )
+static int unpack_pjob(TALLOC_CTX *mem_ctx, uint8 *buf, int buflen,
+		       struct printjob *pjob)
 {
 	int	len = 0;
 	int	used;
-	uint32 pjpid, pjsysjob, pjfd, pjstarttime, pjstatus;
+	uint32 pjpid, pjjobid, pjsysjob, pjfd, pjstarttime, pjstatus;
 	uint32 pjsize, pjpage_count, pjspooled, pjsmbjob;
 
-	if ( !buf || !pjob )
+	if (!buf || !pjob) {
 		return -1;
+	}
 
-	len += tdb_unpack(buf+len, buflen-len, "dddddddddfffff",
+	len += tdb_unpack(buf+len, buflen-len, "ddddddddddfffff",
 				&pjpid,
+				&pjjobid,
 				&pjsysjob,
 				&pjfd,
 				&pjstarttime,
@@ -399,10 +402,11 @@ static int unpack_pjob( uint8 *buf, int buflen, struct printjob *pjob )
 				pjob->clientmachine,
 				pjob->queuename);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list