From c79ca41baf15b4ef7eb287d343b17a53ba41e852 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 25 Mar 2010 17:36:47 -0700 Subject: Fix bug #7288 - SMB job IDs in CUPS job names wrong. Based on a patch from Michael Karcher . I think this is the correct fix. It causes cups_job_submit to use print_parse_jobid(), which I've moved into printing/lpq_parse.c (to allow the link to work). It turns out the old print_parse_jobid() was *broken*, in that the pjob filename was set as an absolute path - not relative to the sharename (due to it not going through the VFS calls). This meant that the original code doing a strncmp on the first part of the filename would always fail - it starts with a "/", not the relative pathname of PRINT_SPOOL_PREFIX ("smbprn."). This fix could fix some other mysterious printing bugs - probably the ones Guenther noticed where job control fails on non-cups backends. Guenther PLEASE CHECK ! Jeremy. --- source3/printing/print_cups.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source3/printing/print_cups.c') diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c index fc1f52a8ef..5c023edf49 100644 --- a/source3/printing/print_cups.c +++ b/source3/printing/print_cups.c @@ -918,6 +918,7 @@ 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; char addr[INET6_ADDRSTRLEN]; DEBUG(5,("cups_job_submit(%d, %p)\n", snum, pjob)); @@ -984,12 +985,20 @@ static int cups_job_submit(int snum, struct printjob *pjob) "job-originating-host-name", NULL, clientname); + /* 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)pjob->smbjob, + (unsigned int)jobid, jobname); if (new_jobname == NULL) { goto out; -- cgit