The branch, master has been updated
via d4f233a spoolss: fix handling of bad EnumJobs levels
via 814b0ad torture/spoolss: test EnumJobs with an invalid level
via e1b6d6e torture/spoolss: add werr_expected arg to EnumJobs helper
from faa3423 s4-dns: Add support for BIND 9.10
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit d4f233a746d89e13aae78008b499c71b695ff882
Author: David Disseldorp <[email protected]>
Date: Mon Oct 27 20:13:59 2014 +0100
spoolss: fix handling of bad EnumJobs levels
Currently Samba is inconsistent when returning WERR_UNKNOWN_LEVEL
errors for spoolss EnumJobs requests - if no print jobs are present,
then WERR_OK will be returned, regardless of whether the EnumJobs level
is supported or not.
This change fixes this behaviour, by catching invalid or unsupported
levels prior to the no-jobs response fast-path.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10898
Signed-off-by: David Disseldorp <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
Autobuild-User(master): Jeremy Allison <[email protected]>
Autobuild-Date(master): Tue Oct 28 03:05:35 CET 2014 on sn-devel-104
commit 814b0ade8c1aa62a15f896d2dc7091403a582968
Author: David Disseldorp <[email protected]>
Date: Mon Oct 27 20:13:58 2014 +0100
torture/spoolss: test EnumJobs with an invalid level
This test confirms that EnumJobs WERR_INVALID_LEVEL responses remain
consistent with and without the presence of outstanding print jobs.
Signed-off-by: David Disseldorp <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
commit e1b6d6eab0824c74b409d00baef41ace8dac3449
Author: David Disseldorp <[email protected]>
Date: Mon Oct 27 20:13:57 2014 +0100
torture/spoolss: add werr_expected arg to EnumJobs helper
This will allow for the future testing of specific EnumJobs failure
cases.
Signed-off-by: David Disseldorp <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
source3/rpc_server/spoolss/srv_spoolss_nt.c | 7 ++-
source4/torture/rpc/spoolss.c | 89 +++++++++++++++++++++++++--
2 files changed, 89 insertions(+), 7 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c
b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index b8a6d77..552d4cb 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -7338,6 +7338,11 @@ WERROR _spoolss_EnumJobs(struct pipes_struct *p,
return WERR_INVALID_PARAM;
}
+ if ((r->in.level != 1) && (r->in.level != 2) && (r->in.level != 3)) {
+ DEBUG(4, ("EnumJobs level %d not supported\n", r->in.level));
+ return WERR_UNKNOWN_LEVEL;
+ }
+
DEBUG(4,("_spoolss_EnumJobs\n"));
*r->out.needed = 0;
@@ -7383,7 +7388,7 @@ WERROR _spoolss_EnumJobs(struct pipes_struct *p,
pinfo2, r->out.info, r->out.count);
break;
default:
- result = WERR_UNKNOWN_LEVEL;
+ SMB_ASSERT(false); /* level checked on entry */
break;
}
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 83933c5..dea5549 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -3255,6 +3255,7 @@ static bool test_EnumJobs_args(struct torture_context
*tctx,
struct dcerpc_binding_handle *b,
struct policy_handle *handle,
uint32_t level,
+ WERROR werr_expected,
uint32_t *count_p,
union spoolss_JobInfo **info_p)
{
@@ -3288,13 +3289,15 @@ static bool test_EnumJobs_args(struct torture_context
*tctx,
status = dcerpc_spoolss_EnumJobs_r(b, tctx, &r);
torture_assert_ntstatus_ok(tctx, status, "EnumJobs failed");
- torture_assert_werr_ok(tctx, r.out.result, "EnumJobs failed");
+ torture_assert_werr_equal(tctx, r.out.result, werr_expected,
+ "EnumJobs failed");
torture_assert(tctx, info, "No jobs returned");
CHECK_NEEDED_SIZE_ENUM_LEVEL(spoolss_EnumJobs, *r.out.info,
r.in.level, count, needed, 4);
} else {
- torture_assert_werr_ok(tctx, r.out.result, "EnumJobs failed");
+ torture_assert_werr_equal(tctx, r.out.result, werr_expected,
+ "EnumJobs failed");
}
if (count_p) {
@@ -3520,7 +3523,7 @@ static bool test_DoPrintTest_check_jobs(struct
torture_context *tctx,
"AddJob failed");
torture_assert(tctx,
- test_EnumJobs_args(tctx, b, handle, 1, &count, &info),
+ test_EnumJobs_args(tctx, b, handle, 1, WERR_OK, &count, &info),
"EnumJobs level 1 failed");
torture_assert_int_equal(tctx, count, num_jobs, "unexpected number of
jobs in queue");
@@ -8305,7 +8308,8 @@ static bool test_print_test_smbd(struct torture_context
*tctx,
/* check back end spoolss job was created */
torture_assert(tctx,
- test_EnumJobs_args(tctx, b, &t->handle, 1, &count, &info),
+ test_EnumJobs_args(tctx, b, &t->handle, 1, WERR_OK,
+ &count, &info),
"EnumJobs level 1 failed");
for (i = 0; i < count; i++) {
@@ -8352,7 +8356,8 @@ static bool test_print_test_purge(struct torture_context
*tctx,
}
torture_assert(tctx,
- test_EnumJobs_args(tctx, b, &t->handle, 1, &count, &info),
+ test_EnumJobs_args(tctx, b, &t->handle, 1, WERR_OK,
+ &count, &info),
"EnumJobs level 1 failed");
torture_assert_int_equal(tctx, count, num_jobs,
@@ -8363,7 +8368,8 @@ static bool test_print_test_purge(struct torture_context
*tctx,
"failed to purge printer");
torture_assert(tctx,
- test_EnumJobs_args(tctx, b, &t->handle, 1, &count, &info),
+ test_EnumJobs_args(tctx, b, &t->handle, 1, WERR_OK,
+ &count, &info),
"EnumJobs level 1 failed");
torture_assert_int_equal(tctx, count, 0,
@@ -8843,6 +8849,76 @@ static bool test_driver_info_winreg(struct
torture_context *tctx,
return true;
}
+static bool test_print_job_enum(struct torture_context *tctx,
+ void *private_data)
+{
+ struct torture_printer_context *t =
+ (struct torture_printer_context
*)talloc_get_type_abort(private_data, struct torture_printer_context);
+ struct dcerpc_pipe *p = t->spoolss_pipe;
+ struct dcerpc_binding_handle *b = p->binding_handle;
+ bool ret = true;
+ uint32_t num_jobs = 8;
+ uint32_t *job_ids;
+ int i;
+ union spoolss_JobInfo *info = NULL;
+ uint32_t count;
+
+ torture_assert(tctx,
+ test_PausePrinter(tctx, b, &t->handle),
+ "failed to pause printer");
+
+ /* enum before jobs, valid level */
+ torture_assert(tctx,
+ test_EnumJobs_args(tctx, b, &t->handle, 1, WERR_OK,
+ &count, &info),
+ "EnumJobs with valid level");
+ torture_assert_int_equal(tctx, count, 0, "EnumJobs count");
+ torture_assert(tctx,
+ test_EnumJobs_args(tctx, b, &t->handle, 2, WERR_OK,
+ &count, &info),
+ "EnumJobs with valid level");
+ torture_assert_int_equal(tctx, count, 0, "EnumJobs count");
+ /* enum before jobs, invalid level - expect failure */
+ torture_assert(tctx,
+ test_EnumJobs_args(tctx, b, &t->handle, 100,
+ WERR_INVALID_LEVEL,
+ &count, &info),
+ "EnumJobs with invalid level");
+
+ job_ids = talloc_zero_array(tctx, uint32_t, num_jobs);
+
+ for (i = 0; i < num_jobs; i++) {
+ ret = test_DoPrintTest_add_one_job(tctx, b, &t->handle,
+ "TorturePrintJob",
+ &job_ids[i]);
+ torture_assert(tctx, ret, "failed to add print job");
+ }
+
+ /* enum after jobs, valid level */
+ torture_assert(tctx,
+ test_EnumJobs_args(tctx, b, &t->handle, 1, WERR_OK,
+ &count, &info),
+ "EnumJobs with valid level");
+ torture_assert_int_equal(tctx, count, num_jobs, "EnumJobs count");
+ torture_assert(tctx,
+ test_EnumJobs_args(tctx, b, &t->handle, 2, WERR_OK,
+ &count, &info),
+ "EnumJobs with valid level");
+ torture_assert_int_equal(tctx, count, num_jobs, "EnumJobs count");
+ /* enum after jobs, invalid level - expect failure */
+ torture_assert(tctx,
+ test_EnumJobs_args(tctx, b, &t->handle, 100,
+ WERR_INVALID_LEVEL,
+ &count, &info),
+ "EnumJobs with invalid level");
+
+ torture_assert(tctx,
+ test_ResumePrinter(tctx, b, &t->handle),
+ "failed to resume printer");
+
+ return true;
+}
+
void torture_tcase_printer(struct torture_tcase *tcase)
{
torture_tcase_add_simple_test(tcase, "openprinter",
test_openprinter_wrap);
@@ -8870,6 +8946,7 @@ void torture_tcase_printer(struct torture_tcase *tcase)
torture_tcase_add_simple_test(tcase, "bidi", test_printer_bidi);
torture_tcase_add_simple_test(tcase, "publish_toggle",
test_printer_publish_toggle);
+ torture_tcase_add_simple_test(tcase, "print_job_enum",
test_print_job_enum);
}
struct torture_suite *torture_rpc_spoolss_printer(TALLOC_CTX *mem_ctx)
--
Samba Shared Repository