2 Unix SMB/CIFS implementation.
3 test suite for RAP / DCERPC consistency
4 Copyright (C) Guenther Deschner 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "libcli/libcli.h"
22 #include "torture/smbtorture.h"
23 #include "torture/util.h"
24 #include "libcli/rap/rap.h"
25 #include "torture/rap/proto.h"
26 #include "param/param.h"
27 #include "torture/rpc/rpc.h"
28 #include "librpc/gen_ndr/ndr_srvsvc_c.h"
30 static bool test_rpc_netservergetinfo(struct torture_context *tctx,
31 struct smbcli_state *cli)
33 struct rap_WserverGetInfo r;
34 struct dcerpc_pipe *p;
35 struct dcerpc_binding_handle *b;
36 struct srvsvc_NetSrvGetInfo s;
37 union srvsvc_NetSrvInfo info;
39 const char *server_name;
41 torture_assert_ntstatus_ok(tctx,
42 torture_rpc_connection(tctx, &p, &ndr_table_srvsvc),
43 "failed to open srvsvc");
45 b = p->binding_handle;
47 s.in.server_unc = NULL;
51 torture_assert_ntstatus_ok(tctx,
52 dcerpc_srvsvc_NetSrvGetInfo_r(b, tctx, &s),
53 "srvsvc_NetSrvGetInfo level 101 failed");
54 torture_assert_werr_ok(tctx, s.out.result,
55 "srvsvc_NetSrvGetInfo level 101 failed");
57 r.in.bufsize = 0xffff;
60 torture_assert_ntstatus_ok(tctx,
61 smbcli_rap_netservergetinfo(cli->tree, lp_iconv_convenience(tctx->lp_ctx), tctx, &r),
62 "rap_netservergetinfo level 0 failed");
63 torture_assert_int_equal(tctx, r.out.status, 0,
64 "rap_netservergetinfo level 0 failed");
66 server_name = talloc_strndup(tctx, info.info101->server_name, 16);
68 torture_assert_str_equal(tctx, r.out.info.info0.name, server_name, "server name");
70 if (torture_setting_bool(tctx, "samba3", false)) {
71 torture_skip(tctx, "skipping netservergetinfo level 1 against samba3");
76 torture_assert_ntstatus_ok(tctx,
77 smbcli_rap_netservergetinfo(cli->tree, lp_iconv_convenience(tctx->lp_ctx), tctx, &r),
78 "rap_netservergetinfo level 1 failed");
79 torture_assert_int_equal(tctx, r.out.status, 0,
80 "rap_netservergetinfo level 1 failed");
82 torture_assert_str_equal(tctx, r.out.info.info1.name, server_name, "server name");
83 torture_assert_int_equal(tctx, r.out.info.info1.version_major, info.info101->version_major, "version major");
84 torture_assert_int_equal(tctx, r.out.info.info1.version_minor, info.info101->version_minor, "version minor");
85 torture_assert_int_equal(tctx, r.out.info.info1.servertype, info.info101->server_type, "server_type");
86 torture_assert_str_equal(tctx, r.out.info.info1.comment, info.info101->comment, "comment");
93 struct torture_suite *torture_rap_rpc(TALLOC_CTX *mem_ctx)
95 struct torture_suite *suite = torture_suite_create(mem_ctx, "RPC");
97 torture_suite_add_1smb_test(suite, "netservergetinfo",
98 test_rpc_netservergetinfo);
100 suite->description = talloc_strdup(suite,
101 "RAP / DCERPC consistency tests");