-/*
+/*
Unix SMB/CIFS implementation.
test security descriptor operations
Copyright (C) Andrew Tridgell 2004
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
io.ntcreatex.in.create_options = 0;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- io.ntcreatex.in.share_access =
- NTCREATEX_SHARE_ACCESS_READ |
+ io.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
io.ntcreatex.in.alloc_size = 0;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
-
+
q.query_secdesc.level = RAW_FILEINFO_SEC_DESC;
q.query_secdesc.in.file.fnum = fnum;
- q.query_secdesc.in.secinfo_flags =
+ q.query_secdesc.in.secinfo_flags =
SECINFO_OWNER |
SECINFO_GROUP |
SECINFO_DACL;
io.ntcreatex.in.create_options =
test_dir ? NTCREATEX_OPTIONS_DIRECTORY : 0;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- io.ntcreatex.in.share_access =
- NTCREATEX_SHARE_ACCESS_READ |
+ io.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
io.ntcreatex.in.alloc_size = 0;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
q.query_secdesc.level = RAW_FILEINFO_SEC_DESC;
q.query_secdesc.in.file.fnum = fnum;
- q.query_secdesc.in.secinfo_flags =
+ q.query_secdesc.in.secinfo_flags =
SECINFO_OWNER |
SECINFO_GROUP |
SECINFO_DACL;
status = security_descriptor_dacl_add(sd, &ace);
CHECK_STATUS(status, NT_STATUS_OK);
-
+
torture_comment(tctx, "creating with an initial ACL\n");
io.ntcreatex.in.sec_desc = sd;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
-
+
FAIL_UNLESS(verify_sd(tctx, cli, fnum, sd));
status = smbcli_close(cli->tree, fnum);
mapping bits
Test copied to smb2/acls.c for SMB2.
*/
-static bool test_creator_sid(struct torture_context *tctx,
+static bool test_creator_sid(struct torture_context *tctx,
struct smbcli_state *cli)
{
NTSTATUS status;
io.ntcreatex.in.access_mask = SEC_STD_READ_CONTROL | SEC_STD_WRITE_DAC | SEC_STD_WRITE_OWNER;
io.ntcreatex.in.create_options = 0;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- io.ntcreatex.in.share_access =
- NTCREATEX_SHARE_ACCESS_READ |
+ io.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
io.ntcreatex.in.alloc_size = 0;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
+ CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
SEC_FILE_READ_DATA|
SEC_FILE_READ_ATTRIBUTE);
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
io.ntcreatex.in.access_mask = SEC_GENERIC_READ;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
+ CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
SEC_RIGHTS_FILE_READ);
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
io.ntcreatex.in.access_mask = SEC_FILE_READ_DATA;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
- SEC_FILE_READ_DATA |
+ CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
+ SEC_FILE_READ_DATA |
SEC_FILE_READ_ATTRIBUTE);
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
SEC_FILE_xx bits
Test copied to smb2/acls.c for SMB2.
*/
-static bool test_generic_bits(struct torture_context *tctx,
+static bool test_generic_bits(struct torture_context *tctx,
struct smbcli_state *cli)
{
NTSTATUS status;
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid.fnum = 0;
io.ntcreatex.in.flags = 0;
- io.ntcreatex.in.access_mask =
- SEC_STD_READ_CONTROL |
- SEC_STD_WRITE_DAC |
+ io.ntcreatex.in.access_mask =
+ SEC_STD_READ_CONTROL |
+ SEC_STD_WRITE_DAC |
SEC_STD_WRITE_OWNER;
io.ntcreatex.in.create_options = 0;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- io.ntcreatex.in.share_access =
- NTCREATEX_SHARE_ACCESS_READ |
+ io.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
io.ntcreatex.in.alloc_size = 0;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
owner_sid = dom_sid_string(tctx, sd_orig->owner_sid);
- status = torture_check_privilege(cli,
- owner_sid,
+ status = torture_check_privilege(cli,
+ owner_sid,
sec_privilege_name(SEC_PRIV_RESTORE));
has_restore_privilege = NT_STATUS_IS_OK(status);
if (!NT_STATUS_IS_OK(status)) {
}
torture_comment(tctx, "SEC_PRIV_RESTORE - %s\n", has_restore_privilege?"Yes":"No");
- status = torture_check_privilege(cli,
- owner_sid,
+ status = torture_check_privilege(cli,
+ owner_sid,
sec_privilege_name(SEC_PRIV_TAKE_OWNERSHIP));
has_take_ownership_privilege = NT_STATUS_IS_OK(status);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(tctx, "SEC_PRIV_TAKE_OWNERSHIP - %s\n", has_take_ownership_privilege?"Yes":"No");
for (i=0;i<ARRAY_SIZE(file_mappings);i++) {
- uint32_t expected_mask =
- SEC_STD_WRITE_DAC |
- SEC_STD_READ_CONTROL |
+ uint32_t expected_mask =
+ SEC_STD_WRITE_DAC |
+ SEC_STD_READ_CONTROL |
SEC_FILE_READ_ATTRIBUTE |
SEC_STD_DELETE;
uint32_t expected_mask_anon = SEC_FILE_READ_ATTRIBUTE;
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
+ CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
expected_mask | file_mappings[i].specific_bits);
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
+ CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
expected_mask_anon | file_mappings[i].specific_bits);
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
}
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid.fnum = 0;
io.ntcreatex.in.flags = 0;
- io.ntcreatex.in.access_mask =
- SEC_STD_READ_CONTROL |
- SEC_STD_WRITE_DAC |
+ io.ntcreatex.in.access_mask =
+ SEC_STD_READ_CONTROL |
+ SEC_STD_WRITE_DAC |
SEC_STD_WRITE_OWNER;
io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
- io.ntcreatex.in.share_access =
- NTCREATEX_SHARE_ACCESS_READ |
+ io.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
io.ntcreatex.in.alloc_size = 0;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
owner_sid = dom_sid_string(tctx, sd_orig->owner_sid);
- status = torture_check_privilege(cli,
- owner_sid,
+ status = torture_check_privilege(cli,
+ owner_sid,
sec_privilege_name(SEC_PRIV_RESTORE));
has_restore_privilege = NT_STATUS_IS_OK(status);
if (!NT_STATUS_IS_OK(status)) {
}
torture_comment(tctx, "SEC_PRIV_RESTORE - %s\n", has_restore_privilege?"Yes":"No");
- status = torture_check_privilege(cli,
- owner_sid,
+ status = torture_check_privilege(cli,
+ owner_sid,
sec_privilege_name(SEC_PRIV_TAKE_OWNERSHIP));
has_take_ownership_privilege = NT_STATUS_IS_OK(status);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(tctx, "SEC_PRIV_TAKE_OWNERSHIP - %s\n", has_take_ownership_privilege?"Yes":"No");
for (i=0;i<ARRAY_SIZE(dir_mappings);i++) {
- uint32_t expected_mask =
- SEC_STD_WRITE_DAC |
- SEC_STD_READ_CONTROL |
+ uint32_t expected_mask =
+ SEC_STD_WRITE_DAC |
+ SEC_STD_READ_CONTROL |
SEC_FILE_READ_ATTRIBUTE |
SEC_STD_DELETE;
uint32_t expected_mask_anon = SEC_FILE_READ_ATTRIBUTE;
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
+ CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
expected_mask | dir_mappings[i].specific_bits);
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
+ CHECK_ACCESS_FLAGS(io.ntcreatex.out.file.fnum,
expected_mask_anon | dir_mappings[i].specific_bits);
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
}
see what access bits the owner of a file always gets
Test copied to smb2/acls.c for SMB2.
*/
-static bool test_owner_bits(struct torture_context *tctx,
+static bool test_owner_bits(struct torture_context *tctx,
struct smbcli_state *cli)
{
NTSTATUS status;
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid.fnum = 0;
io.ntcreatex.in.flags = 0;
- io.ntcreatex.in.access_mask =
- SEC_STD_READ_CONTROL |
- SEC_STD_WRITE_DAC |
+ io.ntcreatex.in.access_mask =
+ SEC_STD_READ_CONTROL |
+ SEC_STD_WRITE_DAC |
SEC_STD_WRITE_OWNER;
io.ntcreatex.in.create_options = 0;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- io.ntcreatex.in.share_access =
- NTCREATEX_SHARE_ACCESS_READ |
+ io.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
io.ntcreatex.in.alloc_size = 0;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
owner_sid = dom_sid_string(tctx, sd_orig->owner_sid);
- status = torture_check_privilege(cli,
- owner_sid,
+ status = torture_check_privilege(cli,
+ owner_sid,
sec_privilege_name(SEC_PRIV_RESTORE));
has_restore_privilege = NT_STATUS_IS_OK(status);
if (!NT_STATUS_IS_OK(status)) {
}
torture_comment(tctx, "SEC_PRIV_RESTORE - %s\n", has_restore_privilege?"Yes":"No");
- status = torture_check_privilege(cli,
- owner_sid,
+ status = torture_check_privilege(cli,
+ owner_sid,
sec_privilege_name(SEC_PRIV_TAKE_OWNERSHIP));
has_take_ownership_privilege = NT_STATUS_IS_OK(status);
if (!NT_STATUS_IS_OK(status)) {
test the inheritance of ACL flags onto new files and directories
Test copied to smb2/acls.c for SMB2.
*/
-static bool test_inheritance(struct torture_context *tctx,
+static bool test_inheritance(struct torture_context *tctx,
struct smbcli_state *cli)
{
NTSTATUS status;
uint32_t dir_flags;
} test_flags[] = {
{
- 0,
+ 0,
0,
0
},
{
SEC_ACE_FLAG_OBJECT_INHERIT,
0,
- SEC_ACE_FLAG_OBJECT_INHERIT |
+ SEC_ACE_FLAG_OBJECT_INHERIT |
SEC_ACE_FLAG_INHERIT_ONLY,
},
{
SEC_ACE_FLAG_CONTAINER_INHERIT,
},
{
- SEC_ACE_FLAG_OBJECT_INHERIT |
+ SEC_ACE_FLAG_OBJECT_INHERIT |
SEC_ACE_FLAG_CONTAINER_INHERIT,
0,
- SEC_ACE_FLAG_OBJECT_INHERIT |
+ SEC_ACE_FLAG_OBJECT_INHERIT |
SEC_ACE_FLAG_CONTAINER_INHERIT,
},
{
0,
},
{
- SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
+ SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
SEC_ACE_FLAG_OBJECT_INHERIT,
0,
0,
},
{
- SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
+ SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
SEC_ACE_FLAG_CONTAINER_INHERIT,
0,
0,
},
{
- SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
- SEC_ACE_FLAG_CONTAINER_INHERIT |
+ SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
+ SEC_ACE_FLAG_CONTAINER_INHERIT |
SEC_ACE_FLAG_OBJECT_INHERIT,
0,
0,
0,
},
{
- SEC_ACE_FLAG_INHERIT_ONLY |
+ SEC_ACE_FLAG_INHERIT_ONLY |
SEC_ACE_FLAG_OBJECT_INHERIT,
0,
- SEC_ACE_FLAG_OBJECT_INHERIT |
+ SEC_ACE_FLAG_OBJECT_INHERIT |
SEC_ACE_FLAG_INHERIT_ONLY,
},
{
- SEC_ACE_FLAG_INHERIT_ONLY |
+ SEC_ACE_FLAG_INHERIT_ONLY |
SEC_ACE_FLAG_CONTAINER_INHERIT,
0,
SEC_ACE_FLAG_CONTAINER_INHERIT,
},
{
- SEC_ACE_FLAG_INHERIT_ONLY |
- SEC_ACE_FLAG_CONTAINER_INHERIT |
+ SEC_ACE_FLAG_INHERIT_ONLY |
+ SEC_ACE_FLAG_CONTAINER_INHERIT |
SEC_ACE_FLAG_OBJECT_INHERIT,
0,
- SEC_ACE_FLAG_CONTAINER_INHERIT |
+ SEC_ACE_FLAG_CONTAINER_INHERIT |
SEC_ACE_FLAG_OBJECT_INHERIT,
},
{
- SEC_ACE_FLAG_INHERIT_ONLY |
+ SEC_ACE_FLAG_INHERIT_ONLY |
SEC_ACE_FLAG_NO_PROPAGATE_INHERIT,
0,
0,
},
{
- SEC_ACE_FLAG_INHERIT_ONLY |
- SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
+ SEC_ACE_FLAG_INHERIT_ONLY |
+ SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
SEC_ACE_FLAG_OBJECT_INHERIT,
0,
0,
},
{
- SEC_ACE_FLAG_INHERIT_ONLY |
- SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
+ SEC_ACE_FLAG_INHERIT_ONLY |
+ SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
SEC_ACE_FLAG_CONTAINER_INHERIT,
0,
0,
},
{
- SEC_ACE_FLAG_INHERIT_ONLY |
- SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
- SEC_ACE_FLAG_CONTAINER_INHERIT |
+ SEC_ACE_FLAG_INHERIT_ONLY |
+ SEC_ACE_FLAG_NO_PROPAGATE_INHERIT |
+ SEC_ACE_FLAG_CONTAINER_INHERIT |
SEC_ACE_FLAG_OBJECT_INHERIT,
0,
0,
goto check_dir;
}
- if (q.query_secdesc.out.sd->dacl->aces[0].flags !=
+ if (q.query_secdesc.out.sd->dacl->aces[0].flags !=
test_flags[i].file_flags) {
torture_warning(tctx, "incorrect file_flags 0x%x - expected 0x%x for parent 0x%x with (i=%d)\n",
q.query_secdesc.out.sd->dacl->aces[0].flags,
continue;
}
- if ((test_flags[i].parent_flags & SEC_ACE_FLAG_CONTAINER_INHERIT) &&
+ if ((test_flags[i].parent_flags & SEC_ACE_FLAG_CONTAINER_INHERIT) &&
(test_flags[i].parent_flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT)) {
if (q.query_secdesc.out.sd->dacl == NULL ||
q.query_secdesc.out.sd->dacl->num_aces != 1 ||
!dom_sid_equal(&q.query_secdesc.out.sd->dacl->aces[1].trustee,
creator_owner) ||
q.query_secdesc.out.sd->dacl->aces[0].flags != 0 ||
- q.query_secdesc.out.sd->dacl->aces[1].flags !=
+ q.query_secdesc.out.sd->dacl->aces[1].flags !=
(test_flags[i].dir_flags | SEC_ACE_FLAG_INHERIT_ONLY)) {
torture_warning(tctx, "(CI) Bad sd in child dir - expected 0x%x for parent 0x%x (i=%d)\n",
test_flags[i].dir_flags,
test dynamic acl inheritance
Test copied to smb2/acls.c for SMB2.
*/
-static bool test_inheritance_dynamic(struct torture_context *tctx,
+static bool test_inheritance_dynamic(struct torture_context *tctx,
struct smbcli_state *cli)
{
NTSTATUS status;
union smb_setfileinfo set;
struct security_descriptor *sd, *sd_orig=NULL;
const char *owner_sid;
-
+
torture_comment(tctx, "TESTING DYNAMIC ACL INHERITANCE\n");
if (!torture_setup_dir(cli, BASEDIR))
/* test what access mask is needed for getting and setting security_descriptors
Test copied to smb2/acls.c for SMB2. */
-static bool test_sd_get_set(struct torture_context *tctx,
+static bool test_sd_get_set(struct torture_context *tctx,
struct smbcli_state *cli)
{
NTSTATUS status;
SEC_FLAG_SYSTEM_SECURITY |
SEC_FLAG_MAXIMUM_ALLOWED |
SEC_STD_ALL |
- SEC_FILE_ALL |
+ SEC_FILE_ALL |
NO_BITS_HACK;
uint64_t get_owner_bits = SEC_MASK_GENERIC | SEC_FLAG_MAXIMUM_ALLOWED | SEC_STD_READ_CONTROL;
uint64_t set_owner_bits = SEC_GENERIC_ALL | SEC_FLAG_MAXIMUM_ALLOWED | SEC_STD_WRITE_OWNER;
status = smbcli_close(cli->tree, fnum);
CHECK_STATUS(status, NT_STATUS_OK);
- /*
+ /*
* now try each access_mask bit and no bit at all in a loop
* and see what's allowed
* NOTE: if i == 32 it means access_mask = 0 (see NO_BITS_HACK above)
#endif
-/*
+/*
basic testing of security descriptor calls
*/
struct torture_suite *torture_raw_acls(TALLOC_CTX *mem_ctx)
-/*
+/*
Unix SMB/CIFS implementation.
chkpath individual test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
}
ret &= test_path(cli, BASEDIR "\\test.txt..", NT_STATUS_NOT_A_DIRECTORY, NT_STATUS_DOS(ERRDOS,ERRbadpath));
-
+
if (!torture_set_file_attribute(cli->tree, BASEDIR, FILE_ATTRIBUTE_HIDDEN)) {
printf("failed to set basedir hidden\n");
ret = false;
return ret;
}
-/*
- basic testing of chkpath calls
+/*
+ basic testing of chkpath calls
*/
-bool torture_raw_chkpath(struct torture_context *torture,
+bool torture_raw_chkpath(struct torture_context *torture,
struct smbcli_state *cli)
{
bool ret = true;
-/*
+/*
Unix SMB/CIFS implementation.
RAW_CLOSE_* individual test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "torture/raw/proto.h"
/**
- * basic testing of all RAW_CLOSE_* calls
+ * basic testing of all RAW_CLOSE_* calls
*/
bool torture_raw_close(struct torture_context *torture,
struct smbcli_state *cli)
status = smb_raw_close(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
-
+
printf("Testing close.in.write_time\n");
/* the file should have the write time set */
if (basetime != nt_time_to_unix(finfo.all_info.out.write_time)) {
printf("Incorrect write time on file - %s - %s\n",
- timestring(torture, basetime),
+ timestring(torture, basetime),
nt_time_string(torture, finfo.all_info.out.write_time));
dump_all_info(torture, &finfo);
ret = false;
printf("Testing other times\n");
/* none of the other times should be set to that time */
- if (nt_time_equal(&finfo.all_info.out.write_time,
+ if (nt_time_equal(&finfo.all_info.out.write_time,
&finfo.all_info.out.access_time) ||
- nt_time_equal(&finfo.all_info.out.write_time,
+ nt_time_equal(&finfo.all_info.out.write_time,
&finfo.all_info.out.create_time) ||
- nt_time_equal(&finfo.all_info.out.write_time,
+ nt_time_equal(&finfo.all_info.out.write_time,
&finfo.all_info.out.change_time)) {
printf("Incorrect times after close - only write time should be set\n");
dump_all_info(torture, &finfo);
ret = false;
}
}
-
+
smbcli_unlink(cli->tree, fname);
REOPEN;
status = smb_raw_pathinfo(cli->tree, torture, &finfo);
CHECK_STATUS(status, NT_STATUS_OK);
- if (!nt_time_equal(&finfo.all_info.out.write_time,
+ if (!nt_time_equal(&finfo.all_info.out.write_time,
&finfo2.all_info.out.write_time)) {
printf("Incorrect write time on file - 0 time should be ignored\n");
dump_all_info(torture, &finfo);
io_flush.flush.in.file.fnum = fnum;
status = smb_raw_flush(cli->tree, &io_flush);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
-
+
done:
smbcli_close(cli->tree, fnum);
-/*
+/*
Unix SMB/CIFS implementation.
libcli composite function testing
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 3 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, see <http://www.gnu.org/licenses/>.
*/
}
}
torture_comment(tctx, "count=%d\n", *count);
-
+
for (i=0;i<num_ops;i++) {
status = smb_composite_loadfile_recv(c[i], tctx);
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OK, "loadfile failed");
io1.in.fname = talloc_asprintf(io_orig, BASEDIR "\\test%d.txt", i);
io1.in.data = NULL;
io1.in.size = 0;
-
+
status = smb_composite_savefile(cli->tree, &io1);
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OK, "savefile failed");
status = smb_composite_appendacl(cli->tree, io_orig[i], io_orig[i]);
torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OK, "appendacl failed");
}
-
+
/* fill Security Descriptor with aces to be added */
torture_comment(tctx, "(%s) appendacl[%d] failed - %s\n", __location__, i, nt_errstr(status));
return false;
}
-
+
security_descriptor_dacl_add(io_orig[i]->out.sd, ace);
torture_assert(tctx,
security_acl_equal(io_orig[i]->out.sd->dacl,
io[i]->out.sd->dacl),
"appendacl failed - needed acl isn't set");
}
-
+
talloc_free (ace);
talloc_free (test_sid);
talloc_free (test_sd);
-
+
return true;
}
-/*
+/*
Unix SMB/CIFS implementation.
test suite for session setup operations
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
status = smb_composite_sesssetup(session, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
-
+
session->vuid = setup.out.vuid;
torture_comment(tctx, "create a third security context on the same transport, with given vuid\n");
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */
setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx);
-
+
setup.in.credentials = samba_cmdline_get_creds();
status = smb_composite_sesssetup(session3, &setup);
setup.in.sesskey = cli->transport->negotiate.sesskey;
setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */
setup.in.workgroup = lpcfg_workgroup(tctx->lp_ctx);
-
+
anon_creds = cli_credentials_init(tctx);
cli_credentials_set_conf(anon_creds, tctx->lp_ctx);
cli_credentials_set_anonymous(anon_creds);
setup.in.credentials = anon_creds;
-
+
status = smb_composite_sesssetup(session3, &setup);
CHECK_STATUS(status, NT_STATUS_OK);
talloc_free(session4);
}
-
+
torture_comment(tctx, "use the same tree as the existing connection\n");
tree = smbcli_tree_init(session, tctx, false);
tree->tid = cli->tree->tid;
setups[i].in.sesskey = cli->transport->negotiate.sesskey;
setups[i].in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */
setups[i].in.workgroup = lpcfg_workgroup(tctx->lp_ctx);
-
+
setups[i].in.credentials = samba_cmdline_get_creds();
setups[i].in.gensec_settings = gensec_settings;
share = torture_setting_string(tctx, "share", NULL);
host = torture_setting_string(tctx, "host", NULL);
-
+
torture_comment(tctx, "create a second tree context on the same session\n");
tree = smbcli_tree_init(cli->session, tctx, false);
tcon.tconx.in.flags = TCONX_FLAG_EXTENDED_RESPONSE;
tcon.tconx.in.password = data_blob(NULL, 0);
tcon.tconx.in.path = talloc_asprintf(tctx, "\\\\%s\\%s", host, share);
- tcon.tconx.in.device = "A:";
+ tcon.tconx.in.device = "A:";
status = smb_raw_tcon(tree, tctx, &tcon);
CHECK_STATUS(status, NT_STATUS_OK);
-
+
tree->tid = tcon.tconx.out.tid;
torture_comment(tctx, "tid1=%d tid2=%d\n", cli->tree->tid, tree->tid);
torture_comment(tctx, "try a tconx with a bad device type\n");
- tcon.tconx.in.device = "FOO";
+ tcon.tconx.in.device = "FOO";
status = smb_raw_tcon(tree, tctx, &tcon);
CHECK_STATUS(status, NT_STATUS_BAD_DEVICE_TYPE);
/* close down the new tree */
talloc_free(tree);
-
+
done:
return ret;
}
/* close down the new tree */
talloc_free(tree);
-
+
done:
return ret;
}
setup.in.gensec_settings = lpcfg_gensec_settings(tctx, tctx->lp_ctx);
status = smb_composite_sesssetup(session, &setup);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(status, NT_STATUS_OK);
session->vuid = setup.out.vuid;
vuid1 = cli->session->vuid;
share = torture_setting_string(tctx, "share", NULL);
host = torture_setting_string(tctx, "host", NULL);
-
+
torture_comment(tctx, "create a second tree context on the same session\n");
tree = smbcli_tree_init(cli->session, tctx, false);
tcon.tconx.in.flags = TCONX_FLAG_EXTENDED_RESPONSE;
tcon.tconx.in.password = data_blob(NULL, 0);
tcon.tconx.in.path = talloc_asprintf(tctx, "\\\\%s\\%s", host, share);
- tcon.tconx.in.device = "A:";
+ tcon.tconx.in.device = "A:";
status = smb_raw_tcon(tree, tctx, &tcon);
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(status, NT_STATUS_OK);
tree->tid = tcon.tconx.out.tid;
-/*
+/*
Unix SMB/CIFS implementation.
ioctl individual test suite
Copyright (C) Andrew Tridgell 2003
Copyright (C) James J Myers 2003 <myersjj@samba.org>
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
return ret;
}
-/*
- basic testing of some ioctl calls
+/*
+ basic testing of some ioctl calls
*/
-bool torture_raw_ioctl(struct torture_context *torture,
+bool torture_raw_ioctl(struct torture_context *torture,
struct smbcli_state *cli)
{
bool ret = true;
-/*
+/*
Unix SMB/CIFS implementation.
test suite for various lock operations
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
torture_comment(tctx, "Testing RAW_LOCK_LOCK\n");
io.generic.level = RAW_LOCK_LOCK;
-
+
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
"Failed to create %s - %s\n",
torture_comment(tctx, "Testing RAW_LOCK_LOCKX\n");
io.generic.level = RAW_LOCK_LOCKX;
-
+
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
"Failed to create %s - %s\n",
/*
test high pid
*/
-static bool test_pidhigh(struct torture_context *tctx,
+static bool test_pidhigh(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_lock io;
io.generic.level = RAW_LOCK_LOCKX;
cli->session->pid = 1;
-
+
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
"Failed to create %s - %s\n",
/*
test locking&X async operation
*/
-static bool test_async(struct torture_context *tctx,
+static bool test_async(struct torture_context *tctx,
struct smbcli_state *cli)
{
struct smbcli_session *session;
/*
test NT_STATUS_LOCK_NOT_GRANTED vs. NT_STATUS_FILE_LOCK_CONFLICT
*/
-static bool test_errorcode(struct torture_context *tctx,
+static bool test_errorcode(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_lock io;
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
lock[0].pid--;
- /*
+ /*
* demonstrate that a successful lock with count = 0 and the same offset,
* doesn't reset the error cache
*/
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- /*
+ /*
* demonstrate that a successful lock with count = 0 and outside the locked range,
* doesn't reset the error cache
*/
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- /*
+ /*
* demonstrate that a lock with count = 0 and inside the locked range,
* fails and resets the error cache
*/
status = smb_raw_lock(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
- /*
+ /*
* demonstrate that a successful lock in a different range
* doesn't reset the cache, the failing lock on the 2nd handle
* resets the cache
/*
test LOCKING_ANDX_CHANGE_LOCKTYPE
*/
-static bool test_changetype(struct torture_context *tctx,
+static bool test_changetype(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_lock io;
torture_comment(tctx, "Testing LOCKING_ANDX_CHANGE_LOCKTYPE\n");
io.generic.level = RAW_LOCK_LOCKX;
-
+
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
torture_assert(tctx,(fnum != -1), talloc_asprintf(tctx,
"Failed to create %s - %s\n",
-/*
+/*
Unix SMB/CIFS implementation.
locking benchmark
Copyright (C) Andrew Tridgell 2006
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
state->req->async.fn = lock_completion;
}
-static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te,
+static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te,
struct timeval t, void *private_data);
-static void reopen_file(struct tevent_context *ev, struct tevent_timer *te,
+static void reopen_file(struct tevent_context *ev, struct tevent_timer *te,
struct timeval t, void *private_data)
{
struct benchlock_state *state = (struct benchlock_state *)private_data;
if (!NT_STATUS_IS_OK(status)) {
talloc_free(state->te);
state->te = tevent_add_timer(state->ev, state->mem_ctx,
- timeval_current_ofs(1,0),
+ timeval_current_ofs(1,0),
reopen_connection, state);
return;
}
tevent_add_timer(state->ev, state->mem_ctx, timeval_zero(), reopen_file, state);
}
-
+
/*
reopen a connection
*/
-static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te,
+static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te,
struct timeval t, void *private_data)
{
struct benchlock_state *state = (struct benchlock_state *)private_data;
talloc_free(state->tree);
state->tree = NULL;
- ctx = smb_composite_connect_send(io, state->mem_ctx,
+ ctx = smb_composite_connect_send(io, state->mem_ctx,
lpcfg_resolve_context(state->tctx->lp_ctx),
state->ev);
if (ctx == NULL) {
NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) {
talloc_free(state->tree);
state->tree = NULL;
- num_connected--;
+ num_connected--;
DEBUG(0,("reopening connection to %s\n", state->dest_host));
talloc_free(state->te);
state->te = tevent_add_timer(state->ev, state->mem_ctx,
- timeval_current_ofs(1,0),
+ timeval_current_ofs(1,0),
reopen_connection, state);
} else {
DEBUG(0,("Lock failed - %s\n", nt_errstr(status)));
NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) {
talloc_free(state->tree);
state->tree = NULL;
- num_connected--;
+ num_connected--;
DEBUG(0,("reopening connection to %s\n", state->dest_host));
talloc_free(state->te);
state->te = tevent_add_timer(state->ev, state->mem_ctx,
- timeval_current_ofs(1,0),
+ timeval_current_ofs(1,0),
reopen_connection, state);
}
}
-static void report_rate(struct tevent_context *ev, struct tevent_timer *te,
+static void report_rate(struct tevent_context *ev, struct tevent_timer *te,
struct timeval t, void *private_data)
{
- struct benchlock_state *state = talloc_get_type(private_data,
+ struct benchlock_state *state = talloc_get_type(private_data,
struct benchlock_state);
int i;
for (i=0;i<nprocs;i++) {
}
}
-/*
+/*
benchmark locking calls
*/
bool torture_bench_lock(struct torture_context *torture)
dest_port = get_sockaddr_port(dest_ss);
state[i].dest_host = talloc_strdup(state[i].mem_ctx, dest_str);
- state[i].dest_ports = talloc_array(state[i].mem_ctx,
+ state[i].dest_ports = talloc_array(state[i].mem_ctx,
const char *, 2);
- state[i].dest_ports[0] = talloc_asprintf(state[i].dest_ports,
+ state[i].dest_ports[0] = talloc_asprintf(state[i].dest_ports,
"%u", dest_port);
state[i].dest_ports[1] = NULL;
state[i].called_name = talloc_strdup(state[i].mem_ctx,
}
for (i=0;i<nprocs;i++) {
- state[i].fnum = smbcli_open(state[i].tree,
- FNAME,
+ state[i].fnum = smbcli_open(state[i].tree,
+ FNAME,
O_RDWR|O_CREAT, DENY_NONE);
if (state[i].fnum == -1) {
printf("Failed to open %s on connection %d\n", FNAME, i);
lock_send(&state[i]);
}
- tv = timeval_current();
+ tv = timeval_current();
if (progress) {
tevent_add_timer(torture->ev, state, timeval_current_ofs(1, 0), report_rate, state);
-/*
+/*
Unix SMB/CIFS implementation.
RAW_MKDIR_* and RAW_RMDIR_* individual test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
- /*
+ /*
basic mkdir
*/
md.mkdir.level = RAW_MKDIR_MKDIR;
md.mkdir.in.path = "..\\..\\..";
status = smb_raw_mkdir(cli->tree, &md);
CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
-
+
printf("Testing t2mkdir\n");
/* try a t2mkdir - need to work out why this fails! */
md.t2mkdir.level = RAW_MKDIR_T2MKDIR;
md.t2mkdir.in.path = path;
- md.t2mkdir.in.num_eas = 0;
+ md.t2mkdir.in.num_eas = 0;
status = smb_raw_mkdir(cli->tree, &md);
CHECK_STATUS(status, NT_STATUS_OK);
}
-/*
- basic testing of all RAW_MKDIR_* calls
+/*
+ basic testing of all RAW_MKDIR_* calls
*/
-bool torture_raw_mkdir(struct torture_context *torture,
+bool torture_raw_mkdir(struct torture_context *torture,
struct smbcli_state *cli)
{
bool ret = true;
-/*
+/*
Unix SMB/CIFS implementation.
basic raw test suite for multiplexing
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
torture_comment(tctx, "send 2nd async open, conflicting\n");
tv = timeval_current();
req2 = smb_raw_open_send(cli->tree, &io);
-
+
torture_comment(tctx, "close first sync open\n");
smbcli_close(cli->tree, fnum1);
io.writex.in.wmode = 0;
io.writex.in.remaining = 0;
io.writex.in.count = 4;
- io.writex.in.data = (const uint8_t *)&fnum;
+ io.writex.in.data = (const uint8_t *)&fnum;
req = smb_raw_write_send(cli->tree, &io);
/* unlock the range */
smb_raw_ntcancel(req);
torture_comment(tctx, "sending 2nd cancel\n");
- /* the 2nd cancel is totally harmless, but tests the server trying to
+ /* the 2nd cancel is totally harmless, but tests the server trying to
cancel an already cancelled request */
smb_raw_ntcancel(req);
-/*
+/*
basic testing of multiplexing notify
*/
bool torture_raw_mux(struct torture_context *torture, struct smbcli_state *cli)
-/*
+/*
Unix SMB/CIFS implementation.
basic raw test suite for change notify
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#define BASEDIR_CN1_DIR BASEDIR "_CN1_DIR"
-/*
+/*
basic testing of change notify on directories
*/
static bool test_notify_dir(struct torture_context *tctx,
"smbcli_unlink");
/* (1st unlink) as the 2nd notify directly returns,
- this unlink is only seen by the 1st notify and
+ this unlink is only seen by the 1st notify and
the 3rd notify (later) */
torture_comment(tctx, "Testing notify on unlink for the first file\n");
status = smbcli_unlink(cli2->tree, BASEDIR_CN1_DIR "\\test0.txt");
return false;
}
-/*
+/*
testing of recursive change notify
*/
*/
smbcli_mkdir(cli->tree, BASEDIR_CN1_RECUR "\\subdir-name");
smbcli_mkdir(cli2->tree, BASEDIR_CN1_RECUR "\\subdir-name\\subname1");
- smbcli_close(cli->tree,
+ smbcli_close(cli->tree,
smbcli_open(cli->tree,
BASEDIR_CN1_RECUR "\\subdir-name\\subname2",
O_CREAT, 0));
ret &= check_rename_reply(tctx,
cli, __LINE__, ¬ify.nttrans.out.changes[5],
NOTIFY_ACTION_MODIFIED, "subname2-r");
-
+
ret &= check_rename_reply(tctx,
cli, __LINE__, ¬ify.nttrans.out.changes[8],
NOTIFY_ACTION_OLD_NAME, "subname2-r");
return ret;
}
-/*
+/*
testing of change notify mask change
*/
smbcli_mkdir(cli->tree, BASEDIR_CN1_CNMC "\\subdir-name");
smbcli_mkdir(cli->tree, BASEDIR_CN1_CNMC "\\subdir-name\\subname1");
- smbcli_close(cli->tree,
+ smbcli_close(cli->tree,
smbcli_open(cli->tree,
BASEDIR_CN1_CNMC "\\subdir-name\\subname2",
O_CREAT, 0));
}
-/*
+/*
testing of mask bits for change notify
*/
return ret;
}
-/*
+/*
test setting up two change notify requests on one handle
*/
}
-/*
+/*
test multiple change notifies at different depths and with/without recursion
*/
status = smb_raw_changenotify_recv(req, tctx, ¬ify);
dirs[i].counted += notify.nttrans.out.num_changes;
}
-
+
all_done = true;
for (i=0;i<ARRAY_SIZE(dirs);i++) {
with change notify
*/
-static struct smbcli_tree *secondary_tcon(struct smbcli_state *cli,
+static struct smbcli_tree *secondary_tcon(struct smbcli_state *cli,
struct torture_context *tctx)
{
NTSTATUS status;
share = torture_setting_string(tctx, "share", NULL);
host = torture_setting_string(tctx, "host", NULL);
-
+
torture_comment(tctx, "create a second tree context on the same session\n");
tree = smbcli_tree_init(cli->session, tctx, false);
tcon.tconx.in.flags = TCONX_FLAG_EXTENDED_RESPONSE;
tcon.tconx.in.password = data_blob(NULL, 0);
tcon.tconx.in.path = talloc_asprintf(tctx, "\\\\%s\\%s", host, share);
- tcon.tconx.in.device = "A:";
+ tcon.tconx.in.device = "A:";
status = smb_raw_tcon(tree, tctx, &tcon);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tree);
}
-/*
+/*
very simple change notify test
*/
struct smbcli_request *req;
extern int torture_numops;
struct smbcli_tree *tree = NULL;
-
+
torture_comment(tctx, "TESTING SIMPLE CHANGE NOTIFY\n");
torture_assert(tctx, torture_setup_dir(cli, BASEDIR_CN1_NTCON),
-/*
+/*
Unix SMB/CIFS implementation.
RAW_OPEN_* individual test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.openold.out.file.fnum;
CHECK_RDWR(fnum, RDWR_RDWR);
-
+
if (io.openold.in.open_mode != io.openold.out.rmode) {
torture_warning(tctx, "(%s) rmode should equal open_mode - 0x%x 0x%x\n",
__location__, io.openold.out.rmode, io.openold.in.open_mode);
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
if (torture_setting_bool(tctx, "samba3", false)) {
- CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE,
+ CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE,
attrib & ~(FILE_ATTRIBUTE_NONINDEXED|
FILE_ATTRIBUTE_SPARSE));
}
else {
- CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE,
+ CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE,
attrib & ~(FILE_ATTRIBUTE_NONINDEXED));
}
smbcli_close(cli->tree, io.openx.out.file.fnum);
return ret;
}
-
+
/*
test RAW_OPEN_NTCREATEX
CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
- CHECK_VAL(io.ntcreatex.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED,
+ CHECK_VAL(io.ntcreatex.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED,
FILE_ATTRIBUTE_DIRECTORY);
CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
CHECK_ALL_INFO(io.ntcreatex.out.size, size);
CHECK_VAL(io.ntcreatex.out.size, 0);
CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
smbcli_unlink(cli->tree, fname);
-
+
done:
smbcli_close(cli->tree, fnum);
CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
- CHECK_VAL(io.ntcreatex.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED,
+ CHECK_VAL(io.ntcreatex.out.attrib & ~FILE_ATTRIBUTE_NONINDEXED,
FILE_ATTRIBUTE_DIRECTORY);
CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
CHECK_ALL_INFO(io.ntcreatex.out.size, size);
CHECK_VAL(io.ntcreatex.out.size, 0);
CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
smbcli_unlink(cli->tree, fname);
-
+
done:
smbcli_close(cli->tree, fnum);
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.mknew.out.file.fnum;
- CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE,
+ CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE,
attrib & ~FILE_ATTRIBUTE_NONINDEXED);
-
+
done:
smbcli_close(cli->tree, fnum);
smbcli_deltree(cli->tree, BASEDIR);
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.create.out.file.fnum;
- CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE,
+ CHECK_ALL_INFO(FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_ARCHIVE,
attrib & ~FILE_ATTRIBUTE_NONINDEXED);
-
+
done:
smbcli_close(cli->tree, fnum);
smbcli_deltree(cli->tree, BASEDIR);
smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
- smbcli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
io.openxreadx.level = RAW_OPEN_OPENX_READX;
io.openxreadx.in.fname = fname;
io.openxreadx.in.write_time = 0;
io.openxreadx.in.size = 1024*1024;
io.openxreadx.in.timeout = 0;
-
+
io.openxreadx.in.offset = 0;
io.openxreadx.in.mincnt = sizeof(buf2);
io.openxreadx.in.maxcnt = sizeof(buf2);
/*
test RAW_OPEN_OPENX without a leading slash on the path.
NetApp filers are known to fail on this.
-
+
*/
static bool test_no_leading_slash(struct torture_context *tctx, struct smbcli_state *cli)
{
/* Create the file */
fnum = create_complex_file(cli, tctx, fname);
smbcli_write(cli->tree, fnum, 0, buf, 0, sizeof(buf));
- smbcli_close(cli->tree, fnum);
+ smbcli_close(cli->tree, fnum);
/* Prepare to open the file using path without leading slash */
io.openx.level = RAW_OPEN_OPENX;
test RAW_OPEN_OPENX against an existing directory to
ensure it returns NT_STATUS_FILE_IS_A_DIRECTORY.
Samba 3.2.0 - 3.2.6 are known to fail this.
-
+
*/
static bool test_openx_over_dir(struct torture_context *tctx, struct smbcli_state *cli)
{
/* Create the Directory */
status = create_directory_handle(cli->tree, fname, &d_fnum);
- smbcli_close(cli->tree, d_fnum);
+ smbcli_close(cli->tree, d_fnum);
/* Prepare to open the file over the directory. */
io.openx.level = RAW_OPEN_OPENX;
int i, num_files = 3;
int num_ok = 0;
int num_collision = 0;
-
+
clients = talloc_array(mem_ctx, struct smbcli_state *, num_files);
requests = talloc_array(mem_ctx, struct smbcli_request *, num_files);
ios = talloc_array(mem_ctx, union smb_open, num_files);
if (NT_STATUS_IS_OK(status)) {
num_ok += 1;
- }
+ }
if (NT_STATUS_EQUAL(status,
NT_STATUS_OBJECT_NAME_COLLISION)) {
-/*
+/*
Unix SMB/CIFS implementation.
open benchmark
Copyright (C) Andrew Tridgell 2007
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
};
static void next_open(struct benchopen_state *state);
-static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te,
+static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te,
struct timeval t, void *private_data);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(state->te);
state->te = tevent_add_timer(state->ev, state->mem_ctx,
- timeval_current_ofs(1,0),
+ timeval_current_ofs(1,0),
reopen_connection, state);
return;
}
next_open(state);
}
-
+
/*
reopen a connection
*/
-static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te,
+static void reopen_connection(struct tevent_context *ev, struct tevent_timer *te,
struct timeval t, void *private_data)
{
struct benchopen_state *state = (struct benchopen_state *)private_data;
state->open_fnum = -1;
state->close_fnum = -1;
- ctx = smb_composite_connect_send(io, state->mem_ctx,
+ ctx = smb_composite_connect_send(io, state->mem_ctx,
lpcfg_resolve_context(state->tctx->lp_ctx),
state->ev);
if (ctx == NULL) {
talloc_free(state->cli);
state->tree = NULL;
state->cli = NULL;
- num_connected--;
+ num_connected--;
DEBUG(0,("[%u] reopening connection to %s\n",
state->client_num, state->dest_host));
talloc_free(state->te);
state->te = tevent_add_timer(state->ev, state->mem_ctx,
- timeval_current_ofs(1,0),
+ timeval_current_ofs(1,0),
reopen_connection, state);
return;
}
}
next_open(state);
-}
+}
/*
called when a close completes
talloc_free(state->cli);
state->tree = NULL;
state->cli = NULL;
- num_connected--;
+ num_connected--;
DEBUG(0,("[%u] reopening connection to %s\n",
state->client_num, state->dest_host));
talloc_free(state->te);
state->te = tevent_add_timer(state->ev, state->mem_ctx,
- timeval_current_ofs(1,0),
+ timeval_current_ofs(1,0),
reopen_connection, state);
return;
}
DEBUG(2,("[%d] close completed %d (fnum[%d])\n",
state->client_num, state->close_file_num,
state->close_fnum));
-}
+}
static void echo_completion(struct smbcli_request *req)
{
NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) {
talloc_free(state->tree);
state->tree = NULL;
- num_connected--;
+ num_connected--;
DEBUG(0,("[%u] reopening connection to %s\n",
state->client_num, state->dest_host));
talloc_free(state->te);
state->te = tevent_add_timer(state->ev, state->mem_ctx,
- timeval_current_ofs(1,0),
+ timeval_current_ofs(1,0),
reopen_connection, state);
}
}
-static void report_rate(struct tevent_context *ev, struct tevent_timer *te,
+static void report_rate(struct tevent_context *ev, struct tevent_timer *te,
struct timeval t, void *private_data)
{
- struct benchopen_state *state = talloc_get_type(private_data,
+ struct benchopen_state *state = talloc_get_type(private_data,
struct benchopen_state);
int i;
for (i=0;i<nprocs;i++) {
}
}
-/*
+/*
benchmark open calls
*/
bool torture_bench_open(struct torture_context *torture)
bool progress=false;
progress = torture_setting_bool(torture, "progress", true);
-
+
nprocs = torture_setting_int(torture, "nprocs", 4);
state = talloc_zero_array(mem_ctx, struct benchopen_state, nprocs);
dest_port = get_sockaddr_port(dest_ss);
state[i].dest_host = talloc_strdup(state[i].mem_ctx, dest_str);
- state[i].dest_ports = talloc_array(state[i].mem_ctx,
+ state[i].dest_ports = talloc_array(state[i].mem_ctx,
const char *, 2);
- state[i].dest_ports[0] = talloc_asprintf(state[i].dest_ports,
+ state[i].dest_ports[0] = talloc_asprintf(state[i].dest_ports,
"%u", dest_port);
state[i].dest_ports[1] = NULL;
state[i].called_name = talloc_strdup(state[i].mem_ctx,
next_open(&state[i]);
}
- tv = timeval_current();
+ tv = timeval_current();
if (progress) {
report_te = tevent_add_timer(torture->ev, state, timeval_current_ofs(1, 0),
-/*
+/*
Unix SMB/CIFS implementation.
basic raw test suite for oplocks
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*
a handler function for oplock break requests. Ack it as a break to none
*/
-static bool oplock_handler_ack_to_none(struct smbcli_transport *transport,
- uint16_t tid, uint16_t fnum,
+static bool oplock_handler_ack_to_none(struct smbcli_transport *transport,
+ uint16_t tid, uint16_t fnum,
uint8_t level, void *private_data)
{
struct smbcli_tree *tree = (struct smbcli_tree *)private_data;
/*
a handler function for oplock break requests - close the file
*/
-static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t tid,
+static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t tid,
uint16_t fnum, uint8_t level, void *private_data)
{
union smb_close io;
*/
torture_comment(tctx, "BATCH1: open with batch oplock\n");
ZERO_STRUCT(break_info);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, tctx, &io);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
torture_comment(tctx, "BATCH2: open with batch oplock\n");
ZERO_STRUCT(break_info);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, tctx, &io);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
torture_comment(tctx, "BATCH3: if we close on break then the unlink can succeed\n");
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_close, cli1->tree);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, tctx, &io);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, tctx, &io);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, tctx, &io);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_WRITE;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, tctx, &io);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, tctx, &io);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
ZERO_STRUCT(break_info);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli2->tree, tctx, &io);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
status = smb_raw_open(cli1->tree, tctx, &io);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
ZERO_STRUCT(break_info);
torture_comment(tctx, "second open with attributes only shouldn't cause oplock break\n");
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
status = smb_raw_open(cli2->tree, tctx, &io);
torture_comment(tctx, "BATCH9: open with attributes only can create file\n");
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
ZERO_STRUCT(break_info);
smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_given, cli1->tree);
smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_given, cli2->tree);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
torture_comment(tctx, "BATCH13: open with batch oplock\n");
ZERO_STRUCT(break_info);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
NTCREATEX_SHARE_ACCESS_WRITE|
torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_OVERWRITE disposition causes oplock break\n");
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
torture_comment(tctx, "BATCH14: open with batch oplock\n");
ZERO_STRUCT(break_info);
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
NTCREATEX_SHARE_ACCESS_WRITE|
torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_SUPERSEDE disposition causes oplock break\n");
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
return false;
}
talloc_steal(mem_ctx, cli[i]);
- smbcli_oplock_handler(cli[i]->transport, oplock_handler_close,
+ smbcli_oplock_handler(cli[i]->transport, oplock_handler_close,
cli[i]->tree);
}
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = BASEDIR "\\test.dat";
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
- NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
- tv = timeval_current();
+ tv = timeval_current();
/*
we open the same file with SHARE_ACCESS_NONE from all the
torture_comment(torture, "%.2f ops/second\n", count/timeval_elapsed(&tv));
smb_raw_exit(cli[torture_nprocs-1]->session);
-
+
done:
smb_raw_exit(cli[0]->session);
smbcli_deltree(cli[0]->tree, BASEDIR);
},
};
-static bool oplock_handler_hold(struct smbcli_transport *transport,
- uint16_t tid, uint16_t fnum, uint8_t level,
+static bool oplock_handler_hold(struct smbcli_transport *transport,
+ uint16_t tid, uint16_t fnum, uint8_t level,
void *private_data)
{
struct smbcli_tree *tree = (struct smbcli_tree *)private_data;
}
-/*
+/*
used for manual testing of oplocks - especially interaction with
other filesystems (such as NFS and local access)
*/
-bool torture_hold_oplock(struct torture_context *torture,
+bool torture_hold_oplock(struct torture_context *torture,
struct smbcli_state *cli)
{
struct tevent_context *ev = torture->ev;
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = hold_info[i].fname;
- io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
NTCREATEX_FLAGS_REQUEST_OPLOCK |
NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
printf("opening %s\n", hold_info[i].fname);
status = smb_raw_open(cli->tree, cli, &io);
if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to open %s - %s\n",
+ printf("Failed to open %s - %s\n",
hold_info[i].fname, nt_errstr(status));
return false;
}
if (io.ntcreatex.out.oplock_level != BATCH_OPLOCK_RETURN) {
- printf("Oplock not granted for %s - expected %d but got %d\n",
- hold_info[i].fname, BATCH_OPLOCK_RETURN,
+ printf("Oplock not granted for %s - expected %d but got %d\n",
+ hold_info[i].fname, BATCH_OPLOCK_RETURN,
io.ntcreatex.out.oplock_level);
return false;
}
-/*
+/*
Unix SMB/CIFS implementation.
ping pong test
Significantly based on and borrowed from lockbench.c by
Copyright (C) Andrew Tridgell 2006
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
printf("write failed\n");
exit(1);
}
-}
+}
static void read_byte(struct smbcli_state *cli, int fd, uint8_t *c, int offset)
{
printf("read failed\n");
exit(1);
}
-}
+}
-/*
+/*
ping pong
*/
bool torture_ping_pong(struct torture_context *torture)
uint8_t c;
read_byte(cli, fd, &c, i);
incr = c-val[i];
- val[i] = c;
+ val[i] = c;
}
if (do_writes) {
fflush(stdout);
}
if (timeval_elapsed(&start) > 1.0) {
- printf("%8u locks/sec\r",
+ printf("%8u locks/sec\r",
(unsigned)(2*count/timeval_elapsed(&start)));
fflush(stdout);
start = timeval_current();
loops++;
}
}
-
-/*
+/*
Unix SMB/CIFS implementation.
RAW_FILEINFO_* individual test suite
Copyright (C) Andrew Tridgell 2003
Copyright (C) Andrew Bartlett <abartlet@samba.org> 2007
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
int i;
for (i=0; levels[i].name; i++) {
if (NT_STATUS_IS_OK(levels[i].fnum_status) &&
- strcmp(name, levels[i].name) == 0 &&
+ strcmp(name, levels[i].name) == 0 &&
!levels[i].only_paths) {
return &levels[i].fnum_finfo;
}
}
for (i=0; levels[i].name; i++) {
if (NT_STATUS_IS_OK(levels[i].fname_status) &&
- strcmp(name, levels[i].name) == 0 &&
+ strcmp(name, levels[i].name) == 0 &&
!levels[i].only_handles) {
return &levels[i].fname_finfo;
}
ret = false; \
}} while(0)
-/* used to find hints on unknown values - and to make sure
+/* used to find hints on unknown values - and to make sure
we zero-fill */
#if 0 /* unused */
#define VAL_UNKNOWN(n1, v1) do {if (s1->n1.out.v1 != 0) { \
}} while(0)
#endif
-/* basic testing of all RAW_FILEINFO_* calls
- for each call we test that it succeeds, and where possible test
- for consistency between the calls.
+/* basic testing of all RAW_FILEINFO_* calls
+ for each call we test that it succeeds, and where possible test
+ for consistency between the calls.
*/
-static bool torture_raw_qfileinfo_internals(struct torture_context *torture,
- TALLOC_CTX *mem_ctx,
- struct smbcli_tree *tree,
+static bool torture_raw_qfileinfo_internals(struct torture_context *torture,
+ TALLOC_CTX *mem_ctx,
+ struct smbcli_tree *tree,
int fnum, const char *fname,
bool is_ipc)
{
size_t i;
bool ret = true;
size_t count;
- union smb_fileinfo *s1, *s2;
+ union smb_fileinfo *s1, *s2;
NTTIME correct_time;
uint64_t correct_size;
uint32_t correct_attrib;
if (!levels[i].only_paths) {
levels[i].fnum_finfo.generic.level = levels[i].level;
levels[i].fnum_finfo.generic.in.file.fnum = fnum;
- levels[i].fnum_status = smb_raw_fileinfo(tree, mem_ctx,
+ levels[i].fnum_status = smb_raw_fileinfo(tree, mem_ctx,
&levels[i].fnum_finfo);
}
if (!levels[i].only_handles) {
levels[i].fname_finfo.generic.level = levels[i].level;
levels[i].fname_finfo.generic.in.file.path = talloc_strdup(mem_ctx, fname);
- levels[i].fname_status = smb_raw_pathinfo(tree, mem_ctx,
+ levels[i].fname_status = smb_raw_pathinfo(tree, mem_ctx,
&levels[i].fname_finfo);
}
}
nt_errstr(levels[i].fname_status));
continue;
} else if (!levels[i].only_handles && !NT_STATUS_EQUAL(NT_STATUS_INVALID_DEVICE_REQUEST, levels[i].fname_status)) {
- printf("ERROR: fname level %s failed, expected NT_STATUS_INVALID_DEVICE_REQUEST - %s\n",
+ printf("ERROR: fname level %s failed, expected NT_STATUS_INVALID_DEVICE_REQUEST - %s\n",
levels[i].name, nt_errstr(levels[i].fname_status));
count++;
}
continue;
}
if (!levels[i].only_paths && !NT_STATUS_EQUAL(levels[i].expected_ipc_fnum_status, levels[i].fnum_status)) {
- printf("ERROR: fnum level %s failed, expected %s - %s\n",
- levels[i].name, nt_errstr(levels[i].expected_ipc_fnum_status),
+ printf("ERROR: fnum level %s failed, expected %s - %s\n",
+ levels[i].name, nt_errstr(levels[i].expected_ipc_fnum_status),
nt_errstr(levels[i].fnum_status));
count++;
}
}
if (!levels[i].only_paths && !NT_STATUS_IS_OK(levels[i].fnum_status)) {
- printf("ERROR: fnum level %s failed - %s\n",
+ printf("ERROR: fnum level %s failed - %s\n",
levels[i].name, nt_errstr(levels[i].fnum_status));
count++;
}
if (!levels[i].only_handles && !NT_STATUS_IS_OK(levels[i].fname_status)) {
- printf("ERROR: fname level %s failed - %s\n",
+ printf("ERROR: fname level %s failed - %s\n",
levels[i].name, nt_errstr(levels[i].fname_status));
count++;
}
}
-
+
}
if (count != 0) {
s1 ? s1->stream_info.out.num_streams : -1);
}
skip_streams = true;
- }
+ }
/* this code is incredibly repititive but doesn't lend itself to loops, so
we use lots of macros to make it less painful */
- /* first off we check the levels that are supposed to be aliases. It will be quite rare for
+ /* first off we check the levels that are supposed to be aliases. It will be quite rare for
this code to fail, but we need to check it for completeness */
s1 = fnum_find("STANDARD_INFO");
correct_size = s1->standard_info.out.size;
torture_comment(torture, "size: %u\n", (unsigned int)correct_size);
-
+
SIZE_CHECK("GETATTR", getattr, size);
SIZE_CHECK("GETATTRE", getattre, size);
SIZE_CHECK("STANDARD", standard, size);
s1 = fnum_find("STANDARD_INFO");
correct_size = s1->standard_info.out.alloc_size;
torture_comment(torture, "alloc_size: %u\n", (unsigned int)correct_size);
-
+
SIZE_CHECK("GETATTRE", getattre, alloc_size);
SIZE_CHECK("STANDARD", standard, alloc_size);
SIZE_CHECK("EA_SIZE", ea_size, alloc_size);
s1 = fnum_find("BASIC_INFO");
correct_attrib = s1->basic_info.out.attrib;
torture_comment(torture, "attrib: 0x%x\n", (unsigned int)correct_attrib);
-
+
ATTRIB_CHECK("GETATTR", getattr, attrib);
if (!is_ipc) {
ATTRIB_CHECK("GETATTRE", getattre, attrib);
if (s1 && s1->all_info.out.fname.s) {
char *p = strrchr(s1->all_info.out.fname.s, '\\');
if (!p) {
- printf("Not a full path in all_info/fname? - '%s'\n",
+ printf("Not a full path in all_info/fname? - '%s'\n",
s1->all_info.out.fname.s);
ret = false;
} else {
torture_comment(torture, "no alternate name information\n");
} else {
torture_comment(torture, "alt_name: %s\n", correct_name);
-
+
NAME_CHECK("ALT_NAME_INFO", alt_name_info, fname, STR_UNICODE);
NAME_CHECK("ALT_NAME_INFORMATION", alt_name_info, fname, STR_UNICODE);
-
+
/* and make sure we can open by alternate name */
smbcli_close(tree, fnum);
- fnum = smbcli_nt_create_full(tree, correct_name, 0,
+ fnum = smbcli_nt_create_full(tree, correct_name, 0,
SEC_RIGHTS_FILE_ALL,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
- NTCREATEX_SHARE_ACCESS_WRITE,
- NTCREATEX_DISP_OVERWRITE_IF,
+ NTCREATEX_SHARE_ACCESS_WRITE,
+ NTCREATEX_DISP_OVERWRITE_IF,
0, 0);
if (fnum == -1) {
printf("Unable to open by alt_name - %s\n", smbcli_errstr(tree));
ret = false;
}
-
+
if (!skip_streams) {
correct_name = "::$DATA";
torture_comment(torture, "stream_name: %s\n", correct_name);
-
+
NAME_CHECK("STREAM_INFO", stream_info, streams[0].stream_name, STR_UNICODE);
NAME_CHECK("STREAM_INFORMATION", stream_info, streams[0].stream_name, STR_UNICODE);
}
}
-
+
/* make sure the EAs look right */
s1 = fnum_find("ALL_EAS");
s2 = fnum_find("ALL_INFO");
if (s1) {
for (i=0;i<s1->all_eas.out.num_eas;i++) {
- printf(" flags=%d %s=%*.*s\n",
+ printf(" flags=%d %s=%*.*s\n",
s1->all_eas.out.eas[i].flags,
s1->all_eas.out.eas[i].name.s,
(int)s1->all_eas.out.eas[i].value.length,
s2->all_info.out.ea_size);
}
} else {
- if (s2->all_info.out.ea_size !=
+ if (s2->all_info.out.ea_size !=
ea_list_size(s1->all_eas.out.num_eas, s1->all_eas.out.eas)) {
printf("ERROR: ea_list_size=%d != fnum all_info.out.ea_size=%d\n",
(int)ea_list_size(s1->all_eas.out.num_eas, s1->all_eas.out.eas),
ret = false; \
}} while (0)
- VAL_CHECK("STANDARD_INFO", standard_info, delete_pending,
+ VAL_CHECK("STANDARD_INFO", standard_info, delete_pending,
"ALL_INFO", all_info, delete_pending);
- VAL_CHECK("STANDARD_INFO", standard_info, directory,
+ VAL_CHECK("STANDARD_INFO", standard_info, directory,
"ALL_INFO", all_info, directory);
- VAL_CHECK("STANDARD_INFO", standard_info, nlink,
+ VAL_CHECK("STANDARD_INFO", standard_info, nlink,
"ALL_INFO", all_info, nlink);
s1 = fnum_find("BASIC_INFO");
if (s1 && is_ipc) {
ret = false;
}
}
- VAL_CHECK("EA_INFO", ea_info, ea_size,
+ VAL_CHECK("EA_INFO", ea_info, ea_size,
"ALL_INFO", all_info, ea_size);
if (!is_ipc) {
- VAL_CHECK("EA_SIZE", ea_size, ea_size,
+ VAL_CHECK("EA_SIZE", ea_size, ea_size,
"ALL_INFO", all_info, ea_size);
}
}} while (0)
#endif
/* now get a bit fancier .... */
-
+
/* when we set the delete disposition then the link count should drop
to 0 and delete_pending should be 1 */
-
+
return ret;
}
-/* basic testing of all RAW_FILEINFO_* calls
- for each call we test that it succeeds, and where possible test
- for consistency between the calls.
+/* basic testing of all RAW_FILEINFO_* calls
+ for each call we test that it succeeds, and where possible test
+ for consistency between the calls.
*/
-bool torture_raw_qfileinfo(struct torture_context *torture,
+bool torture_raw_qfileinfo(struct torture_context *torture,
struct smbcli_state *cli)
{
int fnum;
}
ret = torture_raw_qfileinfo_internals(torture, torture, cli->tree, fnum, fname, false /* is_ipc */);
-
+
smbcli_close(cli->tree, fnum);
smbcli_unlink(cli->tree, fname);
return ret;
}
-bool torture_raw_qfileinfo_pipe(struct torture_context *torture,
+bool torture_raw_qfileinfo_pipe(struct torture_context *torture,
struct smbcli_state *cli)
{
bool ret = true;
-/*
+/*
Unix SMB/CIFS implementation.
RAW_QFS_* individual test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
ret = false; \
}} while(0)
-/* used to find hints on unknown values - and to make sure
+/* used to find hints on unknown values - and to make sure
we zero-fill */
#define VAL_UNKNOWN(n1, v1) do {if (s1->n1.out.v1 != 0) { \
printf("%s/%s non-zero unknown - %u (0x%x) at %s(%d)\n", \
ret = false; \
}} while(0)
-/* basic testing of all RAW_QFS_* calls
- for each call we test that it succeeds, and where possible test
- for consistency between the calls.
+/* basic testing of all RAW_QFS_* calls
+ for each call we test that it succeeds, and where possible test
+ for consistency between the calls.
Some of the consistency tests assume that the target filesystem is
quiescent, which is sometimes hard to achieve
*/
-bool torture_raw_qfsinfo(struct torture_context *torture,
+bool torture_raw_qfsinfo(struct torture_context *torture,
struct smbcli_state *cli)
{
size_t i;
bool ret = true;
size_t count;
- union smb_fsinfo *s1, *s2;
+ union smb_fsinfo *s1, *s2;
/* scan all the levels, pulling the results */
for (i=0; levels[i].name; i++) {
if ((cap & levels[i].capability_mask) != levels[i].capability_mask) {
continue;
}
-
+
if (!NT_STATUS_IS_OK(levels[i].status)) {
- printf("ERROR: level %s failed - %s\n",
+ printf("ERROR: level %s failed - %s\n",
levels[i].name, nt_errstr(levels[i].status));
count++;
}
VAL_APPROX_EQUAL(size_info, avail_alloc_units, size_info, avail_alloc_units);
VAL_EQUAL(size_info, sectors_per_unit, size_info, sectors_per_unit);
VAL_EQUAL(size_info, bytes_per_sector, size_info, bytes_per_sector);
- }
+ }
s1 = find("DEVICE_INFO");
s2 = find("DEVICE_INFORMATION");
if (s1 && s2) {
VAL_EQUAL(device_info, device_type, device_info, device_type);
VAL_EQUAL(device_info, characteristics, device_info, characteristics);
- }
+ }
s1 = find("VOLUME_INFO");
s2 = find("VOLUME_INFORMATION");
VAL_EQUAL (volume_info, serial_number, volume_info, serial_number);
STR_EQUAL (volume_info, volume_name.s, volume_info, volume_name.s);
torture_comment(torture, "volume_info.volume_name = '%s'\n", s1->volume_info.out.volume_name.s);
- }
+ }
s1 = find("ATTRIBUTE_INFO");
s2 = find("ATTRIBUTE_INFORMATION");
if (s1 && s2) {
- VAL_EQUAL(attribute_info, fs_attr,
+ VAL_EQUAL(attribute_info, fs_attr,
attribute_info, fs_attr);
- VAL_EQUAL(attribute_info, max_file_component_length,
+ VAL_EQUAL(attribute_info, max_file_component_length,
attribute_info, max_file_component_length);
STR_EQUAL(attribute_info, fs_type.s, attribute_info, fs_type.s);
torture_comment(torture, "attribute_info.fs_type = '%s'\n", s1->attribute_info.out.fs_type.s);
- }
+ }
torture_comment(torture, "check for consistent disk sizes\n");
s1 = find("DSKATTR");
if (s1 && s2) {
double size1, size2;
double scale = s1->dskattr.out.blocks_per_unit * s1->dskattr.out.block_size;
- size1 = 1.0 *
- s1->dskattr.out.units_total *
- s1->dskattr.out.blocks_per_unit *
+ size1 = 1.0 *
+ s1->dskattr.out.units_total *
+ s1->dskattr.out.blocks_per_unit *
s1->dskattr.out.block_size / scale;
size2 = 1.0 *
s2->allocation.out.sectors_per_unit *
s2->allocation.out.total_alloc_units *
s2->allocation.out.bytes_per_sector / scale;
if (fabs(size1 - size2) > 1) {
- printf("Inconsistent total size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n",
+ printf("Inconsistent total size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n",
size1, size2);
ret = false;
}
if (s1 && s2) {
double size1, size2;
double scale = s1->dskattr.out.blocks_per_unit * s1->dskattr.out.block_size;
- size1 = 1.0 *
- s1->dskattr.out.units_free *
- s1->dskattr.out.blocks_per_unit *
+ size1 = 1.0 *
+ s1->dskattr.out.units_free *
+ s1->dskattr.out.blocks_per_unit *
s1->dskattr.out.block_size / scale;
size2 = 1.0 *
s2->allocation.out.sectors_per_unit *
s2->allocation.out.avail_alloc_units *
s2->allocation.out.bytes_per_sector / scale;
if (fabs(size1 - size2) > 1) {
- printf("Inconsistent avail size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n",
+ printf("Inconsistent avail size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n",
size1, size2);
ret = false;
}
torture_comment(torture, "free disk = %.0f MB\n", size1*scale/1.0e6);
}
-
+
torture_comment(torture, "volume info consistency\n");
s1 = find("VOLUME");
s2 = find("VOLUME_INFO");
if (s1 && s2) {
VAL_EQUAL(volume, serial_number, volume_info, serial_number);
STR_EQUAL(volume, volume_name.s, volume_info, volume_name.s);
- }
+ }
/* disk size consistency - notice that 'avail_alloc_units' maps to the caller
available allocation units, not the total */
VAL_APPROX_EQUAL(size_info, avail_alloc_units, full_size_information, call_avail_alloc_units);
VAL_EQUAL(size_info, sectors_per_unit, full_size_information, sectors_per_unit);
VAL_EQUAL(size_info, bytes_per_sector, full_size_information, bytes_per_sector);
- }
+ }
printf("check for non-zero unknown fields\n");
s1 = find("QUOTA_INFORMATION");
}} while (0)
torture_comment(torture, "check for correct termination\n");
-
+
STR_CHECK("VOLUME", volume, volume_name, 0);
STR_CHECK("VOLUME_INFO", volume_info, volume_name, STR_UNICODE);
STR_CHECK("VOLUME_INFORMATION", volume_info, volume_name, STR_UNICODE);
-/*
+/*
Unix SMB/CIFS implementation.
SMB torture tester
Copyright (C) Jelmer Vernooij 2006
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
-/*
+/*
Unix SMB/CIFS implementation.
test suite for various read operations
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
io.read.in.count = ~0;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
-
+
done:
smbcli_close(cli->tree, fnum);
/*
test lockread ops
*/
-static bool test_lockread(struct torture_context *tctx,
+static bool test_lockread(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_read io;
printf("Testing RAW_READ_LOCKREAD\n");
io.generic.level = RAW_READ_LOCKREAD;
-
+
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
io.lockread.in.count = ~0;
status = smb_raw_read(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
-
+
done:
smbcli_close(cli->tree, fnum);
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
printf("Testing RAW_READ_READX\n");
-
+
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
io.readx.in.mincnt = 100;
io.readx.in.maxcnt = 200;
status = smb_raw_read(cli->tree, &io);
- CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
+ CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT);
if (!(cli->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
printf("skipping large file tests - CAP_LARGE_FILES not set\n");
/*
test readbraw ops
*/
-static bool test_readbraw(struct torture_context *tctx,
+static bool test_readbraw(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_read io;
torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
printf("Testing RAW_READ_READBRAW\n");
-
+
fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
if (fnum == -1) {
printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree));
/*
test read for execute
*/
-static bool test_read_for_execute(struct torture_context *tctx,
+static bool test_read_for_execute(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_open op;
}
-/*
+/*
basic testing of read calls
*/
struct torture_suite *torture_raw_read(TALLOC_CTX *mem_ctx)
torture_suite_add_1smb_test(suite, "readx", test_readx);
torture_suite_add_1smb_test(suite, "lockread", test_lockread);
torture_suite_add_1smb_test(suite, "readbraw", test_readbraw);
- torture_suite_add_1smb_test(suite, "read for execute",
+ torture_suite_add_1smb_test(suite, "read for execute",
test_read_for_execute);
return suite;
-/*
+/*
Unix SMB/CIFS implementation.
rename test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*
test SMBmv ops
*/
-static bool test_mv(struct torture_context *tctx,
+static bool test_mv(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_rename io;
op.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
op.ntcreatex.in.create_options = 0;
op.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- op.ntcreatex.in.share_access =
- NTCREATEX_SHARE_ACCESS_READ |
+ op.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
op.ntcreatex.in.alloc_size = 0;
op.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
io.rename.in.pattern1 = fname1;
io.rename.in.pattern2 = fname2;
io.rename.in.attrib = 0;
-
+
torture_comment(tctx, "trying rename while first file open\n");
status = smb_raw_rename(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
smbcli_close(cli->tree, fnum);
op.ntcreatex.in.access_mask = SEC_FILE_READ_DATA;
- op.ntcreatex.in.share_access =
- NTCREATEX_SHARE_ACCESS_DELETE |
+ op.ntcreatex.in.share_access =
+ NTCREATEX_SHARE_ACCESS_DELETE |
NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
status = smb_raw_open(cli->tree, tctx, &op);
smb_raw_exit(cli->session);
status = smb_raw_rename(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
-
+
torture_comment(tctx, "Trying self rename\n");
io.rename.in.pattern1 = fname2;
io.rename.in.pattern2 = fname2;
/*
test SMBntrename ops
*/
-static bool test_ntrename(struct torture_context *tctx,
+static bool test_ntrename(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_rename io;
torture_comment(tctx, "Trying simple rename\n");
fnum = create_complex_file(cli, tctx, fname1);
-
+
io.generic.level = RAW_RENAME_NTRENAME;
io.ntrename.in.old_name = fname1;
io.ntrename.in.new_name = fname2;
io.ntrename.in.attrib = 0;
io.ntrename.in.cluster_size = 0;
io.ntrename.in.flags = RENAME_FLAG_RENAME;
-
+
status = smb_raw_rename(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION);
-
+
smbcli_close(cli->tree, fnum);
status = smb_raw_rename(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
torture_comment(tctx, "trying wildcard rename\n");
io.ntrename.in.old_name = BASEDIR "\\*.txt";
io.ntrename.in.new_name = fname1;
-
+
status = smb_raw_rename(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
torture_all_info(cli->tree, fname1);
torture_all_info(cli->tree, fname2);
}
-
+
io.ntrename.in.flags = RENAME_FLAG_MOVE_CLUSTER_INFORMATION;
status = smb_raw_rename(cli->tree, &io);
}
}
}
-
+
done:
smb_raw_exit(cli->session);
smbcli_deltree(cli->tree, BASEDIR);
ren_io.rename.in.pattern1 = dname1;
ren_io.rename.in.pattern2 = dname2;
ren_io.rename.in.attrib = 0;
-
+
status = smb_raw_rename(cli->tree, &ren_io);
CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
extern bool test_trans2rename(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2);
extern bool test_nttransrename(struct torture_context *tctx, struct smbcli_state *cli1);
-/*
+/*
basic testing of rename calls
*/
struct torture_suite *torture_raw_rename(TALLOC_CTX *mem_ctx)
-/*
+/*
Unix SMB/CIFS implementation.
Test samba3 hide unreadable/unwriteable
Copyright (C) Volker Lendecke 2006
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
info->unix_basic.in.end_of_file = SMB_SIZE_NO_CHANGE_HI;
info->unix_basic.in.end_of_file <<= 32;
info->unix_basic.in.end_of_file |= SMB_SIZE_NO_CHANGE_LO;
-
+
info->unix_basic.in.num_bytes = SMB_SIZE_NO_CHANGE_HI;
info->unix_basic.in.num_bytes <<= 32;
info->unix_basic.in.num_bytes |= SMB_SIZE_NO_CHANGE_LO;
-
+
info->unix_basic.in.status_change_time = SMB_TIME_NO_CHANGE_HI;
info->unix_basic.in.status_change_time <<= 32;
info->unix_basic.in.status_change_time |= SMB_TIME_NO_CHANGE_LO;
smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR);
smbcli_unlink(cli->tree, fname);
-
+
return true;
}
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR,
DENY_NONE);
- torture_assert(tctx, fnum != -1,
+ torture_assert(tctx, fnum != -1,
talloc_asprintf(tctx, "smbcli_open failed: %s\n",
smbcli_errstr(cli->tree)));
smbcli_close(cli->tree, fnum);
- fnum = smbcli_nt_create_full(cli->tree, fname, 0,
+ fnum = smbcli_nt_create_full(cli->tree, fname, 0,
SEC_RIGHTS_FILE_ALL,
FILE_ATTRIBUTE_NORMAL,
NTCREATEX_SHARE_ACCESS_DELETE,
NTCREATEX_DISP_OPEN, 0, 0);
- torture_assert(tctx, fnum != -1,
+ torture_assert(tctx, fnum != -1,
talloc_asprintf(tctx, "smbcli_open failed: %s\n",
smbcli_errstr(cli->tree)));
status = smbcli_nt_delete_on_close(cli->tree, fnum, true);
- torture_assert_ntstatus_ok(tctx, status,
+ torture_assert_ntstatus_ok(tctx, status,
"setting delete_on_close on file failed !");
status = smbcli_chmod(cli->tree, dname, 0);
- torture_assert_ntstatus_ok(tctx, status,
+ torture_assert_ntstatus_ok(tctx, status,
"smbcli_chmod on file failed !");
status = smbcli_close(cli->tree, fnum);
"smbcli_close");
result = true;
-
+
return result;
}
-/*
+/*
Unix SMB/CIFS implementation.
Test some misc Samba3 code paths
Copyright (C) Volker Lendecke 2006
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
torture_assert_ntstatus_equal(torture, torture_second_tcon(torture, cli->session,
torture_setting_string(torture, "share", NULL),
- &tree2),
+ &tree2),
NT_STATUS_OK,
"creating second tcon");
torture_assert_goto(torture, torture_open_connection(&cli_dos, torture, 1), ret, fail, "Could not open DOS connection\n");
torture_assert_goto(torture, lpcfg_set_cmdline(torture->lp_ctx, "nt status support",
- nt_status_support ? "yes":"no"),
+ nt_status_support ? "yes":"no"),
ret, fail, "Could not set 'nt status support' back to where it was\n");
torture_assert_goto(torture, lpcfg_set_cmdline(torture->lp_ctx, "client ntlmv2 auth",
client_ntlmv2_auth ? "yes":"no"),
dirname));
CHECK_STATUS(torture, status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
- torture_assert_goto(torture, fpath = talloc_asprintf(mem_ctx, "%s\\%s", dirname, fname),
+ torture_assert_goto(torture, fpath = talloc_asprintf(mem_ctx, "%s\\%s", dirname, fname),
ret, fail, "Could not allocate fpath\n");
fnum = smbcli_open(cli_nt->tree, fpath, O_RDWR | O_CREAT, DENY_NONE);
io.ntcreatex.in.create_options = 0;
io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
io.ntcreatex.in.fname = "\\";
- torture_assert_ntstatus_equal_goto(tctx, smb_raw_open(cli->tree, tctx, &io),
+ torture_assert_ntstatus_equal_goto(tctx, smb_raw_open(cli->tree, tctx, &io),
NT_STATUS_OK,
ret, done, "smb_open on the directory failed: %s\n");
-/*
+/*
Unix SMB/CIFS implementation.
RAW_SEARCH_* individual test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
}
/*
- do a single file (non-wildcard) search
+ do a single file (non-wildcard) search
*/
-NTSTATUS torture_single_search(struct smbcli_state *cli,
+NTSTATUS torture_single_search(struct smbcli_state *cli,
TALLOC_CTX *tctx,
const char *pattern,
enum smb_search_level level,
c.fclose.in.id = data->search.id;
status = smb_raw_search_close(cli->tree, &c);
}
-
+
return status;
}
{
int i;
for (i=0;i<ARRAY_SIZE(levels);i++) {
- if (NT_STATUS_IS_OK(levels[i].status) &&
+ if (NT_STATUS_IS_OK(levels[i].status) &&
strcmp(levels[i].name, name) == 0) {
return &levels[i].data;
}
return smb_raw_trans2(cli_unix->tree, tctx, &tp);
}
-/*
+/*
basic testing of all RAW_SEARCH_* calls using a single file
*/
static bool test_one_file(struct torture_context *tctx,
levels[i].data_level,
0,
&levels[i].data);
-
+
expected_status = NT_STATUS_NO_SUCH_FILE;
if (levels[i].level == RAW_SEARCH_SEARCH ||
levels[i].level == RAW_SEARCH_FFIRST ||
torture_result(tctx,
TORTURE_FAIL,
__location__"search level %s(%d) should fail with %s - %s\n",
- levels[i].name, (int)levels[i].level,
+ levels[i].name, (int)levels[i].level,
nt_errstr(expected_status),
nt_errstr(status));
ret = false;
ret = false; \
} \
}} while (0)
-
+
/* check that all the results are as expected */
CHECK_VAL("SEARCH", search, attrib, all_info, all_info, attrib&0xFFF);
CHECK_VAL("STANDARD", standard, attrib, all_info, all_info, attrib&0xFFF);
data->count++;
data->list = talloc_realloc(data->tctx,
- data->list,
+ data->list,
union smb_search_data,
data->count);
enum continue_type {CONT_FLAGS, CONT_NAME, CONT_RESUME_KEY};
/*
- do a single file (non-wildcard) search
+ do a single file (non-wildcard) search
*/
-static NTSTATUS multiple_search(struct smbcli_state *cli,
+static NTSTATUS multiple_search(struct smbcli_state *cli,
TALLOC_CTX *tctx,
const char *pattern,
enum smb_search_data_level data_level,
io.t2ffirst.in.storage_type = 0;
io.t2ffirst.in.pattern = pattern;
if (cont_type == CONT_RESUME_KEY) {
- io.t2ffirst.in.flags |= FLAG_TRANS2_FIND_REQUIRE_RESUME |
+ io.t2ffirst.in.flags |= FLAG_TRANS2_FIND_REQUIRE_RESUME |
FLAG_TRANS2_FIND_BACKUP_INTENT;
}
}
status = smb_raw_search_first(cli->tree, tctx,
&io, data, multiple_search_callback);
-
+
while (NT_STATUS_IS_OK(status)) {
if (data_level == RAW_SEARCH_DATA_SEARCH) {
-/*
+/*
basic testing of search calls using many files
*/
-static bool test_many_files(struct torture_context *tctx,
+static bool test_many_files(struct torture_context *tctx,
struct smbcli_state *cli)
{
const int num_files = 700;
}
result.tctx = talloc_new(tctx);
-
+
torture_comment(tctx,
"Continue %s via %s\n", search_types[t].name, search_types[t].cont_name);
- status = multiple_search(cli, tctx, BASEDIR "\\*.*",
+ status = multiple_search(cli, tctx, BASEDIR "\\*.*",
search_types[t].data_level,
search_types[t].cont_type,
&result);
}
if (i == result->count) {
if (exist) {
- printf("failed: '%s' should exist with attribute %s\n",
+ printf("failed: '%s' should exist with attribute %s\n",
name, attrib_string(result->list, attrib));
return false;
}
}
if (!exist) {
- printf("failed: '%s' should NOT exist (has attribute %s)\n",
+ printf("failed: '%s' should NOT exist (has attribute %s)\n",
name, attrib_string(result->list, result->list[i].both_directory_info.attrib));
return false;
}
if ((result->list[i].both_directory_info.attrib&0xFFF) != attrib) {
printf("failed: '%s' should have attribute 0x%x (has 0x%x)\n",
- name,
+ name,
attrib, result->list[i].both_directory_info.attrib);
return false;
}
return true;
}
-/*
+/*
test what happens when the directory is modified during a search
*/
-static bool test_modify_search(struct torture_context *tctx,
+static bool test_modify_search(struct torture_context *tctx,
struct smbcli_state *cli)
{
const int num_files = 20;
&io, &result, multiple_search_callback);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(result.count, 1);
-
+
printf("pulling the second file\n");
io2.t2fnext.level = RAW_SEARCH_TRANS2;
io2.t2fnext.data_level = RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO;
smbcli_unlink(cli->tree, BASEDIR "\\T014-14.txt");
torture_set_file_attribute(cli->tree, BASEDIR "\\T015-15.txt", FILE_ATTRIBUTE_HIDDEN);
torture_set_file_attribute(cli->tree, BASEDIR "\\T016-16.txt", FILE_ATTRIBUTE_NORMAL);
- torture_set_file_attribute(cli->tree, BASEDIR "\\T017-17.txt", FILE_ATTRIBUTE_SYSTEM);
- torture_set_file_attribute(cli->tree, BASEDIR "\\T018-18.txt", 0);
+ torture_set_file_attribute(cli->tree, BASEDIR "\\T017-17.txt", FILE_ATTRIBUTE_SYSTEM);
+ torture_set_file_attribute(cli->tree, BASEDIR "\\T018-18.txt", 0);
sfinfo.generic.level = RAW_SFILEINFO_DISPOSITION_INFORMATION;
sfinfo.generic.in.file.fnum = fnum;
sfinfo.disposition_info.in.delete_on_close = 1;
if (!ret) {
for (i=0;i<result.count;i++) {
- printf("%s %s (0x%x)\n",
- result.list[i].both_directory_info.name.s,
+ printf("%s %s (0x%x)\n",
+ result.list[i].both_directory_info.name.s,
attrib_string(tctx, result.list[i].both_directory_info.attrib),
result.list[i].both_directory_info.attrib);
}
}
-/*
+/*
testing if directories always come back sorted
*/
static bool test_sorted(struct torture_context *tctx, struct smbcli_state *cli)
ZERO_STRUCT(result);
result.tctx = tctx;
-
- status = multiple_search(cli, tctx, BASEDIR "\\*.*",
+
+ status = multiple_search(cli, tctx, BASEDIR "\\*.*",
RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO,
- CONT_NAME, &result);
+ CONT_NAME, &result);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(result.count, num_files);
name1 = result.list[i].both_directory_info.name.s;
name2 = result.list[i+1].both_directory_info.name.s;
if (strcasecmp_m(name1, name2) > 0) {
- printf("non-alphabetical order at entry %d '%s' '%s'\n",
+ printf("non-alphabetical order at entry %d '%s' '%s'\n",
i, name1, name2);
printf("Server does not produce sorted directory listings (not an error)\n");
goto done;
-/*
+/*
basic testing of many old style search calls using separate dirs
*/
-static bool test_many_dirs(struct torture_context *tctx,
+static bool test_many_dirs(struct torture_context *tctx,
struct smbcli_state *cli)
{
const int num_dirs = 20;
dname = talloc_asprintf(cli, BASEDIR "\\d%d", i);
status = smbcli_mkdir(cli->tree, dname);
if (!NT_STATUS_IS_OK(status)) {
- printf("(%s) Failed to create %s - %s\n",
+ printf("(%s) Failed to create %s - %s\n",
__location__, dname, nt_errstr(status));
ret = false;
goto done;
fname = talloc_asprintf(cli, BASEDIR "\\d%d\\f%d-%d.txt", i, i, n);
fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE);
if (fnum == -1) {
- printf("(%s) Failed to create %s - %s\n",
+ printf("(%s) Failed to create %s - %s\n",
__location__, fname, smbcli_errstr(cli->tree));
ret = false;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
if (strncasecmp(file[i].search.name, fname, strlen(fname)) != 0) {
- printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
+ printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
__location__, file[i].search.name, fname);
ret = false;
goto done;
}
CHECK_STATUS(status, NT_STATUS_OK);
if (strncasecmp(file2[i].search.name, fname, strlen(fname)) != 0) {
- printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
+ printf("(%s) incorrect name '%s' expected '%s'[12].txt\n",
__location__, file2[i].search.name, fname);
ret = false;
goto done;
CHECK_STATUS(status, NT_STATUS_OK);
if (strncasecmp(file3[i].search.name, file2[i].search.name, 3) != 0) {
- printf("(%s) incorrect name '%s' on rewind at dir %d\n",
+ printf("(%s) incorrect name '%s' on rewind at dir %d\n",
__location__, file2[i].search.name, i);
ret = false;
goto done;
if (torture_setting_bool(tctx, "rewind_support", true) &&
strcmp(file3[i].search.name, file2[i].search.name) != 0) {
- printf("(%s) server did not rewind - got '%s' expected '%s'\n",
+ printf("(%s) server did not rewind - got '%s' expected '%s'\n",
__location__, file3[i].search.name, file2[i].search.name);
ret = false;
goto done;
}
-/*
+/*
testing of OS/2 style delete
*/
-static bool test_os2_delete(struct torture_context *tctx,
+static bool test_os2_delete(struct torture_context *tctx,
struct smbcli_state *cli)
{
const int num_files = 700;
CHECK_STATUS(status, NT_STATUS_OK);
if (total_deleted != num_files) {
- printf("error: deleted %d - expected to delete %d\n",
+ printf("error: deleted %d - expected to delete %d\n",
total_deleted, num_files);
ret = false;
}
return strcmp(r1->ea_list.name.s, r2->ea_list.name.s);
}
-/*
+/*
testing of the rather strange ea_list level
*/
-static bool test_ea_list(struct torture_context *tctx,
+static bool test_ea_list(struct torture_context *tctx,
struct smbcli_state *cli)
{
int fnum;
setfile.generic.in.file.path = BASEDIR "\\file3.txt";
status = smb_raw_setpathinfo(cli->tree, &setfile);
CHECK_STATUS(status, NT_STATUS_OK);
-
+
ZERO_STRUCT(result);
result.tctx = tctx;
return ret;
}
-/*
+/*
basic testing of all RAW_SEARCH_* calls using a single file
*/
struct torture_suite *torture_raw_search(TALLOC_CTX *mem_ctx)
-/*
+/*
Unix SMB/CIFS implementation.
seek test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
finfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
finfo.position_information.in.file.fnum = fnum;
-
+
printf("Trying bad handle\n");
io.lseek.in.file.fnum = fnum+1;
io.lseek.in.mode = SEEK_MODE_START;
status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(finfo.position_information.out.position, 0);
-
+
printf("Trying relative seek\n");
io.lseek.in.file.fnum = fnum;
io.lseek.in.mode = SEEK_MODE_CURRENT;
if (smbcli_write(cli->tree, fnum, 0, c, 0, 2) != 2) {
printf("Write failed - %s\n", smbcli_errstr(cli->tree));
ret = false;
- goto done;
+ goto done;
}
printf("Testing position information change\n");
status = smb_raw_seek(cli->tree, &io);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(io.lseek.out.offset, 2);
-
+
if (smbcli_read(cli->tree, fnum, c, 0, 1) != 1) {
printf("Read failed - %s\n", smbcli_errstr(cli->tree));
ret = false;
- goto done;
+ goto done;
}
printf("Testing position information change\n");
status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
CHECK_STATUS(status, NT_STATUS_OK);
CHECK_VALUE(finfo.position_information.out.position, 0);
-
+
done:
smb_raw_exit(cli->session);
}
-/*
+/*
basic testing of seek calls
*/
bool torture_raw_seek(struct torture_context *torture, struct smbcli_state *cli)
-/*
+/*
Unix SMB/CIFS implementation.
RAW_SFILEINFO_* individual test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#define BASEDIR "\\testsfileinfo"
-/* basic testing of all RAW_SFILEINFO_* calls
- for each call we test that it succeeds, and where possible test
- for consistency between the calls.
+/* basic testing of all RAW_SFILEINFO_* calls
+ for each call we test that it succeeds, and where possible test
+ for consistency between the calls.
*/
static bool
torture_raw_sfileinfo_base(struct torture_context *torture, struct smbcli_state *cli)
time_t basetime = (time(NULL) - 86400) & ~1;
bool check_fnum;
int n = time(NULL) % 100;
-
+
path_fname = talloc_asprintf(torture, BASEDIR "\\fname_test_%d.txt", n);
path_fname_new = talloc_asprintf(torture, BASEDIR "\\fname_test_new_%d.txt", n);
fnum_fname = talloc_asprintf(torture, BASEDIR "\\fnum_test_%d.txt", n);
} while (0)
RECREATE_BOTH;
-
+
#define CHECK_CALL_FNUM(call, rightstatus) do { \
check_fnum = true; \
call_name = #call; \
goto done; \
}} while (0)
-
+
printf("Test setattr\n");
sfinfo.setattr.in.attrib = FILE_ATTRIBUTE_READONLY;
sfinfo.setattr.in.write_time = basetime;
return ret;
}
-/*
+/*
look for the w2k3 setpathinfo STANDARD bug
*/
static bool torture_raw_sfileinfo_bug(struct torture_context *torture,
int fnum;
if (!torture_setting_bool(torture, "dangerous", false))
- torture_skip(torture,
+ torture_skip(torture,
"torture_raw_sfileinfo_bug disabled - enable dangerous tests to use\n");
fnum = create_complex_file(cli, torture, fname);
-/*
+/*
Unix SMB/CIFS implementation.
test alternate data streams
Copyright (C) Andrew Tridgell 2004
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
*/
static bool check_stream(struct smbcli_state *cli, const char *location,
TALLOC_CTX *mem_ctx,
- const char *fname, const char *sname,
+ const char *fname, const char *sname,
const char *value)
{
int fnum;
}
return true;
}
-
+
if (fnum == -1) {
printf("(%s) Failed to open stream '%s' - %s\n",
location, full_name, smbcli_errstr(cli->tree));
}
buf = talloc_array(mem_ctx, uint8_t, strlen(value)+11);
-
+
ret = smbcli_read(cli->tree, fnum, buf, 0, strlen(value)+11);
if (ret != strlen(value)) {
printf("(%s) Failed to read %lu bytes from stream '%s' - got %d\n",
status = smb_raw_open(cli->tree, tctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
-
+
smbcli_close(cli->tree, fnum);
status = smbcli_unlink(cli->tree, sname2);
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
return ret;
}
-/*
+/*
* Test FILE_SHARE_DELETE on streams
*
* A stream opened with !FILE_SHARE_DELETE prevents the main file to be opened
return ret;
}
-/*
+/*
basic testing of streams calls
*/
struct torture_suite *torture_raw_streams(TALLOC_CTX *tctx)
-/*
+/*
Unix SMB/CIFS implementation.
unlink test suite
Copyright (C) Andrew Tridgell 2003
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*
- test delete on close
+ test delete on close
*/
-static bool test_delete_on_close(struct torture_context *tctx,
+static bool test_delete_on_close(struct torture_context *tctx,
struct smbcli_state *cli)
{
union smb_open op;
printf("Testing with directory delete_on_close 1\n");
status = create_directory_handle(cli->tree, dname, &fnum);
CHECK_STATUS(status, NT_STATUS_OK);
-
+
sfinfo.disposition_info.in.file.fnum = fnum;
sfinfo.disposition_info.in.delete_on_close = 1;
status = smb_raw_setfileinfo(cli->tree, &sfinfo);
printf("Testing open dir with delete_on_close\n");
status = create_directory_handle(cli->tree, dname, &fnum);
CHECK_STATUS(status, NT_STATUS_OK);
-
+
smbcli_close(cli->tree, fnum);
fnum2 = create_complex_file(cli, tctx, inside);
smbcli_close(cli->tree, fnum2);
status = create_directory_handle(cli->tree, dname, &fnum);
CHECK_STATUS(status, NT_STATUS_OK);
smbcli_close(cli->tree, fnum);
-
+
fnum2 = create_complex_file(cli, tctx, inside);
smbcli_close(cli->tree, fnum2);
printf("Testing pre-existing open dir with second delete_on_close\n");
status = create_directory_handle(cli->tree, dname, &fnum);
CHECK_STATUS(status, NT_STATUS_OK);
-
+
smbcli_close(cli->tree, fnum);
fnum = create_complex_file(cli, tctx, inside);
status = smb_raw_rmdir(cli->tree, &dio);
CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY);
-
+
smbcli_close(cli->tree, fnum);
status = smb_raw_rmdir(cli->tree, &dio);
CHECK_STATUS(status, NT_STATUS_DIRECTORY_NOT_EMPTY);
-
+
done:
smb_raw_exit(cli->session);
smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
-/*
+/*
basic testing of unlink calls
*/
struct torture_suite *torture_raw_unlink(TALLOC_CTX *mem_ctx)