summaryrefslogtreecommitdiffstats
path: root/source/printing
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-02-22 01:30:39 +0000
committerJeremy Allison <jra@samba.org>2001-02-22 01:30:39 +0000
commit01ca93e6d731dae90d2797eb8c63f8ab650d9ed8 (patch)
tree5f9320ebfc346735c3f4fce596b330b396b05ba2 /source/printing
parenta77e31f7d8794f83c16d880fd22c3a9d6efb89c8 (diff)
downloadsamba-01ca93e6d731dae90d2797eb8c63f8ab650d9ed8.tar.gz
samba-01ca93e6d731dae90d2797eb8c63f8ab650d9ed8.tar.xz
samba-01ca93e6d731dae90d2797eb8c63f8ab650d9ed8.zip
Fixed file descriptor leak in error conditions on print close.
NT sends "delete on close" to cancel a print job copied from the command line. Cope with this. Jeremy.
Diffstat (limited to 'source/printing')
-rw-r--r--source/printing/printfsp.c8
-rw-r--r--source/printing/printing.c2
2 files changed, 10 insertions, 0 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;
}