Line data Source code
1 : /*
2 : Unix SMB/CIFS implementation.
3 : chkpath individual test suite
4 : Copyright (C) Andrew Tridgell 2003
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/locale.h"
22 : #include "libcli/raw/libcliraw.h"
23 : #include "libcli/libcli.h"
24 : #include "torture/util.h"
25 : #include "torture/raw/proto.h"
26 :
27 : #define BASEDIR "\\rawchkpath"
28 :
29 : #define CHECK_STATUS(status, correct, dos_correct) do { \
30 : if (!NT_STATUS_EQUAL(status, correct) && !NT_STATUS_EQUAL(status, dos_correct)) { \
31 : printf("(%d) Incorrect status %s - should be %s\n", \
32 : __LINE__, nt_errstr(status), nt_errstr(correct)); \
33 : ret = false; \
34 : goto done; \
35 : }} while (0)
36 :
37 :
38 10 : static NTSTATUS single_search(struct smbcli_state *cli,
39 : TALLOC_CTX *mem_ctx, const char *pattern)
40 : {
41 0 : union smb_search_first io;
42 0 : NTSTATUS status;
43 :
44 10 : io.t2ffirst.level = RAW_SEARCH_TRANS2;
45 10 : io.t2ffirst.data_level = RAW_SEARCH_DATA_STANDARD;
46 10 : io.t2ffirst.in.search_attrib = 0;
47 10 : io.t2ffirst.in.max_count = 1;
48 10 : io.t2ffirst.in.flags = FLAG_TRANS2_FIND_CLOSE;
49 10 : io.t2ffirst.in.storage_type = 0;
50 10 : io.t2ffirst.in.pattern = pattern;
51 :
52 10 : status = smb_raw_search_first(cli->tree, mem_ctx,
53 : &io, NULL, NULL);
54 :
55 10 : return status;
56 : }
57 :
58 295 : static bool test_path_ex(struct smbcli_state *cli, struct torture_context *tctx,
59 : const char *path, const char *path_expected,
60 : NTSTATUS expected, NTSTATUS dos_expected)
61 : {
62 0 : union smb_chkpath io;
63 0 : union smb_fileinfo finfo;
64 0 : NTSTATUS status;
65 :
66 295 : io.chkpath.in.path = path;
67 295 : status = smb_raw_chkpath(cli->tree, &io);
68 295 : if (!NT_STATUS_EQUAL(status, expected) && !NT_STATUS_EQUAL(status, dos_expected)) {
69 0 : printf("FAILED %-30s chkpath %s should be %s or %s\n",
70 : path, nt_errstr(status), nt_errstr(expected), nt_errstr(dos_expected));
71 0 : return false;
72 : } else {
73 295 : printf("%-30s chkpath correct (%s)\n", path, nt_errstr(status));
74 : }
75 :
76 295 : if (NT_STATUS_EQUAL(expected, NT_STATUS_NOT_A_DIRECTORY)) {
77 15 : expected = NT_STATUS_OK;
78 : }
79 :
80 295 : ZERO_STRUCT(finfo);
81 295 : finfo.generic.level = RAW_FILEINFO_NAME_INFO;
82 295 : finfo.generic.in.file.path = path;
83 295 : status = smb_raw_pathinfo(cli->tree, cli, &finfo);
84 295 : if (!NT_STATUS_EQUAL(status, expected) && !NT_STATUS_EQUAL(status, dos_expected)) {
85 0 : printf("FAILED: %-30s pathinfo %s should be %s or %s\n",
86 : path, nt_errstr(status), nt_errstr(expected), nt_errstr(dos_expected));
87 0 : return false;
88 : }
89 :
90 295 : if (!NT_STATUS_IS_OK(status)) {
91 205 : printf("%-30s chkpath correct (%s)\n", path, nt_errstr(status));
92 205 : return true;
93 : }
94 :
95 90 : if (path_expected &&
96 90 : (!finfo.name_info.out.fname.s ||
97 89 : strcmp(finfo.name_info.out.fname.s, path_expected) != 0)) {
98 3 : if (tctx && torture_setting_bool(tctx, "samba4", false)) {
99 3 : printf("IGNORE: %-30s => %-20s should be %s\n",
100 : path, finfo.name_info.out.fname.s, path_expected);
101 3 : return true;
102 : }
103 0 : printf("FAILED: %-30s => %-20s should be %s\n",
104 : path, finfo.name_info.out.fname.s, path_expected);
105 0 : return false;
106 : }
107 87 : printf("%-30s => %-20s correct\n",
108 : path, finfo.name_info.out.fname.s);
109 :
110 87 : return true;
111 : }
112 :
113 225 : static bool test_path(struct smbcli_state *cli, const char *path,
114 : NTSTATUS expected, NTSTATUS dos_expected)
115 : {
116 225 : return test_path_ex(cli, NULL, path, path, expected, dos_expected);
117 : }
118 :
119 5 : static bool test_chkpath(struct smbcli_state *cli, struct torture_context *tctx)
120 : {
121 0 : union smb_chkpath io;
122 0 : NTSTATUS status;
123 5 : bool ret = true;
124 5 : int fnum = -1;
125 :
126 5 : io.chkpath.in.path = BASEDIR;
127 :
128 5 : status = smb_raw_chkpath(cli->tree, &io);
129 5 : CHECK_STATUS(status, NT_STATUS_OK, NT_STATUS_OK);
130 :
131 5 : ret &= test_path(cli, BASEDIR "\\nodir", NT_STATUS_OBJECT_NAME_NOT_FOUND, NT_STATUS_DOS(ERRDOS,ERRbadpath));
132 :
133 5 : fnum = create_complex_file(cli, tctx, BASEDIR "\\test.txt..");
134 5 : if (fnum == -1) {
135 0 : printf("failed to open test.txt - %s\n", smbcli_errstr(cli->tree));
136 0 : ret = false;
137 0 : goto done;
138 : }
139 :
140 5 : ret &= test_path(cli, BASEDIR "\\test.txt..", NT_STATUS_NOT_A_DIRECTORY, NT_STATUS_DOS(ERRDOS,ERRbadpath));
141 :
142 5 : if (!torture_set_file_attribute(cli->tree, BASEDIR, FILE_ATTRIBUTE_HIDDEN)) {
143 0 : printf("failed to set basedir hidden\n");
144 0 : ret = false;
145 0 : goto done;
146 : }
147 :
148 5 : ret &= test_path_ex(cli, tctx, BASEDIR, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
149 5 : ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR) + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
150 5 : ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR"\\\\") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
151 5 : ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR"\\foo\\..") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
152 5 : ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR"\\f\\o\\o\\..\\..\\..") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
153 5 : ret &= test_path_ex(cli, tctx, ((const char *)BASEDIR"\\foo\\\\..\\\\") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
154 5 : ret &= test_path_ex(cli, tctx, BASEDIR"\\", BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
155 5 : ret &= test_path_ex(cli, tctx, BASEDIR"\\\\..\\"BASEDIR, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
156 5 : ret &= test_path_ex(cli, tctx, BASEDIR"\\\\\\", BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
157 5 : ret &= test_path_ex(cli, tctx, "\\\\\\\\"BASEDIR"\\\\\\\\", BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
158 5 : ret &= test_path_ex(cli, tctx, "\\\\\\\\"BASEDIR, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
159 10 : ret &= test_path_ex(cli, tctx, BASEDIR "\\foo\\..\\test.txt..", BASEDIR "\\test.txt..",
160 5 : NT_STATUS_NOT_A_DIRECTORY, NT_STATUS_DOS(ERRDOS,ERRbadpath));
161 5 : ret &= test_path_ex(cli, tctx, "", "\\", NT_STATUS_OK, NT_STATUS_OK);
162 5 : ret &= test_path(cli, ".", NT_STATUS_OBJECT_NAME_INVALID, NT_STATUS_DOS(ERRDOS,ERRbadpath));
163 5 : ret &= test_path(cli, ".\\", NT_STATUS_OBJECT_NAME_INVALID, NT_STATUS_DOS(ERRDOS,ERRbadpath));
164 5 : ret &= test_path(cli, "\\\\\\.\\", NT_STATUS_OBJECT_NAME_INVALID, NT_STATUS_DOS(ERRDOS,ERRbadpath));
165 5 : ret &= test_path(cli, ".\\.", NT_STATUS_OBJECT_PATH_NOT_FOUND, NT_STATUS_DOS(ERRDOS,ERRbadpath));
166 5 : ret &= test_path(cli, "." BASEDIR, NT_STATUS_OBJECT_PATH_NOT_FOUND, NT_STATUS_DOS(ERRDOS,ERRbadpath));
167 5 : ret &= test_path(cli, BASEDIR "\\.", NT_STATUS_OBJECT_NAME_INVALID, NT_STATUS_DOS(ERRDOS,ERRbadpath));
168 5 : ret &= test_path(cli, BASEDIR "\\.\\test.txt..", NT_STATUS_OBJECT_PATH_NOT_FOUND, NT_STATUS_DOS(ERRDOS,ERRbadpath));
169 5 : ret &= test_path(cli, ".\\.\\", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
170 5 : ret &= test_path(cli, ".\\.\\.", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
171 5 : ret &= test_path(cli, ".\\.\\.aaaaa", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
172 5 : ret &= test_path(cli, "\\.\\", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
173 5 : ret &= test_path(cli, "\\.\\\\", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
174 5 : ret &= test_path(cli, "\\.\\\\\\\\\\\\", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
175 :
176 : /* Note that the two following paths are identical but
177 : give different NT status returns for chkpth and findfirst. */
178 :
179 5 : printf("Testing findfirst on %s\n", "\\.\\\\\\\\\\\\.");
180 5 : status = single_search(cli, tctx, "\\.\\\\\\\\\\\\.");
181 5 : CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRinvalidname));
182 :
183 5 : ret &= test_path(cli, "\\.\\\\\\\\\\\\.", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
184 :
185 : /* We expect this open to fail with the same error code as the chkpath below. */
186 5 : printf("Testing Open on %s\n", "\\.\\\\\\\\\\\\.");
187 : /* findfirst seems to fail with a different error. */
188 5 : (void)smbcli_nt_create_full(cli->tree, "\\.\\\\\\\\\\\\.",
189 : 0, SEC_RIGHTS_FILE_ALL,
190 : FILE_ATTRIBUTE_NORMAL,
191 : NTCREATEX_SHARE_ACCESS_DELETE|
192 : NTCREATEX_SHARE_ACCESS_READ|
193 : NTCREATEX_SHARE_ACCESS_WRITE,
194 : NTCREATEX_DISP_OVERWRITE_IF,
195 : 0, 0);
196 5 : status = smbcli_nt_error(cli->tree);
197 5 : CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
198 :
199 :
200 5 : ret &= test_path(cli, "\\.\\\\xxx", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
201 5 : ret &= test_path(cli, "..\\..\\..", NT_STATUS_OBJECT_PATH_SYNTAX_BAD,NT_STATUS_DOS(ERRDOS,ERRinvalidpath));
202 5 : ret &= test_path(cli, "\\..", NT_STATUS_OBJECT_PATH_SYNTAX_BAD,NT_STATUS_DOS(ERRDOS,ERRinvalidpath));
203 5 : ret &= test_path(cli, "\\.\\\\\\\\\\\\xxx", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
204 5 : ret &= test_path(cli, BASEDIR"\\.\\", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
205 5 : ret &= test_path(cli, BASEDIR"\\.\\\\", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
206 5 : ret &= test_path(cli, BASEDIR"\\.\\nt", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
207 5 : ret &= test_path(cli, BASEDIR"\\.\\.\\nt", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
208 5 : ret &= test_path(cli, BASEDIR"\\nt", NT_STATUS_OK, NT_STATUS_OK);
209 5 : ret &= test_path(cli, BASEDIR".\\foo", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
210 5 : ret &= test_path(cli, BASEDIR"xx\\foo", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
211 5 : ret &= test_path(cli, ".\\", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
212 5 : ret &= test_path(cli, ".\\.", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
213 5 : ret &= test_path(cli, ".\\.\\.\\.\\foo\\.\\.\\", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
214 5 : ret &= test_path(cli, BASEDIR".\\.\\.\\.\\foo\\.\\.\\", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
215 5 : ret &= test_path(cli, BASEDIR".\\.\\.\\.\\foo\\..\\.\\", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
216 5 : ret &= test_path(cli, BASEDIR".", NT_STATUS_OBJECT_NAME_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
217 5 : ret &= test_path(cli, "\\", NT_STATUS_OK,NT_STATUS_OK);
218 5 : ret &= test_path(cli, "\\.", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
219 5 : ret &= test_path(cli, "\\..\\", NT_STATUS_OBJECT_PATH_SYNTAX_BAD,NT_STATUS_DOS(ERRDOS,ERRinvalidpath));
220 5 : ret &= test_path(cli, "\\..", NT_STATUS_OBJECT_PATH_SYNTAX_BAD,NT_STATUS_DOS(ERRDOS,ERRinvalidpath));
221 5 : ret &= test_path(cli, BASEDIR "\\.", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
222 5 : ret &= test_path_ex(cli, tctx, BASEDIR "\\..", "\\", NT_STATUS_OK,NT_STATUS_OK);
223 5 : ret &= test_path(cli, BASEDIR "\\nt\\V S\\VB98\\vb600", NT_STATUS_OBJECT_NAME_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
224 5 : ret &= test_path(cli, BASEDIR "\\nt\\V S\\VB98\\vb6.exe", NT_STATUS_NOT_A_DIRECTORY,NT_STATUS_DOS(ERRDOS,ERRbadpath));
225 :
226 : /* We expect this open to fail with the same error code as the chkpath below. */
227 5 : printf("Testing Open on %s\n", BASEDIR".\\.\\.\\.\\foo\\..\\.\\");
228 : /* findfirst seems to fail with a different error. */
229 5 : (void)smbcli_nt_create_full(cli->tree, BASEDIR".\\.\\.\\.\\foo\\..\\.\\",
230 : 0, SEC_RIGHTS_FILE_ALL,
231 : FILE_ATTRIBUTE_NORMAL,
232 : NTCREATEX_SHARE_ACCESS_DELETE|
233 : NTCREATEX_SHARE_ACCESS_READ|
234 : NTCREATEX_SHARE_ACCESS_WRITE,
235 : NTCREATEX_DISP_OVERWRITE_IF,
236 : 0, 0);
237 5 : status = smbcli_nt_error(cli->tree);
238 5 : CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
239 :
240 5 : printf("Testing findfirst on %s\n", BASEDIR".\\.\\.\\.\\foo\\..\\.\\");
241 5 : status = single_search(cli, tctx, BASEDIR".\\.\\.\\.\\foo\\..\\.\\");
242 5 : CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
243 :
244 : /* We expect this open to fail with the same error code as the chkpath below. */
245 : /* findfirst seems to fail with a different error. */
246 5 : printf("Testing Open on %s\n", BASEDIR "\\nt\\V S\\VB98\\vb6.exe\\3");
247 5 : (void)smbcli_nt_create_full(cli->tree, BASEDIR "\\nt\\V S\\VB98\\vb6.exe\\3",
248 : 0, SEC_RIGHTS_FILE_ALL,
249 : FILE_ATTRIBUTE_NORMAL,
250 : NTCREATEX_SHARE_ACCESS_DELETE|
251 : NTCREATEX_SHARE_ACCESS_READ|
252 : NTCREATEX_SHARE_ACCESS_WRITE,
253 : NTCREATEX_DISP_OVERWRITE_IF,
254 : 0, 0);
255 5 : status = smbcli_nt_error(cli->tree);
256 5 : CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
257 :
258 5 : ret &= test_path(cli, BASEDIR "\\nt\\V S\\VB98\\vb6.exe\\3", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
259 5 : ret &= test_path(cli, BASEDIR "\\nt\\V S\\VB98\\vb6.exe\\3\\foo", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
260 5 : ret &= test_path(cli, BASEDIR "\\nt\\3\\foo", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
261 5 : ret &= test_path(cli, BASEDIR "\\nt\\V S\\*\\vb6.exe\\3", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
262 5 : ret &= test_path(cli, BASEDIR "\\nt\\V S\\*\\*\\vb6.exe\\3", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
263 :
264 5 : done:
265 5 : smbcli_close(cli->tree, fnum);
266 5 : return ret;
267 : }
268 :
269 5 : static bool test_chkpath_names(struct smbcli_state *cli, struct torture_context *tctx)
270 : {
271 0 : union smb_chkpath io;
272 0 : union smb_fileinfo finfo;
273 0 : NTSTATUS status;
274 5 : bool ret = true;
275 0 : uint8_t i;
276 :
277 : /*
278 : * we don't test characters >= 0x80 yet,
279 : * as somehow our client libraries can't do that
280 : */
281 640 : for (i=0x01; i <= 0x7F; i++) {
282 : /*
283 : * it's important that we test the last character
284 : * because of the error code with ':' 0x3A
285 : * and servers without stream support
286 : */
287 635 : char *path = talloc_asprintf(tctx, "%s\\File0x%02X%c",
288 : BASEDIR, i, i);
289 0 : NTSTATUS expected;
290 0 : NTSTATUS expected_dos1;
291 0 : NTSTATUS expected_dos2;
292 :
293 635 : expected = NT_STATUS_OBJECT_NAME_NOT_FOUND;
294 635 : expected_dos1 = NT_STATUS_DOS(ERRDOS,ERRbadpath);
295 635 : expected_dos2 = NT_STATUS_DOS(ERRDOS,ERRbadfile);
296 :
297 635 : switch (i) {
298 40 : case '"':/*0x22*/
299 : case '*':/*0x2A*/
300 : case '/':/*0x2F*/
301 : case ':':/*0x3A*/
302 : case '<':/*0x3C*/
303 : case '>':/*0x3E*/
304 : case '?':/*0x3F*/
305 : case '|':/*0x7C*/
306 45 : if (i == '/' &&
307 5 : torture_setting_bool(tctx, "samba3", false)) {
308 : /* samba 3 handles '/' as '\\' */
309 4 : break;
310 : }
311 36 : expected = NT_STATUS_OBJECT_NAME_INVALID;
312 36 : expected_dos1 = NT_STATUS_DOS(ERRDOS,ERRbadpath);
313 36 : expected_dos2 = NT_STATUS_DOS(ERRDOS,ERRinvalidname);
314 36 : break;
315 595 : default:
316 595 : if (i <= 0x1F) {
317 155 : expected = NT_STATUS_OBJECT_NAME_INVALID;
318 155 : expected_dos1 = NT_STATUS_DOS(ERRDOS,ERRbadpath);
319 155 : expected_dos2 = NT_STATUS_DOS(ERRDOS,ERRinvalidname);
320 : }
321 595 : break;
322 : }
323 :
324 1905 : printf("Checking File0x%02X%c%s expected[%s|%s|%s]\n",
325 635 : i, isprint(i)?(char)i:' ',
326 635 : isprint(i)?"":"(not printable)",
327 : nt_errstr(expected),
328 : nt_errstr(expected_dos1),
329 : nt_errstr(expected_dos2));
330 :
331 635 : io.chkpath.in.path = path;
332 635 : status = smb_raw_chkpath(cli->tree, &io);
333 635 : CHECK_STATUS(status, expected, expected_dos1);
334 :
335 635 : ZERO_STRUCT(finfo);
336 635 : finfo.generic.level = RAW_FILEINFO_NAME_INFO;
337 635 : finfo.generic.in.file.path = path;
338 635 : status = smb_raw_pathinfo(cli->tree, cli, &finfo);
339 635 : CHECK_STATUS(status, expected, expected_dos2);
340 :
341 635 : talloc_free(path);
342 : }
343 :
344 5 : done:
345 5 : return ret;
346 : }
347 :
348 : /*
349 : basic testing of chkpath calls
350 : */
351 5 : bool torture_raw_chkpath(struct torture_context *torture,
352 : struct smbcli_state *cli)
353 : {
354 5 : bool ret = true;
355 0 : int fnum;
356 :
357 5 : torture_assert(torture, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
358 :
359 5 : if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt"))) {
360 0 : printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
361 0 : return false;
362 : }
363 :
364 5 : if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\V S"))) {
365 0 : printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
366 0 : return false;
367 : }
368 :
369 5 : if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\V S\\VB98"))) {
370 0 : printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree));
371 0 : return false;
372 : }
373 :
374 5 : fnum = create_complex_file(cli, torture, BASEDIR "\\nt\\V S\\VB98\\vb6.exe");
375 5 : if (fnum == -1) {
376 0 : printf("failed to open \\nt\\V S\\VB98\\vb6.exe - %s\n", smbcli_errstr(cli->tree));
377 0 : ret = false;
378 0 : goto done;
379 : }
380 :
381 5 : ret &= test_chkpath(cli, torture);
382 5 : ret &= test_chkpath_names(cli, torture);
383 :
384 5 : done:
385 :
386 5 : smb_raw_exit(cli->session);
387 5 : smbcli_deltree(cli->tree, BASEDIR);
388 :
389 5 : return ret;
390 : }
|