From b51703baf152c309ce325ce573c1683d7e503122 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 15 Nov 2005 04:38:59 +0000 Subject: r11730: added parsing and tests for a bunch more SMB2 getinfo levels (This used to be commit ca65bf0235cbfab451e5d5ceac9f714acc0cd46c) --- source4/torture/smb2/util.c | 199 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 source4/torture/smb2/util.c (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c new file mode 100644 index 0000000000..7c4c99e777 --- /dev/null +++ b/source4/torture/smb2/util.c @@ -0,0 +1,199 @@ +/* + Unix SMB/CIFS implementation. + + helper functions for SMB2 test suite + + Copyright (C) Andrew Tridgell 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#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" + +/* + show lots of information about a file +*/ +void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) +{ + NTSTATUS status; + TALLOC_CTX *tmp_ctx = talloc_new(tree); + union smb2_fileinfo io; + + status = smb2_getinfo_level(tree, tmp_ctx, handle, SMB2_GETINFO_FILE_ALL_INFO, &io); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("getinfo failed - %s\n", nt_errstr(status))); + talloc_free(tmp_ctx); + return; + } + + d_printf("\tcreate_time: %s\n", nt_time_string(tmp_ctx, io.all_info.create_time)); + d_printf("\taccess_time: %s\n", nt_time_string(tmp_ctx, io.all_info.access_time)); + d_printf("\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info.write_time)); + d_printf("\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info.change_time)); + d_printf("\tattrib: 0x%x\n", io.all_info.file_attr); + d_printf("\talloc_size: %llu\n", (uint64_t)io.all_info.alloc_size); + d_printf("\tsize: %llu\n", (uint64_t)io.all_info.size); + d_printf("\tnlink: %u\n", io.all_info.nlink); + d_printf("\tdelete_pending: %u\n", io.all_info.delete_pending); + d_printf("\tdirectory: %u\n", io.all_info.directory); + d_printf("\tfile_id: %llu\n", io.all_info.file_id); + d_printf("\tea_size: %u\n", io.all_info.ea_size); + d_printf("\taccess_mask: 0x%08x\n", io.all_info.access_mask); + d_printf("\tunknown5: 0x%llx\n", io.all_info.unknown5); + d_printf("\tunknown6: 0x%llx\n", io.all_info.unknown6); + d_printf("\tfname: '%s'\n", io.all_info.fname); + + talloc_free(tmp_ctx); +} + + +/* + open a smb2 connection +*/ +BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) +{ + NTSTATUS status; + const char *host = lp_parm_string(-1, "torture", "host"); + const char *share = lp_parm_string(-1, "torture", "share"); + struct cli_credentials *credentials = cmdline_credentials; + + status = smb2_connect(mem_ctx, host, share, credentials, tree, + event_context_find(mem_ctx)); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n", + host, share, nt_errstr(status)); + return False; + } + return True; +} + + +/* + create and return a handle to a test file +*/ +NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname, + struct smb2_handle *handle) +{ + struct smb2_create io; + struct smb2_read r; + NTSTATUS status; + + 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.open_disposition = NTCREATEX_DISP_OPEN_IF; + io.in.share_access = + NTCREATEX_SHARE_ACCESS_DELETE| + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; + io.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; + io.in.fname = fname; + + status = smb2_create(tree, &io); + NT_STATUS_NOT_OK_RETURN(status); + + *handle = io.out.handle; + + ZERO_STRUCT(r); + r.in.buffer_code = 0x31; + r.in.length = 5; + r.in.offset = 0; + r.in.handle = *handle; + + smb2_read(tree, tree, &r); + + return NT_STATUS_OK; +} + +/* + create and return a handle to a test directory +*/ +NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, + struct smb2_handle *handle) +{ + struct smb2_create io; + NTSTATUS status; + + ZERO_STRUCT(io); + io.in.buffer_code = 0x39; + io.in.oplock_flags = 0; + io.in.access_mask = SEC_RIGHTS_DIR_ALL; + io.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; + io.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE; + io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + io.in.fname = fname; + + status = smb2_create(tree, &io); + NT_STATUS_NOT_OK_RETURN(status); + + *handle = io.out.handle; + + return NT_STATUS_OK; +} + + +/* + create a complex file using the old SMB protocol, to make it easier to + find fields in SMB2 getinfo levels +*/ +BOOL torture_setup_complex_file(const char *fname) +{ + struct smbcli_state *cli; + int fnum; + + if (!torture_open_connection(&cli)) { + return False; + } + + fnum = create_complex_file(cli, cli, fname); + + if (DEBUGLVL(1)) { + torture_all_info(cli->tree, fname); + } + + talloc_free(cli); + return fnum != -1; +} + +/* + create a complex directory using the old SMB protocol, to make it easier to + find fields in SMB2 getinfo levels +*/ +BOOL torture_setup_complex_dir(const char *dname) +{ + struct smbcli_state *cli; + int fnum; + + if (!torture_open_connection(&cli)) { + return False; + } + + fnum = create_complex_dir(cli, cli, dname); + + if (DEBUGLVL(1)) { + torture_all_info(cli->tree, dname); + } + + talloc_free(cli); + return fnum != -1; +} -- cgit From baa3cba4c461fe62abe7bb65dc3fdbdc5007ef5f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 16 Nov 2005 04:35:49 +0000 Subject: r11736: display EAs and streams in smb2 torture tests (This used to be commit 2baea9a5ec0a805b90c8b48454e395ce40a35a74) --- source4/torture/smb2/util.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 7c4c99e777..73217152ee 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -60,6 +60,34 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) d_printf("\tunknown6: 0x%llx\n", io.all_info.unknown6); d_printf("\tfname: '%s'\n", io.all_info.fname); + /* the EAs, if any */ + status = smb2_getinfo_level(tree, tmp_ctx, handle, + SMB2_GETINFO_FILE_ALL_EAS, &io); + if (NT_STATUS_IS_OK(status)) { + int i; + for (i=0;i Date: Wed, 16 Nov 2005 11:01:15 +0000 Subject: r11741: - the buffer code (first 2 bytes in the SMB2 body) seem to be the length of the fixed body part, and +1 if there's a dynamic part - there're 3 types of dynamic blobs with uint16_t offset/uint16_t size with uint16_t offset/uint32_t size with uint32_t offset/uint32_t size /* aligned to 8 bytes */ - strings are transmitted in UTF-16 with no termination and packet into a uint16/uint16 blob metze (This used to be commit 79103c51e5c752fbdb4d25a0047b65002828df89) --- source4/torture/smb2/util.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 73217152ee..2c3965831a 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -124,7 +124,6 @@ NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname, NTSTATUS status; 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; @@ -135,14 +134,14 @@ NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname, NTCREATEX_SHARE_ACCESS_WRITE; io.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; io.in.fname = fname; + io.in.blob = data_blob(NULL, 0); - status = smb2_create(tree, &io); + status = smb2_create(tree, tree, &io); NT_STATUS_NOT_OK_RETURN(status); *handle = io.out.handle; ZERO_STRUCT(r); - r.in.buffer_code = 0x31; r.in.length = 5; r.in.offset = 0; r.in.handle = *handle; @@ -162,7 +161,6 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, NTSTATUS status; ZERO_STRUCT(io); - io.in.buffer_code = 0x39; io.in.oplock_flags = 0; io.in.access_mask = SEC_RIGHTS_DIR_ALL; io.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; @@ -170,8 +168,9 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE; io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; io.in.fname = fname; + io.in.blob = data_blob(NULL, 0); - status = smb2_create(tree, &io); + status = smb2_create(tree, tree, &io); NT_STATUS_NOT_OK_RETURN(status); *handle = io.out.handle; -- cgit From 7a43b32c3b6aeae3572c810fef243d883fe74f28 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Nov 2005 04:03:31 +0000 Subject: r11755: added names for all of the SMB2 qfs info levels (they all map exactly to equivalent SMB qfs levels) (This used to be commit 4ce48d02aa12d6fa699bf8b250b14851870f0096) --- source4/torture/smb2/util.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 2c3965831a..6cbc230630 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -48,6 +48,7 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) d_printf("\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info.write_time)); d_printf("\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info.change_time)); d_printf("\tattrib: 0x%x\n", io.all_info.file_attr); + d_printf("\tunknown1: 0x%x\n", io.all_info.unknown1); d_printf("\talloc_size: %llu\n", (uint64_t)io.all_info.alloc_size); d_printf("\tsize: %llu\n", (uint64_t)io.all_info.size); d_printf("\tnlink: %u\n", io.all_info.nlink); @@ -60,6 +61,13 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) d_printf("\tunknown6: 0x%llx\n", io.all_info.unknown6); d_printf("\tfname: '%s'\n", io.all_info.fname); + /* short name, if any */ + status = smb2_getinfo_level(tree, tmp_ctx, handle, + SMB2_GETINFO_FILE_SHORT_INFO, &io); + if (NT_STATUS_IS_OK(status)) { + d_printf("\tshort name: '%s'\n", io.short_info.short_name); + } + /* the EAs, if any */ status = smb2_getinfo_level(tree, tmp_ctx, handle, SMB2_GETINFO_FILE_ALL_EAS, &io); -- cgit From eedb92ce724e505f94ed49f9b238be617c52ccb4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 17 Nov 2005 11:06:13 +0000 Subject: r11758: unified the parse code for the SMB and SMB2 qfsinfo and qfileinfo calls (This used to be commit ba897e537b9a1544dc214e9d5504c87fee6fced2) --- source4/torture/smb2/util.c | 73 +++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 6cbc230630..95624220f7 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -34,65 +34,68 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) { NTSTATUS status; TALLOC_CTX *tmp_ctx = talloc_new(tree); - union smb2_fileinfo io; + union smb_fileinfo io; - status = smb2_getinfo_level(tree, tmp_ctx, handle, SMB2_GETINFO_FILE_ALL_INFO, &io); + io.generic.level = RAW_FILEINFO_SMB2_ALL_INFORMATION; + io.generic.in.handle = handle; + + status = smb2_getinfo_file(tree, tmp_ctx, &io); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("getinfo failed - %s\n", nt_errstr(status))); talloc_free(tmp_ctx); return; } - d_printf("\tcreate_time: %s\n", nt_time_string(tmp_ctx, io.all_info.create_time)); - d_printf("\taccess_time: %s\n", nt_time_string(tmp_ctx, io.all_info.access_time)); - d_printf("\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info.write_time)); - d_printf("\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info.change_time)); - d_printf("\tattrib: 0x%x\n", io.all_info.file_attr); - d_printf("\tunknown1: 0x%x\n", io.all_info.unknown1); - d_printf("\talloc_size: %llu\n", (uint64_t)io.all_info.alloc_size); - d_printf("\tsize: %llu\n", (uint64_t)io.all_info.size); - d_printf("\tnlink: %u\n", io.all_info.nlink); - d_printf("\tdelete_pending: %u\n", io.all_info.delete_pending); - d_printf("\tdirectory: %u\n", io.all_info.directory); - d_printf("\tfile_id: %llu\n", io.all_info.file_id); - d_printf("\tea_size: %u\n", io.all_info.ea_size); - d_printf("\taccess_mask: 0x%08x\n", io.all_info.access_mask); - d_printf("\tunknown5: 0x%llx\n", io.all_info.unknown5); - d_printf("\tunknown6: 0x%llx\n", io.all_info.unknown6); - d_printf("\tfname: '%s'\n", io.all_info.fname); + d_printf("\tcreate_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.create_time)); + d_printf("\taccess_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.access_time)); + d_printf("\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.write_time)); + d_printf("\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.change_time)); + d_printf("\tattrib: 0x%x\n", io.all_info2.out.attrib); + d_printf("\tunknown1: 0x%x\n", io.all_info2.out.unknown1); + d_printf("\talloc_size: %llu\n", (uint64_t)io.all_info2.out.alloc_size); + d_printf("\tsize: %llu\n", (uint64_t)io.all_info2.out.size); + d_printf("\tnlink: %u\n", io.all_info2.out.nlink); + d_printf("\tdelete_pending: %u\n", io.all_info2.out.delete_pending); + d_printf("\tdirectory: %u\n", io.all_info2.out.directory); + d_printf("\tfile_id: %llu\n", io.all_info2.out.file_id); + d_printf("\tea_size: %u\n", io.all_info2.out.ea_size); + d_printf("\taccess_mask: 0x%08x\n", io.all_info2.out.access_mask); + d_printf("\tunknown2: 0x%llx\n", io.all_info2.out.unknown2); + d_printf("\tunknown3: 0x%llx\n", io.all_info2.out.unknown3); + d_printf("\tfname: '%s'\n", io.all_info2.out.fname.s); /* short name, if any */ - status = smb2_getinfo_level(tree, tmp_ctx, handle, - SMB2_GETINFO_FILE_SHORT_INFO, &io); + io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION; + status = smb2_getinfo_file(tree, tmp_ctx, &io); if (NT_STATUS_IS_OK(status)) { - d_printf("\tshort name: '%s'\n", io.short_info.short_name); + d_printf("\tshort name: '%s'\n", io.alt_name_info.out.fname.s); } /* the EAs, if any */ - status = smb2_getinfo_level(tree, tmp_ctx, handle, - SMB2_GETINFO_FILE_ALL_EAS, &io); + io.generic.level = RAW_FILEINFO_SMB2_ALL_EAS; + status = smb2_getinfo_file(tree, tmp_ctx, &io); if (NT_STATUS_IS_OK(status)) { int i; - for (i=0;i Date: Fri, 18 Nov 2005 06:31:33 +0000 Subject: r11773: added a SMB2-SETINFO test suite. This tests the following levels: BASIC_INFORMATION DISPOSITION_INFORMATION ALLOCATION_INFORMATION END_OF_FILE_INFORMATION POSITION_INFORMATION MODE_INFORMATION (This used to be commit 8804b6a7eb59ab0a9088f89d191194fba71befe3) --- source4/torture/smb2/util.c | 151 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 95624220f7..bb239bdd1b 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -26,6 +26,157 @@ #include "libcli/smb2/smb2_calls.h" #include "lib/cmdline/popt_common.h" #include "lib/events/events.h" +#include "system/time.h" + + +/* + close a handle with SMB2 +*/ +NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h) +{ + struct smb2_close c; + + ZERO_STRUCT(c); + c.in.handle = h; + + return smb2_close(tree, &c); +} + +/* + unlink a file with SMB2 +*/ +NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname) +{ + struct smb2_create io; + NTSTATUS status; + + ZERO_STRUCT(io); + io.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.in.open_disposition = NTCREATEX_DISP_OPEN; + io.in.share_access = + NTCREATEX_SHARE_ACCESS_DELETE| + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; + io.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; + io.in.fname = fname; + io.in.blob = data_blob(NULL, 0); + + status = smb2_create(tree, tree, &io); + if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { + return NT_STATUS_OK; + } + NT_STATUS_NOT_OK_RETURN(status); + + return smb2_util_close(tree, io.out.handle); +} + +/* + write to a file on SMB2 +*/ +NTSTATUS smb2_util_write(struct smb2_tree *tree, + struct smb2_handle handle, + const void *buf, off_t offset, size_t size) +{ + struct smb2_write w; + + ZERO_STRUCT(w); + w.in.offset = offset; + w.in.handle = handle; + w.in.data = data_blob_const(buf, size); + + return smb2_write(tree, &w); +} + +/* + create a complex file using the SMB2 protocol +*/ +NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, struct smb2_handle *handle) +{ + char buf[7] = "abc"; + struct smb2_create io; + union smb_setfileinfo setfile; + union smb_fileinfo fileinfo; + time_t t = (time(NULL) & ~1); + NTSTATUS status; + + ZERO_STRUCT(io); + io.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; + io.in.share_access = + NTCREATEX_SHARE_ACCESS_DELETE| + NTCREATEX_SHARE_ACCESS_READ| + NTCREATEX_SHARE_ACCESS_WRITE; + io.in.create_options = 0; + io.in.fname = fname; + io.in.blob = data_blob(NULL, 0); + + status = smb2_create(tree, tree, &io); + NT_STATUS_NOT_OK_RETURN(status); + + *handle = io.out.handle; + + status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf)); + NT_STATUS_NOT_OK_RETURN(status); + +#if 0 + if (strchr(fname, ':') == NULL) { + /* setup some EAs */ + setfile.generic.level = RAW_SFILEINFO_EA_SET; + setfile.generic.file.fnum = fnum; + setfile.ea_set.in.num_eas = 2; + setfile.ea_set.in.eas = talloc_array(mem_ctx, struct ea_struct, 2); + setfile.ea_set.in.eas[0].flags = 0; + setfile.ea_set.in.eas[0].name.s = "EAONE"; + setfile.ea_set.in.eas[0].value = data_blob_talloc(mem_ctx, "VALUE1", 6); + setfile.ea_set.in.eas[1].flags = 0; + setfile.ea_set.in.eas[1].name.s = "SECONDEA"; + setfile.ea_set.in.eas[1].value = data_blob_talloc(mem_ctx, "ValueTwo", 8); + status = smb_raw_setfileinfo(cli->tree, &setfile); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to setup EAs\n"); + } + } +#endif + + /* make sure all the timestamps aren't the same, and are also + in different DST zones*/ + setfile.generic.level = RAW_SFILEINFO_BASIC_INFORMATION; + setfile.generic.file.handle = *handle; + + setfile.basic_info.in.create_time = t + 9*30*24*60*60; + setfile.basic_info.in.access_time = t + 6*30*24*60*60; + setfile.basic_info.in.write_time = t + 3*30*24*60*60; + setfile.basic_info.in.change_time = t + 1*30*24*60*60; + setfile.basic_info.in.attrib = FILE_ATTRIBUTE_NORMAL; + + status = smb2_setinfo_file(tree, &setfile); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to setup file times - %s\n", nt_errstr(status)); + } + + /* make sure all the timestamps aren't the same */ + fileinfo.generic.level = RAW_FILEINFO_BASIC_INFORMATION; + fileinfo.generic.in.handle = *handle; + + status = smb2_getinfo_file(tree, tree, &fileinfo); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to query file times - %s\n", nt_errstr(status)); + } + + if (setfile.basic_info.in.create_time != fileinfo.basic_info.out.create_time) { + printf("create_time not setup correctly\n"); + } + if (setfile.basic_info.in.access_time != fileinfo.basic_info.out.access_time) { + printf("access_time not setup correctly\n"); + } + if (setfile.basic_info.in.write_time != fileinfo.basic_info.out.write_time) { + printf("write_time not setup correctly\n"); + } + + return NT_STATUS_OK; +} /* show lots of information about a file -- cgit From c8c7fb2492d3f19939df67f98e4ea6ad423274da Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Nov 2005 09:25:25 +0000 Subject: r11775: added support for creating files on SMB2 with initial EA lists and an ACL (This used to be commit ff197092988cee64742f83df23c43ae664a196f9) --- source4/torture/smb2/util.c | 54 +++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 26 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index bb239bdd1b..56309929ad 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -60,7 +60,6 @@ NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname) NTCREATEX_SHARE_ACCESS_WRITE; io.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; io.in.fname = fname; - io.in.blob = data_blob(NULL, 0); status = smb2_create(tree, tree, &io); if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { @@ -93,6 +92,7 @@ NTSTATUS smb2_util_write(struct smb2_tree *tree, */ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, struct smb2_handle *handle) { + TALLOC_CTX *tmp_ctx = talloc_new(tree); char buf[7] = "abc"; struct smb2_create io; union smb_setfileinfo setfile; @@ -110,9 +110,33 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str NTCREATEX_SHARE_ACCESS_WRITE; io.in.create_options = 0; io.in.fname = fname; - io.in.blob = data_blob(NULL, 0); - status = smb2_create(tree, tree, &io); + io.in.sd = security_descriptor_create(tmp_ctx, + NULL, NULL, + SID_NT_AUTHENTICATED_USERS, + SEC_ACE_TYPE_ACCESS_ALLOWED, + SEC_RIGHTS_FILE_ALL | SEC_STD_ALL, + 0, + SID_WORLD, + SEC_ACE_TYPE_ACCESS_ALLOWED, + SEC_RIGHTS_FILE_READ | SEC_STD_ALL, + 0, + NULL); + + if (strchr(fname, ':') == NULL) { + /* setup some EAs */ + io.in.eas.num_eas = 2; + io.in.eas.eas = talloc_array(tmp_ctx, struct ea_struct, 2); + io.in.eas.eas[0].flags = 0; + io.in.eas.eas[0].name.s = "EAONE"; + io.in.eas.eas[0].value = data_blob_talloc(tmp_ctx, "VALUE1", 6); + io.in.eas.eas[1].flags = 0; + io.in.eas.eas[1].name.s = "SECONDEA"; + io.in.eas.eas[1].value = data_blob_talloc(tmp_ctx, "ValueTwo", 8); + } + + status = smb2_create(tree, tmp_ctx, &io); + talloc_free(tmp_ctx); NT_STATUS_NOT_OK_RETURN(status); *handle = io.out.handle; @@ -120,26 +144,6 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf)); NT_STATUS_NOT_OK_RETURN(status); -#if 0 - if (strchr(fname, ':') == NULL) { - /* setup some EAs */ - setfile.generic.level = RAW_SFILEINFO_EA_SET; - setfile.generic.file.fnum = fnum; - setfile.ea_set.in.num_eas = 2; - setfile.ea_set.in.eas = talloc_array(mem_ctx, struct ea_struct, 2); - setfile.ea_set.in.eas[0].flags = 0; - setfile.ea_set.in.eas[0].name.s = "EAONE"; - setfile.ea_set.in.eas[0].value = data_blob_talloc(mem_ctx, "VALUE1", 6); - setfile.ea_set.in.eas[1].flags = 0; - setfile.ea_set.in.eas[1].name.s = "SECONDEA"; - setfile.ea_set.in.eas[1].value = data_blob_talloc(mem_ctx, "ValueTwo", 8); - status = smb_raw_setfileinfo(cli->tree, &setfile); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to setup EAs\n"); - } - } -#endif - /* make sure all the timestamps aren't the same, and are also in different DST zones*/ setfile.generic.level = RAW_SFILEINFO_BASIC_INFORMATION; @@ -294,9 +298,8 @@ NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname, NTCREATEX_SHARE_ACCESS_DELETE| NTCREATEX_SHARE_ACCESS_READ| NTCREATEX_SHARE_ACCESS_WRITE; - io.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; + io.in.create_options = 0; io.in.fname = fname; - io.in.blob = data_blob(NULL, 0); status = smb2_create(tree, tree, &io); NT_STATUS_NOT_OK_RETURN(status); @@ -330,7 +333,6 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE; io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; io.in.fname = fname; - io.in.blob = data_blob(NULL, 0); status = smb2_create(tree, tree, &io); NT_STATUS_NOT_OK_RETURN(status); -- cgit From 1692b2e571d4c692eae020522d298b6fca3f1804 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Nov 2005 09:51:13 +0000 Subject: r11776: no need to call out to SMB to setup test files for SMB2 any more (This used to be commit dae70c5baed7d5613d793dca15dda3007c1a690a) --- source4/torture/smb2/util.c | 84 +++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 38 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 56309929ad..776714da9e 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -88,9 +88,10 @@ NTSTATUS smb2_util_write(struct smb2_tree *tree, } /* - create a complex file using the SMB2 protocol + create a complex file/dir using the SMB2 protocol */ -NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, struct smb2_handle *handle) +static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, + struct smb2_handle *handle, BOOL dir) { TALLOC_CTX *tmp_ctx = talloc_new(tree); char buf[7] = "abc"; @@ -100,6 +101,7 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str time_t t = (time(NULL) & ~1); NTSTATUS status; + smb2_util_unlink(tree, fname); ZERO_STRUCT(io); io.in.access_mask = SEC_RIGHTS_FILE_ALL; io.in.file_attr = FILE_ATTRIBUTE_NORMAL; @@ -110,6 +112,12 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str NTCREATEX_SHARE_ACCESS_WRITE; io.in.create_options = 0; io.in.fname = fname; + if (dir) { + io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; + io.in.share_access &= ~NTCREATEX_SHARE_ACCESS_DELETE; + io.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; + io.in.open_disposition = NTCREATEX_DISP_CREATE; + } io.in.sd = security_descriptor_create(tmp_ctx, NULL, NULL, @@ -141,8 +149,10 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str *handle = io.out.handle; - status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf)); - NT_STATUS_NOT_OK_RETURN(status); + if (!dir) { + status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf)); + NT_STATUS_NOT_OK_RETURN(status); + } /* make sure all the timestamps aren't the same, and are also in different DST zones*/ @@ -182,6 +192,24 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, str return NT_STATUS_OK; } +/* + create a complex file using the SMB2 protocol +*/ +NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, + struct smb2_handle *handle) +{ + return smb2_create_complex(tree, fname, handle, False); +} + +/* + create a complex dir using the SMB2 protocol +*/ +NTSTATUS smb2_create_complex_dir(struct smb2_tree *tree, const char *fname, + struct smb2_handle *handle) +{ + return smb2_create_complex(tree, fname, handle, True); +} + /* show lots of information about a file */ @@ -201,6 +229,7 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) return; } + d_printf("all_info for '%s'\n", io.all_info2.out.fname.s); d_printf("\tcreate_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.create_time)); d_printf("\taccess_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.access_time)); d_printf("\twrite_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.write_time)); @@ -217,7 +246,6 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) d_printf("\taccess_mask: 0x%08x\n", io.all_info2.out.access_mask); d_printf("\tunknown2: 0x%llx\n", io.all_info2.out.unknown2); d_printf("\tunknown3: 0x%llx\n", io.all_info2.out.unknown3); - d_printf("\tfname: '%s'\n", io.all_info2.out.fname.s); /* short name, if any */ io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION; @@ -347,44 +375,24 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, create a complex file using the old SMB protocol, to make it easier to find fields in SMB2 getinfo levels */ -BOOL torture_setup_complex_file(const char *fname) +NTSTATUS torture_setup_complex_file(struct smb2_tree *tree, const char *fname) { - struct smbcli_state *cli; - int fnum; - - if (!torture_open_connection(&cli)) { - return False; - } - - fnum = create_complex_file(cli, cli, fname); - - if (DEBUGLVL(1)) { - torture_all_info(cli->tree, fname); - } - - talloc_free(cli); - return fnum != -1; + struct smb2_handle handle; + NTSTATUS status = smb2_create_complex_file(tree, fname, &handle); + NT_STATUS_NOT_OK_RETURN(status); + return smb2_util_close(tree, handle); } + /* - create a complex directory using the old SMB protocol, to make it easier to + create a complex dir using the old SMB protocol, to make it easier to find fields in SMB2 getinfo levels */ -BOOL torture_setup_complex_dir(const char *dname) +NTSTATUS torture_setup_complex_dir(struct smb2_tree *tree, const char *fname) { - struct smbcli_state *cli; - int fnum; - - if (!torture_open_connection(&cli)) { - return False; - } - - fnum = create_complex_dir(cli, cli, dname); - - if (DEBUGLVL(1)) { - torture_all_info(cli->tree, dname); - } - - talloc_free(cli); - return fnum != -1; + struct smb2_handle handle; + NTSTATUS status = smb2_create_complex_dir(tree, fname, &handle); + NT_STATUS_NOT_OK_RETURN(status); + return smb2_util_close(tree, handle); } + -- cgit From 3922b68d13ec79b8ebf55d0624668bf6483930a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Nov 2005 10:07:14 +0000 Subject: r11777: display the security_descriptor in torture_smb2_all_info() (This used to be commit d1067fc25df57b1b6ef59a69f979ed76df5c46cd) --- source4/torture/smb2/util.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 776714da9e..7afce0137f 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -282,6 +282,16 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) } } + /* the security descriptor */ + io.query_secdesc.level = RAW_FILEINFO_SEC_DESC; + io.query_secdesc.secinfo_flags = + SECINFO_OWNER|SECINFO_GROUP| + SECINFO_DACL; + status = smb2_getinfo_file(tree, tmp_ctx, &io); + if (NT_STATUS_IS_OK(status)) { + NDR_PRINT_DEBUG(security_descriptor, io.query_secdesc.out.sd); + } + talloc_free(tmp_ctx); } -- cgit From d5f37ecf94e2b63511102b3fd34c0e7bcd8d7879 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 18 Nov 2005 11:45:24 +0000 Subject: r11780: it turns out that the MxAc tag isn't a security descriptor, its a request that the server return its own MxAc blob which contains the maximum allowed access_mask for the returned file handle (This used to be commit c0288aa8cd46ca384074f89430c226d725c39475) --- source4/torture/smb2/util.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 7afce0137f..b39f53d8e1 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -103,7 +103,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, smb2_util_unlink(tree, fname); ZERO_STRUCT(io); - io.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; io.in.file_attr = FILE_ATTRIBUTE_NORMAL; io.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; io.in.share_access = @@ -119,18 +119,6 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, io.in.open_disposition = NTCREATEX_DISP_CREATE; } - io.in.sd = security_descriptor_create(tmp_ctx, - NULL, NULL, - SID_NT_AUTHENTICATED_USERS, - SEC_ACE_TYPE_ACCESS_ALLOWED, - SEC_RIGHTS_FILE_ALL | SEC_STD_ALL, - 0, - SID_WORLD, - SEC_ACE_TYPE_ACCESS_ALLOWED, - SEC_RIGHTS_FILE_READ | SEC_STD_ALL, - 0, - NULL); - if (strchr(fname, ':') == NULL) { /* setup some EAs */ io.in.eas.num_eas = 2; -- cgit From 7d6f36682eab29cb23c40dd915acad61fb5d68cb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 19 Nov 2005 05:55:08 +0000 Subject: r11800: - filled in unknown fields in SMB2 all_info level - allow setting of the ALL_EAS flags bits in SMB2 getinfo (This used to be commit 8c7c54a46dfb91c053d07a5e606892a41213c605) --- source4/torture/smb2/util.c | 47 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index b39f53d8e1..886aaea09f 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -232,8 +232,8 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) d_printf("\tfile_id: %llu\n", io.all_info2.out.file_id); d_printf("\tea_size: %u\n", io.all_info2.out.ea_size); d_printf("\taccess_mask: 0x%08x\n", io.all_info2.out.access_mask); - d_printf("\tunknown2: 0x%llx\n", io.all_info2.out.unknown2); - d_printf("\tunknown3: 0x%llx\n", io.all_info2.out.unknown3); + d_printf("\tposition: 0x%llx\n", io.all_info2.out.position); + d_printf("\tmode: 0x%llx\n", io.all_info2.out.mode); /* short name, if any */ io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION; @@ -270,14 +270,16 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) } } - /* the security descriptor */ - io.query_secdesc.level = RAW_FILEINFO_SEC_DESC; - io.query_secdesc.secinfo_flags = - SECINFO_OWNER|SECINFO_GROUP| - SECINFO_DACL; - status = smb2_getinfo_file(tree, tmp_ctx, &io); - if (NT_STATUS_IS_OK(status)) { - NDR_PRINT_DEBUG(security_descriptor, io.query_secdesc.out.sd); + if (DEBUGLVL(1)) { + /* the security descriptor */ + io.query_secdesc.level = RAW_FILEINFO_SEC_DESC; + io.query_secdesc.secinfo_flags = + SECINFO_OWNER|SECINFO_GROUP| + SECINFO_DACL; + status = smb2_getinfo_file(tree, tmp_ctx, &io); + if (NT_STATUS_IS_OK(status)) { + NDR_PRINT_DEBUG(security_descriptor, io.query_secdesc.out.sd); + } } talloc_free(tmp_ctx); @@ -394,3 +396,28 @@ NTSTATUS torture_setup_complex_dir(struct smb2_tree *tree, const char *fname) return smb2_util_close(tree, handle); } + +/* + return a handle to the root of the share +*/ +NTSTATUS smb2_util_roothandle(struct smb2_tree *tree, struct smb2_handle *handle) +{ + struct smb2_create io; + NTSTATUS status; + + ZERO_STRUCT(io); + io.in.oplock_flags = 0; + io.in.access_mask = SEC_STD_SYNCHRONIZE | SEC_DIR_READ_ATTRIBUTE | SEC_DIR_LIST; + io.in.file_attr = 0; + io.in.open_disposition = NTCREATEX_DISP_OPEN; + io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE; + io.in.create_options = NTCREATEX_OPTIONS_ASYNC_ALERT; + io.in.fname = ""; + + status = smb2_create(tree, tree, &io); + NT_STATUS_NOT_OK_RETURN(status); + + *handle = io.out.handle; + + return NT_STATUS_OK; +} -- cgit From 03d301ead5f702872b8cb948b8cd01b0fa0db5f7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 30 Nov 2005 02:08:15 +0000 Subject: r11967: Fix more 64-bit warnings. (This used to be commit 9c4436a124f874ae240feaf590141d48c33a635f) --- source4/torture/smb2/util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 886aaea09f..a3d6ed8d66 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -224,16 +224,16 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) d_printf("\tchange_time: %s\n", nt_time_string(tmp_ctx, io.all_info2.out.change_time)); d_printf("\tattrib: 0x%x\n", io.all_info2.out.attrib); d_printf("\tunknown1: 0x%x\n", io.all_info2.out.unknown1); - d_printf("\talloc_size: %llu\n", (uint64_t)io.all_info2.out.alloc_size); - d_printf("\tsize: %llu\n", (uint64_t)io.all_info2.out.size); + d_printf("\talloc_size: %llu\n", (long long)io.all_info2.out.alloc_size); + d_printf("\tsize: %llu\n", (long long)io.all_info2.out.size); d_printf("\tnlink: %u\n", io.all_info2.out.nlink); d_printf("\tdelete_pending: %u\n", io.all_info2.out.delete_pending); d_printf("\tdirectory: %u\n", io.all_info2.out.directory); - d_printf("\tfile_id: %llu\n", io.all_info2.out.file_id); + d_printf("\tfile_id: %llu\n", (long long)io.all_info2.out.file_id); d_printf("\tea_size: %u\n", io.all_info2.out.ea_size); d_printf("\taccess_mask: 0x%08x\n", io.all_info2.out.access_mask); - d_printf("\tposition: 0x%llx\n", io.all_info2.out.position); - d_printf("\tmode: 0x%llx\n", io.all_info2.out.mode); + d_printf("\tposition: 0x%llx\n", (long long)io.all_info2.out.position); + d_printf("\tmode: 0x%llx\n", (long long)io.all_info2.out.mode); /* short name, if any */ io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION; -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/torture/smb2/util.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index a3d6ed8d66..953ef448d9 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -21,7 +21,6 @@ */ #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" -- cgit From 307e43bb5628e8b53a930c2928279af994281ba5 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 10 Mar 2006 20:49:20 +0000 Subject: r14173: change smb interface structures to always use a union smb_file, to abtract - const char *path fot qpathinfo and setpathinfo - uint16_t fnum for SMB - smb2_handle handle for SMB2 the idea is to later add a struct ntvfs_handle *ntvfs so that the ntvfs subsystem don't need to know the difference between SMB and SMB2 metze (This used to be commit 2ef3f5970901b5accdb50f0d0115b5d46b0c788f) --- source4/torture/smb2/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 953ef448d9..9be9b07c5b 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -159,7 +159,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, /* make sure all the timestamps aren't the same */ fileinfo.generic.level = RAW_FILEINFO_BASIC_INFORMATION; - fileinfo.generic.in.handle = *handle; + fileinfo.generic.file.handle = *handle; status = smb2_getinfo_file(tree, tree, &fileinfo); if (!NT_STATUS_IS_OK(status)) { @@ -207,7 +207,7 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) union smb_fileinfo io; io.generic.level = RAW_FILEINFO_SMB2_ALL_INFORMATION; - io.generic.in.handle = handle; + io.generic.file.handle = handle; status = smb2_getinfo_file(tree, tmp_ctx, &io); if (!NT_STATUS_IS_OK(status)) { @@ -272,7 +272,7 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) if (DEBUGLVL(1)) { /* the security descriptor */ io.query_secdesc.level = RAW_FILEINFO_SEC_DESC; - io.query_secdesc.secinfo_flags = + io.query_secdesc.in.secinfo_flags = SECINFO_OWNER|SECINFO_GROUP| SECINFO_DACL; status = smb2_getinfo_file(tree, tmp_ctx, &io); -- cgit From a1b295ed4823ce8d06f830b8db9a5d965c934b54 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 12 Mar 2006 22:48:25 +0000 Subject: r14256: - rename smb_file -> smb_handle - move it into the in/out substructs again - allow file.path only on smb_fileinfo/smb_setfileinfo metze (This used to be commit be6d5298a2cdb7e7c61d70471bad445645af5963) --- source4/torture/smb2/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 9be9b07c5b..84a35900a3 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -144,7 +144,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, /* make sure all the timestamps aren't the same, and are also in different DST zones*/ setfile.generic.level = RAW_SFILEINFO_BASIC_INFORMATION; - setfile.generic.file.handle = *handle; + setfile.generic.in.file.handle = *handle; setfile.basic_info.in.create_time = t + 9*30*24*60*60; setfile.basic_info.in.access_time = t + 6*30*24*60*60; @@ -159,7 +159,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, /* make sure all the timestamps aren't the same */ fileinfo.generic.level = RAW_FILEINFO_BASIC_INFORMATION; - fileinfo.generic.file.handle = *handle; + fileinfo.generic.in.file.handle = *handle; status = smb2_getinfo_file(tree, tree, &fileinfo); if (!NT_STATUS_IS_OK(status)) { @@ -207,7 +207,7 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) union smb_fileinfo io; io.generic.level = RAW_FILEINFO_SMB2_ALL_INFORMATION; - io.generic.file.handle = handle; + io.generic.in.file.handle = handle; status = smb2_getinfo_file(tree, tmp_ctx, &io); if (!NT_STATUS_IS_OK(status)) { -- cgit From 8528016978b084213ef53d66e1b6e831b1a01acc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 00:23:11 +0000 Subject: r14464: Don't include ndr_BASENAME.h files unless strictly required, instead try to include just the BASENAME.h files (containing only structs) (This used to be commit 3dd477ca5147f28a962b8437e2611a8222d706bd) --- source4/torture/smb2/util.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 84a35900a3..70be00f5fd 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -26,6 +26,7 @@ #include "lib/cmdline/popt_common.h" #include "lib/events/events.h" #include "system/time.h" +#include "librpc/gen_ndr/ndr_security.h" /* -- cgit From e306c5bf129a981693bd251d45597f1e584ee850 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 20 May 2006 10:46:38 +0000 Subject: r15741: move smb2 request structures into the main smb request structs as new levels metze (This used to be commit 91806353174704857dfcc15a730af7232cfde660) --- source4/torture/smb2/util.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 70be00f5fd..89c5488426 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -37,7 +37,7 @@ NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h) struct smb2_close c; ZERO_STRUCT(c); - c.in.handle = h; + c.in.file.handle = h; return smb2_close(tree, &c); } @@ -67,7 +67,7 @@ NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname) } NT_STATUS_NOT_OK_RETURN(status); - return smb2_util_close(tree, io.out.handle); + return smb2_util_close(tree, io.out.file.handle); } /* @@ -80,8 +80,8 @@ NTSTATUS smb2_util_write(struct smb2_tree *tree, struct smb2_write w; ZERO_STRUCT(w); + w.in.file.handle = handle; w.in.offset = offset; - w.in.handle = handle; w.in.data = data_blob_const(buf, size); return smb2_write(tree, &w); @@ -135,7 +135,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, talloc_free(tmp_ctx); NT_STATUS_NOT_OK_RETURN(status); - *handle = io.out.handle; + *handle = io.out.file.handle; if (!dir) { status = smb2_util_write(tree, *handle, buf, 0, sizeof(buf)); @@ -332,12 +332,12 @@ NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname, status = smb2_create(tree, tree, &io); NT_STATUS_NOT_OK_RETURN(status); - *handle = io.out.handle; + *handle = io.out.file.handle; ZERO_STRUCT(r); + r.in.file.handle = *handle; r.in.length = 5; r.in.offset = 0; - r.in.handle = *handle; smb2_read(tree, tree, &r); @@ -365,7 +365,7 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, status = smb2_create(tree, tree, &io); NT_STATUS_NOT_OK_RETURN(status); - *handle = io.out.handle; + *handle = io.out.file.handle; return NT_STATUS_OK; } @@ -417,7 +417,7 @@ NTSTATUS smb2_util_roothandle(struct smb2_tree *tree, struct smb2_handle *handle status = smb2_create(tree, tree, &io); NT_STATUS_NOT_OK_RETURN(status); - *handle = io.out.handle; + *handle = io.out.file.handle; return NT_STATUS_OK; } -- cgit From f0c737b92441ef54978ce8566be932092896bb6a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 1 Jul 2006 14:20:14 +0000 Subject: r16736: - convert unix times to nttime before sending it to the wire... - return an error code if an error happens metze (This used to be commit 9b52322e90003302ec99e2808c80c6c733a84358) --- source4/torture/smb2/util.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 89c5488426..cd5cfdafa6 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -147,15 +147,16 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, setfile.generic.level = RAW_SFILEINFO_BASIC_INFORMATION; setfile.generic.in.file.handle = *handle; - setfile.basic_info.in.create_time = t + 9*30*24*60*60; - setfile.basic_info.in.access_time = t + 6*30*24*60*60; - setfile.basic_info.in.write_time = t + 3*30*24*60*60; - setfile.basic_info.in.change_time = t + 1*30*24*60*60; + unix_to_nt_time(&setfile.basic_info.in.create_time, t + 9*30*24*60*60); + unix_to_nt_time(&setfile.basic_info.in.access_time, t + 6*30*24*60*60); + unix_to_nt_time(&setfile.basic_info.in.write_time, t + 3*30*24*60*60); + unix_to_nt_time(&setfile.basic_info.in.change_time, t + 1*30*24*60*60); setfile.basic_info.in.attrib = FILE_ATTRIBUTE_NORMAL; status = smb2_setinfo_file(tree, &setfile); if (!NT_STATUS_IS_OK(status)) { printf("Failed to setup file times - %s\n", nt_errstr(status)); + return status; } /* make sure all the timestamps aren't the same */ @@ -165,19 +166,28 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, status = smb2_getinfo_file(tree, tree, &fileinfo); if (!NT_STATUS_IS_OK(status)) { printf("Failed to query file times - %s\n", nt_errstr(status)); + return status; + } - if (setfile.basic_info.in.create_time != fileinfo.basic_info.out.create_time) { - printf("create_time not setup correctly\n"); - } - if (setfile.basic_info.in.access_time != fileinfo.basic_info.out.access_time) { - printf("access_time not setup correctly\n"); - } - if (setfile.basic_info.in.write_time != fileinfo.basic_info.out.write_time) { - printf("write_time not setup correctly\n"); - } - - return NT_STATUS_OK; +#define CHECK_TIME(field) do {\ + if (setfile.basic_info.in.field != fileinfo.basic_info.out.field) { \ + printf("(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \ + __location__, \ + nt_time_string(tree, setfile.basic_info.in.field), \ + setfile.basic_info.in.field, \ + nt_time_string(tree, fileinfo.basic_info.out.field), \ + fileinfo.basic_info.out.field); \ + status = NT_STATUS_INVALID_PARAMETER; \ + } \ +} while (0) + + CHECK_TIME(create_time); + CHECK_TIME(access_time); + CHECK_TIME(write_time); + CHECK_TIME(change_time); + + return status; } /* -- cgit From 1fcd8c8a90a593d9ed88f73770a060f3d89d1673 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 8 Jul 2006 11:05:24 +0000 Subject: r16874: query all information metze (This used to be commit 0ff9c5775724a4644dee10ce1476d728b515a569) --- source4/torture/smb2/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index cd5cfdafa6..da74e47c0a 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -160,7 +160,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, } /* make sure all the timestamps aren't the same */ - fileinfo.generic.level = RAW_FILEINFO_BASIC_INFORMATION; + fileinfo.generic.level = RAW_FILEINFO_SMB2_ALL_INFORMATION; fileinfo.generic.in.file.handle = *handle; status = smb2_getinfo_file(tree, tree, &fileinfo); @@ -171,7 +171,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, } #define CHECK_TIME(field) do {\ - if (setfile.basic_info.in.field != fileinfo.basic_info.out.field) { \ + if (setfile.basic_info.in.field != fileinfo.all_info2.out.field) { \ printf("(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \ __location__, \ nt_time_string(tree, setfile.basic_info.in.field), \ -- cgit From 30ee8beb9316a99e8a49993306252591106cb349 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Sep 2006 10:05:58 +0000 Subject: r18301: I discovered how to load the warnings from a build farm build into emacs compile mode (hint, paste to a file, and compile as "cat filename"). This allowed me to fix nearly all the warnings for a IA_64 SuSE build very quickly. (This used to be commit eba6c84efff735bb0ca941ac4b755ce2b0591667) --- source4/torture/smb2/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index da74e47c0a..d167f6690e 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -175,9 +175,9 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, printf("(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \ __location__, \ nt_time_string(tree, setfile.basic_info.in.field), \ - setfile.basic_info.in.field, \ + (unsigned long long)setfile.basic_info.in.field, \ nt_time_string(tree, fileinfo.basic_info.out.field), \ - fileinfo.basic_info.out.field); \ + (unsigned long long)fileinfo.basic_info.out.field); \ status = NT_STATUS_INVALID_PARAMETER; \ } \ } while (0) -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/torture/smb2/util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index d167f6690e..5e680fbcec 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/torture/smb2/util.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 5e680fbcec..caa3a5fd52 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -26,6 +26,7 @@ #include "lib/events/events.h" #include "system/time.h" #include "librpc/gen_ndr/ndr_security.h" +#include "param/param.h" /* -- cgit From 98b57d5eb61094a9c88e2f7d90d3e21b7e74e9d8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 16:46:30 +0000 Subject: r25035: Fix some more warnings, use service pointer rather than service number in more places. (This used to be commit df9cebcb97e20564359097148665bd519f31bc6f) --- source4/torture/smb2/util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index caa3a5fd52..8c55813c8c 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -27,6 +27,7 @@ #include "system/time.h" #include "librpc/gen_ndr/ndr_security.h" #include "param/param.h" +#include "torture/smb2/proto.h" /* @@ -302,8 +303,8 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) { NTSTATUS status; - const char *host = lp_parm_string(-1, "torture", "host"); - const char *share = lp_parm_string(-1, "torture", "share"); + const char *host = lp_parm_string(NULL, "torture", "host"); + const char *share = lp_parm_string(NULL, "torture", "share"); struct cli_credentials *credentials = cmdline_credentials; status = smb2_connect(mem_ctx, host, share, credentials, tree, -- cgit From 803e57da44e826e1adbf5f9743633273285d30f7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 14 Sep 2007 13:16:46 +0000 Subject: r25159: fix missing declarations warning metze (This used to be commit 3d321a5efc22f8a702095f7704a36325a97db138) --- source4/torture/smb2/util.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 8c55813c8c..946368a2ed 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -27,6 +27,8 @@ #include "system/time.h" #include "librpc/gen_ndr/ndr_security.h" #include "param/param.h" + +#include "torture/torture.h" #include "torture/smb2/proto.h" -- cgit From 60a1046c5c5783799bd64fe18e03534670f83d82 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 29 Sep 2007 18:00:19 +0000 Subject: r25430: Add the loadparm context to all parametric options. (This used to be commit fd697d77c9fe67a00939a1f04b35c451316fff58) --- source4/torture/smb2/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 946368a2ed..1852d9a984 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -305,8 +305,8 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) { NTSTATUS status; - const char *host = lp_parm_string(NULL, "torture", "host"); - const char *share = lp_parm_string(NULL, "torture", "share"); + const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host"); + const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share"); struct cli_credentials *credentials = cmdline_credentials; status = smb2_connect(mem_ctx, host, share, credentials, tree, -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/torture/smb2/util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 1852d9a984..705f10a841 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -94,7 +94,7 @@ NTSTATUS smb2_util_write(struct smb2_tree *tree, create a complex file/dir using the SMB2 protocol */ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, - struct smb2_handle *handle, BOOL dir) + struct smb2_handle *handle, bool dir) { TALLOC_CTX *tmp_ctx = talloc_new(tree); char buf[7] = "abc"; @@ -199,7 +199,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, struct smb2_handle *handle) { - return smb2_create_complex(tree, fname, handle, False); + return smb2_create_complex(tree, fname, handle, false); } /* @@ -208,7 +208,7 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, NTSTATUS smb2_create_complex_dir(struct smb2_tree *tree, const char *fname, struct smb2_handle *handle) { - return smb2_create_complex(tree, fname, handle, True); + return smb2_create_complex(tree, fname, handle, true); } /* @@ -302,7 +302,7 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) /* open a smb2 connection */ -BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) +bool torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) { NTSTATUS status; const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host"); @@ -314,9 +314,9 @@ BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n", host, share, nt_errstr(status)); - return False; + return false; } - return True; + return true; } -- cgit From bbdfbf8d9d486aee51117976b8f825759a4c4a37 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 00:28:22 +0100 Subject: r26238: Add a loadparm context parameter to torture_context, remove more uses of global_loadparm. (This used to be commit a33a5530545086b81a3b205aa109dff11c546926) --- source4/torture/smb2/util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 705f10a841..ab3d299c5a 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -302,15 +302,15 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) /* open a smb2 connection */ -bool torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) +bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tree) { NTSTATUS status; - const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host"); - const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share"); + const char *host = torture_setting_string(tctx, "host", NULL); + const char *share = torture_setting_string(tctx, "share", NULL); struct cli_credentials *credentials = cmdline_credentials; - status = smb2_connect(mem_ctx, host, share, credentials, tree, - event_context_find(mem_ctx)); + status = smb2_connect(tctx, host, share, credentials, tree, + event_context_find(tctx)); if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n", host, share, nt_errstr(status)); -- cgit From 1f69adddc54d3b4b91df0ce639b3faccb85b2eb7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 21:25:14 +0100 Subject: r26267: Fix two calls of smb2_connect I missed. (This used to be commit fc824a5c457e341995c14bd1cf34894ffc4c62c2) --- source4/torture/smb2/util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index ab3d299c5a..3170b0073d 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -309,7 +309,9 @@ bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tr const char *share = torture_setting_string(tctx, "share", NULL); struct cli_credentials *credentials = cmdline_credentials; - status = smb2_connect(tctx, host, share, credentials, tree, + status = smb2_connect(tctx, host, share, + lp_name_resolve_order(tctx->lp_ctx), + credentials, tree, event_context_find(tctx)); if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n", -- cgit From 5f4842cf65ce64bfdf577cd549565da20ca818cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 18:41:19 +0100 Subject: r26376: Add context for libcli_resolve. (This used to be commit 459e1466a411d6f83b7372e248566e6e71c745fc) --- source4/torture/smb2/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 3170b0073d..fe88296a32 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -27,6 +27,7 @@ #include "system/time.h" #include "librpc/gen_ndr/ndr_security.h" #include "param/param.h" +#include "libcli/resolve/resolve.h" #include "torture/torture.h" #include "torture/smb2/proto.h" @@ -310,7 +311,7 @@ bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tr struct cli_credentials *credentials = cmdline_credentials; status = smb2_connect(tctx, host, share, - lp_name_resolve_order(tctx->lp_ctx), + lp_resolve_context(tctx->lp_ctx), credentials, tree, event_context_find(tctx)); if (!NT_STATUS_IS_OK(status)) { -- cgit From 88d2e0522737fb8856fb0f52c2af8a2f56130f19 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 13 Feb 2008 15:05:44 +1100 Subject: updated SMB2 create operation to match WSPP. Adding some defined for various new create options (This used to be commit d037dc23ced3df6bce98cbf4810fb5f1247336bd) --- source4/torture/smb2/util.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index fe88296a32..219c2140d3 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -55,9 +55,9 @@ NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname) NTSTATUS status; ZERO_STRUCT(io); - io.in.access_mask = SEC_RIGHTS_FILE_ALL; - io.in.file_attr = FILE_ATTRIBUTE_NORMAL; - io.in.open_disposition = NTCREATEX_DISP_OPEN; + io.in.desired_access = SEC_RIGHTS_FILE_ALL; + io.in.file_attributes = FILE_ATTRIBUTE_NORMAL; + io.in.create_disposition = NTCREATEX_DISP_OPEN; io.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE| NTCREATEX_SHARE_ACCESS_READ| @@ -107,9 +107,9 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, smb2_util_unlink(tree, fname); ZERO_STRUCT(io); - io.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - io.in.file_attr = FILE_ATTRIBUTE_NORMAL; - io.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; + io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED; + io.in.file_attributes = FILE_ATTRIBUTE_NORMAL; + io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF; io.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE| NTCREATEX_SHARE_ACCESS_READ| @@ -119,8 +119,8 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, if (dir) { io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; io.in.share_access &= ~NTCREATEX_SHARE_ACCESS_DELETE; - io.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; - io.in.open_disposition = NTCREATEX_DISP_CREATE; + io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY; + io.in.create_disposition = NTCREATEX_DISP_CREATE; } if (strchr(fname, ':') == NULL) { @@ -334,10 +334,10 @@ NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname, NTSTATUS status; ZERO_STRUCT(io); - io.in.oplock_flags = 0; - io.in.access_mask = SEC_RIGHTS_FILE_ALL; - io.in.file_attr = FILE_ATTRIBUTE_NORMAL; - io.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io.in.oplock_level = 0; + io.in.desired_access = SEC_RIGHTS_FILE_ALL; + io.in.file_attributes = FILE_ATTRIBUTE_NORMAL; + io.in.create_disposition = NTCREATEX_DISP_OPEN_IF; io.in.share_access = NTCREATEX_SHARE_ACCESS_DELETE| NTCREATEX_SHARE_ACCESS_READ| @@ -370,10 +370,10 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname, NTSTATUS status; ZERO_STRUCT(io); - io.in.oplock_flags = 0; - io.in.access_mask = SEC_RIGHTS_DIR_ALL; - io.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; - io.in.open_disposition = NTCREATEX_DISP_OPEN_IF; + io.in.oplock_level = 0; + io.in.desired_access = SEC_RIGHTS_DIR_ALL; + io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY; + io.in.create_disposition = NTCREATEX_DISP_OPEN_IF; io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE; io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; io.in.fname = fname; @@ -422,10 +422,10 @@ NTSTATUS smb2_util_roothandle(struct smb2_tree *tree, struct smb2_handle *handle NTSTATUS status; ZERO_STRUCT(io); - io.in.oplock_flags = 0; - io.in.access_mask = SEC_STD_SYNCHRONIZE | SEC_DIR_READ_ATTRIBUTE | SEC_DIR_LIST; - io.in.file_attr = 0; - io.in.open_disposition = NTCREATEX_DISP_OPEN; + io.in.oplock_level = 0; + io.in.desired_access = SEC_STD_SYNCHRONIZE | SEC_DIR_READ_ATTRIBUTE | SEC_DIR_LIST; + io.in.file_attributes = 0; + io.in.create_disposition = NTCREATEX_DISP_OPEN; io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE; io.in.create_options = NTCREATEX_OPTIONS_ASYNC_ALERT; io.in.fname = ""; -- cgit From 10a374421bac7df15ab398bc46580be0d06d9d7d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 18 Feb 2008 14:54:59 +1100 Subject: open a root handle in SMB2 should use a NULL filename, not a zero length filename (This used to be commit a29dd708bf26440552ffa9d83332329b4c108857) --- source4/torture/smb2/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 219c2140d3..f85b1c42ff 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -123,6 +123,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, io.in.create_disposition = NTCREATEX_DISP_CREATE; } + /* it seems vista is now fussier about alignment? */ if (strchr(fname, ':') == NULL) { /* setup some EAs */ io.in.eas.num_eas = 2; @@ -428,7 +429,7 @@ NTSTATUS smb2_util_roothandle(struct smb2_tree *tree, struct smb2_handle *handle io.in.create_disposition = NTCREATEX_DISP_OPEN; io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE; io.in.create_options = NTCREATEX_OPTIONS_ASYNC_ALERT; - io.in.fname = ""; + io.in.fname = NULL; status = smb2_create(tree, tree, &io); NT_STATUS_NOT_OK_RETURN(status); -- cgit From 4b9c7df9b7465a360e7a528a116ed3740447b7be Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2008 23:06:27 +0200 Subject: Avoid event_find_context when a event context is already available. (This used to be commit 4ca264679ecfd938c538a93f4efff1bfa23c3744) --- source4/torture/smb2/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index f85b1c42ff..6ac3926c98 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -314,7 +314,7 @@ bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tr status = smb2_connect(tctx, host, share, lp_resolve_context(tctx->lp_ctx), credentials, tree, - event_context_find(tctx)); + tctx->ev); if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n", host, share, nt_errstr(status)); -- cgit From 66cbf7eb59ab4a29dca1d30850c9aeb35a598b3d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 19 May 2008 11:39:16 +1000 Subject: added mkdir to SMB2 proxy (This used to be commit 1323aab11fbf346e19c4cef227d727ddfcaa7d60) --- source4/torture/smb2/util.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 6ac3926c98..4995bbe978 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -22,6 +22,7 @@ #include "includes.h" #include "libcli/smb2/smb2.h" #include "libcli/smb2/smb2_calls.h" +#include "libcli/smb_composite/smb_composite.h" #include "lib/cmdline/popt_common.h" #include "lib/events/events.h" #include "system/time.h" @@ -51,27 +52,12 @@ NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h) */ NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname) { - struct smb2_create io; - NTSTATUS status; - + union smb_unlink io; + ZERO_STRUCT(io); - io.in.desired_access = SEC_RIGHTS_FILE_ALL; - io.in.file_attributes = FILE_ATTRIBUTE_NORMAL; - io.in.create_disposition = NTCREATEX_DISP_OPEN; - io.in.share_access = - NTCREATEX_SHARE_ACCESS_DELETE| - NTCREATEX_SHARE_ACCESS_READ| - NTCREATEX_SHARE_ACCESS_WRITE; - io.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE; - io.in.fname = fname; - - status = smb2_create(tree, tree, &io); - if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - return NT_STATUS_OK; - } - NT_STATUS_NOT_OK_RETURN(status); + io.unlink.in.pattern = fname; - return smb2_util_close(tree, io.out.file.handle); + return smb2_composite_unlink(tree, &io); } /* -- cgit From f8f0cc985b181d5d19703fa3d16ec3de876fe4a8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 May 2008 11:59:18 +1000 Subject: moved these util functions into libcli (This used to be commit b2f1154bc338fb56fc998f40159156cb6859075b) --- source4/torture/smb2/util.c | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 4995bbe978..af4f345104 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -34,32 +34,6 @@ #include "torture/smb2/proto.h" -/* - close a handle with SMB2 -*/ -NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h) -{ - struct smb2_close c; - - ZERO_STRUCT(c); - c.in.file.handle = h; - - return smb2_close(tree, &c); -} - -/* - unlink a file with SMB2 -*/ -NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname) -{ - union smb_unlink io; - - ZERO_STRUCT(io); - io.unlink.in.pattern = fname; - - return smb2_composite_unlink(tree, &io); -} - /* write to a file on SMB2 */ -- cgit From beaa01e403dda7557a6acdf0181d79d58a33bbbe Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 30 May 2008 17:03:54 +1000 Subject: implemented client side SMB2 signing This doessn't work against Windows yet, and I've submitted a WSPP request for clarification of the docs to try and find out why. Meanwhile this is no worse than what we had, as it only gets used when the server demands signing, and we didn't work then anyway. (This used to be commit b788096add3586d7277efcd3bf5ca7f3a604cb7a) --- source4/torture/smb2/util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/torture/smb2/util.c') diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index af4f345104..3a437acbab 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -270,11 +270,14 @@ bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tr const char *host = torture_setting_string(tctx, "host", NULL); const char *share = torture_setting_string(tctx, "share", NULL); struct cli_credentials *credentials = cmdline_credentials; + struct smbcli_options options; + + lp_smbcli_options(tctx->lp_ctx, &options); status = smb2_connect(tctx, host, share, lp_resolve_context(tctx->lp_ctx), credentials, tree, - tctx->ev); + tctx->ev, &options); if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n", host, share, nt_errstr(status)); -- cgit