s3: smbd: printing: Re-implement delete-on-close semantics for print files missing...
authorJeremy Allison <jra@samba.org>
Thu, 31 May 2018 17:35:48 +0000 (10:35 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 1 Jun 2018 18:32:03 +0000 (20:32 +0200)
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

selftest/knownfail.d/smbspool [deleted file]
source3/printing/printspoolss.c

diff --git a/selftest/knownfail.d/smbspool b/selftest/knownfail.d/smbspool
deleted file mode 100644 (file)
index a61fc4d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.blackbox.smbspool.delete.on.close
index 6000202..9d565de 100644 (file)
@@ -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) {