2 Unix SMB/CIFS implementation.
3 Initial test for the smb2 client lib
4 Copyright (C) Volker Lendecke 2011
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 "torture/proto.h"
24 #include "../libcli/smb/smbXcli_base.h"
25 #include "libcli/security/security.h"
26 #include "libsmb/proto.h"
27 #include "auth/credentials/credentials.h"
28 #include "auth/gensec/gensec.h"
29 #include "auth_generic.h"
30 #include "../librpc/ndr/libndr.h"
31 #include "libsmb/clirap.h"
33 extern fstring host
, workgroup
, share
, password
, username
, myname
;
34 extern struct cli_credentials
*torture_creds
;
36 bool run_smb2_basic(int dummy
)
38 struct cli_state
*cli
;
40 uint64_t fid_persistent
, fid_volatile
;
41 const char *hello
= "Hello, world\n";
45 uint32_t dir_data_length
;
46 uint32_t saved_tid
= 0;
47 struct smbXcli_tcon
*saved_tcon
= NULL
;
48 uint64_t saved_uid
= 0;
50 printf("Starting SMB2-BASIC\n");
52 if (!torture_init_connection(&cli
)) {
56 status
= smbXcli_negprot(cli
->conn
, cli
->timeout
,
57 PROTOCOL_SMB2_02
, PROTOCOL_SMB2_02
);
58 if (!NT_STATUS_IS_OK(status
)) {
59 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
63 status
= cli_session_setup_creds(cli
, torture_creds
);
64 if (!NT_STATUS_IS_OK(status
)) {
65 printf("cli_session_setup returned %s\n", nt_errstr(status
));
69 status
= cli_tree_connect(cli
, share
, "?????", NULL
);
70 if (!NT_STATUS_IS_OK(status
)) {
71 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
75 status
= smb2cli_create(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
76 cli
->smb2
.tcon
, "smb2-basic.txt",
77 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
78 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
79 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
80 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
81 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
82 FILE_CREATE
, /* create_disposition, */
83 FILE_DELETE_ON_CLOSE
, /* create_options, */
84 NULL
, /* smb2_create_blobs *blobs */
88 if (!NT_STATUS_IS_OK(status
)) {
89 printf("smb2cli_create returned %s\n", nt_errstr(status
));
93 status
= smb2cli_write(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
94 cli
->smb2
.tcon
, strlen(hello
), 0, fid_persistent
,
95 fid_volatile
, 0, 0, (const uint8_t *)hello
, NULL
);
96 if (!NT_STATUS_IS_OK(status
)) {
97 printf("smb2cli_write returned %s\n", nt_errstr(status
));
101 status
= smb2cli_flush(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
102 cli
->smb2
.tcon
, fid_persistent
, fid_volatile
);
103 if (!NT_STATUS_IS_OK(status
)) {
104 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
108 status
= smb2cli_read(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
109 cli
->smb2
.tcon
, 0x10000, 0, fid_persistent
,
111 talloc_tos(), &result
, &nread
);
112 if (!NT_STATUS_IS_OK(status
)) {
113 printf("smb2cli_read returned %s\n", nt_errstr(status
));
117 if (nread
!= strlen(hello
)) {
118 printf("smb2cli_read returned %d bytes, expected %d\n",
119 (int)nread
, (int)strlen(hello
));
123 if (memcmp(hello
, result
, nread
) != 0) {
124 printf("smb2cli_read returned '%s', expected '%s'\n",
129 status
= smb2cli_close(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
130 cli
->smb2
.tcon
, 0, fid_persistent
, fid_volatile
);
131 if (!NT_STATUS_IS_OK(status
)) {
132 printf("smb2cli_close returned %s\n", nt_errstr(status
));
136 status
= smb2cli_create(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
138 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
139 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
142 SEC_DIR_READ_ATTRIBUTE
, /* desired_access, */
143 0, /* file_attributes, */
144 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
145 FILE_OPEN
, /* create_disposition, */
146 FILE_SYNCHRONOUS_IO_NONALERT
|FILE_DIRECTORY_FILE
, /* create_options, */
147 NULL
, /* smb2_create_blobs *blobs */
151 if (!NT_STATUS_IS_OK(status
)) {
152 printf("smb2cli_create returned %s\n", nt_errstr(status
));
156 status
= smb2cli_query_directory(
157 cli
->conn
, cli
->timeout
, cli
->smb2
.session
, cli
->smb2
.tcon
,
158 1, 0, 0, fid_persistent
, fid_volatile
, "*", 0xffff,
159 talloc_tos(), &dir_data
, &dir_data_length
);
161 if (!NT_STATUS_IS_OK(status
)) {
162 printf("smb2cli_query_directory returned %s\n", nt_errstr(status
));
166 status
= smb2cli_close(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
167 cli
->smb2
.tcon
, 0, fid_persistent
, fid_volatile
);
168 if (!NT_STATUS_IS_OK(status
)) {
169 printf("smb2cli_close returned %s\n", nt_errstr(status
));
173 saved_tid
= smb2cli_tcon_current_id(cli
->smb2
.tcon
);
174 saved_tcon
= cli_state_save_tcon(cli
);
175 if (saved_tcon
== NULL
) {
178 cli
->smb2
.tcon
= smbXcli_tcon_create(cli
);
179 smb2cli_tcon_set_values(cli
->smb2
.tcon
,
184 0, /* capabilities */
185 0 /* maximal_access */);
186 status
= smb2cli_tdis(cli
->conn
,
190 if (!NT_STATUS_IS_OK(status
)) {
191 printf("smb2cli_tdis returned %s\n", nt_errstr(status
));
194 cli_state_restore_tcon(cli
, saved_tcon
);
196 status
= smb2cli_tdis(cli
->conn
,
200 if (!NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
)) {
201 printf("2nd smb2cli_tdis returned %s\n", nt_errstr(status
));
205 saved_uid
= smb2cli_session_current_id(cli
->smb2
.session
);
206 status
= smb2cli_logoff(cli
->conn
, cli
->timeout
, cli
->smb2
.session
);
207 if (!NT_STATUS_IS_OK(status
)) {
208 printf("smb2cli_logoff returned %s\n", nt_errstr(status
));
212 cli
->smb2
.session
= smbXcli_session_create(cli
, cli
->conn
);
213 if (cli
->smb2
.session
== NULL
) {
214 printf("smbXcli_session_create() returned NULL\n");
218 smb2cli_session_set_id_and_flags(cli
->smb2
.session
, saved_uid
, 0);
220 status
= smb2cli_logoff(cli
->conn
, cli
->timeout
, cli
->smb2
.session
);
221 if (!NT_STATUS_EQUAL(status
, NT_STATUS_USER_SESSION_DELETED
)) {
222 printf("2nd smb2cli_logoff returned %s\n", nt_errstr(status
));
229 bool run_smb2_negprot(int dummy
)
231 struct cli_state
*cli
;
233 enum protocol_types protocol
;
234 const char *name
= NULL
;
236 printf("Starting SMB2-NEGPROT\n");
238 if (!torture_init_connection(&cli
)) {
242 status
= smbXcli_negprot(cli
->conn
, cli
->timeout
,
243 PROTOCOL_CORE
, PROTOCOL_LATEST
);
244 if (!NT_STATUS_IS_OK(status
)) {
245 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
249 protocol
= smbXcli_conn_protocol(cli
->conn
);
250 name
= smb_protocol_types_string(protocol
);
252 if (protocol
>= PROTOCOL_SMB2_02
) {
253 printf("Server supports %s\n", name
);
255 printf("Server DOES NOT support SMB2, only %s\n", name
);
259 status
= smbXcli_negprot(cli
->conn
, cli
->timeout
,
261 if (!NT_STATUS_EQUAL(status
, NT_STATUS_CONNECTION_RESET
) &&
262 !NT_STATUS_EQUAL(status
, NT_STATUS_CONNECTION_DISCONNECTED
) &&
263 !NT_STATUS_EQUAL(status
, NT_STATUS_CONNECTION_ABORTED
)) {
264 printf("2nd smbXcli_negprot should disconnect - returned %s\n",
269 if (smbXcli_conn_is_connected(cli
->conn
)) {
270 printf("2nd smbXcli_negprot should disconnect "
271 "- still connected\n");
278 bool run_smb2_anonymous(int dummy
)
280 struct cli_state
*cli
= NULL
;
282 struct cli_credentials
*anon_creds
= NULL
;
285 printf("Starting SMB2-ANONYMOUS\n");
287 if (!torture_init_connection(&cli
)) {
291 status
= smbXcli_negprot(cli
->conn
, cli
->timeout
,
292 PROTOCOL_SMB2_02
, PROTOCOL_LATEST
);
293 if (!NT_STATUS_IS_OK(status
)) {
294 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
298 anon_creds
= cli_credentials_init_anon(talloc_tos());
299 if (anon_creds
== NULL
) {
300 printf("cli_credentials_init_anon failed\n");
304 status
= cli_session_setup_creds(cli
, anon_creds
);
305 if (!NT_STATUS_IS_OK(status
)) {
306 printf("cli_session_setup returned %s\n", nt_errstr(status
));
310 guest
= smbXcli_session_is_guest(cli
->smb2
.session
);
312 printf("anonymous session should not have guest authentication\n");
319 bool run_smb2_session_reconnect(int dummy
)
321 struct cli_state
*cli1
;
322 struct cli_state
*cli2
;
325 uint64_t fid_persistent
, fid_volatile
;
326 struct tevent_context
*ev
;
327 struct tevent_req
*subreq
;
328 DATA_BLOB in_blob
= data_blob_null
;
330 DATA_BLOB session_key
;
331 struct auth_generic_state
*auth_generic_state
;
332 struct iovec
*recv_iov
;
333 const char *hello
= "Hello, world\n";
337 printf("Starting SMB2-SESSION-RECONNECT\n");
339 if (!torture_init_connection(&cli1
)) {
343 status
= smbXcli_negprot(cli1
->conn
, cli1
->timeout
,
344 PROTOCOL_SMB2_02
, PROTOCOL_LATEST
);
345 if (!NT_STATUS_IS_OK(status
)) {
346 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
350 status
= cli_session_setup_creds(cli1
, torture_creds
);
351 if (!NT_STATUS_IS_OK(status
)) {
352 printf("cli_session_setup returned %s\n", nt_errstr(status
));
356 status
= cli_tree_connect(cli1
, share
, "?????", NULL
);
357 if (!NT_STATUS_IS_OK(status
)) {
358 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
362 status
= smb2cli_create(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
363 cli1
->smb2
.tcon
, "session-reconnect.txt",
364 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
365 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
366 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
367 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
368 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
369 FILE_CREATE
, /* create_disposition, */
370 FILE_DELETE_ON_CLOSE
, /* create_options, */
371 NULL
, /* smb2_create_blobs *blobs */
375 if (!NT_STATUS_IS_OK(status
)) {
376 printf("smb2cli_create on cli1 %s\n", nt_errstr(status
));
380 status
= smb2cli_write(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
381 cli1
->smb2
.tcon
, strlen(hello
), 0, fid_persistent
,
382 fid_volatile
, 0, 0, (const uint8_t *)hello
, NULL
);
383 if (!NT_STATUS_IS_OK(status
)) {
384 printf("smb2cli_write returned %s\n", nt_errstr(status
));
388 status
= smb2cli_flush(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
389 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
390 if (!NT_STATUS_IS_OK(status
)) {
391 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
395 status
= smb2cli_read(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
396 cli1
->smb2
.tcon
, 0x10000, 0, fid_persistent
,
398 talloc_tos(), &result
, &nread
);
399 if (!NT_STATUS_IS_OK(status
)) {
400 printf("smb2cli_read returned %s\n", nt_errstr(status
));
404 if (nread
!= strlen(hello
)) {
405 printf("smb2cli_read returned %d bytes, expected %d\n",
406 (int)nread
, (int)strlen(hello
));
410 if (memcmp(hello
, result
, nread
) != 0) {
411 printf("smb2cli_read returned '%s', expected '%s'\n",
416 /* prepare second session */
418 if (!torture_init_connection(&cli2
)) {
422 status
= smbXcli_negprot(cli2
->conn
, cli2
->timeout
,
423 PROTOCOL_SMB2_02
, PROTOCOL_LATEST
);
424 if (!NT_STATUS_IS_OK(status
)) {
425 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
429 status
= auth_generic_client_prepare(talloc_tos(), &auth_generic_state
);
430 if (!NT_STATUS_IS_OK(status
)) {
431 printf("auth_generic_client_prepare returned %s\n", nt_errstr(status
));
435 gensec_want_feature(auth_generic_state
->gensec_security
,
436 GENSEC_FEATURE_SESSION_KEY
);
438 status
= auth_generic_set_creds(auth_generic_state
, torture_creds
);
439 if (!NT_STATUS_IS_OK(status
)) {
440 printf("auth_generic_set_creds returned %s\n", nt_errstr(status
));
444 status
= auth_generic_client_start(auth_generic_state
, GENSEC_OID_NTLMSSP
);
445 if (!NT_STATUS_IS_OK(status
)) {
446 printf("auth_generic_client_start returned %s\n", nt_errstr(status
));
450 ev
= samba_tevent_context_init(talloc_tos());
452 printf("samba_tevent_context_init() returned NULL\n");
456 status
= gensec_update(auth_generic_state
->gensec_security
,
457 talloc_tos(), data_blob_null
, &in_blob
);
458 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
459 printf("gensec_update returned %s\n", nt_errstr(status
));
463 cli2
->smb2
.session
= smbXcli_session_create(cli2
, cli2
->conn
);
465 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
470 SMB2_CAP_DFS
, /* in_capabilities */
472 /* in_previous_session_id: */
473 smb2cli_session_current_id(cli1
->smb2
.session
),
474 &in_blob
); /* in_security_buffer */
475 if (subreq
== NULL
) {
476 printf("smb2cli_session_setup_send() returned NULL\n");
480 ok
= tevent_req_poll(subreq
, ev
);
482 printf("tevent_req_poll() returned false\n");
486 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
488 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
489 printf("smb2cli_session_setup_recv returned %s\n",
494 status
= gensec_update(auth_generic_state
->gensec_security
,
495 talloc_tos(), out_blob
, &in_blob
);
496 if (!NT_STATUS_IS_OK(status
)) {
497 printf("auth_generic_update returned %s\n", nt_errstr(status
));
501 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
506 SMB2_CAP_DFS
, /* in_capabilities */
508 /* in_previous_session_id: */
509 smb2cli_session_current_id(cli1
->smb2
.session
),
510 &in_blob
); /* in_security_buffer */
511 if (subreq
== NULL
) {
512 printf("smb2cli_session_setup_send() returned NULL\n");
516 ok
= tevent_req_poll(subreq
, ev
);
518 printf("tevent_req_poll() returned false\n");
522 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
523 &recv_iov
, &out_blob
);
524 if (!NT_STATUS_IS_OK(status
)) {
525 printf("smb2cli_session_setup_recv returned %s\n",
530 status
= gensec_session_key(auth_generic_state
->gensec_security
, talloc_tos(),
532 if (!NT_STATUS_IS_OK(status
)) {
533 printf("gensec_session_key returned %s\n",
538 /* check file operation on the old client */
540 status
= smb2cli_flush(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
541 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
542 if (!NT_STATUS_EQUAL(status
, NT_STATUS_USER_SESSION_DELETED
)) {
543 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
547 status
= cli_tree_connect(cli1
, share
, "?????", NULL
);
548 if (!NT_STATUS_EQUAL(status
, NT_STATUS_USER_SESSION_DELETED
)) {
549 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
554 * checking file operations without signing.
555 * on w2k8r2 at least, flush, read and write also work the same way,
556 * while create gives ACCESS_DENIED without signing
558 status
= smb2cli_flush(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
559 cli2
->smb2
.tcon
, fid_persistent
, fid_volatile
);
560 if (!NT_STATUS_EQUAL(status
, NT_STATUS_FILE_CLOSED
) &&
561 !NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
))
563 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
567 status
= smb2cli_write(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
568 cli2
->smb2
.tcon
, strlen(hello
), 0, fid_persistent
,
569 fid_volatile
, 0, 0, (const uint8_t *)hello
, NULL
);
570 if (!NT_STATUS_EQUAL(status
, NT_STATUS_FILE_CLOSED
) &&
571 !NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
))
573 printf("smb2cli_write returned %s\n", nt_errstr(status
));
577 status
= smb2cli_read(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
578 cli2
->smb2
.tcon
, 0x10000, 0, fid_persistent
,
580 talloc_tos(), &result
, &nread
);
581 if (!NT_STATUS_EQUAL(status
, NT_STATUS_FILE_CLOSED
) &&
582 !NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
))
584 printf("smb2cli_read returned %s\n", nt_errstr(status
));
588 status
= smb2cli_create(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
589 cli2
->smb2
.tcon
, "session-reconnect.txt",
590 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
591 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
592 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
593 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
594 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
595 FILE_CREATE
, /* create_disposition, */
596 FILE_DELETE_ON_CLOSE
, /* create_options, */
597 NULL
, /* smb2_create_blobs *blobs */
601 if (!NT_STATUS_EQUAL(status
, NT_STATUS_ACCESS_DENIED
) &&
602 !NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
)) {
603 printf("smb2cli_create on cli2 %s\n", nt_errstr(status
));
607 /* now grab the session key and try with signing */
609 status
= smb2cli_session_set_session_key(cli2
->smb2
.session
,
612 if (!NT_STATUS_IS_OK(status
)) {
613 printf("smb2cli_session_set_session_key %s\n", nt_errstr(status
));
617 /* the tid seems to be irrelevant at this stage */
619 status
= smb2cli_flush(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
620 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
621 if (!NT_STATUS_EQUAL(status
, NT_STATUS_FILE_CLOSED
) &&
622 !NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
))
624 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
628 status
= smb2cli_write(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
629 cli1
->smb2
.tcon
, strlen(hello
), 0, fid_persistent
,
630 fid_volatile
, 0, 0, (const uint8_t *)hello
, NULL
);
631 if (!NT_STATUS_EQUAL(status
, NT_STATUS_FILE_CLOSED
) &&
632 !NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
))
634 printf("smb2cli_write returned %s\n", nt_errstr(status
));
638 status
= smb2cli_read(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
639 cli1
->smb2
.tcon
, 0x10000, 0, fid_persistent
,
641 talloc_tos(), &result
, &nread
);
642 if (!NT_STATUS_EQUAL(status
, NT_STATUS_FILE_CLOSED
) &&
643 !NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
))
645 printf("smb2cli_read returned %s\n", nt_errstr(status
));
649 status
= smb2cli_create(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
650 cli1
->smb2
.tcon
, "session-reconnect.txt",
651 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
652 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
653 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
654 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
655 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
656 FILE_CREATE
, /* create_disposition, */
657 FILE_DELETE_ON_CLOSE
, /* create_options, */
658 NULL
, /* smb2_create_blobs *blobs */
662 if (!NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
) &&
663 !NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
))
665 printf("smb2cli_create on cli2 %s\n", nt_errstr(status
));
669 /* now do a new tcon and test file calls again */
671 status
= cli_tree_connect(cli2
, share
, "?????", NULL
);
672 if (!NT_STATUS_IS_OK(status
)) {
673 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
677 status
= smb2cli_create(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
678 cli2
->smb2
.tcon
, "session-reconnect.txt",
679 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
680 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
681 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
682 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
683 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
684 FILE_CREATE
, /* create_disposition, */
685 FILE_DELETE_ON_CLOSE
, /* create_options, */
686 NULL
, /* smb2_create_blobs *blobs */
690 if (!NT_STATUS_IS_OK(status
)) {
691 printf("smb2cli_create on cli2 %s\n", nt_errstr(status
));
695 status
= smb2cli_write(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
696 cli2
->smb2
.tcon
, strlen(hello
), 0, fid_persistent
,
697 fid_volatile
, 0, 0, (const uint8_t *)hello
, NULL
);
698 if (!NT_STATUS_IS_OK(status
)) {
699 printf("smb2cli_write returned %s\n", nt_errstr(status
));
703 status
= smb2cli_flush(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
704 cli2
->smb2
.tcon
, fid_persistent
, fid_volatile
);
705 if (!NT_STATUS_IS_OK(status
)) {
706 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
710 status
= smb2cli_read(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
711 cli2
->smb2
.tcon
, 0x10000, 0, fid_persistent
,
713 talloc_tos(), &result
, &nread
);
714 if (!NT_STATUS_IS_OK(status
)) {
715 printf("smb2cli_read returned %s\n", nt_errstr(status
));
719 if (nread
!= strlen(hello
)) {
720 printf("smb2cli_read returned %d bytes, expected %d\n",
721 (int)nread
, (int)strlen(hello
));
725 if (memcmp(hello
, result
, nread
) != 0) {
726 printf("smb2cli_read returned '%s', expected '%s'\n",
734 bool run_smb2_tcon_dependence(int dummy
)
736 struct cli_state
*cli
;
738 uint64_t fid_persistent
, fid_volatile
;
739 const char *hello
= "Hello, world\n";
742 struct smbXcli_tcon
*tcon2
;
745 printf("Starting SMB2-TCON-DEPENDENCE\n");
747 if (!torture_init_connection(&cli
)) {
751 status
= smbXcli_negprot(cli
->conn
, cli
->timeout
,
752 PROTOCOL_SMB2_02
, PROTOCOL_LATEST
);
753 if (!NT_STATUS_IS_OK(status
)) {
754 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
758 status
= cli_session_setup_creds(cli
, torture_creds
);
759 if (!NT_STATUS_IS_OK(status
)) {
760 printf("cli_session_setup returned %s\n", nt_errstr(status
));
764 status
= cli_tree_connect(cli
, share
, "?????", NULL
);
765 if (!NT_STATUS_IS_OK(status
)) {
766 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
770 status
= smb2cli_create(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
771 cli
->smb2
.tcon
, "tcon_depedence.txt",
772 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
773 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
774 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
775 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
776 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
777 FILE_CREATE
, /* create_disposition, */
778 FILE_DELETE_ON_CLOSE
, /* create_options, */
779 NULL
, /* smb2_create_blobs *blobs */
783 if (!NT_STATUS_IS_OK(status
)) {
784 printf("smb2cli_create on cli %s\n", nt_errstr(status
));
788 status
= smb2cli_write(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
789 cli
->smb2
.tcon
, strlen(hello
), 0, fid_persistent
,
790 fid_volatile
, 0, 0, (const uint8_t *)hello
, NULL
);
791 if (!NT_STATUS_IS_OK(status
)) {
792 printf("smb2cli_write returned %s\n", nt_errstr(status
));
796 status
= smb2cli_flush(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
797 cli
->smb2
.tcon
, fid_persistent
, fid_volatile
);
798 if (!NT_STATUS_IS_OK(status
)) {
799 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
803 status
= smb2cli_read(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
804 cli
->smb2
.tcon
, 0x10000, 0, fid_persistent
,
806 talloc_tos(), &result
, &nread
);
807 if (!NT_STATUS_IS_OK(status
)) {
808 printf("smb2cli_read returned %s\n", nt_errstr(status
));
812 if (nread
!= strlen(hello
)) {
813 printf("smb2cli_read returned %d bytes, expected %d\n",
814 (int)nread
, (int)strlen(hello
));
818 if (memcmp(hello
, result
, nread
) != 0) {
819 printf("smb2cli_read returned '%s', expected '%s'\n",
824 /* check behaviour with wrong tid... */
826 tcon2
= smbXcli_tcon_create(cli
);
827 tcon2_id
= smb2cli_tcon_current_id(cli
->smb2
.tcon
);
829 smb2cli_tcon_set_values(tcon2
,
834 0, /* capabilities */
835 0 /* maximal_access */);
837 status
= smb2cli_read(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
838 tcon2
, 0x10000, 0, fid_persistent
,
840 talloc_tos(), &result
, &nread
);
841 if (!NT_STATUS_EQUAL(status
, NT_STATUS_NETWORK_NAME_DELETED
)) {
842 printf("smb2cli_read returned %s\n", nt_errstr(status
));
851 bool run_smb2_multi_channel(int dummy
)
853 struct cli_state
*cli1
;
854 struct cli_state
*cli2
;
855 struct cli_state
*cli3
;
858 uint64_t fid_persistent
, fid_volatile
;
859 struct tevent_context
*ev
;
860 struct tevent_req
*subreq
;
861 DATA_BLOB in_blob
= data_blob_null
;
863 DATA_BLOB channel_session_key
;
864 struct auth_generic_state
*auth_generic_state
;
865 struct iovec
*recv_iov
;
866 const char *hello
= "Hello, world\n";
869 struct GUID saved_guid
= cli_state_client_guid
;
871 printf("Starting SMB2-MULTI-CHANNEL\n");
873 cli_state_client_guid
= GUID_random();
875 if (!torture_init_connection(&cli1
)) {
879 if (!torture_init_connection(&cli2
)) {
883 if (!torture_init_connection(&cli3
)) {
887 cli_state_client_guid
= saved_guid
;
889 status
= smbXcli_negprot(cli1
->conn
, cli1
->timeout
,
890 PROTOCOL_SMB2_22
, PROTOCOL_LATEST
);
891 if (!NT_STATUS_IS_OK(status
)) {
892 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
896 status
= smbXcli_negprot(cli2
->conn
, cli2
->timeout
,
897 PROTOCOL_SMB2_22
, PROTOCOL_LATEST
);
898 if (!NT_STATUS_IS_OK(status
)) {
899 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
903 status
= smbXcli_negprot(cli3
->conn
, cli3
->timeout
,
904 PROTOCOL_SMB2_22
, PROTOCOL_LATEST
);
905 if (!NT_STATUS_IS_OK(status
)) {
906 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
910 status
= cli_session_setup_creds(cli1
, torture_creds
);
911 if (!NT_STATUS_IS_OK(status
)) {
912 printf("smb2cli_sesssetup returned %s\n", nt_errstr(status
));
916 status
= cli_tree_connect(cli1
, share
, "?????", NULL
);
917 if (!NT_STATUS_IS_OK(status
)) {
918 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
922 status
= smb2cli_session_create_channel(cli2
,
925 &cli2
->smb2
.session
);
926 if (!NT_STATUS_IS_OK(status
)) {
927 printf("smb2cli_session_create_channel returned %s\n",
932 status
= auth_generic_client_prepare(talloc_tos(), &auth_generic_state
);
933 if (!NT_STATUS_IS_OK(status
)) {
934 printf("auth_generic_client_prepare returned %s\n", nt_errstr(status
));
938 gensec_want_feature(auth_generic_state
->gensec_security
,
939 GENSEC_FEATURE_SESSION_KEY
);
941 status
= auth_generic_set_creds(auth_generic_state
, torture_creds
);
942 if (!NT_STATUS_IS_OK(status
)) {
943 printf("auth_generic_set_creds returned %s\n", nt_errstr(status
));
947 status
= auth_generic_client_start(auth_generic_state
, GENSEC_OID_NTLMSSP
);
948 if (!NT_STATUS_IS_OK(status
)) {
949 printf("auth_generic_client_start returned %s\n", nt_errstr(status
));
953 ev
= samba_tevent_context_init(talloc_tos());
955 printf("samba_tevent_context_init() returned NULL\n");
959 status
= gensec_update(auth_generic_state
->gensec_security
,
960 talloc_tos(), data_blob_null
, &in_blob
);
961 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
962 printf("gensec_update returned %s\n", nt_errstr(status
));
966 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
971 SMB2_CAP_DFS
, /* in_capabilities */
973 0, /* in_previous_session_id */
974 &in_blob
); /* in_security_buffer */
975 if (subreq
== NULL
) {
976 printf("smb2cli_session_setup_send() returned NULL\n");
980 ok
= tevent_req_poll(subreq
, ev
);
982 printf("tevent_req_poll() returned false\n");
986 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
988 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
989 printf("smb2cli_session_setup_recv returned %s\n",
994 status
= gensec_update(auth_generic_state
->gensec_security
,
995 talloc_tos(), out_blob
, &in_blob
);
996 if (!NT_STATUS_IS_OK(status
)) {
997 printf("auth_generic_update returned %s\n", nt_errstr(status
));
1001 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
1005 0x01, /* in_flags */
1006 SMB2_CAP_DFS
, /* in_capabilities */
1008 0, /* in_previous_session_id */
1009 &in_blob
); /* in_security_buffer */
1010 if (subreq
== NULL
) {
1011 printf("smb2cli_session_setup_send() returned NULL\n");
1015 ok
= tevent_req_poll(subreq
, ev
);
1017 printf("tevent_req_poll() returned false\n");
1021 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
1022 &recv_iov
, &out_blob
);
1023 if (!NT_STATUS_IS_OK(status
)) {
1024 printf("smb2cli_session_setup_recv returned %s\n",
1029 status
= gensec_session_key(auth_generic_state
->gensec_security
, talloc_tos(),
1030 &channel_session_key
);
1031 if (!NT_STATUS_IS_OK(status
)) {
1032 printf("gensec_session_key returned %s\n",
1037 status
= smb2cli_session_set_channel_key(cli2
->smb2
.session
,
1038 channel_session_key
,
1040 if (!NT_STATUS_IS_OK(status
)) {
1041 printf("smb2cli_session_set_channel_key %s\n", nt_errstr(status
));
1045 status
= smb2cli_session_create_channel(cli3
,
1048 &cli3
->smb2
.session
);
1049 if (!NT_STATUS_IS_OK(status
)) {
1050 printf("smb2cli_session_create_channel returned %s\n",
1055 status
= auth_generic_client_prepare(talloc_tos(), &auth_generic_state
);
1056 if (!NT_STATUS_IS_OK(status
)) {
1057 printf("auth_generic_client_prepare returned %s\n", nt_errstr(status
));
1061 gensec_want_feature(auth_generic_state
->gensec_security
,
1062 GENSEC_FEATURE_SESSION_KEY
);
1064 status
= auth_generic_set_creds(auth_generic_state
, torture_creds
);
1065 if (!NT_STATUS_IS_OK(status
)) {
1066 printf("auth_generic_set_creds returned %s\n", nt_errstr(status
));
1070 status
= auth_generic_client_start(auth_generic_state
, GENSEC_OID_NTLMSSP
);
1071 if (!NT_STATUS_IS_OK(status
)) {
1072 printf("auth_generic_client_start returned %s\n", nt_errstr(status
));
1076 status
= gensec_update(auth_generic_state
->gensec_security
,
1077 talloc_tos(), data_blob_null
, &in_blob
);
1078 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
1079 printf("gensec_update returned %s\n", nt_errstr(status
));
1083 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
1087 0x01, /* in_flags */
1088 SMB2_CAP_DFS
, /* in_capabilities */
1090 0, /* in_previous_session_id */
1091 &in_blob
); /* in_security_buffer */
1092 if (subreq
== NULL
) {
1093 printf("smb2cli_session_setup_send() returned NULL\n");
1097 ok
= tevent_req_poll(subreq
, ev
);
1099 printf("tevent_req_poll() returned false\n");
1103 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
1105 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
1106 printf("smb2cli_session_setup_recv returned %s\n",
1111 status
= gensec_update(auth_generic_state
->gensec_security
,
1112 talloc_tos(), out_blob
, &in_blob
);
1113 if (!NT_STATUS_IS_OK(status
)) {
1114 printf("auth_generic_update returned %s\n", nt_errstr(status
));
1118 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
1122 0x01, /* in_flags */
1123 SMB2_CAP_DFS
, /* in_capabilities */
1125 0, /* in_previous_session_id */
1126 &in_blob
); /* in_security_buffer */
1127 if (subreq
== NULL
) {
1128 printf("smb2cli_session_setup_send() returned NULL\n");
1132 ok
= tevent_req_poll(subreq
, ev
);
1134 printf("tevent_req_poll() returned false\n");
1138 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
1139 &recv_iov
, &out_blob
);
1140 if (!NT_STATUS_IS_OK(status
)) {
1141 printf("smb2cli_session_setup_recv returned %s\n",
1146 status
= gensec_session_key(auth_generic_state
->gensec_security
, talloc_tos(),
1147 &channel_session_key
);
1148 if (!NT_STATUS_IS_OK(status
)) {
1149 printf("gensec_session_key returned %s\n",
1154 status
= smb2cli_session_set_channel_key(cli3
->smb2
.session
,
1155 channel_session_key
,
1157 if (!NT_STATUS_IS_OK(status
)) {
1158 printf("smb2cli_session_set_channel_key %s\n", nt_errstr(status
));
1162 status
= smb2cli_create(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
1163 cli1
->smb2
.tcon
, "multi-channel.txt",
1164 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
1165 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
1166 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
1167 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
1168 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
1169 FILE_CREATE
, /* create_disposition, */
1170 FILE_DELETE_ON_CLOSE
, /* create_options, */
1171 NULL
, /* smb2_create_blobs *blobs */
1175 if (!NT_STATUS_IS_OK(status
)) {
1176 printf("smb2cli_create on cli2 %s\n", nt_errstr(status
));
1180 status
= smb2cli_write(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
1181 cli1
->smb2
.tcon
, strlen(hello
), 0, fid_persistent
,
1182 fid_volatile
, 0, 0, (const uint8_t *)hello
, NULL
);
1183 if (!NT_STATUS_IS_OK(status
)) {
1184 printf("smb2cli_write returned %s\n", nt_errstr(status
));
1188 status
= smb2cli_flush(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
1189 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1190 if (!NT_STATUS_IS_OK(status
)) {
1191 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1195 status
= smb2cli_flush(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
1196 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1197 if (!NT_STATUS_IS_OK(status
)) {
1198 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1202 status
= smb2cli_flush(cli3
->conn
, cli3
->timeout
, cli3
->smb2
.session
,
1203 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1204 if (!NT_STATUS_IS_OK(status
)) {
1205 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1209 status
= smb2cli_read(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
1210 cli1
->smb2
.tcon
, 0x10000, 0, fid_persistent
,
1212 talloc_tos(), &result
, &nread
);
1213 if (!NT_STATUS_IS_OK(status
)) {
1214 printf("smb2cli_read returned %s\n", nt_errstr(status
));
1218 if (nread
!= strlen(hello
)) {
1219 printf("smb2cli_read returned %d bytes, expected %d\n",
1220 (int)nread
, (int)strlen(hello
));
1224 if (memcmp(hello
, result
, nread
) != 0) {
1225 printf("smb2cli_read returned '%s', expected '%s'\n",
1230 status
= auth_generic_client_prepare(talloc_tos(), &auth_generic_state
);
1231 if (!NT_STATUS_IS_OK(status
)) {
1232 printf("auth_generic_client_prepare returned %s\n", nt_errstr(status
));
1236 gensec_want_feature(auth_generic_state
->gensec_security
,
1237 GENSEC_FEATURE_SESSION_KEY
);
1239 status
= auth_generic_set_creds(auth_generic_state
, torture_creds
);
1240 if (!NT_STATUS_IS_OK(status
)) {
1241 printf("auth_generic_set_creds returned %s\n", nt_errstr(status
));
1245 status
= auth_generic_client_start(auth_generic_state
, GENSEC_OID_NTLMSSP
);
1246 if (!NT_STATUS_IS_OK(status
)) {
1247 printf("auth_generic_client_start returned %s\n", nt_errstr(status
));
1251 status
= gensec_update(auth_generic_state
->gensec_security
,
1252 talloc_tos(), data_blob_null
, &in_blob
);
1253 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
1254 printf("gensec_update returned %s\n", nt_errstr(status
));
1258 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
1263 SMB2_CAP_DFS
, /* in_capabilities */
1265 0, /* in_previous_session_id */
1266 &in_blob
); /* in_security_buffer */
1267 if (subreq
== NULL
) {
1268 printf("smb2cli_session_setup_send() returned NULL\n");
1272 ok
= tevent_req_poll(subreq
, ev
);
1274 printf("tevent_req_poll() returned false\n");
1278 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
1280 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
1281 printf("smb2cli_session_setup_recv returned %s\n",
1286 status
= gensec_update(auth_generic_state
->gensec_security
,
1287 talloc_tos(), out_blob
, &in_blob
);
1288 if (!NT_STATUS_IS_OK(status
)) {
1289 printf("auth_generic_update returned %s\n", nt_errstr(status
));
1293 status
= smb2cli_flush(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
1294 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1295 if (!NT_STATUS_IS_OK(status
)) {
1296 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1300 status
= smb2cli_flush(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
1301 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1302 if (!NT_STATUS_IS_OK(status
)) {
1303 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1307 status
= smb2cli_flush(cli3
->conn
, cli3
->timeout
, cli3
->smb2
.session
,
1308 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1309 if (!NT_STATUS_IS_OK(status
)) {
1310 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1314 status
= smb2cli_create(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
1315 cli1
->smb2
.tcon
, "multi-channel-invalid.txt",
1316 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
1317 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
1318 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
1319 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
1320 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
1321 FILE_CREATE
, /* create_disposition, */
1322 FILE_DELETE_ON_CLOSE
, /* create_options, */
1323 NULL
, /* smb2_create_blobs *blobs */
1327 if (!NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
1328 printf("smb2cli_create %s\n", nt_errstr(status
));
1332 status
= smb2cli_create(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
1333 cli1
->smb2
.tcon
, "multi-channel-invalid.txt",
1334 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
1335 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
1336 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
1337 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
1338 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
1339 FILE_CREATE
, /* create_disposition, */
1340 FILE_DELETE_ON_CLOSE
, /* create_options, */
1341 NULL
, /* smb2_create_blobs *blobs */
1345 if (!NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
1346 printf("smb2cli_create %s\n", nt_errstr(status
));
1350 status
= smb2cli_create(cli3
->conn
, cli3
->timeout
, cli3
->smb2
.session
,
1351 cli1
->smb2
.tcon
, "multi-channel-invalid.txt",
1352 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
1353 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
1354 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
1355 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
1356 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
1357 FILE_CREATE
, /* create_disposition, */
1358 FILE_DELETE_ON_CLOSE
, /* create_options, */
1359 NULL
, /* smb2_create_blobs *blobs */
1363 if (!NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
1364 printf("smb2cli_create %s\n", nt_errstr(status
));
1368 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
1373 SMB2_CAP_DFS
, /* in_capabilities */
1375 0, /* in_previous_session_id */
1376 &in_blob
); /* in_security_buffer */
1377 if (subreq
== NULL
) {
1378 printf("smb2cli_session_setup_send() returned NULL\n");
1382 ok
= tevent_req_poll(subreq
, ev
);
1384 printf("tevent_req_poll() returned false\n");
1388 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
1389 &recv_iov
, &out_blob
);
1390 if (!NT_STATUS_IS_OK(status
)) {
1391 printf("smb2cli_session_setup_recv returned %s\n",
1396 status
= smb2cli_close(cli3
->conn
, cli3
->timeout
, cli3
->smb2
.session
,
1397 cli1
->smb2
.tcon
, 0, fid_persistent
, fid_volatile
);
1398 if (!NT_STATUS_IS_OK(status
)) {
1399 printf("smb2cli_close returned %s\n", nt_errstr(status
));
1403 status
= smb2cli_flush(cli3
->conn
, cli3
->timeout
, cli3
->smb2
.session
,
1404 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1405 if (!NT_STATUS_EQUAL(status
, NT_STATUS_FILE_CLOSED
)) {
1406 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1410 status
= smb2cli_flush(cli2
->conn
, cli2
->timeout
, cli2
->smb2
.session
,
1411 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1412 if (!NT_STATUS_EQUAL(status
, NT_STATUS_FILE_CLOSED
)) {
1413 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1417 status
= smb2cli_flush(cli1
->conn
, cli1
->timeout
, cli1
->smb2
.session
,
1418 cli1
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1419 if (!NT_STATUS_EQUAL(status
, NT_STATUS_FILE_CLOSED
)) {
1420 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1427 bool run_smb2_session_reauth(int dummy
)
1429 struct cli_state
*cli
;
1432 uint64_t fid_persistent
, fid_volatile
;
1433 uint64_t dir_persistent
, dir_volatile
;
1435 uint32_t dir_data_length
;
1436 struct tevent_context
*ev
;
1437 struct tevent_req
*subreq
;
1438 DATA_BLOB in_blob
= data_blob_null
;
1440 DATA_BLOB in_input_buffer
;
1441 DATA_BLOB out_output_buffer
;
1442 uint8_t in_file_info_class
;
1443 struct auth_generic_state
*auth_generic_state
;
1444 struct iovec
*recv_iov
;
1446 struct smbXcli_tcon
*saved_tcon
;
1448 printf("Starting SMB2-SESSION_REAUTH\n");
1450 if (!torture_init_connection(&cli
)) {
1455 * PROTOCOL_SMB2_22 has a bug in win8pre0
1456 * it behaves like PROTOCOL_SMB2_02
1457 * and returns NT_STATUS_REQUEST_NOT_ACCEPTED,
1458 * while it allows it on PROTOCOL_SMB2_02.
1460 status
= smbXcli_negprot(cli
->conn
, cli
->timeout
,
1461 PROTOCOL_SMB2_10
, PROTOCOL_SMB2_10
);
1462 if (!NT_STATUS_IS_OK(status
)) {
1463 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
1467 status
= cli_session_setup_creds(cli
, torture_creds
);
1468 if (!NT_STATUS_IS_OK(status
)) {
1469 printf("smb2cli_sesssetup returned %s\n", nt_errstr(status
));
1473 status
= cli_tree_connect(cli
, share
, "?????", NULL
);
1474 if (!NT_STATUS_IS_OK(status
)) {
1475 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
1479 status
= smb2cli_create(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1480 cli
->smb2
.tcon
, "session-reauth.txt",
1481 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
1482 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
1483 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
1484 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
1485 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
1486 FILE_CREATE
, /* create_disposition, */
1487 FILE_DELETE_ON_CLOSE
, /* create_options, */
1488 NULL
, /* smb2_create_blobs *blobs */
1492 if (!NT_STATUS_IS_OK(status
)) {
1493 printf("smb2cli_create %s\n", nt_errstr(status
));
1497 status
= smb2cli_create(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1499 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
1500 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
1501 SEC_STD_SYNCHRONIZE
|
1503 SEC_DIR_READ_ATTRIBUTE
, /* desired_access, */
1504 0, /* file_attributes, */
1505 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
1506 FILE_OPEN
, /* create_disposition, */
1507 FILE_SYNCHRONOUS_IO_NONALERT
|FILE_DIRECTORY_FILE
, /* create_options, */
1508 NULL
, /* smb2_create_blobs *blobs */
1512 if (!NT_STATUS_IS_OK(status
)) {
1513 printf("smb2cli_create returned %s\n", nt_errstr(status
));
1517 status
= smb2cli_query_directory(
1518 cli
->conn
, cli
->timeout
, cli
->smb2
.session
, cli
->smb2
.tcon
,
1519 1, 0x3, 0, dir_persistent
, dir_volatile
,
1520 "session-reauth.txt", 0xffff,
1521 talloc_tos(), &dir_data
, &dir_data_length
);
1522 if (!NT_STATUS_IS_OK(status
)) {
1523 printf("smb2cli_query_directory returned %s\n", nt_errstr(status
));
1527 status
= auth_generic_client_prepare(talloc_tos(), &auth_generic_state
);
1528 if (!NT_STATUS_IS_OK(status
)) {
1529 printf("auth_generic_client_prepare returned %s\n", nt_errstr(status
));
1533 gensec_want_feature(auth_generic_state
->gensec_security
,
1534 GENSEC_FEATURE_SESSION_KEY
);
1536 status
= auth_generic_set_creds(auth_generic_state
, torture_creds
);
1537 if (!NT_STATUS_IS_OK(status
)) {
1538 printf("auth_generic_set_creds returned %s\n", nt_errstr(status
));
1542 status
= auth_generic_client_start(auth_generic_state
, GENSEC_OID_NTLMSSP
);
1543 if (!NT_STATUS_IS_OK(status
)) {
1544 printf("auth_generic_client_start returned %s\n", nt_errstr(status
));
1548 ev
= samba_tevent_context_init(talloc_tos());
1550 printf("samba_tevent_context_init() returned NULL\n");
1554 status
= gensec_update(auth_generic_state
->gensec_security
,
1555 talloc_tos(), data_blob_null
, &in_blob
);
1556 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
1557 printf("gensec_update returned %s\n", nt_errstr(status
));
1561 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
1566 SMB2_CAP_DFS
, /* in_capabilities */
1568 0, /* in_previous_session_id */
1569 &in_blob
); /* in_security_buffer */
1570 if (subreq
== NULL
) {
1571 printf("smb2cli_session_setup_send() returned NULL\n");
1575 ok
= tevent_req_poll(subreq
, ev
);
1577 printf("tevent_req_poll() returned false\n");
1581 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
1583 if (!NT_STATUS_EQUAL(status
, NT_STATUS_MORE_PROCESSING_REQUIRED
)) {
1584 printf("smb2cli_session_setup_recv returned %s\n",
1589 status
= gensec_update(auth_generic_state
->gensec_security
,
1590 talloc_tos(), out_blob
, &in_blob
);
1591 if (!NT_STATUS_IS_OK(status
)) {
1592 printf("auth_generic_update returned %s\n", nt_errstr(status
));
1596 status
= smb2cli_flush(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1597 cli
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1598 if (!NT_STATUS_IS_OK(status
)) {
1599 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1603 status
= smb2cli_query_directory(
1604 cli
->conn
, cli
->timeout
, cli
->smb2
.session
, cli
->smb2
.tcon
,
1605 1, 0x3, 0, dir_persistent
, dir_volatile
,
1606 "session-reauth.txt", 0xffff,
1607 talloc_tos(), &dir_data
, &dir_data_length
);
1608 if (!NT_STATUS_IS_OK(status
)) {
1609 printf("smb2cli_query_directory returned %s\n", nt_errstr(status
));
1614 * query_info seems to be a path based operation on Windows...
1616 status
= smb2cli_query_info(cli
->conn
,
1620 SMB2_GETINFO_SECURITY
,
1621 0, /* in_file_info_class */
1622 1024, /* in_max_output_length */
1623 NULL
, /* in_input_buffer */
1624 SECINFO_OWNER
, /* in_additional_info */
1629 &out_output_buffer
);
1630 if (!NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
1631 printf("smb2cli_query_info (security) returned %s\n", nt_errstr(status
));
1635 in_file_info_class
= SMB_FILE_POSITION_INFORMATION
- 1000;
1636 status
= smb2cli_query_info(cli
->conn
,
1642 1024, /* in_max_output_length */
1643 NULL
, /* in_input_buffer */
1644 0, /* in_additional_info */
1649 &out_output_buffer
);
1650 if (!NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
1651 printf("smb2cli_query_info (position) returned %s\n", nt_errstr(status
));
1655 in_input_buffer
= data_blob_talloc(talloc_tos(), NULL
, 8);
1656 SBVAL(in_input_buffer
.data
, 0, 512);
1658 in_file_info_class
= SMB_FILE_POSITION_INFORMATION
- 1000;
1659 status
= smb2cli_set_info(cli
->conn
,
1666 0, /* in_additional_info */
1669 if (!NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
1670 printf("smb2cli_set_info (position) returned %s\n", nt_errstr(status
));
1674 status
= smb2cli_create(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1675 cli
->smb2
.tcon
, "session-reauth-invalid.txt",
1676 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
1677 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
1678 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
1679 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
1680 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
1681 FILE_CREATE
, /* create_disposition, */
1682 FILE_DELETE_ON_CLOSE
, /* create_options, */
1683 NULL
, /* smb2_create_blobs *blobs */
1687 if (!NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
1688 printf("smb2cli_create %s\n", nt_errstr(status
));
1692 status
= smb2cli_create(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1694 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
1695 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
1696 SEC_STD_SYNCHRONIZE
|
1698 SEC_DIR_READ_ATTRIBUTE
, /* desired_access, */
1699 0, /* file_attributes, */
1700 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
1701 FILE_OPEN
, /* create_disposition, */
1702 FILE_SYNCHRONOUS_IO_NONALERT
|FILE_DIRECTORY_FILE
, /* create_options, */
1703 NULL
, /* smb2_create_blobs *blobs */
1707 if (!NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
1708 printf("smb2cli_create returned %s\n", nt_errstr(status
));
1712 saved_tid
= smb2cli_tcon_current_id(cli
->smb2
.tcon
);
1713 saved_tcon
= cli
->smb2
.tcon
;
1714 cli
->smb2
.tcon
= smbXcli_tcon_create(cli
);
1715 smb2cli_tcon_set_values(cli
->smb2
.tcon
,
1720 0, /* capabilities */
1721 0 /* maximal_access */);
1722 status
= cli_tree_connect(cli
, share
, "?????", NULL
);
1723 if (!NT_STATUS_EQUAL(status
, NT_STATUS_INVALID_HANDLE
)) {
1724 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
1727 talloc_free(cli
->smb2
.tcon
);
1728 cli
->smb2
.tcon
= saved_tcon
;
1730 subreq
= smb2cli_session_setup_send(talloc_tos(), ev
,
1735 SMB2_CAP_DFS
, /* in_capabilities */
1737 0, /* in_previous_session_id */
1738 &in_blob
); /* in_security_buffer */
1739 if (subreq
== NULL
) {
1740 printf("smb2cli_session_setup_send() returned NULL\n");
1744 ok
= tevent_req_poll(subreq
, ev
);
1746 printf("tevent_req_poll() returned false\n");
1750 status
= smb2cli_session_setup_recv(subreq
, talloc_tos(),
1751 &recv_iov
, &out_blob
);
1752 if (!NT_STATUS_IS_OK(status
)) {
1753 printf("smb2cli_session_setup_recv returned %s\n",
1758 status
= smb2cli_flush(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1759 cli
->smb2
.tcon
, fid_persistent
, fid_volatile
);
1760 if (!NT_STATUS_IS_OK(status
)) {
1761 printf("smb2cli_flush returned %s\n", nt_errstr(status
));
1765 status
= smb2cli_query_info(cli
->conn
,
1769 SMB2_GETINFO_SECURITY
,
1770 0, /* in_file_info_class */
1771 1024, /* in_max_output_length */
1772 NULL
, /* in_input_buffer */
1773 SECINFO_OWNER
, /* in_additional_info */
1778 &out_output_buffer
);
1779 if (!NT_STATUS_IS_OK(status
)) {
1780 printf("smb2cli_query_info (security) returned %s\n", nt_errstr(status
));
1784 in_file_info_class
= SMB_FILE_POSITION_INFORMATION
- 1000;
1785 status
= smb2cli_query_info(cli
->conn
,
1791 1024, /* in_max_output_length */
1792 NULL
, /* in_input_buffer */
1793 0, /* in_additional_info */
1798 &out_output_buffer
);
1799 if (!NT_STATUS_IS_OK(status
)) {
1800 printf("smb2cli_query_info (position) returned %s\n", nt_errstr(status
));
1804 in_input_buffer
= data_blob_talloc(talloc_tos(), NULL
, 8);
1805 SBVAL(in_input_buffer
.data
, 0, 512);
1807 in_file_info_class
= SMB_FILE_POSITION_INFORMATION
- 1000;
1808 status
= smb2cli_set_info(cli
->conn
,
1815 0, /* in_additional_info */
1818 if (!NT_STATUS_IS_OK(status
)) {
1819 printf("smb2cli_set_info (position) returned %s\n", nt_errstr(status
));
1823 in_file_info_class
= SMB_FILE_POSITION_INFORMATION
- 1000;
1824 status
= smb2cli_query_info(cli
->conn
,
1830 1024, /* in_max_output_length */
1831 NULL
, /* in_input_buffer */
1832 0, /* in_additional_info */
1837 &out_output_buffer
);
1838 if (!NT_STATUS_IS_OK(status
)) {
1839 printf("smb2cli_query_info (position) returned %s\n", nt_errstr(status
));
1843 status
= smb2cli_close(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1844 cli
->smb2
.tcon
, 0, fid_persistent
, fid_volatile
);
1845 if (!NT_STATUS_IS_OK(status
)) {
1846 printf("smb2cli_close returned %s\n", nt_errstr(status
));
1850 status
= smb2cli_create(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1851 cli
->smb2
.tcon
, "session-reauth.txt",
1852 SMB2_OPLOCK_LEVEL_NONE
, /* oplock_level, */
1853 SMB2_IMPERSONATION_IMPERSONATION
, /* impersonation_level, */
1854 SEC_STD_ALL
| SEC_FILE_ALL
, /* desired_access, */
1855 FILE_ATTRIBUTE_NORMAL
, /* file_attributes, */
1856 FILE_SHARE_READ
|FILE_SHARE_WRITE
|FILE_SHARE_DELETE
, /* share_access, */
1857 FILE_CREATE
, /* create_disposition, */
1858 FILE_DELETE_ON_CLOSE
, /* create_options, */
1859 NULL
, /* smb2_create_blobs *blobs */
1863 if (!NT_STATUS_IS_OK(status
)) {
1864 printf("smb2cli_create %s\n", nt_errstr(status
));
1868 status
= smb2cli_query_directory(
1869 cli
->conn
, cli
->timeout
, cli
->smb2
.session
, cli
->smb2
.tcon
,
1870 1, 0x3, 0, dir_persistent
, dir_volatile
,
1871 "session-reauth.txt", 0xffff,
1872 talloc_tos(), &dir_data
, &dir_data_length
);
1873 if (!NT_STATUS_IS_OK(status
)) {
1874 printf("smb2cli_query_directory returned %s\n", nt_errstr(status
));
1878 status
= smb2cli_close(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1879 cli
->smb2
.tcon
, 0, dir_persistent
, dir_volatile
);
1880 if (!NT_STATUS_IS_OK(status
)) {
1881 printf("smb2cli_close returned %s\n", nt_errstr(status
));
1885 status
= smb2cli_close(cli
->conn
, cli
->timeout
, cli
->smb2
.session
,
1886 cli
->smb2
.tcon
, 0, fid_persistent
, fid_volatile
);
1887 if (!NT_STATUS_IS_OK(status
)) {
1888 printf("smb2cli_close returned %s\n", nt_errstr(status
));
1892 saved_tid
= smb2cli_tcon_current_id(cli
->smb2
.tcon
);
1893 saved_tcon
= cli
->smb2
.tcon
;
1894 cli
->smb2
.tcon
= smbXcli_tcon_create(cli
);
1895 smb2cli_tcon_set_values(cli
->smb2
.tcon
,
1900 0, /* capabilities */
1901 0 /* maximal_access */);
1902 status
= cli_tree_connect(cli
, share
, "?????", NULL
);
1903 if (!NT_STATUS_IS_OK(status
)) {
1904 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
1907 talloc_free(cli
->smb2
.tcon
);
1908 cli
->smb2
.tcon
= saved_tcon
;
1913 static NTSTATUS
check_size(struct cli_state
*cli
,
1918 off_t size_read
= 0;
1920 NTSTATUS status
= cli_qfileinfo_basic(cli
,
1930 if (!NT_STATUS_IS_OK(status
)) {
1931 printf("cli_smb2_qfileinfo_basic of %s failed (%s)\n",
1937 if (size
!= size_read
) {
1938 printf("size (%u) != size_read(%u) for %s\n",
1940 (unsigned int)size_read
,
1942 /* Use EOF to mean bad size. */
1943 return NT_STATUS_END_OF_FILE
;
1945 return NT_STATUS_OK
;
1948 /* Ensure cli_ftruncate() works for SMB2. */
1950 bool run_smb2_ftruncate(int dummy
)
1952 struct cli_state
*cli
= NULL
;
1953 const char *fname
= "smb2_ftruncate.txt";
1954 uint16_t fnum
= (uint16_t)-1;
1955 bool correct
= false;
1956 size_t buflen
= 1024*1024;
1957 uint8_t *buf
= NULL
;
1961 printf("Starting SMB2-FTRUNCATE\n");
1963 if (!torture_init_connection(&cli
)) {
1967 status
= smbXcli_negprot(cli
->conn
, cli
->timeout
,
1968 PROTOCOL_SMB2_02
, PROTOCOL_SMB2_02
);
1969 if (!NT_STATUS_IS_OK(status
)) {
1970 printf("smbXcli_negprot returned %s\n", nt_errstr(status
));
1974 status
= cli_session_setup_creds(cli
, torture_creds
);
1975 if (!NT_STATUS_IS_OK(status
)) {
1976 printf("cli_session_setup returned %s\n", nt_errstr(status
));
1980 status
= cli_tree_connect(cli
, share
, "?????", NULL
);
1981 if (!NT_STATUS_IS_OK(status
)) {
1982 printf("cli_tree_connect returned %s\n", nt_errstr(status
));
1986 cli_setatr(cli
, fname
, 0, 0);
1987 cli_unlink(cli
, fname
, FILE_ATTRIBUTE_SYSTEM
| FILE_ATTRIBUTE_HIDDEN
);
1989 status
= cli_ntcreate(cli
,
1993 FILE_ATTRIBUTE_NORMAL
,
2001 if (!NT_STATUS_IS_OK(status
)) {
2002 printf("open of %s failed (%s)\n", fname
, nt_errstr(status
));
2006 buf
= talloc_zero_array(cli
, uint8_t, buflen
);
2012 status
= cli_writeall(cli
,
2020 if (!NT_STATUS_IS_OK(status
)) {
2021 printf("write of %u to %s failed (%s)\n",
2022 (unsigned int)buflen
,
2028 status
= check_size(cli
, fnum
, fname
, buflen
);
2029 if (!NT_STATUS_IS_OK(status
)) {
2033 /* Now ftruncate. */
2034 for ( i
= 0; i
< 10; i
++) {
2035 status
= cli_ftruncate(cli
, fnum
, i
*1024);
2036 if (!NT_STATUS_IS_OK(status
)) {
2037 printf("cli_ftruncate %u of %s failed (%s)\n",
2038 (unsigned int)i
*1024,
2043 status
= check_size(cli
, fnum
, fname
, i
*1024);
2044 if (!NT_STATUS_IS_OK(status
)) {
2057 if (fnum
!= (uint16_t)-1) {
2058 cli_close(cli
, fnum
);
2060 cli_setatr(cli
, fname
, 0, 0);
2061 cli_unlink(cli
, fname
, FILE_ATTRIBUTE_SYSTEM
| FILE_ATTRIBUTE_HIDDEN
);
2063 if (!torture_close_connection(cli
)) {