1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | test suite for rpc bind operations
|
---|
4 |
|
---|
5 | Copyright (C) Guenther Deschner 2010
|
---|
6 |
|
---|
7 | This program is free software; you can redistribute it and/or modify
|
---|
8 | it under the terms of the GNU General Public License as published by
|
---|
9 | the Free Software Foundation; either version 3 of the License, or
|
---|
10 | (at your option) any later version.
|
---|
11 |
|
---|
12 | This program is distributed in the hope that it will be useful,
|
---|
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | GNU General Public License for more details.
|
---|
16 |
|
---|
17 | You should have received a copy of the GNU General Public License
|
---|
18 | along with this program; if not, write to the Free Software
|
---|
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include "includes.h"
|
---|
23 | #include "torture/rpc/torture_rpc.h"
|
---|
24 | #include "librpc/gen_ndr/ndr_lsa_c.h"
|
---|
25 | #include "lib/cmdline/popt_common.h"
|
---|
26 |
|
---|
27 | static bool test_openpolicy(struct torture_context *tctx,
|
---|
28 | struct dcerpc_pipe *p)
|
---|
29 | {
|
---|
30 | struct dcerpc_binding_handle *b = p->binding_handle;
|
---|
31 | struct policy_handle *handle;
|
---|
32 |
|
---|
33 | torture_assert(tctx,
|
---|
34 | test_lsa_OpenPolicy2(b, tctx, &handle),
|
---|
35 | "failed to open policy");
|
---|
36 |
|
---|
37 | torture_assert(tctx,
|
---|
38 | test_lsa_Close(b, tctx, handle),
|
---|
39 | "failed to close policy");
|
---|
40 |
|
---|
41 | return true;
|
---|
42 | }
|
---|
43 |
|
---|
44 | static bool test_bind(struct torture_context *tctx,
|
---|
45 | const void *private_data)
|
---|
46 | {
|
---|
47 | struct dcerpc_binding *binding;
|
---|
48 | struct dcerpc_pipe *p;
|
---|
49 | const uint32_t *flags = (const uint32_t *)private_data;
|
---|
50 |
|
---|
51 | torture_assert_ntstatus_ok(tctx,
|
---|
52 | torture_rpc_binding(tctx, &binding),
|
---|
53 | "failed to parse binding string");
|
---|
54 |
|
---|
55 | binding->flags &= ~DCERPC_AUTH_OPTIONS;
|
---|
56 | binding->flags |= *flags;
|
---|
57 |
|
---|
58 | torture_assert_ntstatus_ok(tctx,
|
---|
59 | dcerpc_pipe_connect_b(tctx, &p, binding,
|
---|
60 | &ndr_table_lsarpc,
|
---|
61 | cmdline_credentials,
|
---|
62 | tctx->ev,
|
---|
63 | tctx->lp_ctx),
|
---|
64 | "failed to connect pipe");
|
---|
65 |
|
---|
66 | torture_assert(tctx,
|
---|
67 | test_openpolicy(tctx, p),
|
---|
68 | "failed to test openpolicy");
|
---|
69 |
|
---|
70 | talloc_free(p);
|
---|
71 |
|
---|
72 | return true;
|
---|
73 | }
|
---|
74 |
|
---|
75 | static void test_bind_op(struct torture_suite *suite,
|
---|
76 | const char *name,
|
---|
77 | uint32_t flags)
|
---|
78 | {
|
---|
79 | uint32_t *flags_p = talloc(suite, uint32_t);
|
---|
80 |
|
---|
81 | *flags_p = flags;
|
---|
82 |
|
---|
83 | torture_suite_add_simple_tcase_const(suite, name, test_bind, flags_p);
|
---|
84 | }
|
---|
85 |
|
---|
86 |
|
---|
87 | struct torture_suite *torture_rpc_bind(TALLOC_CTX *mem_ctx)
|
---|
88 | {
|
---|
89 | struct torture_suite *suite = torture_suite_create(mem_ctx, "bind");
|
---|
90 | struct {
|
---|
91 | const char *test_name;
|
---|
92 | uint32_t flags;
|
---|
93 | } tests[] = {
|
---|
94 | {
|
---|
95 | .test_name = "ntlm,sign",
|
---|
96 | .flags = DCERPC_AUTH_NTLM | DCERPC_SIGN
|
---|
97 | },{
|
---|
98 | .test_name = "ntlm,sign,seal",
|
---|
99 | .flags = DCERPC_AUTH_NTLM | DCERPC_SIGN | DCERPC_SEAL
|
---|
100 | },{
|
---|
101 | .test_name = "spnego,sign",
|
---|
102 | .flags = DCERPC_AUTH_SPNEGO | DCERPC_SIGN
|
---|
103 | },{
|
---|
104 | .test_name = "spnego,sign,seal",
|
---|
105 | .flags = DCERPC_AUTH_SPNEGO | DCERPC_SIGN | DCERPC_SEAL
|
---|
106 | }
|
---|
107 | };
|
---|
108 | int i;
|
---|
109 |
|
---|
110 | for (i=0; i < ARRAY_SIZE(tests); i++) {
|
---|
111 | test_bind_op(suite, tests[i].test_name, tests[i].flags);
|
---|
112 | }
|
---|
113 | for (i=0; i < ARRAY_SIZE(tests); i++) {
|
---|
114 | test_bind_op(suite, talloc_asprintf(suite, "bigendian,%s", tests[i].test_name), tests[i].flags | DCERPC_PUSH_BIGENDIAN);
|
---|
115 | }
|
---|
116 |
|
---|
117 | return suite;
|
---|
118 | }
|
---|