summaryrefslogtreecommitdiff
path: root/source4/torture/smb2/setinfo.c
diff options
context:
space:
mode:
authorZack Kirsch <zack.kirsch@isilon.com>2009-07-04 16:16:23 -0700
committerTim Prouty <tprouty@samba.org>2009-12-07 16:54:16 -0800
commitd252d23ff15577e2c7049181b5b30692c4bcd6bc (patch)
tree0fa17dedd67aa45046abc8639958537d27b6bdb3 /source4/torture/smb2/setinfo.c
parent8ceb428c5568bd690cb6811a0618f7866633705b (diff)
downloadsamba-d252d23ff15577e2c7049181b5b30692c4bcd6bc.tar.gz
samba-d252d23ff15577e2c7049181b5b30692c4bcd6bc.tar.bz2
samba-d252d23ff15577e2c7049181b5b30692c4bcd6bc.zip
s4 torture: Port RAW-ACLS tests to SMB2
- The smblsa calls had to be commented out for now and should be fixed later, but they aren't crucial to the test. - The first two tests from RAW-ACLS were already ported to torture_smb2_setinfo() and test_create_acl(). Modifications were made similar to the RAW-ACLS changes. - test_sd_get_set() was ported, but does not pass against XP or Vista; it is not added to the SMB2-ACLS test suite. - printf -> torture_comment / torture_warning / torture_result
Diffstat (limited to 'source4/torture/smb2/setinfo.c')
-rw-r--r--source4/torture/smb2/setinfo.c89
1 files changed, 40 insertions, 49 deletions
diff --git a/source4/torture/smb2/setinfo.c b/source4/torture/smb2/setinfo.c
index 7a912b4989..38642a673d 100644
--- a/source4/torture/smb2/setinfo.c
+++ b/source4/torture/smb2/setinfo.c
@@ -32,11 +32,20 @@
#define BASEDIR ""
+#define FAIL_UNLESS(__cond) \
+ do { \
+ if (__cond) {} else { \
+ torture_result(tctx, TORTURE_FAIL, "%s) condition violated: %s\n", \
+ __location__, #__cond); \
+ ret = false; goto done; \
+ } \
+ } while(0)
+
/* basic testing of all SMB2 setinfo calls
for each call we test that it succeeds, and where possible test
for consistency between the calls.
*/
-bool torture_smb2_setinfo(struct torture_context *torture)
+bool torture_smb2_setinfo(struct torture_context *tctx)
{
struct smb2_tree *tree;
bool ret = true;
@@ -55,10 +64,10 @@ bool torture_smb2_setinfo(struct torture_context *torture)
ZERO_STRUCT(handle);
- fname = talloc_asprintf(torture, BASEDIR "fnum_test_%d.txt", n);
- fname_new = talloc_asprintf(torture, BASEDIR "fnum_test_new_%d.txt", n);
+ fname = talloc_asprintf(tctx, BASEDIR "fnum_test_%d.txt", n);
+ fname_new = talloc_asprintf(tctx, BASEDIR "fnum_test_new_%d.txt", n);
- if (!torture_smb2_connection(torture, &tree)) {
+ if (!torture_smb2_connection(tctx, &tree)) {
return false;
}
@@ -66,7 +75,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
smb2_util_close(tree, handle); \
status = smb2_create_complex_file(tree, fname, &handle); \
if (!NT_STATUS_IS_OK(status)) { \
- printf("(%s) ERROR: open of %s failed (%s)\n", \
+ torture_result(tctx, TORTURE_ERROR, "(%s) ERROR: open of %s failed (%s)\n", \
__location__, fname, nt_errstr(status)); \
ret = false; \
goto done; \
@@ -84,7 +93,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
sfinfo.generic.in.file.handle = handle; \
status = smb2_setinfo_file(tree, &sfinfo); \
if (!NT_STATUS_EQUAL(status, rightstatus)) { \
- printf("(%s) %s - %s (should be %s)\n", __location__, #call, \
+ torture_result(tctx, TORTURE_FAIL, "(%s) %s - %s (should be %s)\n", __location__, #call, \
nt_errstr(status), nt_errstr(rightstatus)); \
ret = false; \
goto done; \
@@ -95,9 +104,9 @@ bool torture_smb2_setinfo(struct torture_context *torture)
do { if (NT_STATUS_IS_OK(status)) { \
finfo2.generic.level = RAW_FILEINFO_ ## call; \
finfo2.generic.in.file.handle = handle; \
- status2 = smb2_getinfo_file(tree, torture, &finfo2); \
+ status2 = smb2_getinfo_file(tree, tctx, &finfo2); \
if (!NT_STATUS_IS_OK(status2)) { \
- printf("(%s) %s - %s\n", __location__, #call, nt_errstr(status2)); \
+ torture_result(tctx, TORTURE_FAIL, "(%s) %s - %s\n", __location__, #call, nt_errstr(status2)); \
ret = false; \
goto done; \
} \
@@ -106,7 +115,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
#define CHECK_VALUE(call, stype, field, value) do { \
CHECK1(call); \
if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(status2) && finfo2.stype.out.field != value) { \
- printf("(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \
+ torture_result(tctx, TORTURE_FAIL, "(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \
call_name, #stype, #field, \
(uint_t)value, (uint_t)finfo2.stype.out.field); \
torture_smb2_all_info(tree, handle); \
@@ -117,12 +126,12 @@ bool torture_smb2_setinfo(struct torture_context *torture)
#define CHECK_TIME(call, stype, field, value) do { \
CHECK1(call); \
if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(status2) && nt_time_to_unix(finfo2.stype.out.field) != value) { \
- printf("(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \
+ torture_result(tctx, TORTURE_FAIL, "(%s) %s - %s/%s should be 0x%x - 0x%x\n", __location__, \
call_name, #stype, #field, \
(uint_t)value, \
(uint_t)nt_time_to_unix(finfo2.stype.out.field)); \
- printf("\t%s", timestring(torture, value)); \
- printf("\t%s\n", nt_time_string(torture, finfo2.stype.out.field)); \
+ torture_warning(tctx, "\t%s", timestring(tctx, value)); \
+ torture_warning(tctx, "\t%s\n", nt_time_string(tctx, finfo2.stype.out.field)); \
torture_smb2_all_info(tree, handle); \
ret = false; \
goto done; \
@@ -130,7 +139,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
#define CHECK_STATUS(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
- printf("(%s) Incorrect status %s - should be %s\n", \
+ torture_result(tctx, TORTURE_FAIL, "(%s) Incorrect status %s - should be %s\n", \
__location__, nt_errstr(status), nt_errstr(correct)); \
ret = false; \
goto done; \
@@ -138,7 +147,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
torture_smb2_all_info(tree, handle);
- printf("test basic_information level\n");
+ torture_comment(tctx, "test basic_information level\n");
basetime += 86400;
unix_to_nt_time(&sfinfo.basic_info.in.create_time, basetime + 100);
unix_to_nt_time(&sfinfo.basic_info.in.access_time, basetime + 200);
@@ -152,7 +161,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
CHECK_TIME(SMB2_ALL_INFORMATION, all_info2, change_time, basetime + 400);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, attrib, FILE_ATTRIBUTE_READONLY);
- printf("a zero time means don't change\n");
+ torture_comment(tctx, "a zero time means don't change\n");
unix_to_nt_time(&sfinfo.basic_info.in.create_time, 0);
unix_to_nt_time(&sfinfo.basic_info.in.access_time, 0);
unix_to_nt_time(&sfinfo.basic_info.in.write_time, 0);
@@ -165,26 +174,26 @@ bool torture_smb2_setinfo(struct torture_context *torture)
CHECK_TIME(SMB2_ALL_INFORMATION, all_info2, change_time, basetime + 400);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, attrib, FILE_ATTRIBUTE_NORMAL);
- printf("change the attribute\n");
+ torture_comment(tctx, "change the attribute\n");
sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_HIDDEN;
CHECK_CALL(BASIC_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, attrib, FILE_ATTRIBUTE_HIDDEN);
- printf("zero attrib means don't change\n");
+ torture_comment(tctx, "zero attrib means don't change\n");
sfinfo.basic_info.in.attrib = 0;
CHECK_CALL(BASIC_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, attrib, FILE_ATTRIBUTE_HIDDEN);
- printf("can't change a file to a directory\n");
+ torture_comment(tctx, "can't change a file to a directory\n");
sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_DIRECTORY;
CHECK_CALL(BASIC_INFORMATION, NT_STATUS_INVALID_PARAMETER);
- printf("restore attribute\n");
+ torture_comment(tctx, "restore attribute\n");
sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_NORMAL;
CHECK_CALL(BASIC_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, attrib, FILE_ATTRIBUTE_NORMAL);
- printf("test disposition_information level\n");
+ torture_comment(tctx, "test disposition_information level\n");
sfinfo.disposition_info.in.delete_on_close = 1;
CHECK_CALL(DISPOSITION_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, delete_pending, 1);
@@ -195,7 +204,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, delete_pending, 0);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, nlink, 1);
- printf("test allocation_information level\n");
+ torture_comment(tctx, "test allocation_information level\n");
sfinfo.allocation_info.in.alloc_size = 0;
CHECK_CALL(ALLOCATION_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, size, 0);
@@ -206,7 +215,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, alloc_size, 4096);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, size, 0);
- printf("test end_of_file_info level\n");
+ torture_comment(tctx, "test end_of_file_info level\n");
sfinfo.end_of_file_info.in.size = 37;
CHECK_CALL(END_OF_FILE_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, size, 37);
@@ -215,13 +224,13 @@ bool torture_smb2_setinfo(struct torture_context *torture)
CHECK_CALL(END_OF_FILE_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, size, 7);
- printf("test position_information level\n");
+ torture_comment(tctx, "test position_information level\n");
sfinfo.position_information.in.position = 123456;
CHECK_CALL(POSITION_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(POSITION_INFORMATION, position_information, position, 123456);
CHECK_VALUE(SMB2_ALL_INFORMATION, all_info2, position, 123456);
- printf("test mode_information level\n");
+ torture_comment(tctx, "test mode_information level\n");
sfinfo.mode_information.in.mode = 2;
CHECK_CALL(MODE_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(MODE_INFORMATION, mode_information, mode, 2);
@@ -234,7 +243,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
CHECK_CALL(MODE_INFORMATION, NT_STATUS_OK);
CHECK_VALUE(MODE_INFORMATION, mode_information, mode, 0);
- printf("test sec_desc level\n");
+ torture_comment(tctx, "test sec_desc level\n");
ZERO_STRUCT(finfo2);
finfo2.query_secdesc.in.secinfo_flags =
SECINFO_OWNER |
@@ -243,7 +252,7 @@ bool torture_smb2_setinfo(struct torture_context *torture)
CHECK1(SEC_DESC);
sd = finfo2.query_secdesc.out.sd;
- test_sid = dom_sid_parse_talloc(torture, "S-1-5-32-1234-5432");
+ test_sid = dom_sid_parse_talloc(tctx, SID_NT_AUTHENTICATED_USERS);
ZERO_STRUCT(ace);
ace.type = SEC_ACE_TYPE_ACCESS_ALLOWED;
ace.flags = 0;
@@ -252,23 +261,14 @@ bool torture_smb2_setinfo(struct torture_context *torture)
status = security_descriptor_dacl_add(sd, &ace);
CHECK_STATUS(status, NT_STATUS_OK);
- printf("add a new ACE to the DACL\n");
+ torture_comment(tctx, "add a new ACE to the DACL\n");
sfinfo.set_secdesc.in.secinfo_flags = finfo2.query_secdesc.in.secinfo_flags;
sfinfo.set_secdesc.in.sd = sd;
CHECK_CALL(SEC_DESC, NT_STATUS_OK);
- CHECK1(SEC_DESC);
-
- if (!security_acl_equal(finfo2.query_secdesc.out.sd->dacl, sd->dacl)) {
- printf("%s: security descriptors don't match!\n", __location__);
- printf("got:\n");
- NDR_PRINT_DEBUG(security_descriptor, finfo2.query_secdesc.out.sd);
- printf("expected:\n");
- NDR_PRINT_DEBUG(security_descriptor, sd);
- ret = false;
- }
+ FAIL_UNLESS(smb2_util_verify_sd(tctx, tree, handle, sd));
- printf("remove it again\n");
+ torture_comment(tctx, "remove it again\n");
status = security_descriptor_dacl_del(sd, test_sid);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -276,21 +276,12 @@ bool torture_smb2_setinfo(struct torture_context *torture)
sfinfo.set_secdesc.in.secinfo_flags = finfo2.query_secdesc.in.secinfo_flags;
sfinfo.set_secdesc.in.sd = sd;
CHECK_CALL(SEC_DESC, NT_STATUS_OK);
- CHECK1(SEC_DESC);
-
- if (!security_acl_equal(finfo2.query_secdesc.out.sd->dacl, sd->dacl)) {
- printf("%s: security descriptors don't match!\n", __location__);
- printf("got:\n");
- NDR_PRINT_DEBUG(security_descriptor, finfo2.query_secdesc.out.sd);
- printf("expected:\n");
- NDR_PRINT_DEBUG(security_descriptor, sd);
- ret = false;
- }
+ FAIL_UNLESS(smb2_util_verify_sd(tctx, tree, handle, sd));
done:
status = smb2_util_close(tree, handle);
if (NT_STATUS_IS_ERR(status)) {
- printf("Failed to delete %s - %s\n", fname, nt_errstr(status));
+ torture_warning(tctx, "Failed to delete %s - %s\n", fname, nt_errstr(status));
}
smb2_util_unlink(tree, fname);