summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid O'Neill <dmo@samba.org>2001-01-22 16:59:24 +0000
committerDavid O'Neill <dmo@samba.org>2001-01-22 16:59:24 +0000
commit7599c82cceec73fe33b6daa4a908937aed768f80 (patch)
tree60b0c2b47eb9d8734b0045630f9f027af6095cb0
parent912dbe49ce25563413746d3bcb62ac3f3cd0f4cb (diff)
downloadsamba-7599c82cceec73fe33b6daa4a908937aed768f80.tar.gz
samba-7599c82cceec73fe33b6daa4a908937aed768f80.tar.bz2
samba-7599c82cceec73fe33b6daa4a908937aed768f80.zip
Changes from APPLIANCE_HEAD:
source/smbd/lanman.c - cleanup and bug fix for win9x print queue purge. source/printing/printing.c - cleanup and bug fix for win9x print queue purge. - print_job_end() changed to cleanup spool file in the event of a failure returned from the print_run_command() (This used to be commit 0235fbef37b400a2bf875163878e497282cd1739)
-rw-r--r--source3/printing/printing.c50
-rw-r--r--source3/smbd/lanman.c7
2 files changed, 37 insertions, 20 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index a22c8b749a..75d61accd1 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -534,6 +534,14 @@ static BOOL print_job_delete1(int jobid)
snum = print_job_snum(jobid);
+ /* Hrm - we need to be able to cope with deleting a job before it
+ has reached the spooler. */
+
+ if (pjob->sysjob == -1) {
+ DEBUG(5, ("attempt to delete job %d not seen by lpr\n",
+ jobid));
+ }
+
if (pjob->spooled && pjob->sysjob != -1) {
/* need to delete the spooled entry */
fstring jobstr;
@@ -906,7 +914,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname)
BOOL print_job_end(int jobid)
{
struct printjob *pjob = print_job_find(jobid);
- int snum;
+ int snum, ret;
SMB_STRUCT_STAT sbuf;
pstring current_directory;
pstring print_directory;
@@ -958,7 +966,7 @@ BOOL print_job_end(int jobid)
pstring_sub(jobname, "'", "_");
/* send it to the system spooler */
- print_run_command(snum,
+ ret = print_run_command(snum,
lp_printcommand(snum), NULL,
"%s", p,
"%J", jobname,
@@ -967,19 +975,23 @@ BOOL print_job_end(int jobid)
chdir(wd);
- pjob->spooled = True;
- print_job_store(jobid, pjob);
-
- /* make sure the database is up to date */
- if (print_cache_expired(snum)) print_queue_update(snum);
-
- /* Send a printer notify message */
-
- printer_name = PRINTERNAME(snum);
-
- message_send_all(conn_tdb_ctx(),MSG_PRINTER_NOTIFY, printer_name, strlen(printer_name) + 1, False);
-
- return True;
+ if (ret == 0) {
+ /* The print job has been sucessfully handed over to the back-end */
+
+ pjob->spooled = True;
+ print_job_store(jobid, pjob);
+
+ /* make sure the database is up to date */
+ if (print_cache_expired(snum)) print_queue_update(snum);
+
+ return True;
+ } else {
+ /* The print job was not succesfully started. Cleanup */
+ /* Still need to add proper error return propagation! 010122:JRR */
+ unlink(pjob->filename);
+ tdb_delete(tdb, print_key(jobid));
+ return False;
+ }
}
/* utility fn to enumerate the print queue */
@@ -1212,11 +1224,15 @@ BOOL print_queue_purge(struct current_user *user, int snum, int *errcode)
print_status_struct status;
char *printer_name;
int njobs, i;
+ BOOL can_job_admin;
+ can_job_admin = print_access_check(user, snum, JOB_ACCESS_ADMINISTER);
njobs = print_queue_status(snum, &queue, &status);
- if (print_access_check(user, snum, PRINTER_ACCESS_ADMINISTER)) {
- for (i=0;i<njobs;i++) {
+ for (i=0;i<njobs;i++) {
+ BOOL owner = is_owner(user, queue[i].job);
+
+ if (owner || can_job_admin) {
print_job_delete1(queue[i].job);
}
}
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index a2178f052b..fd59f4603a 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -1947,6 +1947,7 @@ static BOOL api_WPrintQueueCtrl(connection_struct *conn,uint16 vuid, char *param
char *QueueName = skip_string(str2,1);
int errcode = NERR_notsupported;
int snum;
+ extern struct current_user current_user;
/* check it's a supported varient */
if (!(strcsequal(str1,"z") && strcsequal(str2,"")))
@@ -1965,13 +1966,13 @@ static BOOL api_WPrintQueueCtrl(connection_struct *conn,uint16 vuid, char *param
switch (function) {
case 74: /* Pause queue */
- if (print_queue_pause(NULL, snum, &errcode)) errcode = NERR_Success;
+ if (print_queue_pause(&current_user, snum, &errcode)) errcode = NERR_Success;
break;
case 75: /* Resume queue */
- if (print_queue_resume(NULL, snum, &errcode)) errcode = NERR_Success;
+ if (print_queue_resume(&current_user, snum, &errcode)) errcode = NERR_Success;
break;
case 103: /* Purge */
- if (print_queue_purge(NULL, snum, &errcode)) errcode = NERR_Success;
+ if (print_queue_purge(&current_user, snum, &errcode)) errcode = NERR_Success;
break;
}