r26529: Indeed, this belongs in the schema module. Ranged results need to use
[jelmer/samba4-debian.git] / source / torture / util.c
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB torture tester utility functions
4    Copyright (C) Jelmer Vernooij 2006
5    
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.
10    
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.
15    
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/>.
18 */
19
20 #include "includes.h"
21 #include "system/filesys.h"
22 #include "system/wait.h"
23 #include "torture/torture.h"
24 #include "libcli/raw/interfaces.h"
25 #include "libcli/raw/libcliraw.h"
26
27 /**
28   check if 2 NTTIMEs are equal.
29 */
30 bool nt_time_equal(NTTIME *t1, NTTIME *t2)
31 {
32         return *t1 == *t2;
33 }
34
35 NTSTATUS torture_second_tcon(TALLOC_CTX *mem_ctx,
36                              struct smbcli_session *session,
37                              const char *sharename,
38                              struct smbcli_tree **res)
39 {
40         union smb_tcon tcon;
41         struct smbcli_tree *result;
42         TALLOC_CTX *tmp_ctx;
43         NTSTATUS status;
44
45         if ((tmp_ctx = talloc_new(mem_ctx)) == NULL) {
46                 return NT_STATUS_NO_MEMORY;
47         }
48
49         result = smbcli_tree_init(session, tmp_ctx, false);
50         if (result == NULL) {
51                 talloc_free(tmp_ctx);
52                 return NT_STATUS_NO_MEMORY;
53         }
54
55         tcon.generic.level = RAW_TCON_TCONX;
56         tcon.tconx.in.flags = 0;
57
58         /* Ignore share mode security here */
59         tcon.tconx.in.password = data_blob(NULL, 0);
60         tcon.tconx.in.path = sharename;
61         tcon.tconx.in.device = "?????";
62
63         status = smb_raw_tcon(result, tmp_ctx, &tcon);
64         if (!NT_STATUS_IS_OK(status)) {
65                 talloc_free(tmp_ctx);
66                 return status;
67         }
68
69         result->tid = tcon.tconx.out.tid;
70         *res = talloc_steal(mem_ctx, result);
71         talloc_free(tmp_ctx);
72         return NT_STATUS_OK;
73 }