s4-torture: add spoolss_SetPrinter ndr test to validate secdesc_ptr
authorGünther Deschner <gd@samba.org>
Fri, 11 Nov 2016 18:17:55 +0000 (19:17 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 11 Nov 2016 21:57:22 +0000 (22:57 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11197

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/torture/ndr/spoolss.c

index c8c466d2afdafb5460d9b68289e9cc7b8db490b2..72a4f5b9844e6901bf3cd56ed75f1948cfc9af00 100644 (file)
@@ -1769,6 +1769,61 @@ static bool setjobnamedproperty_req_check(struct torture_context *tctx,
        return true;
 }
 
+static const uint8_t setprinter_level_3_xpsp3_req_data[] = {
+       0x00, 0x00, 0x00, 0x00, 0x3c, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x2b, 0x55, 0x94, 0xbe, 0x50, 0x28, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+       0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0xd1, 0xe9, 0x06,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00,
+       0x04, 0x00, 0x02, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x80,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0xa0, 0x00, 0x06, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x18, 0x00, 0x0c, 0x00, 0x0f, 0x00, 0x01, 0x02, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00,
+       0x00, 0x09, 0x18, 0x00, 0x30, 0x00, 0x0f, 0x00, 0x01, 0x02, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02, 0x00, 0x00,
+       0x00, 0x00, 0x24, 0x00, 0x08, 0x00, 0x02, 0x00, 0x01, 0x05, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00, 0xa4, 0xc0, 0x7d, 0x3b,
+       0xcc, 0xce, 0x29, 0xa7, 0xd1, 0xc7, 0xe9, 0xd4, 0x50, 0x04, 0x00, 0x00,
+       0x00, 0x00, 0x18, 0x00, 0x0c, 0x00, 0x0f, 0x00, 0x01, 0x02, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x26, 0x02, 0x00, 0x00,
+       0x00, 0x09, 0x18, 0x00, 0x30, 0x00, 0x0f, 0x00, 0x01, 0x02, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x26, 0x02, 0x00, 0x00,
+       0x00, 0x00, 0x14, 0x00, 0x08, 0x00, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static bool setprinter_level_3_xpsp3_req_check(struct torture_context *tctx,
+                                              struct spoolss_SetPrinter *r)
+{
+       struct GUID guid;
+
+       torture_assert_ntstatus_ok(tctx,
+               GUID_from_string("0000053c-0000-0000-2b55-94be50280000", &guid),
+               "failed to parse GUID");
+       torture_assert_int_equal(tctx, r->in.handle->handle_type, 0, "handle_type");
+       torture_assert_guid_equal(tctx, r->in.handle->uuid, guid, "handle.uuid");
+
+       torture_assert(tctx, r->in.info_ctr, "info_ctr");
+       torture_assert_int_equal(tctx, r->in.info_ctr->level, 3, "level");
+       torture_assert_int_equal(tctx, r->in.info_ctr->info.info3->sec_desc_ptr, 0x06e9d108, "sec_desc_ptr");
+
+       torture_assert(tctx, r->in.devmode_ctr, "devmode_ctr");
+       torture_assert_int_equal(tctx, r->in.devmode_ctr->_ndr_size, 0, "_ndr_size");
+       torture_assert(tctx, r->in.devmode_ctr->devmode == NULL, "devmode");
+
+       torture_assert(tctx, r->in.secdesc_ctr, "secdesc_ctr");
+       torture_assert_int_equal(tctx, r->in.secdesc_ctr->sd_size, 0x000000b4, "sd_size");
+       torture_assert_int_equal(tctx, r->in.secdesc_ctr->sd->revision, SECURITY_DESCRIPTOR_REVISION_1, "revision");
+       torture_assert_int_equal(tctx, r->in.secdesc_ctr->sd->type, 0x8004, "type");
+       torture_assert(tctx, r->in.secdesc_ctr->sd, "sd");
+       torture_assert(tctx, r->in.secdesc_ctr->sd->owner_sid == NULL, "owner_sid");
+       torture_assert(tctx, r->in.secdesc_ctr->sd->group_sid == NULL, "group_sid");
+       torture_assert(tctx, r->in.secdesc_ctr->sd->sacl == NULL, "sacl");
+       torture_assert(tctx, r->in.secdesc_ctr->sd->dacl, "dacl");
+
+       return true;
+}
+
 struct torture_suite *ndr_spoolss_suite(TALLOC_CTX *ctx)
 {
        struct torture_suite *suite = torture_suite_create(ctx, "spoolss");
@@ -1859,5 +1914,8 @@ struct torture_suite *ndr_spoolss_suite(TALLOC_CTX *ctx)
        torture_suite_add_ndr_pull_fn_test(suite, spoolss_SetJobNamedProperty, setjobnamedproperty_req_data, NDR_IN, setjobnamedproperty_req_check);
        torture_suite_add_ndr_pull_fn_test(suite, winspool_AsyncSetJobNamedProperty, setjobnamedproperty_req_data, NDR_IN, NULL);
 
+       torture_suite_add_ndr_pull_fn_test(suite, spoolss_SetPrinter, setprinter_level_3_xpsp3_req_data, NDR_IN, setprinter_level_3_xpsp3_req_check);
+       torture_suite_add_ndr_pull_fn_test(suite, winspool_AsyncSetPrinter, setprinter_level_3_xpsp3_req_data, NDR_IN, NULL);
+
        return suite;
 }