r23792: convert Samba4 to GPLv3
[ira/wip.git] / source / torture / rpc / bind.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    dcerpc torture tests
5
6    Copyright (C) Andrew Tridgell 2003
7    Copyright (C) Andrew Bartlett <abartlet@samba.org 2004
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #include "includes.h"
24 #include "torture/torture.h"
25 #include "librpc/gen_ndr/ndr_lsa.h"
26 #include "librpc/gen_ndr/ndr_lsa_c.h"
27 #include "lib/cmdline/popt_common.h"
28 #include "librpc/rpc/dcerpc.h"
29 #include "torture/rpc/rpc.h"
30 #include "libcli/libcli.h"
31 #include "libcli/composite/composite.h"
32 #include "libcli/smb_composite/smb_composite.h"
33
34 /*
35   This test is 'bogus' in that it doesn't actually perform to the
36   spec.  We need to deal with other things inside the DCERPC layer,
37   before we could have multiple binds.
38
39   We should never pass this test, until such details are fixed in our
40   client, and it looks like multible binds are never used anyway.
41
42 */
43
44 BOOL torture_multi_bind(struct torture_context *torture) 
45 {
46         struct dcerpc_pipe *p;
47         struct dcerpc_binding *binding;
48         const char *binding_string = torture_setting_string(torture, "binding", NULL);
49         TALLOC_CTX *mem_ctx;
50         NTSTATUS status;
51         BOOL ret;
52
53         mem_ctx = talloc_init("torture_multi_bind");
54
55         status = dcerpc_parse_binding(mem_ctx, binding_string, &binding);
56         if (!NT_STATUS_IS_OK(status)) {
57                 printf("Failed to parse dcerpc binding '%s'\n", binding_string);
58                 talloc_free(mem_ctx);
59                 return False;
60         }
61
62         status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_lsarpc);
63         
64         if (!NT_STATUS_IS_OK(status)) {
65                 talloc_free(mem_ctx);
66                 return False;
67         }
68
69         status = dcerpc_pipe_auth(mem_ctx, &p, binding, &dcerpc_table_lsarpc, cmdline_credentials);
70
71         if (NT_STATUS_IS_OK(status)) {
72                 printf("(incorrectly) allowed re-bind to uuid %s - %s\n", 
73                         GUID_string(mem_ctx, &dcerpc_table_lsarpc.syntax_id.uuid), nt_errstr(status));
74                 ret = False;
75         } else {
76                 printf("\n");
77                 ret = True;
78         }
79
80         talloc_free(mem_ctx);
81
82         return ret;
83 }