*/
#include "includes.h"
-#include "libcli/raw/libcliraw.h"
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
-#include "lib/cmdline/popt_common.h"
-#include "lib/events/events.h"
/*
send a close
TALLOC_CTX *tmp_ctx = talloc_new(tree);
ZERO_STRUCT(io);
- io.in.buffer_code = 0x18;
io.in.flags = SMB2_CLOSE_FLAGS_FULL_INFORMATION;
io.in.handle = handle;
status = smb2_close(tree, &io);
printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
- printf("alloc_size = %lld\n", io.out.alloc_size);
- printf("size = %lld\n", io.out.size);
+ printf("alloc_size = %lld\n", (long long)io.out.alloc_size);
+ printf("size = %lld\n", (long long)io.out.size);
printf("file_attr = 0x%x\n", io.out.file_attr);
}
{
struct smb2_write w;
struct smb2_read r;
+ struct smb2_flush f;
NTSTATUS status;
DATA_BLOB data;
int i;
}
ZERO_STRUCT(w);
- w.in.buffer_code = 0x31;
w.in.offset = 0;
w.in.handle = handle;
w.in.data = data;
- memset(w.in._pad, 0xff, 16);
-
status = smb2_write(tree, &w);
if (!NT_STATUS_IS_OK(status)) {
printf("write failed - %s\n", nt_errstr(status));
torture_smb2_all_info(tree, handle);
- memset(w.in._pad, 0xff, 16);
-
status = smb2_write(tree, &w);
if (!NT_STATUS_IS_OK(status)) {
printf("write failed - %s\n", nt_errstr(status));
torture_smb2_all_info(tree, handle);
+ ZERO_STRUCT(f);
+ f.in.handle = handle;
+
+ status = smb2_flush(tree, &f);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("flush failed - %s\n", nt_errstr(status));
+ return status;
+ }
+
ZERO_STRUCT(r);
- r.in.buffer_code = 0x31;
r.in.length = data.length;
r.in.offset = 0;
r.in.handle = handle;
TALLOC_CTX *tmp_ctx = talloc_new(tree);
ZERO_STRUCT(io);
- io.in.buffer_code = 0x39;
io.in.oplock_flags = 0;
io.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.in.file_attr = FILE_ATTRIBUTE_NORMAL;
io.in.create_options = NTCREATEX_OPTIONS_WRITE_THROUGH;
io.in.fname = fname;
- status = smb2_create(tree, &io);
+ status = smb2_create(tree, tmp_ctx, &io);
if (!NT_STATUS_IS_OK(status)) {
printf("create1 failed - %s\n", nt_errstr(status));
return io.out.handle;
printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
printf("write_time = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
printf("change_time = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
- printf("alloc_size = %lld\n", io.out.alloc_size);
- printf("size = %lld\n", io.out.size);
+ printf("alloc_size = %lld\n", (long long)io.out.alloc_size);
+ printf("size = %lld\n", (long long)io.out.size);
printf("file_attr = 0x%x\n", io.out.file_attr);
printf("handle = %016llx%016llx\n",
- io.out.handle.data[0],
- io.out.handle.data[1]);
+ (long long)io.out.handle.data[0],
+ (long long)io.out.handle.data[1]);
}
talloc_free(tmp_ctx);
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct smb2_tree *tree;
struct smb2_handle h1, h2;
+ NTSTATUS status;
if (!torture_smb2_connection(mem_ctx, &tree)) {
return False;
torture_smb2_close(tree, h1);
torture_smb2_close(tree, h2);
+ status = smb2_tdis(tree);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("tdis failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ status = smb2_tdis(tree);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) {
+ printf("tdis should have disabled session - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ status = smb2_logoff(tree->session);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Logoff failed - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ status = smb2_logoff(tree->session);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_USER_SESSION_DELETED)) {
+ printf("Logoff should have disabled session - %s\n", nt_errstr(status));
+ return False;
+ }
+
+ status = smb2_keepalive(tree->session->transport);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("keepalive failed? - %s\n", nt_errstr(status));
+ return False;
+ }
+
talloc_free(mem_ctx);
return True;