summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2018-05-31 10:35:48 -0700
committerKarolin Seeger <kseeger@samba.org>2018-06-20 09:22:24 +0200
commit6121a6fec193b28e04329a4fde4ea058b9b7cfec (patch)
tree97fd00ed760b42e9ec1fca6569c6f3bf09725603
parente5ffffddfe580698624c832ad9b2e32c93fd5974 (diff)
downloadsamba-6121a6fec193b28e04329a4fde4ea058b9b7cfec.tar.gz
s3: smbd: printing: Re-implement delete-on-close semantics for print files missing since 3.5.x.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13457 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Jun 1 20:32:03 CEST 2018 on sn-devel-144 (cherry picked from commit 364175b359f018c8641359440fa07b0ea567b045)
-rw-r--r--selftest/knownfail.d/smbspool1
-rw-r--r--source3/printing/printspoolss.c17
2 files changed, 17 insertions, 1 deletions
diff --git a/selftest/knownfail.d/smbspool b/selftest/knownfail.d/smbspool
deleted file mode 100644
index a61fc4dca5d..00000000000
--- a/selftest/knownfail.d/smbspool
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.blackbox.smbspool.delete.on.close
diff --git a/source3/printing/printspoolss.c b/source3/printing/printspoolss.c
index 60002020351..9d565de120a 100644
--- a/source3/printing/printspoolss.c
+++ b/source3/printing/printspoolss.c
@@ -309,6 +309,23 @@ void print_spool_end(files_struct *fsp, enum file_close_type close_type)
WERROR werr;
struct dcerpc_binding_handle *b = NULL;
+ if (fsp->fh->private_options &
+ NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE) {
+ int ret;
+
+ /*
+ * Job was requested to be cancelled by setting
+ * delete on close so truncate the job file.
+ * print_job_end() which is called from
+ * _spoolss_EndDocPrinter() will take
+ * care of deleting it for us.
+ */
+ ret = ftruncate(fsp->fh->fd, 0);
+ if (ret == -1) {
+ DBG_ERR("ftruncate failed: %s\n", strerror(errno));
+ }
+ }
+
b = fsp->conn->spoolss_pipe->binding_handle;
switch (close_type) {