summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-03-03 00:23:09 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-03-03 00:23:09 +0100
commitc7dc53b8514f83800184d2b20b1897e54843a614 (patch)
tree4f09d783271dc5e38809ed02c8252d73f8b147e5 /source4/torture
parent375df425c5014dc852995038e8e5668f98af8ba3 (diff)
parent85d53f7b603f7c15b007f8c3fdde1989f07a6eb2 (diff)
downloadsamba-c7dc53b8514f83800184d2b20b1897e54843a614.tar.gz
samba-c7dc53b8514f83800184d2b20b1897e54843a614.tar.bz2
samba-c7dc53b8514f83800184d2b20b1897e54843a614.zip
Merge branch 'v4-0-test' into id10ts-registry
(This used to be commit f98b59021a5ea39c7970ebc5520d17775e500b8c)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/config.mk17
-rw-r--r--source4/torture/ldap/cldap.c4
-rw-r--r--source4/torture/ldap/cldapbench.c2
-rw-r--r--source4/torture/libnet/groupinfo.c2
-rw-r--r--source4/torture/libnet/groupman.c6
-rw-r--r--source4/torture/libnet/libnet_user.c17
-rw-r--r--source4/torture/libnet/userinfo.c12
-rw-r--r--source4/torture/libnet/userman.c56
-rw-r--r--source4/torture/libnet/utils.c68
-rw-r--r--source4/torture/libnet/utils.h9
-rw-r--r--source4/torture/local/config.mk1
-rw-r--r--source4/torture/nbt/dgram.c9
-rw-r--r--source4/torture/nbt/query.c3
-rw-r--r--source4/torture/nbt/register.c6
-rw-r--r--source4/torture/nbt/wins.c2
-rw-r--r--source4/torture/nbt/winsbench.c2
-rw-r--r--source4/torture/nbt/winsreplication.c32
-rw-r--r--source4/torture/raw/chkpath.c77
-rw-r--r--source4/torture/raw/composite.c2
-rw-r--r--source4/torture/raw/oplock.c872
-rw-r--r--source4/torture/raw/qfsinfo.c29
-rw-r--r--source4/torture/raw/setfileinfo.c115
-rw-r--r--source4/torture/rpc/dssync.c2
-rw-r--r--source4/torture/rpc/samr.c45
-rw-r--r--source4/torture/t_strcmp.c20
25 files changed, 1214 insertions, 196 deletions
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 626349a45d..e35a26e49f 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -3,8 +3,7 @@
SO_VERSION = 0
VERSION = 0.0.1
PC_FILE = torture.pc
-PUBLIC_HEADERS = torture.h ui.h
-PUBLIC_PROTO_HEADER = proto.h
+PRIVATE_PROTO_HEADER = proto.h
OBJ_FILES = \
torture.o \
ui.o
@@ -14,6 +13,8 @@ PUBLIC_DEPENDENCIES = \
LIBTALLOC \
LIBPOPT
+PUBLIC_HEADERS += torture/torture.h torture/ui.h
+
[SUBSYSTEM::TORTURE_UTIL]
OBJ_FILES = util_smb.o util_provision.o
PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls
@@ -314,10 +315,11 @@ PRIVATE_DEPENDENCIES = \
dcerpc \
LIBCLI_SMB \
SMBREADLINE
-MANPAGE = man/smbtorture.1
# End BINARY smbtorture
#################################
+MANPAGES += torture/man/smbtorture.1
+
#################################
# Start BINARY gentest
[BINARY::gentest]
@@ -332,10 +334,11 @@ PRIVATE_DEPENDENCIES = \
POPT_CREDENTIALS \
LIBCLI_SMB \
LIBCLI_RAW
-MANPAGE = man/gentest.1
# End BINARY gentest
#################################
+MANPAGES += torture/man/gentest.1
+
#################################
# Start BINARY masktest
[BINARY::masktest]
@@ -349,10 +352,11 @@ PRIVATE_DEPENDENCIES = \
POPT_SAMBA \
POPT_CREDENTIALS \
LIBCLI_SMB
-MANPAGE = man/masktest.1
# End BINARY masktest
#################################
+MANPAGES += torture/man/masktest.1
+
#################################
# Start BINARY locktest
[BINARY::locktest]
@@ -366,10 +370,11 @@ PRIVATE_DEPENDENCIES = \
LIBSAMBA-UTIL \
LIBCLI_SMB \
LIBSAMBA-CONFIG
-MANPAGE = man/locktest.1
# End BINARY locktest
#################################
+MANPAGES += torture/man/locktest.1
+
COV_TARGET = test
COV_VARS = \
diff --git a/source4/torture/ldap/cldap.c b/source4/torture/ldap/cldap.c
index 4e58059770..dbe9d2f9a4 100644
--- a/source4/torture/ldap/cldap.c
+++ b/source4/torture/ldap/cldap.c
@@ -38,7 +38,7 @@
*/
static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL);
+ struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
NTSTATUS status;
struct cldap_netlogon search, empty_search;
union nbt_cldap_netlogon n1;
@@ -244,7 +244,7 @@ static void cldap_dump_results(struct cldap_search *search)
*/
static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL);
+ struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
NTSTATUS status;
struct cldap_search search;
const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL };
diff --git a/source4/torture/ldap/cldapbench.c b/source4/torture/ldap/cldapbench.c
index c57ed6d48a..83e505e164 100644
--- a/source4/torture/ldap/cldapbench.c
+++ b/source4/torture/ldap/cldapbench.c
@@ -51,7 +51,7 @@ static void request_handler(struct cldap_request *req)
*/
static bool bench_cldap(struct torture_context *tctx, const char *address)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL);
+ struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
int num_sent=0;
struct timeval tv = timeval_current();
bool ret = true;
diff --git a/source4/torture/libnet/groupinfo.c b/source4/torture/libnet/groupinfo.c
index 55edb9d40d..4ddb1cefbe 100644
--- a/source4/torture/libnet/groupinfo.c
+++ b/source4/torture/libnet/groupinfo.c
@@ -96,7 +96,7 @@ bool torture_groupinfo(struct torture_context *torture)
/*
* Testing synchronous version
*/
- if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) {
+ if (!test_opendomain(torture, p, mem_ctx, &h, &name, &sid)) {
ret = false;
goto done;
}
diff --git a/source4/torture/libnet/groupman.c b/source4/torture/libnet/groupman.c
index adb055c750..51b1c65b30 100644
--- a/source4/torture/libnet/groupman.c
+++ b/source4/torture/libnet/groupman.c
@@ -67,12 +67,10 @@ bool torture_groupadd(struct torture_context *torture)
&p,
&ndr_table_samr);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
- }
+ torture_assert_ntstatus_ok(torture, status, "RPC connection");
domain_name.string = lp_workgroup(torture->lp_ctx);
- if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ if (!test_opendomain(torture, p, mem_ctx, &h, &domain_name, &sid)) {
ret = false;
goto done;
}
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c
index 6ea670629e..31300a7937 100644
--- a/source4/torture/libnet/libnet_user.c
+++ b/source4/torture/libnet/libnet_user.c
@@ -339,12 +339,13 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
const char* logon_scripts[] = { "start_login.cmd", "login.bat", "start.cmd" };
const char* home_dirs[] = { "\\\\srv\\home", "\\\\homesrv\\home\\user", "\\\\pdcsrv\\domain" };
const char* home_drives[] = { "H:", "z:", "I:", "J:", "n:" };
+ const uint32_t flags[] = { (ACB_DISABLED | ACB_NORMAL),
+ (ACB_NORMAL | ACB_PWNOEXP),
+ (ACB_NORMAL) };
const char *homedir, *homedrive, *logonscript;
struct timeval now;
int i, testfld;
- srandom((unsigned)time(NULL));
-
printf("Fields to change: [");
for (i = 0; i < num_changes && i < FIELDS_NUM; i++) {
@@ -382,14 +383,14 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
case home_directory:
continue_if_field_set(r->in.home_directory);
- homedir = home_dirs[random() % (sizeof(home_dirs)/sizeof(char*))];
+ homedir = home_dirs[random() % ARRAY_SIZE(home_dirs)];
r->in.home_directory = talloc_strdup(mem_ctx, homedir);
fldname = "home_dir";
break;
case home_drive:
continue_if_field_set(r->in.home_drive);
- homedrive = home_drives[random() % (sizeof(home_drives)/sizeof(char*))];
+ homedrive = home_drives[random() % ARRAY_SIZE(home_drives)];
r->in.home_drive = talloc_strdup(mem_ctx, homedrive);
fldname = "home_drive";
break;
@@ -403,7 +404,7 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
case logon_script:
continue_if_field_set(r->in.logon_script);
- logonscript = logon_scripts[random() % (sizeof(logon_scripts)/sizeof(char*))];
+ logonscript = logon_scripts[random() % ARRAY_SIZE(logon_scripts)];
r->in.logon_script = talloc_strdup(mem_ctx, logonscript);
fldname = "logon_script";
break;
@@ -422,6 +423,12 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
fldname = "acct_expiry";
break;
+ case acct_flags:
+ continue_if_field_set(r->in.acct_flags);
+ r->in.acct_flags = flags[random() % ARRAY_SIZE(flags)];
+ fldname = "acct_flags";
+ break;
+
default:
fldname = "unknown_field";
}
diff --git a/source4/torture/libnet/userinfo.c b/source4/torture/libnet/userinfo.c
index e862435d20..11e57f852d 100644
--- a/source4/torture/libnet/userinfo.c
+++ b/source4/torture/libnet/userinfo.c
@@ -152,12 +152,12 @@ bool torture_userinfo(struct torture_context *torture)
/*
* Testing synchronous version
*/
- if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) {
+ if (!test_opendomain(torture, p, mem_ctx, &h, &name, &sid)) {
ret = false;
goto done;
}
- if (!test_user_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) {
+ if (!test_user_create(torture, p, mem_ctx, &h, TEST_USERNAME, &rid)) {
ret = false;
goto done;
}
@@ -167,7 +167,7 @@ bool torture_userinfo(struct torture_context *torture)
goto done;
}
- if (!test_user_cleanup(p, mem_ctx, &h, TEST_USERNAME)) {
+ if (!test_user_cleanup(torture, p, mem_ctx, &h, TEST_USERNAME)) {
ret = false;
goto done;
}
@@ -175,12 +175,12 @@ bool torture_userinfo(struct torture_context *torture)
/*
* Testing asynchronous version and monitor messages
*/
- if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) {
+ if (!test_opendomain(torture, p, mem_ctx, &h, &name, &sid)) {
ret = false;
goto done;
}
- if (!test_user_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) {
+ if (!test_user_create(torture, p, mem_ctx, &h, TEST_USERNAME, &rid)) {
ret = false;
goto done;
}
@@ -190,7 +190,7 @@ bool torture_userinfo(struct torture_context *torture)
goto done;
}
- if (!test_user_cleanup(p, mem_ctx, &h, TEST_USERNAME)) {
+ if (!test_user_cleanup(torture, p, mem_ctx, &h, TEST_USERNAME)) {
ret = false;
goto done;
}
diff --git a/source4/torture/libnet/userman.c b/source4/torture/libnet/userman.c
index 0d08284a9f..5ce0a64022 100644
--- a/source4/torture/libnet/userman.c
+++ b/source4/torture/libnet/userman.c
@@ -79,7 +79,8 @@ static bool test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-static bool test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_usermod(struct torture_context *tctx, struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx,
struct policy_handle *handle, int num_changes,
struct libnet_rpc_usermod *mod, char **username)
{
@@ -102,9 +103,10 @@ static bool test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
mod->in.username = talloc_strdup(mem_ctx, *username);
mod->in.domain_handle = *handle;
- printf("modifying user (%d simultaneous change(s))\n", num_changes);
+ torture_comment(tctx, "modifying user (%d simultaneous change(s))\n",
+ num_changes);
- printf("fields to change: [");
+ torture_comment(tctx, "fields to change: [");
for (i = 0; i < num_changes && i < FIELDS_NUM - 1; i++) {
const char *fldname;
@@ -189,7 +191,7 @@ static bool test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
case acct_flags:
continue_if_field_set(mod->in.change.acct_flags);
- mod->in.change.acct_flags = flags[random() % (sizeof(flags)/sizeof(uint32_t))];
+ mod->in.change.acct_flags = flags[random() % ARRAY_SIZE(flags)];
mod->in.change.fields |= USERMOD_FIELD_ACCT_FLAGS;
fldname = "acct_flags";
break;
@@ -201,13 +203,10 @@ static bool test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
printf(((i < num_changes - 1) ? "%s," : "%s"), fldname);
}
- printf("]\n");
+ torture_comment(tctx, "]\n");
status = libnet_rpc_usermod(p, mem_ctx, mod);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to call sync libnet_rpc_usermod - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to call sync libnet_rpc_usermod");
return true;
}
@@ -266,7 +265,8 @@ static bool test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
}
-static bool test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+static bool test_compare(struct torture_context *tctx,
+ struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct libnet_rpc_usermod *mod,
const char *username)
{
@@ -282,10 +282,7 @@ static bool test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
info.in.level = 21; /* the most rich infolevel available */
status = libnet_rpc_userinfo(p, mem_ctx, &info);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Failed to call sync libnet_rpc_userinfo");
i = &info.out.info.info21;
@@ -321,12 +318,10 @@ bool torture_useradd(struct torture_context *torture)
&p,
&ndr_table_samr);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
- }
+ torture_assert_ntstatus_ok(torture, status, "RPC connect failed");
domain_name.string = lp_workgroup(torture->lp_ctx);
- if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ if (!test_opendomain(torture, p, mem_ctx, &h, &domain_name, &sid)) {
ret = false;
goto done;
}
@@ -336,12 +331,12 @@ bool torture_useradd(struct torture_context *torture)
goto done;
}
- if (!test_user_cleanup(p, mem_ctx, &h, name)) {
+ if (!test_user_cleanup(torture, p, mem_ctx, &h, name)) {
ret = false;
goto done;
}
- if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ if (!test_opendomain(torture, p, mem_ctx, &h, &domain_name, &sid)) {
ret = false;
goto done;
}
@@ -351,7 +346,7 @@ bool torture_useradd(struct torture_context *torture)
goto done;
}
- if (!test_user_cleanup(p, mem_ctx, &h, name)) {
+ if (!test_user_cleanup(torture, p, mem_ctx, &h, name)) {
ret = false;
goto done;
}
@@ -385,12 +380,12 @@ bool torture_userdel(struct torture_context *torture)
}
domain_name.string = lp_workgroup(torture->lp_ctx);
- if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ if (!test_opendomain(torture, p, mem_ctx, &h, &domain_name, &sid)) {
ret = false;
goto done;
}
- if (!test_user_create(p, mem_ctx, &h, name, &rid)) {
+ if (!test_user_create(torture, p, mem_ctx, &h, name, &rid)) {
ret = false;
goto done;
}
@@ -425,20 +420,17 @@ bool torture_usermod(struct torture_context *torture)
&p,
&ndr_table_samr);
- if (!NT_STATUS_IS_OK(status)) {
- ret = false;
- goto done;
- }
+ torture_assert_ntstatus_ok(torture, status, "RPC connect");
domain_name.string = lp_workgroup(torture->lp_ctx);
name = talloc_strdup(mem_ctx, TEST_USERNAME);
- if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) {
+ if (!test_opendomain(torture, p, mem_ctx, &h, &domain_name, &sid)) {
ret = false;
goto done;
}
- if (!test_user_create(p, mem_ctx, &h, name, &rid)) {
+ if (!test_user_create(torture, p, mem_ctx, &h, name, &rid)) {
ret = false;
goto done;
}
@@ -446,19 +438,19 @@ bool torture_usermod(struct torture_context *torture)
for (i = 1; i < FIELDS_NUM; i++) {
struct libnet_rpc_usermod m;
- if (!test_usermod(p, mem_ctx, &h, i, &m, &name)) {
+ if (!test_usermod(torture, p, mem_ctx, &h, i, &m, &name)) {
ret = false;
goto cleanup;
}
- if (!test_compare(p, mem_ctx, &h, &m, name)) {
+ if (!test_compare(torture, p, mem_ctx, &h, &m, name)) {
ret = false;
goto cleanup;
}
}
cleanup:
- if (!test_user_cleanup(p, mem_ctx, &h, name)) {
+ if (!test_user_cleanup(torture, p, mem_ctx, &h, name)) {
ret = false;
goto done;
}
diff --git a/source4/torture/libnet/utils.c b/source4/torture/libnet/utils.c
index 47bb9315c7..d4124cc823 100644
--- a/source4/torture/libnet/utils.c
+++ b/source4/torture/libnet/utils.c
@@ -29,7 +29,8 @@
#include "param/param.h"
-bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_opendomain(struct torture_context *tctx,
+ struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct lsa_String *domname,
struct dom_sid2 *sid)
{
@@ -39,51 +40,41 @@ bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct samr_LookupDomain r2;
struct samr_OpenDomain r3;
- printf("connecting\n");
+ torture_comment(tctx, "connecting\n");
r1.in.system_name = 0;
r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
r1.out.connect_handle = &h;
status = dcerpc_samr_Connect(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Connect failed - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "Connect failed");
r2.in.connect_handle = &h;
r2.in.domain_name = domname;
- printf("domain lookup on %s\n", domname->string);
+ torture_comment(tctx, "domain lookup on %s\n", domname->string);
status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LookupDomain failed - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "LookupDomain failed");
r3.in.connect_handle = &h;
r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
r3.in.sid = r2.out.sid;
r3.out.domain_handle = &domain_handle;
- printf("opening domain\n");
+ torture_comment(tctx, "opening domain\n");
status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenDomain failed - %s\n", nt_errstr(status));
- return false;
- } else {
- *handle = domain_handle;
- }
+ torture_assert_ntstatus_ok(tctx, status, "OpenDomain failed");
+ *handle = domain_handle;
*sid = *r2.out.sid;
return true;
}
-bool test_user_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
- struct policy_handle *domain_handle,
+bool test_user_cleanup(struct torture_context *tctx, struct dcerpc_pipe *p,
+ TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle,
const char *name)
{
NTSTATUS status;
@@ -100,13 +91,10 @@ bool test_user_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r1.in.num_names = 1;
r1.in.names = names;
- printf("user account lookup '%s'\n", name);
+ torture_comment(tctx, "user account lookup '%s'\n", name);
status = dcerpc_samr_LookupNames(p, mem_ctx, &r1);
- if (!NT_STATUS_IS_OK(status)) {
- printf("LookupNames failed - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "LookupNames failed");
rid = r1.out.rids.ids[0];
@@ -115,30 +103,25 @@ bool test_user_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r2.in.rid = rid;
r2.out.user_handle = &user_handle;
- printf("opening user account\n");
+ torture_comment(tctx, "opening user account\n");
status = dcerpc_samr_OpenUser(p, mem_ctx, &r2);
- if (!NT_STATUS_IS_OK(status)) {
- printf("OpenUser failed - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "OpenUser failed");
r3.in.user_handle = &user_handle;
r3.out.user_handle = &user_handle;
- printf("deleting user account\n");
+ torture_comment(tctx, "deleting user account\n");
status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3);
- if (!NT_STATUS_IS_OK(status)) {
- printf("DeleteUser failed - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "DeleteUser failed");
return true;
}
-bool test_user_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_user_create(struct torture_context *tctx,
+ struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char *name,
uint32_t *rid)
{
@@ -155,25 +138,22 @@ bool test_user_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.out.user_handle = &user_handle;
r.out.rid = rid;
- printf("creating user account %s\n", name);
+ torture_comment(tctx, "creating user account %s\n", name);
status = dcerpc_samr_CreateUser(p, mem_ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
printf("CreateUser failed - %s\n", nt_errstr(status));
if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
- printf("User (%s) already exists - attempting to delete and recreate account again\n", name);
- if (!test_user_cleanup(p, mem_ctx, handle, name)) {
+ torture_comment(tctx, "User (%s) already exists - attempting to delete and recreate account again\n", name);
+ if (!test_user_cleanup(tctx, p, mem_ctx, handle, name)) {
return false;
}
- printf("creating user account\n");
+ torture_comment(tctx, "creating user account\n");
status = dcerpc_samr_CreateUser(p, mem_ctx, &r);
- if (!NT_STATUS_IS_OK(status)) {
- printf("CreateUser failed - %s\n", nt_errstr(status));
- return false;
- }
+ torture_assert_ntstatus_ok(tctx, status, "CreateUser failed");
return true;
}
return false;
diff --git a/source4/torture/libnet/utils.h b/source4/torture/libnet/utils.h
index ff94ec49e9..b513b1a29e 100644
--- a/source4/torture/libnet/utils.h
+++ b/source4/torture/libnet/utils.h
@@ -19,15 +19,18 @@
*/
-bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_opendomain(struct torture_context *tctx,
+ struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, struct lsa_String *domname,
struct dom_sid2 *sid);
-bool test_user_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_user_create(struct torture_context *tctx,
+ struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *handle, const char *name,
uint32_t *rid);
-bool test_user_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+bool test_user_cleanup(struct torture_context *tctx,
+ struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
struct policy_handle *domain_handle,
const char *name);
diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk
index d0ba1f2782..4143d415cf 100644
--- a/source4/torture/local/config.mk
+++ b/source4/torture/local/config.mk
@@ -8,6 +8,7 @@ PRIVATE_PROTO_HEADER = \
OBJ_FILES = \
../../lib/charset/tests/iconv.o \
../../lib/talloc/testsuite.o \
+ ../../lib/replace/test/getifaddrs.o \
../../lib/replace/test/os2_delete.o \
../../lib/replace/test/strptime.o \
../../lib/replace/test/testsuite.o \
diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c
index 0315989d66..e1680877e8 100644
--- a/source4/torture/nbt/dgram.c
+++ b/source4/torture/nbt/dgram.c
@@ -64,7 +64,8 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot,
static bool nbt_test_netlogon(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL);
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
const char *myaddress;
struct nbt_netlogon_packet logon;
@@ -146,7 +147,8 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
static bool nbt_test_netlogon2(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL);
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
const char *myaddress;
struct nbt_netlogon_packet logon;
@@ -255,7 +257,8 @@ static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot,
static bool nbt_test_ntlogon(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL);
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
struct test_join *join_ctx;
struct cli_credentials *machine_credentials;
diff --git a/source4/torture/nbt/query.c b/source4/torture/nbt/query.c
index 78210a2a07..1ba6172e5c 100644
--- a/source4/torture/nbt/query.c
+++ b/source4/torture/nbt/query.c
@@ -47,7 +47,8 @@ static void increment_handler(struct nbt_name_request *req)
*/
static bool bench_namequery(struct torture_context *tctx)
{
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL);
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ lp_iconv_convenience(tctx->lp_ctx));
int num_sent=0;
struct result_struct *result;
struct nbt_name_query io;
diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c
index 508c6b4840..b9f06c479d 100644
--- a/source4/torture/nbt/register.c
+++ b/source4/torture/nbt/register.c
@@ -44,7 +44,8 @@ static bool nbt_register_own(struct torture_context *tctx)
{
struct nbt_name_register io;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL);
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *socket_address;
struct nbt_name name;
const char *address;
@@ -113,7 +114,8 @@ static bool nbt_refresh_own(struct torture_context *tctx)
{
struct nbt_name_refresh io;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL);
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ lp_iconv_convenience(tctx->lp_ctx));
const char *myaddress;
struct socket_address *socket_address;
struct nbt_name name;
diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c
index cf115fcd75..059b2dc919 100644
--- a/source4/torture/nbt/wins.c
+++ b/source4/torture/nbt/wins.c
@@ -53,7 +53,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
struct nbt_name_refresh_wins refresh;
struct nbt_name_release release;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL);
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
const char *myaddress;
struct socket_address *socket_address;
struct interface *ifaces;
diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c
index 1488c17757..ea4abaf21b 100644
--- a/source4/torture/nbt/winsbench.c
+++ b/source4/torture/nbt/winsbench.c
@@ -225,7 +225,7 @@ static void generate_request(struct nbt_name_socket *nbtsock, struct wins_state
*/
static bool bench_wins(struct torture_context *tctx)
{
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL);
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
int num_sent=0;
struct timeval tv = timeval_current();
bool ret = true;
diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c
index d96ed3e931..470eee8310 100644
--- a/source4/torture/nbt/winsreplication.c
+++ b/source4/torture/nbt/winsreplication.c
@@ -103,14 +103,14 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
torture_comment(tctx, "Test if assoc_ctx is only valid on the conection it was created on\n");
- wrepl_socket1 = wrepl_socket_init(tctx, NULL);
- wrepl_socket2 = wrepl_socket_init(tctx, NULL);
+ wrepl_socket1 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket2 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup 2 wrepl connections\n");
- status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), NULL, address);
+ status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
- status = wrepl_connect(wrepl_socket2, lp_resolve_context(tctx->lp_ctx), NULL, address);
+ status = wrepl_connect(wrepl_socket2, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
torture_comment(tctx, "Send a start association request (conn1)\n");
@@ -186,10 +186,10 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
torture_comment(tctx, "Test if we always get back the same assoc_ctx\n");
- wrepl_socket = wrepl_socket_init(tctx, NULL);
+ wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
- status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), NULL, address);
+ status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
torture_comment(tctx, "Send 1st start association request\n");
@@ -255,10 +255,10 @@ static bool test_wins_replication(struct torture_context *tctx)
torture_comment(tctx, "Test one pull replication cycle\n");
- wrepl_socket = wrepl_socket_init(tctx, NULL);
+ wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
- status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), NULL, address);
+ status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
torture_comment(tctx, "Send a start association request\n");
@@ -553,11 +553,11 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
if (!ctx) return NULL;
ctx->address = address;
- ctx->pull = wrepl_socket_init(ctx, NULL);
+ ctx->pull = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->pull) return NULL;
torture_comment(tctx, "Setup wrepl conflict pull connection\n");
- status = wrepl_connect(ctx->pull, lp_resolve_context(tctx->lp_ctx), NULL, ctx->address);
+ status = wrepl_connect(ctx->pull, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
if (!NT_STATUS_IS_OK(status)) return NULL;
status = wrepl_associate(ctx->pull, &associate);
@@ -610,7 +610,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
talloc_free(pull_table.out.partners);
- ctx->nbtsock = nbt_name_socket_init(ctx, NULL);
+ ctx->nbtsock = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock) return NULL;
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -628,7 +628,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0);
if (!NT_STATUS_IS_OK(status)) return NULL;
- ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL);
+ ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock_srv) return NULL;
/* Make a port 137 version of ctx->myaddr */
@@ -645,13 +645,13 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
}
if (ctx->myaddr2 && ctx->nbtsock_srv) {
- ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL);
+ ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock2) return NULL;
status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0);
if (!NT_STATUS_IS_OK(status)) return NULL;
- ctx->nbtsock_srv2 = nbt_name_socket_init(ctx, ctx->nbtsock_srv->event_ctx);
+ ctx->nbtsock_srv2 = nbt_name_socket_init(ctx, ctx->nbtsock_srv->event_ctx, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock_srv2) return NULL;
/* Make a port 137 version of ctx->myaddr2 */
@@ -722,9 +722,9 @@ static bool test_wrepl_update_one(struct torture_context *tctx,
uint32_t assoc_ctx;
NTSTATUS status;
- wrepl_socket = wrepl_socket_init(ctx, NULL);
+ wrepl_socket = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
- status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), NULL, ctx->address);
+ status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
status = wrepl_associate(wrepl_socket, &associate);
diff --git a/source4/torture/raw/chkpath.c b/source4/torture/raw/chkpath.c
index 42a3c3cebe..fa69c92caa 100644
--- a/source4/torture/raw/chkpath.c
+++ b/source4/torture/raw/chkpath.c
@@ -54,24 +54,68 @@ static NTSTATUS single_search(struct smbcli_state *cli,
return status;
}
-static bool test_path(struct smbcli_state *cli, const char *path, NTSTATUS expected, NTSTATUS dos_expected)
+static bool test_path_ex(struct smbcli_state *cli, struct torture_context *tctx,
+ const char *path, const char *path_expected,
+ NTSTATUS expected, NTSTATUS dos_expected)
{
union smb_chkpath io;
+ union smb_fileinfo finfo;
NTSTATUS status;
+
io.chkpath.in.path = path;
status = smb_raw_chkpath(cli->tree, &io);
if (!NT_STATUS_EQUAL(status, expected) && !NT_STATUS_EQUAL(status, dos_expected)) {
- printf("%-40s FAILED %s should be %s or %s\n",
+ printf("FAILED %-30s chkpath %s should be %s or %s\n",
path, nt_errstr(status), nt_errstr(expected), nt_errstr(dos_expected));
return false;
} else {
- printf("%-40s correct (%s)\n", path, nt_errstr(status));
+ printf("%-30s chkpath correct (%s)\n", path, nt_errstr(status));
+ }
+
+ if (NT_STATUS_EQUAL(expected, NT_STATUS_NOT_A_DIRECTORY)) {
+ expected = NT_STATUS_OK;
+ }
+
+ ZERO_STRUCT(finfo);
+ finfo.generic.level = RAW_FILEINFO_NAME_INFO;
+ finfo.generic.in.file.path = path;
+ status = smb_raw_pathinfo(cli->tree, cli, &finfo);
+ if (!NT_STATUS_EQUAL(status, expected) && !NT_STATUS_EQUAL(status, dos_expected)) {
+ printf("FAILED: %-30s pathinfo %s should be %s or %s\n",
+ path, nt_errstr(status), nt_errstr(expected), nt_errstr(dos_expected));
+ return false;
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("%-30s chkpath correct (%s)\n", path, nt_errstr(status));
+ return true;
+ }
+ if (path_expected &&
+ (!finfo.name_info.out.fname.s ||
+ strcmp(finfo.name_info.out.fname.s, path_expected) != 0)) {
+ if (tctx && torture_setting_bool(tctx, "samba4", false)) {
+ printf("IGNORE: %-30s => %-20s should be %s\n",
+ path, finfo.name_info.out.fname.s, path_expected);
+ return true;
+ }
+ printf("FAILED: %-30s => %-20s should be %s\n",
+ path, finfo.name_info.out.fname.s, path_expected);
+ return false;
}
+ printf("%-30s => %-20s correct\n",
+ path, finfo.name_info.out.fname.s);
+
return true;
}
-static bool test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static bool test_path(struct smbcli_state *cli, const char *path,
+ NTSTATUS expected, NTSTATUS dos_expected)
+{
+ return test_path_ex(cli, NULL, path, path, expected, dos_expected);
+}
+
+static bool test_chkpath(struct smbcli_state *cli, struct torture_context *tctx)
{
union smb_chkpath io;
NTSTATUS status;
@@ -86,7 +130,7 @@ static bool test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
ret &= test_path(cli, BASEDIR "\\nodir", NT_STATUS_OBJECT_NAME_NOT_FOUND, NT_STATUS_DOS(ERRDOS,ERRbadpath));
- fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\test.txt..");
+ fnum = create_complex_file(cli, tctx, BASEDIR "\\test.txt..");
if (fnum == -1) {
printf("failed to open test.txt - %s\n", smbcli_errstr(cli->tree));
ret = false;
@@ -101,9 +145,20 @@ static bool test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
goto done;
}
- ret &= test_path(cli, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
- ret &= test_path(cli, BASEDIR "\\foo\\..\\test.txt..", NT_STATUS_NOT_A_DIRECTORY, NT_STATUS_DOS(ERRDOS,ERRbadpath));
- ret &= test_path(cli, "", NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, BASEDIR, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, ((char *)BASEDIR) + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, ((char *)BASEDIR"\\\\") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, ((char *)BASEDIR"\\foo\\..") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, ((char *)BASEDIR"\\f\\o\\o\\..\\..\\..") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, ((char *)BASEDIR"\\foo\\\\\..\\\\") + 1, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, BASEDIR"\\", BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, BASEDIR"\\\\..\\"BASEDIR, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, BASEDIR"\\\\\\", BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, "\\\\\\\\"BASEDIR"\\\\\\\\", BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, "\\\\\\\\"BASEDIR, BASEDIR, NT_STATUS_OK, NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, BASEDIR "\\foo\\..\\test.txt..", BASEDIR "\\test.txt..",
+ NT_STATUS_NOT_A_DIRECTORY, NT_STATUS_DOS(ERRDOS,ERRbadpath));
+ ret &= test_path_ex(cli, tctx, "", "\\", NT_STATUS_OK, NT_STATUS_OK);
ret &= test_path(cli, ".", NT_STATUS_OBJECT_NAME_INVALID, NT_STATUS_DOS(ERRDOS,ERRbadpath));
ret &= test_path(cli, ".\\", NT_STATUS_OBJECT_NAME_INVALID, NT_STATUS_DOS(ERRDOS,ERRbadpath));
ret &= test_path(cli, "\\\\\\.\\", NT_STATUS_OBJECT_NAME_INVALID, NT_STATUS_DOS(ERRDOS,ERRbadpath));
@@ -122,7 +177,7 @@ static bool test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
give different NT status returns for chkpth and findfirst. */
printf("testing findfirst on %s\n", "\\.\\\\\\\\\\\\.");
- status = single_search(cli, mem_ctx, "\\.\\\\\\\\\\\\.");
+ status = single_search(cli, tctx, "\\.\\\\\\\\\\\\.");
CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRinvalidname));
ret &= test_path(cli, "\\.\\\\\\\\\\\\.", NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
@@ -164,7 +219,7 @@ static bool test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
ret &= test_path(cli, "\\..\\", NT_STATUS_OBJECT_PATH_SYNTAX_BAD,NT_STATUS_DOS(ERRDOS,ERRinvalidpath));
ret &= test_path(cli, "\\..", NT_STATUS_OBJECT_PATH_SYNTAX_BAD,NT_STATUS_DOS(ERRDOS,ERRinvalidpath));
ret &= test_path(cli, BASEDIR "\\.", NT_STATUS_OBJECT_NAME_INVALID,NT_STATUS_DOS(ERRDOS,ERRbadpath));
- ret &= test_path(cli, BASEDIR "\\..", NT_STATUS_OK,NT_STATUS_OK);
+ ret &= test_path_ex(cli, tctx, BASEDIR "\\..", "\\", NT_STATUS_OK,NT_STATUS_OK);
ret &= test_path(cli, BASEDIR "\\nt\\V S\\VB98\\vb600", NT_STATUS_OBJECT_NAME_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
ret &= test_path(cli, BASEDIR "\\nt\\V S\\VB98\\vb6.exe", NT_STATUS_NOT_A_DIRECTORY,NT_STATUS_DOS(ERRDOS,ERRbadpath));
@@ -183,7 +238,7 @@ static bool test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
printf("testing findfirst on %s\n", BASEDIR".\\.\\.\\.\\foo\\..\\.\\");
- status = single_search(cli, mem_ctx, BASEDIR".\\.\\.\\.\\foo\\..\\.\\");
+ status = single_search(cli, tctx, BASEDIR".\\.\\.\\.\\foo\\..\\.\\");
CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND,NT_STATUS_DOS(ERRDOS,ERRbadpath));
/* We expect this open to fail with the same error code as the chkpath below. */
diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c
index 7238a2fd46..1f31fbc515 100644
--- a/source4/torture/raw/composite.c
+++ b/source4/torture/raw/composite.c
@@ -31,6 +31,7 @@
#include "lib/cmdline/popt_common.h"
#include "torture/util.h"
#include "param/param.h"
+#include "libcli/resolve/resolve.h"
#define BASEDIR "\\composite"
@@ -161,6 +162,7 @@ static bool test_fetchfile(struct smbcli_state *cli, struct torture_context *tct
io2.in.credentials = cmdline_credentials;
io2.in.workgroup = lp_workgroup(tctx->lp_ctx);
io2.in.filename = fname;
+ io2.in.resolve_ctx = lp_resolve_context(tctx->lp_ctx);
lp_smbcli_options(tctx->lp_ctx, &io2.in.options);
printf("testing parallel fetchfile with %d ops\n", torture_numops);
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index e81b634161..7ac88c0996 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -27,11 +27,19 @@
#define CHECK_VAL(v, correct) do { \
if ((v) != (correct)) { \
- torture_comment(tctx, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
+ torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
__location__, #v, (int)v, (int)correct); \
ret = false; \
}} while (0)
+#define CHECK_STRMATCH(v, correct) do { \
+ if (!v || strstr((v),(correct)) == NULL) { \
+ torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got '%s' - should be '%s'\n", \
+ __location__, #v, v?v:"NULL", correct); \
+ ret = false; \
+ } \
+} while (0)
+
#define CHECK_STATUS(tctx, status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
@@ -123,9 +131,9 @@ static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t ti
return true;
}
-static bool test_raw_oplock_normal(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+static bool test_raw_oplock_exclusive1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
{
- const char *fname = BASEDIR "\\test_normal.dat";
+ const char *fname = BASEDIR "\\test_exclusive1.dat";
NTSTATUS status;
bool ret = true;
union smb_open io;
@@ -156,7 +164,7 @@ static bool test_raw_oplock_normal(struct torture_context *tctx, struct smbcli_s
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = fname;
- torture_comment(tctx, "open a file with a normal oplock\n");
+ torture_comment(tctx, "open a file with an exclusive oplock (share mode: none)\n");
ZERO_STRUCT(break_info);
io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
@@ -188,6 +196,381 @@ done:
return ret;
}
+static bool test_raw_oplock_exclusive2(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname = BASEDIR "\\test_exclusive2.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ union smb_unlink unl;
+ uint16_t fnum=0, fnum2=0;
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+
+ torture_comment(tctx, "open a file with an exclusive oplock (share mode: all)\n");
+ ZERO_STRUCT(break_info);
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
+
+ torture_comment(tctx, "a 2nd open should cause a break to level 2\n");
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.fnum, fnum);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+ CHECK_VAL(break_info.failures, 0);
+ ZERO_STRUCT(break_info);
+
+ /* now we have 2 level II oplocks... */
+ torture_comment(tctx, "try to unlink it - should not cause a break, but a sharing violation\n");
+ unl.unlink.in.pattern = fname;
+ unl.unlink.in.attrib = 0;
+ status = smb_raw_unlink(cli2->tree, &unl);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(break_info.failures, 0);
+
+ torture_comment(tctx, "close 1st handle\n");
+ smbcli_close(cli1->tree, fnum);
+
+ torture_comment(tctx, "try to unlink it - should not cause a break, but a sharing violation\n");
+ unl.unlink.in.pattern = fname;
+ unl.unlink.in.attrib = 0;
+ status = smb_raw_unlink(cli2->tree, &unl);
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(break_info.failures, 0);
+
+ torture_comment(tctx, "close 1st handle\n");
+ smbcli_close(cli2->tree, fnum2);
+
+ torture_comment(tctx, "unlink it\n");
+ unl.unlink.in.pattern = fname;
+ unl.unlink.in.attrib = 0;
+ status = smb_raw_unlink(cli2->tree, &unl);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(break_info.failures, 0);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
+static bool test_raw_oplock_exclusive3(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname = BASEDIR "\\test_exclusive3.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ union smb_setfileinfo sfi;
+ uint16_t fnum=0;
+ bool s3 = torture_setting_bool(tctx, "samba3", false);
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+
+ torture_comment(tctx, "open a file with an exclusive oplock (share mode: %s)\n",
+ s3?"all":"none");
+ ZERO_STRUCT(break_info);
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ if (s3) {
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ }
+
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
+
+ torture_comment(tctx, "setpathinfo EOF should trigger a break to none\n");
+ ZERO_STRUCT(sfi);
+ sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFORMATION;
+ sfi.generic.in.file.path = fname;
+ sfi.end_of_file_info.in.size = 100;
+
+ status = smb_raw_setpathinfo(cli2->tree, &sfi);
+
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_NONE);
+
+ smbcli_close(cli1->tree, fnum);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
+static bool test_raw_oplock_exclusive4(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname = BASEDIR "\\test_exclusive4.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ uint16_t fnum=0, fnum2=0;
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+
+ torture_comment(tctx, "open with exclusive oplock\n");
+ ZERO_STRUCT(break_info);
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
+
+ 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.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, NO_OPLOCK_RETURN);
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(break_info.failures, 0);
+
+ smbcli_close(cli1->tree, fnum);
+ smbcli_close(cli2->tree, fnum2);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
+static bool test_raw_oplock_exclusive5(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname = BASEDIR "\\test_exclusive5.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ uint16_t fnum=0, fnum2=0;
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+ smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+
+ torture_comment(tctx, "open with exclusive oplock\n");
+ ZERO_STRUCT(break_info);
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
+
+ ZERO_STRUCT(break_info);
+
+ torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_OVERWRITE_IF dispostion causes oplock break\n");
+
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ io.ntcreatex.in.access_mask = SEC_FILE_READ_ATTRIBUTE|SEC_FILE_WRITE_ATTRIBUTE|SEC_STD_SYNCHRONIZE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.failures, 0);
+
+ smbcli_close(cli1->tree, fnum);
+ smbcli_close(cli2->tree, fnum2);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
+static bool test_raw_oplock_exclusive6(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname1 = BASEDIR "\\test_exclusive6_1.dat";
+ const char *fname2 = BASEDIR "\\test_exclusive6_2.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ union smb_rename rn;
+ uint16_t fnum=0;
+ bool s3 = torture_setting_bool(tctx, "samba3", false);
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname1);
+ smbcli_unlink(cli1->tree, fname2);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname1;
+
+ /* we should use no share mode, when samba3 passes this */
+ torture_comment(tctx, "open a file with an exclusive oplock (share mode: %s)\n",
+ s3?"all":"none");
+ ZERO_STRUCT(break_info);
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED | NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ if (s3) {
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ }
+
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, EXCLUSIVE_OPLOCK_RETURN);
+
+ torture_comment(tctx, "rename should not generate a break but get a sharing violation\n");
+ ZERO_STRUCT(rn);
+ rn.generic.level = RAW_RENAME_RENAME;
+ rn.rename.in.pattern1 = fname1;
+ rn.rename.in.pattern2 = fname2;
+ rn.rename.in.attrib = 0;
+
+ printf("trying rename while first file open\n");
+ status = smb_raw_rename(cli2->tree, &rn);
+
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_VAL(break_info.count, 0);
+ CHECK_VAL(break_info.failures, 0);
+
+ smbcli_close(cli1->tree, fnum);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
static bool test_raw_oplock_batch1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
{
const char *fname = BASEDIR "\\test_batch1.dat";
@@ -1352,6 +1735,475 @@ done:
return ret;
}
+static bool test_raw_oplock_batch16(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname = BASEDIR "\\test_batch16.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ uint16_t fnum=0, fnum2=0;
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+ smbcli_oplock_handler(cli2->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+
+ torture_comment(tctx, "open with batch oplock\n");
+ ZERO_STRUCT(break_info);
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+
+ 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|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
+
+ ZERO_STRUCT(break_info);
+
+ torture_comment(tctx, "second open with attributes only and NTCREATEX_DISP_OVERWRITE_IF dispostion causes oplock break\n");
+
+ 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|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.failures, 0);
+
+ smbcli_close(cli1->tree, fnum);
+ smbcli_close(cli2->tree, fnum2);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
+static bool test_raw_oplock_batch17(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname1 = BASEDIR "\\test_batch17_1.dat";
+ const char *fname2 = BASEDIR "\\test_batch17_2.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ union smb_rename rn;
+ uint16_t fnum=0;
+ bool s3 = torture_setting_bool(tctx, "samba3", false);
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname1);
+ smbcli_unlink(cli1->tree, fname2);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname1;
+
+ /* we should use no share mode, when samba3 passes this */
+ torture_comment(tctx, "open a file with an batch oplock (share mode: %s)\n",
+ s3?"all":"none");
+ ZERO_STRUCT(break_info);
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
+ if (s3) {
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ }
+
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
+
+ torture_comment(tctx, "rename should trigger a break\n");
+ ZERO_STRUCT(rn);
+ rn.generic.level = RAW_RENAME_RENAME;
+ rn.rename.in.pattern1 = fname1;
+ rn.rename.in.pattern2 = fname2;
+ rn.rename.in.attrib = 0;
+
+ printf("trying rename while first file open\n");
+ status = smb_raw_rename(cli2->tree, &rn);
+
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+
+ smbcli_close(cli1->tree, fnum);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
+static bool test_raw_oplock_batch18(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname1 = BASEDIR "\\test_batch18_1.dat";
+ const char *fname2 = BASEDIR "\\test_batch18_2.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ union smb_rename rn;
+ uint16_t fnum=0;
+ bool s3 = torture_setting_bool(tctx, "samba3", false);
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname1);
+ smbcli_unlink(cli1->tree, fname2);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname1;
+
+ /* we should use no share mode, when samba3 passes this */
+ torture_comment(tctx, "open a file with an batch oplock (share mode: %s)\n",
+ s3?"all":"none");
+ ZERO_STRUCT(break_info);
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK |
+ NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
+ if (s3) {
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ }
+
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
+
+ torture_comment(tctx, "ntrename should trigger a break\n");
+ ZERO_STRUCT(rn);
+ rn.generic.level = RAW_RENAME_NTRENAME;
+ rn.ntrename.in.attrib = 0;
+ rn.ntrename.in.flags = RENAME_FLAG_RENAME;
+ rn.ntrename.in.old_name = fname1;
+ rn.ntrename.in.new_name = fname2;
+ printf("trying rename while first file open\n");
+ status = smb_raw_rename(cli2->tree, &rn);
+
+ CHECK_STATUS(tctx, status, NT_STATUS_SHARING_VIOLATION);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+
+ smbcli_close(cli1->tree, fnum);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
+static bool test_raw_oplock_batch19(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname1 = BASEDIR "\\test_batch19_1.dat";
+ const char *fname2 = BASEDIR "\\test_batch19_2.dat";
+ const char *fname3 = BASEDIR "\\test_batch19_3.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ union smb_fileinfo qfi;
+ union smb_setfileinfo sfi;
+ uint16_t fnum=0;
+
+ if (torture_setting_bool(tctx, "samba3", false)) {
+ torture_skip(tctx, "BACHT19 disabled against samba3\n");
+ }
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname1);
+ smbcli_unlink(cli1->tree, fname2);
+ smbcli_unlink(cli1->tree, fname3);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname1;
+
+ torture_comment(tctx, "open a file with an batch oplock (share mode: none)\n");
+ ZERO_STRUCT(break_info);
+ 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);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
+
+ torture_comment(tctx, "setpathinfo rename info should not trigger a break nor a violation\n");
+ ZERO_STRUCT(sfi);
+ sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION;
+ sfi.generic.in.file.path = fname1;
+ sfi.rename_information.in.overwrite = 0;
+ sfi.rename_information.in.root_fid = 0;
+ sfi.rename_information.in.new_name = fname2+strlen(BASEDIR)+1;
+
+ status = smb_raw_setpathinfo(cli2->tree, &sfi);
+
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(break_info.count, 0);
+
+ ZERO_STRUCT(qfi);
+ qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION;
+ qfi.generic.in.file.fnum = fnum;
+
+ status = smb_raw_fileinfo(cli1->tree, tctx, &qfi);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_STRMATCH(qfi.all_info.out.fname.s, fname2);
+
+ torture_comment(tctx, "setfileinfo rename info should not trigger a break nor a violation\n");
+ ZERO_STRUCT(sfi);
+ sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION;
+ sfi.generic.in.file.fnum = fnum;
+ sfi.rename_information.in.overwrite = 0;
+ sfi.rename_information.in.root_fid = 0;
+ sfi.rename_information.in.new_name = fname3+strlen(BASEDIR)+1;
+
+ status = smb_raw_setfileinfo(cli1->tree, &sfi);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(break_info.count, 0);
+
+ ZERO_STRUCT(qfi);
+ qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION;
+ qfi.generic.in.file.fnum = fnum;
+
+ status = smb_raw_fileinfo(cli1->tree, tctx, &qfi);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_STRMATCH(qfi.all_info.out.fname.s, fname3);
+
+ smbcli_close(cli1->tree, fnum);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
+static bool test_raw_oplock_batch20(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2)
+{
+ const char *fname1 = BASEDIR "\\test_batch20_1.dat";
+ const char *fname2 = BASEDIR "\\test_batch20_2.dat";
+ const char *fname3 = BASEDIR "\\test_batch20_3.dat";
+ NTSTATUS status;
+ bool ret = true;
+ union smb_open io;
+ union smb_fileinfo qfi;
+ union smb_setfileinfo sfi;
+ uint16_t fnum=0,fnum2=0;
+
+ if (torture_setting_bool(tctx, "samba3", false)) {
+ torture_skip(tctx, "BACHT20 disabled against samba3\n");
+ }
+
+ if (!torture_setup_dir(cli1, BASEDIR)) {
+ return false;
+ }
+
+ /* cleanup */
+ smbcli_unlink(cli1->tree, fname1);
+ smbcli_unlink(cli1->tree, fname2);
+ smbcli_unlink(cli1->tree, fname3);
+
+ smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_levelII, cli1->tree);
+
+ /*
+ base ntcreatex parms
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname1;
+
+ torture_comment(tctx, "open a file with an batch oplock (share mode: all)\n");
+ ZERO_STRUCT(break_info);
+ 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|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ status = smb_raw_open(cli1->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, BATCH_OPLOCK_RETURN);
+
+ torture_comment(tctx, "setpathinfo rename info should not trigger a break nor a violation\n");
+ ZERO_STRUCT(sfi);
+ sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION;
+ sfi.generic.in.file.path = fname1;
+ sfi.rename_information.in.overwrite = 0;
+ sfi.rename_information.in.root_fid = 0;
+ sfi.rename_information.in.new_name = fname2+strlen(BASEDIR)+1;
+
+ status = smb_raw_setpathinfo(cli2->tree, &sfi);
+
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(break_info.count, 0);
+
+ ZERO_STRUCT(qfi);
+ qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION;
+ qfi.generic.in.file.fnum = fnum;
+
+ status = smb_raw_fileinfo(cli1->tree, tctx, &qfi);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_STRMATCH(qfi.all_info.out.fname.s, fname2);
+
+ /* we should use no share mode, when samba3 passes this */
+ torture_comment(tctx, "open a file with the new name an batch oplock (share mode: all)\n");
+ ZERO_STRUCT(break_info);
+ 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|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ io.ntcreatex.in.fname = fname2;
+ status = smb_raw_open(cli2->tree, tctx, &io);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ fnum2 = io.ntcreatex.out.file.fnum;
+ CHECK_VAL(io.ntcreatex.out.oplock_level, LEVEL_II_OPLOCK_RETURN);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+
+ torture_comment(tctx, "setfileinfo rename info should not trigger a break nor a violation\n");
+ ZERO_STRUCT(sfi);
+ sfi.generic.level = RAW_SFILEINFO_RENAME_INFORMATION;
+ sfi.generic.in.file.fnum = fnum;
+ sfi.rename_information.in.overwrite = 0;
+ sfi.rename_information.in.root_fid = 0;
+ sfi.rename_information.in.new_name = fname3+strlen(BASEDIR)+1;
+
+ status = smb_raw_setfileinfo(cli1->tree, &sfi);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.level, OPLOCK_BREAK_TO_LEVEL_II);
+
+ ZERO_STRUCT(qfi);
+ qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION;
+ qfi.generic.in.file.fnum = fnum;
+
+ status = smb_raw_fileinfo(cli1->tree, tctx, &qfi);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_STRMATCH(qfi.all_info.out.fname.s, fname3);
+
+ ZERO_STRUCT(qfi);
+ qfi.generic.level = RAW_FILEINFO_ALL_INFORMATION;
+ qfi.generic.in.file.fnum = fnum2;
+
+ status = smb_raw_fileinfo(cli2->tree, tctx, &qfi);
+ CHECK_STATUS(tctx, status, NT_STATUS_OK);
+ CHECK_STRMATCH(qfi.all_info.out.fname.s, fname3);
+
+ smbcli_close(cli1->tree, fnum);
+
+done:
+ smb_raw_exit(cli1->session);
+ smb_raw_exit(cli2->session);
+ smbcli_deltree(cli1->tree, BASEDIR);
+ return ret;
+}
+
/*
basic testing of oplocks
*/
@@ -1359,7 +2211,12 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx, "OPLOCK");
- torture_suite_add_2smb_test(suite, "NORMAL", test_raw_oplock_normal);
+ torture_suite_add_2smb_test(suite, "EXCLUSIVE1", test_raw_oplock_exclusive1);
+ torture_suite_add_2smb_test(suite, "EXCLUSIVE2", test_raw_oplock_exclusive2);
+ torture_suite_add_2smb_test(suite, "EXCLUSIVE3", test_raw_oplock_exclusive3);
+ torture_suite_add_2smb_test(suite, "EXCLUSIVE4", test_raw_oplock_exclusive4);
+ torture_suite_add_2smb_test(suite, "EXCLUSIVE5", test_raw_oplock_exclusive5);
+ torture_suite_add_2smb_test(suite, "EXCLUSIVE6", test_raw_oplock_exclusive6);
torture_suite_add_2smb_test(suite, "BATCH1", test_raw_oplock_batch1);
torture_suite_add_2smb_test(suite, "BATCH2", test_raw_oplock_batch2);
torture_suite_add_2smb_test(suite, "BATCH3", test_raw_oplock_batch3);
@@ -1375,6 +2232,11 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx)
torture_suite_add_2smb_test(suite, "BATCH13", test_raw_oplock_batch13);
torture_suite_add_2smb_test(suite, "BATCH14", test_raw_oplock_batch14);
torture_suite_add_2smb_test(suite, "BATCH15", test_raw_oplock_batch15);
+ torture_suite_add_2smb_test(suite, "BATCH16", test_raw_oplock_batch16);
+ torture_suite_add_2smb_test(suite, "BATCH17", test_raw_oplock_batch17);
+ torture_suite_add_2smb_test(suite, "BATCH18", test_raw_oplock_batch18);
+ torture_suite_add_2smb_test(suite, "BATCH19", test_raw_oplock_batch19);
+ torture_suite_add_2smb_test(suite, "BATCH20", test_raw_oplock_batch20);
return suite;
}
diff --git a/source4/torture/raw/qfsinfo.c b/source4/torture/raw/qfsinfo.c
index 3207558624..c1c77edba9 100644
--- a/source4/torture/raw/qfsinfo.c
+++ b/source4/torture/raw/qfsinfo.c
@@ -38,7 +38,7 @@ static struct {
{"SIZE_INFO", RAW_QFS_SIZE_INFO, },
{"DEVICE_INFO", RAW_QFS_DEVICE_INFO, },
{"ATTRIBUTE_INFO", RAW_QFS_ATTRIBUTE_INFO, },
- {"UNIX_INFO", RAW_QFS_UNIX_INFO, CAP_UNIX},
+ {"UNIX_INFO", RAW_QFS_UNIX_INFO, CAP_UNIX},
{"VOLUME_INFORMATION", RAW_QFS_VOLUME_INFORMATION, },
{"SIZE_INFORMATION", RAW_QFS_SIZE_INFORMATION, },
{"DEVICE_INFORMATION", RAW_QFS_DEVICE_INFORMATION, },
@@ -130,7 +130,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
/* scan all the levels, pulling the results */
for (i=0; levels[i].name; i++) {
- printf("Running level %s\n", levels[i].name);
+ torture_comment(torture, "Running level %s\n", levels[i].name);
levels[i].fsinfo.generic.level = levels[i].level;
levels[i].status = smb_raw_fsinfo(cli->tree, torture, &levels[i].fsinfo);
}
@@ -151,14 +151,11 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
}
if (count != 0) {
- printf("%d levels failed\n", count);
- if (count > 13) {
- printf("too many level failures - giving up\n");
- return false;
- }
+ torture_comment(torture, "%d levels failed\n", count);
+ torture_assert(torture, count > 13, "too many level failures - giving up");
}
- printf("check for correct aliases\n");
+ torture_comment(torture, "check for correct aliases\n");
s1 = find("SIZE_INFO");
s2 = find("SIZE_INFORMATION");
if (s1 && s2) {
@@ -181,7 +178,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
STRUCT_EQUAL(volume_info, create_time, volume_info, create_time);
VAL_EQUAL (volume_info, serial_number, volume_info, serial_number);
STR_EQUAL (volume_info, volume_name.s, volume_info, volume_name.s);
- printf("volume_info.volume_name = '%s'\n", s1->volume_info.out.volume_name.s);
+ torture_comment(torture, "volume_info.volume_name = '%s'\n", s1->volume_info.out.volume_name.s);
}
s1 = find("ATTRIBUTE_INFO");
@@ -192,10 +189,10 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
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);
- printf("attribute_info.fs_type = '%s'\n", s1->attribute_info.out.fs_type.s);
+ torture_comment(torture, "attribute_info.fs_type = '%s'\n", s1->attribute_info.out.fs_type.s);
}
- printf("check for consistent disk sizes\n");
+ torture_comment(torture, "check for consistent disk sizes\n");
s1 = find("DSKATTR");
s2 = find("ALLOCATION");
if (s1 && s2) {
@@ -214,10 +211,10 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
size1, size2);
ret = false;
}
- printf("total disk = %.0f MB\n", size1*scale/1.0e6);
+ torture_comment(torture, "total disk = %.0f MB\n", size1*scale/1.0e6);
}
- printf("check consistent free disk space\n");
+ torture_comment(torture, "check consistent free disk space\n");
s1 = find("DSKATTR");
s2 = find("ALLOCATION");
if (s1 && s2) {
@@ -236,10 +233,10 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
size1, size2);
ret = false;
}
- printf("free disk = %.0f MB\n", size1*scale/1.0e6);
+ torture_comment(torture, "free disk = %.0f MB\n", size1*scale/1.0e6);
}
- printf("volume info consistency\n");
+ torture_comment(torture, "volume info consistency\n");
s1 = find("VOLUME");
s2 = find("VOLUME_INFO");
if (s1 && s2) {
@@ -287,7 +284,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
} \
}} while (0)
- printf("check for correct termination\n");
+ 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);
diff --git a/source4/torture/raw/setfileinfo.c b/source4/torture/raw/setfileinfo.c
index e58b3fd760..90ccde7213 100644
--- a/source4/torture/raw/setfileinfo.c
+++ b/source4/torture/raw/setfileinfo.c
@@ -453,6 +453,10 @@ bool torture_raw_sfileinfo_rename(struct torture_context *torture,
char *fnum_fname_new;
char *path_fname;
char *path_fname_new;
+ char *path_dname;
+ char *path_dname_new;
+ char *saved_name;
+ char *saved_name_new;
union smb_fileinfo finfo1, finfo2;
union smb_setfileinfo sfinfo;
NTSTATUS status, status2;
@@ -464,6 +468,8 @@ bool torture_raw_sfileinfo_rename(struct torture_context *torture,
asprintf(&path_fname_new, BASEDIR "\\fname_test_new_%d.txt", n);
asprintf(&fnum_fname, BASEDIR "\\fnum_test_%d.txt", n);
asprintf(&fnum_fname_new, BASEDIR "\\fnum_test_new_%d.txt", n);
+ asprintf(&path_dname, BASEDIR "\\dname_test_%d", n);
+ asprintf(&path_dname_new, BASEDIR "\\dname_test_new_%d", n);
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -553,17 +559,112 @@ bool torture_raw_sfileinfo_rename(struct torture_context *torture,
sfinfo.rename_information.in.root_fid = d_fnum;
CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_INVALID_PARAMETER);
CHECK_STR(NAME_INFO, name_info, fname.s, fnum_fname);
+ smbcli_close(cli->tree, d_fnum);
-done:
- smb_raw_exit(cli->session);
- smbcli_close(cli->tree, fnum);
- if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fnum_fname))) {
- printf("Failed to delete %s - %s\n", fnum_fname, smbcli_errstr(cli->tree));
+ printf("Trying rename directory\n");
+ if (!torture_setup_dir(cli, path_dname)) {
+ ret = false;
+ goto done;
}
- if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, path_fname))) {
- printf("Failed to delete %s - %s\n", path_fname, smbcli_errstr(cli->tree));
+ saved_name = path_fname;
+ saved_name_new = path_fname_new;
+ path_fname = path_dname;
+ path_fname_new = path_dname_new;
+ sfinfo.rename_information.in.new_name = path_dname_new+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 0;
+ sfinfo.rename_information.in.root_fid = 0;
+ CHECK_CALL_PATH(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_dname_new);
+ path_fname = saved_name;
+ path_fname_new = saved_name_new;
+
+ if (torture_setting_bool(torture, "samba3", false)) {
+ printf("SKIP: Trying rename directory with a handle\n");
+ printf("SKIP: Trying rename by path while a handle is open\n");
+ printf("SKIP: Trying rename directory by path while a handle is open\n");
+ goto done;
}
+ printf("Trying rename directory with a handle\n");
+ status = create_directory_handle(cli->tree, path_dname_new, &d_fnum);
+ fnum_saved = fnum;
+ fnum = d_fnum;
+ saved_name = fnum_fname;
+ saved_name_new = fnum_fname_new;
+ fnum_fname = path_dname;
+ fnum_fname_new = path_dname_new;
+ sfinfo.rename_information.in.new_name = path_dname+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 0;
+ sfinfo.rename_information.in.root_fid = 0;
+ CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_dname);
+ smbcli_close(cli->tree, d_fnum);
+ fnum = fnum_saved;
+ fnum_fname = saved_name;
+ fnum_fname_new = saved_name_new;
+
+ printf("Trying rename by path while a handle is open\n");
+ fnum_saved = fnum;
+ fnum = create_complex_file(cli, torture, path_fname);
+ sfinfo.rename_information.in.new_name = path_fname_new+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 0;
+ sfinfo.rename_information.in.root_fid = 0;
+ CHECK_CALL_PATH(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_fname_new);
+ /* check that the handle returns the same name */
+ check_fnum = true;
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_fname_new);
+ /* rename it back on the handle */
+ sfinfo.rename_information.in.new_name = path_fname+strlen(BASEDIR)+1;
+ CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_fname);
+ check_fnum = false;
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_fname);
+ smbcli_close(cli->tree, fnum);
+ fnum = fnum_saved;
+
+ printf("Trying rename directory by path while a handle is open\n");
+ status = create_directory_handle(cli->tree, path_dname, &d_fnum);
+ fnum_saved = fnum;
+ fnum = d_fnum;
+ saved_name = path_fname;
+ saved_name_new = path_fname_new;
+ path_fname = path_dname;
+ path_fname_new = path_dname_new;
+ sfinfo.rename_information.in.new_name = path_dname_new+strlen(BASEDIR)+1;
+ sfinfo.rename_information.in.overwrite = 0;
+ sfinfo.rename_information.in.root_fid = 0;
+ CHECK_CALL_PATH(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_dname_new);
+ path_fname = saved_name;
+ path_fname_new = saved_name_new;
+ saved_name = fnum_fname;
+ saved_name_new = fnum_fname_new;
+ fnum_fname = path_dname;
+ fnum_fname_new = path_dname_new;
+ /* check that the handle returns the same name */
+ check_fnum = true;
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_dname_new);
+ /* rename it back on the handle */
+ sfinfo.rename_information.in.new_name = path_dname+strlen(BASEDIR)+1;
+ CHECK_CALL_FNUM(RENAME_INFORMATION, NT_STATUS_OK);
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_dname);
+ fnum_fname = saved_name;
+ fnum_fname_new = saved_name_new;
+ saved_name = path_fname;
+ saved_name_new = path_fname_new;
+ path_fname = path_dname;
+ path_fname_new = path_dname_new;
+ check_fnum = false;
+ CHECK_STR(NAME_INFO, name_info, fname.s, path_dname);
+ smbcli_close(cli->tree, d_fnum);
+ fnum = fnum_saved;
+ path_fname = saved_name;
+ path_fname_new = saved_name_new;
+
+done:
+ smb_raw_exit(cli->session);
+ smbcli_deltree(cli->tree, BASEDIR);
return ret;
}
diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c
index 4417285e04..b28e429a75 100644
--- a/source4/torture/rpc/dssync.c
+++ b/source4/torture/rpc/dssync.c
@@ -255,7 +255,7 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
struct drsuapi_DsNameString names[1];
bool ret = true;
- struct cldap_socket *cldap = cldap_socket_init(ctx, NULL);
+ struct cldap_socket *cldap = cldap_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
struct cldap_netlogon search;
r.in.bind_handle = &ctx->admin.drsuapi.bind_handle;
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
index 9d6c73891b..1d6ec43399 100644
--- a/source4/torture/rpc/samr.c
+++ b/source4/torture/rpc/samr.c
@@ -416,11 +416,6 @@ static bool test_SetUserInfo(struct dcerpc_pipe *p, struct torture_context *tctx
TEST_USERINFO_INT(21, logon_hours.bits[3], 21, logon_hours.bits[3], 4,
SAMR_FIELD_LOGON_HOURS);
- if (torture_setting_bool(tctx, "samba4", false)) {
- printf("skipping Set Account Flag tests against Samba4\n");
- return ret;
- }
-
TEST_USERINFO_INT_EXP(16, acct_flags, 5, acct_flags,
(base_acct_flags | ACB_DISABLED | ACB_HOMDIRREQ),
(base_acct_flags | ACB_DISABLED | ACB_HOMDIRREQ | user_extra_flags),
@@ -1989,9 +1984,12 @@ static bool test_user_ops(struct dcerpc_pipe *p,
const char *base_acct_name, enum torture_samr_choice which_ops)
{
char *password = NULL;
+ struct samr_QueryUserInfo q;
+ NTSTATUS status;
bool ret = true;
int i;
+ uint32_t rid;
const uint32_t password_fields[] = {
SAMR_FIELD_PASSWORD,
SAMR_FIELD_PASSWORD2,
@@ -1999,6 +1997,11 @@ static bool test_user_ops(struct dcerpc_pipe *p,
0
};
+ status = test_LookupName(p, tctx, domain_handle, base_acct_name, &rid);
+ if (!NT_STATUS_IS_OK(status)) {
+ ret = false;
+ }
+
switch (which_ops) {
case TORTURE_SAMR_USER_ATTRIBUTES:
if (!test_QuerySecurity(p, tctx, user_handle)) {
@@ -2091,6 +2094,29 @@ static bool test_user_ops(struct dcerpc_pipe *p,
ret = false;
}
+ q.in.user_handle = user_handle;
+ q.in.level = 5;
+
+ status = dcerpc_samr_QueryUserInfo(p, tctx, &q);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("QueryUserInfo level %u failed - %s\n",
+ q.in.level, nt_errstr(status));
+ ret = false;
+ } else {
+ uint32_t expected_flags = (base_acct_flags | ACB_PWNOTREQ | ACB_DISABLED);
+ if ((q.out.info->info5.acct_flags) != expected_flags) {
+ printf("QuerUserInfo level 5 failed, it returned 0x%08x when we expected flags of 0x%08x\n",
+ q.out.info->info5.acct_flags,
+ expected_flags);
+ ret = false;
+ }
+ if (q.out.info->info5.rid != rid) {
+ printf("QuerUserInfo level 5 failed, it returned %u when we expected rid of %u\n",
+ q.out.info->info5.rid, rid);
+
+ }
+ }
+
break;
case TORTURE_SAMR_OTHER:
/* We just need the account to exist */
@@ -2667,10 +2693,14 @@ static bool test_CreateUser2(struct dcerpc_pipe *p, struct torture_context *tctx
q.in.level, nt_errstr(status));
ret = false;
} else {
- if ((q.out.info->info5.acct_flags & acct_flags) != acct_flags) {
+ uint32_t expected_flags = (acct_flags | ACB_PWNOTREQ | ACB_DISABLED);
+ if (acct_flags == ACB_NORMAL) {
+ expected_flags |= ACB_PW_EXPIRED;
+ }
+ if ((q.out.info->info5.acct_flags) != expected_flags) {
printf("QuerUserInfo level 5 failed, it returned 0x%08x when we expected flags of 0x%08x\n",
q.out.info->info5.acct_flags,
- acct_flags);
+ expected_flags);
ret = false;
}
switch (acct_flags) {
@@ -3887,7 +3917,6 @@ static bool test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
for (j=0; j<num_names; j++) {
if (names[j] == NULL)
continue;
- /* Hmm. No strequal in samba4 */
if (strequal(names[j], name)) {
names[j] = NULL;
found = true;
diff --git a/source4/torture/t_strcmp.c b/source4/torture/t_strcmp.c
deleted file mode 100644
index 15d000c98f..0000000000
--- a/source4/torture/t_strcmp.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (C) 2003 by Martin Pool
- *
- * Test harness for strcasecmp_m
- */
-
-#include "includes.h"
-
-int main(int argc, char *argv[])
-{
- if (argc != 3) {
- fprintf(stderr, "usage: %s STRING1 STRING2\nCompares two strings\n",
- argv[0]);
- return 2;
- }
-
- printf("%d\n", strcasecmp_m(argv[1], argv[2]));
-
- return 0;
-}