diff options
author | Jeremy Allison <jra@samba.org> | 2002-03-20 21:55:57 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-03-20 21:55:57 +0000 |
commit | 60a7d07d63196d140fed14a75c1c5360f3546905 (patch) | |
tree | 3439e9a8a3f4ffb0c623ecfa04ef3c6903fef852 | |
parent | c770faac5fce67dd4b094b2c20a1f10f4793c35d (diff) | |
download | samba-60a7d07d63196d140fed14a75c1c5360f3546905.tar.gz samba-60a7d07d63196d140fed14a75c1c5360f3546905.tar.bz2 samba-60a7d07d63196d140fed14a75c1c5360f3546905.zip |
Print queue entries *must* have queue names, not numbers - numbers are
not identical between different smbds (mr potter, come here and take
your medicine.... :-).
Jeremy.
(This used to be commit 230941d2fbb746d39c00e482e7f600c68aa45efa)
-rw-r--r-- | source3/include/printing.h | 4 | ||||
-rw-r--r-- | source3/printing/printing.c | 37 |
2 files changed, 32 insertions, 9 deletions
diff --git a/source3/include/printing.h b/source3/include/printing.h index a4a6a25cb9..b99f2aeffb 100644 --- a/source3/include/printing.h +++ b/source3/include/printing.h @@ -42,7 +42,7 @@ struct printjob { fstring filename; /* the filename used to spool the file */ fstring jobname; /* the job name given to us by the client */ fstring user; /* the user who started the job */ - int snum; /* service number of printer for this job */ + fstring queuename; /* service number of printer for this job */ }; /* Information for print interfaces */ @@ -71,6 +71,6 @@ extern struct printif cups_printif; #define MAX_CACHE_VALID_TIME 3600 #define PRINT_SPOOL_PREFIX "smbprn." -#define PRINT_DATABASE_VERSION 3 +#define PRINT_DATABASE_VERSION 4 #endif /* PRINTING_H_ */ diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 7e1f59f590..febdd0eec5 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -163,7 +163,7 @@ static void print_unix_job(int snum, print_queue_struct *q) fstrcpy(pj.filename, ""); fstrcpy(pj.jobname, q->fs_file); fstrcpy(pj.user, q->fs_user); - pj.snum = snum; + fstrcpy(pj.queuename, lp_servicename(snum)); print_job_store(jobid, &pj); } @@ -185,7 +185,7 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void memcpy(&jobid, key.dptr, sizeof(jobid)); memcpy(&pjob, data.dptr, sizeof(pjob)); - if (ts->snum != pjob.snum) { + if (!strequal(lp_servicename(ts->snum), pjob.queuename)) { /* this isn't for the queue we are looking at */ ts->total_jobs++; return 0; @@ -556,7 +556,7 @@ int print_job_snum(int jobid) struct printjob *pjob = print_job_find(jobid); if (!pjob) return -1; - return pjob->snum; + return find_service(pjob->queuename); } /**************************************************************************** @@ -624,6 +624,10 @@ static BOOL print_job_delete1(int jobid) return True; snum = print_job_snum(jobid); + if (snum == -1) { + DEBUG(5,("print_job_delete1: unknown service number for jobid %d\n", jobid)); + return False; + } /* Hrm - we need to be able to cope with deleting a job before it has reached the spooler. */ @@ -676,7 +680,12 @@ BOOL print_job_delete(struct current_user *user, int jobid, WERROR *errcode) int snum = print_job_snum(jobid); char *printer_name; BOOL owner; - + + if (snum == -1) { + DEBUG(5,("print_job_delete: unknown service number for jobid %d\n", jobid)); + return False; + } + owner = is_owner(user, jobid); /* Check access against security descriptor or whether the user @@ -720,6 +729,14 @@ BOOL print_job_pause(struct current_user *user, int jobid, WERROR *errcode) if (!pjob->spooled || pjob->sysjob == -1) return False; snum = print_job_snum(jobid); + if (snum == -1) { + DEBUG(5,("print_job_pause: unknown service number for jobid %d\n", jobid)); + return False; + } + if (snum == -1) { + DEBUG(5,("print_job_resume: unknown service number for jobid %d\n", jobid)); + return False; + } if (!is_owner(user, jobid) && !print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) { @@ -984,7 +1001,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname) fstrcpy(pjob.user, uidtoname(user->uid)); } - pjob.snum = snum; + fstrcpy(pjob.queuename, lp_servicename(snum)); /* lock the database */ tdb_lock_bystring(tdb, "INFO/nextjob"); @@ -1088,6 +1105,10 @@ BOOL print_job_end(int jobid, BOOL normal_close) return False; snum = print_job_snum(jobid); + if (snum == -1) { + DEBUG(5,("print_job_end: unknown service number for jobid %d\n", jobid)); + return False; + } if (normal_close && (sys_fstat(pjob->fd, &sbuf) == 0)) { pjob->size = sbuf.st_size; @@ -1155,7 +1176,8 @@ static int traverse_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void * memcpy(&pjob, data.dptr, sizeof(pjob)); /* maybe it isn't for this queue */ - if (ts->snum != pjob.snum) return 0; + if (!strequal(lp_servicename(ts->snum), pjob.queuename)) + return 0; if (ts->qcount >= ts->maxcount) return 0; @@ -1191,7 +1213,8 @@ static int traverse_count_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, memcpy(&pjob, data.dptr, sizeof(pjob)); /* maybe it isn't for this queue */ - if (ts->snum != pjob.snum) return 0; + if (!strequal(lp_servicename(ts->snum), pjob.queuename)) + return 0; ts->count++; |