The Samba-Bugzilla – Attachment 14236 Details for
Bug 13457
Setting DELETE_ON_CLOSE on a print file handle should cancel (lprm) the job.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
git-am fix for 4.8.next.
look (text/plain), 7.11 KB, created by
Jeremy Allison
on 2018-06-15 17:53:36 UTC
(
hide
)
Description:
git-am fix for 4.8.next.
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2018-06-15 17:53:36 UTC
Size:
7.11 KB
patch
obsolete
>From 4e1b146caeeb293d767e58ffc140a7c64fdd2d3c Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Thu, 31 May 2018 10:18:21 -0700 >Subject: [PATCH 1/2] s3: torture: Add DELETE-PRINT test. > >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> >(cherry picked from commit 42f049858f2037aab5b2097036db3e0375fdbf30) >--- > selftest/knownfail.d/smbspool | 1 + > source3/script/tests/test_smbspool.sh | 63 +++++++++++++++++++++++ > source3/torture/torture.c | 73 +++++++++++++++++++++++++++ > 3 files changed, 137 insertions(+) > create mode 100644 selftest/knownfail.d/smbspool > >diff --git a/selftest/knownfail.d/smbspool b/selftest/knownfail.d/smbspool >new file mode 100644 >index 00000000000..a61fc4dca5d >--- /dev/null >+++ b/selftest/knownfail.d/smbspool >@@ -0,0 +1 @@ >+^samba3.blackbox.smbspool.delete.on.close >diff --git a/source3/script/tests/test_smbspool.sh b/source3/script/tests/test_smbspool.sh >index 899b34d0e40..d95ed064634 100755 >--- a/source3/script/tests/test_smbspool.sh >+++ b/source3/script/tests/test_smbspool.sh >@@ -22,6 +22,7 @@ incdir=`dirname $0`/../../../testprogs/blackbox > samba_bindir="$BINDIR" > samba_vlp="$samba_bindir/vlp" > samba_smbspool="$samba_bindir/smbspool" >+samba_smbtorture3="$samba_bindir/smbtorture3" > samba_smbspool_krb5="$samba_bindir/smbspool_krb5_wrapper" > > test_smbspool_noargs() >@@ -119,6 +120,64 @@ test_vlp_verify() > fi > } > >+test_delete_on_close() >+{ >+ tdbfile="$PREFIX_ABS/$TARGET_ENV/lockdir/vlp.tdb" >+ if [ ! -w $tdbfile ]; then >+ echo "vlp tdbfile $tdbfile doesn't exist or is not writeable!" >+ return 1 >+ fi >+ >+ cmd='$samba_vlp tdbfile=$tdbfile lpq print1 2>&1' >+ eval echo "$cmd" >+ out=$(eval $cmd) >+ ret=$? >+ if [ $ret != 0 ]; then >+ echo "failed to lpq jobs on print1 with $samba_vlp" >+ echo "$out" >+ return 1 >+ fi >+ >+ num_jobs=$(echo "$out" | wc -l) >+ # >+ # Now run the test DELETE-PRINT from smbtorture3 >+ # >+ cmd='$samba_smbtorture3 //$SERVER_IP/print1 -U$USERNAME%$PASSWORD DELETE-PRINT 2>&1' >+ eval echo "$cmd" >+ out_t=$(eval $cmd) >+ ret=$? >+ if [ $ret != 0 ]; then >+ echo "failed to run DELETE-PRINT on print1" >+ echo "$out_t" >+ return 1 >+ fi >+ >+ cmd='$samba_vlp tdbfile=$tdbfile lpq print1 2>&1' >+ eval echo "$cmd" >+ out1=$(eval $cmd) >+ ret=$? >+ if [ $ret != 0 ]; then >+ echo "(2) failed to lpq jobs on print1 with $samba_vlp" >+ echo "$out1" >+ return 1 >+ fi >+ num_jobs1=$(echo "$out1" | wc -l) >+ >+ # >+ # Number of jobs should not change. Job >+ # should not have made it to backend. >+ # >+ if [ "$num_jobs1" -ne "$num_jobs" ]; then >+ echo "delete-on-close fail $num_jobs1 -ne $num_jobs" >+ echo "$out" >+ echo "$out_t" >+ echo "$out1" >+ return 1 >+ fi >+ >+ return 0 >+} >+ > testit "smbspool no args" \ > test_smbspool_noargs $samba_smbspool || \ > failed=$(expr $failed + 1) >@@ -180,4 +239,8 @@ testit "vlp verify example.ps" \ > failed=$(expr $failed + 1) > unset AUTH_INFO_REQUIRED > >+testit "delete on close" \ >+ test_delete_on_close \ >+ || failed=$(expr $failed + 1) >+ > exit $failed >diff --git a/source3/torture/torture.c b/source3/torture/torture.c >index e8944b493d2..dc35bda21d0 100644 >--- a/source3/torture/torture.c >+++ b/source3/torture/torture.c >@@ -4560,6 +4560,78 @@ static bool run_deletetest(int dummy) > return correct; > } > >+/* >+ Exercise delete on close semantics - use on the PRINT1 share in torture >+ testing. >+ */ >+static bool run_delete_print_test(int dummy) >+{ >+ struct cli_state *cli1 = NULL; >+ const char *fname = "print_delete.file"; >+ uint16_t fnum1 = (uint16_t)-1; >+ bool correct = false; >+ const char *buf = "print file data\n"; >+ NTSTATUS status; >+ >+ printf("starting print delete test\n"); >+ >+ if (!torture_open_connection(&cli1, 0)) { >+ return false; >+ } >+ >+ smbXcli_conn_set_sockopt(cli1->conn, sockops); >+ >+ status = cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS, >+ FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF, >+ 0, 0, &fnum1, NULL); >+ if (!NT_STATUS_IS_OK(status)) { >+ printf("open of %s failed (%s)\n", >+ fname, >+ nt_errstr(status)); >+ goto fail; >+ } >+ >+ status = cli_writeall(cli1, >+ fnum1, >+ 0, >+ (const uint8_t *)buf, >+ 0, /* offset */ >+ strlen(buf), /* size */ >+ NULL); >+ if (!NT_STATUS_IS_OK(status)) { >+ printf("writing print file data failed (%s)\n", >+ nt_errstr(status)); >+ goto fail; >+ } >+ >+ status = cli_nt_delete_on_close(cli1, fnum1, true); >+ if (!NT_STATUS_IS_OK(status)) { >+ printf("setting delete_on_close failed (%s)\n", >+ nt_errstr(status)); >+ goto fail; >+ } >+ >+ status = cli_close(cli1, fnum1); >+ if (!NT_STATUS_IS_OK(status)) { >+ printf("close failed (%s)\n", nt_errstr(status)); >+ goto fail; >+ } >+ >+ printf("finished print delete test\n"); >+ >+ correct = true; >+ >+ fail: >+ >+ if (fnum1 != (uint16_t)-1) { >+ cli_close(cli1, fnum1); >+ } >+ >+ if (cli1 && !torture_close_connection(cli1)) { >+ correct = false; >+ } >+ return correct; >+} > > /* > Test wildcard delete. >@@ -11550,6 +11622,7 @@ static struct { > {"RENAME-ACCESS", run_rename_access, 0}, > {"OWNER-RIGHTS", run_owner_rights, 0}, > {"DELETE", run_deletetest, 0}, >+ {"DELETE-PRINT", run_delete_print_test, 0}, > {"WILDDELETE", run_wild_deletetest, 0}, > {"DELETE-LN", run_deletetest_ln, 0}, > {"PROPERTIES", run_properties, 0}, >-- >2.18.0.rc1.244.gcf134e6275-goog > > >From 881204b4357e74b6aa8af2573641c11c2f10fbc7 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Thu, 31 May 2018 10:35:48 -0700 >Subject: [PATCH 2/2] 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) >--- > selftest/knownfail.d/smbspool | 1 - > source3/printing/printspoolss.c | 17 +++++++++++++++++ > 2 files changed, 17 insertions(+), 1 deletion(-) > delete mode 100644 selftest/knownfail.d/smbspool > >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) { >-- >2.18.0.rc1.244.gcf134e6275-goog >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
asn
:
review+
Actions:
View
Attachments on
bug 13457
: 14236 |
14237