summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/printing/printfsp.c8
-rw-r--r--source/printing/printing.c2
-rw-r--r--source/smbd/trans2.c20
3 files changed, 27 insertions, 3 deletions
diff --git a/source/printing/printfsp.c b/source/printing/printfsp.c
index f9042075425..efb97be9194 100644
--- a/source/printing/printfsp.c
+++ b/source/printing/printfsp.c
@@ -82,6 +82,14 @@ print a file - called on closing the file
****************************************************************************/
void print_fsp_end(files_struct *fsp, BOOL normal_close)
{
+ if (fsp->share_mode == FILE_DELETE_ON_CLOSE) {
+ /*
+ * Truncate the job. print_job_end will take
+ * care of deleting it for us. JRA.
+ */
+ sys_ftruncate(fsp->fd, 0);
+ }
+
print_job_end(fsp->print_jobid, normal_close);
if (fsp->fsp_name) {
diff --git a/source/printing/printing.c b/source/printing/printing.c
index 1aa8ced5a5d..ba01a827fbc 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -986,6 +986,8 @@ BOOL print_job_end(int jobid, BOOL normal_close)
* Not a normal close or we couldn't stat the job file,
* so something has gone wrong. Cleanup.
*/
+ close(pjob->fd);
+ pjob->fd = -1;
goto fail;
}
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 15bdc8b671c..6cc65d1b21b 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -1592,9 +1592,6 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
BOOL bad_path = False;
files_struct *fsp = NULL;
- if (!CAN_WRITE(conn))
- return(ERROR(ERRSRV,ERRaccess));
-
if (tran_call == TRANSACT2_SETFILEINFO) {
fsp = file_fsp(params,0);
info_level = SVAL(params,2);
@@ -1616,6 +1613,20 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
}
return(UNIXERROR(ERRDOS,ERRbadpath));
}
+ } else if (fsp->print_file) {
+ /*
+ * Doing a DELETE_ON_CLOSE should cancel a print job.
+ */
+ if ((info_level == SMB_SET_FILE_DISPOSITION_INFO) && CVAL(pdata,0)) {
+ fsp->share_mode = FILE_DELETE_ON_CLOSE;
+
+ DEBUG(3,("call_trans2setfilepathinfo: Cancelling print job (%s)\n",
+ fsp->fsp_name ));
+
+ SSVAL(params,0,0);
+ send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0);
+ return(-1);
+ }
} else {
/*
* Original code - this is an open file.
@@ -1658,6 +1669,9 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
}
}
+ if (!CAN_WRITE(conn))
+ return(ERROR(ERRSRV,ERRaccess));
+
DEBUG(3,("call_trans2setfilepathinfo(%d) %s info_level=%d totdata=%d\n",
tran_call,fname,info_level,total_data));