summaryrefslogtreecommitdiff
path: root/source3/torture/torture.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/torture/torture.c')
-rw-r--r--source3/torture/torture.c228
1 files changed, 79 insertions, 149 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 0368d01dc7..5466d8ef9e 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -3043,6 +3043,7 @@ static BOOL run_opentest(int dummy)
size_t fsize;
BOOL correct = True;
char *tmp_path;
+ uint16 attr;
printf("starting open test\n");
@@ -3417,174 +3418,106 @@ static BOOL run_opentest(int dummy)
cli_unlink(&cli1, fname);
- if (!torture_close_connection(&cli1)) {
- correct = False;
+ /* Test 8 - attributes test #1... */
+ fnum1 = cli_nt_create_full(&cli1, fname,FILE_WRITE_DATA, FILE_ATTRIBUTE_HIDDEN,
+ FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0);
+
+ if (fnum1 == -1) {
+ printf("test 8 open 1 of %s failed (%s)\n", fname, cli_errstr(&cli1));
+ return False;
}
- if (!torture_close_connection(&cli2)) {
- correct = False;
+
+ if (!cli_close(&cli1, fnum1)) {
+ printf("test 8 close 1 of %s failed (%s)\n", fname, cli_errstr(&cli1));
+ return False;
}
-
- return correct;
-}
-static uint32 open_attrs_table[] = {
- FILE_ATTRIBUTE_NORMAL,
- FILE_ATTRIBUTE_ARCHIVE,
- FILE_ATTRIBUTE_READONLY,
- FILE_ATTRIBUTE_HIDDEN,
- FILE_ATTRIBUTE_SYSTEM,
-
- FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY,
- FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN,
- FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM,
- FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN,
- FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM,
- FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM,
-
- FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN,
- FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM,
- FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM,
- FILE_ATTRIBUTE_HIDDEN,FILE_ATTRIBUTE_SYSTEM,
-};
-
-struct trunc_open_results {
- int num;
- uint32 init_attr;
- uint32 trunc_attr;
- uint32 result_attr;
-};
-
-static struct trunc_open_results attr_results[] = {
- { 0, FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_ARCHIVE },
- { 1, FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_ARCHIVE },
- { 2, FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY },
- { 16, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_NORMAL, FILE_ATTRIBUTE_ARCHIVE },
- { 17, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_ARCHIVE },
- { 18, FILE_ATTRIBUTE_ARCHIVE, FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY },
- { 51, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN },
- { 54, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN },
- { 56, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN },
- { 68, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM },
- { 71, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM },
- { 73, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM },
- { 99, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_HIDDEN,FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN },
- { 102, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN },
- { 104, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN },
- { 116, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM },
- { 119, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM },
- { 121, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM },
- { 170, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN },
- { 173, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM },
- { 227, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN },
- { 230, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN },
- { 232, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN },
- { 244, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM },
- { 247, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_SYSTEM },
- { 249, FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM, FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM }
-};
-
-static BOOL run_openattrtest(int dummy)
-{
- static struct cli_state cli1;
- const char *fname = "\\openattr.file";
- int fnum1;
- BOOL correct = True;
- uint16 attr;
- int i, j, k, l;
+ /* FILE_SUPERSEDE && FILE_OVERWRITE_IF have the same effect here. */
+ fnum1 = cli_nt_create_full(&cli1, fname,FILE_READ_DATA, FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0);
- printf("starting open attr test\n");
-
- if (!torture_open_connection(&cli1)) {
+ if (fnum1 == -1) {
+ printf("test 8 open 2 of %s failed (%s)\n", fname, cli_errstr(&cli1));
return False;
}
-
- cli_sockopt(&cli1, sockops);
- for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32); i++) {
- cli_setatr(&cli1, fname, 0, 0);
- cli_unlink(&cli1, fname);
- fnum1 = cli_nt_create_full(&cli1, fname,FILE_WRITE_DATA, open_attrs_table[i],
- FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0);
+ if (!cli_close(&cli1, fnum1)) {
+ printf("test 8 close 2 of %s failed (%s)\n", fname, cli_errstr(&cli1));
+ return False;
+ }
- if (fnum1 == -1) {
- printf("open %d (1) of %s failed (%s)\n", i, fname, cli_errstr(&cli1));
- return False;
- }
+ /* This open should fail with ACCESS_DENIED for FILE_SUPERSEDE, FILE_OVERWRITE and FILE_OVERWRITE_IF. */
+ fnum1 = cli_nt_create_full(&cli1, fname,FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_NONE, FILE_OVERWRITE, 0);
- if (!cli_close(&cli1, fnum1)) {
- printf("close %d (1) of %s failed (%s)\n", i, fname, cli_errstr(&cli1));
- return False;
+ if (fnum1 != -1) {
+ printf("test 8 open 3 of %s succeeded - should have failed with (NT_STATUS_ACCESS_DENIED)\n", fname);
+ correct = False;
+ cli_close(&cli1, fnum1);
+ } else {
+ if (check_error(__LINE__, &cli1, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED)) {
+ printf("correct error code NT_STATUS_ACCESS_DENIED/ERRDOS:ERRnoaccess returned\n");
}
+ }
- for (j = 0; j < sizeof(open_attrs_table)/sizeof(uint32); j++) {
- fnum1 = cli_nt_create_full(&cli1, fname,FILE_READ_DATA|FILE_WRITE_DATA, open_attrs_table[j],
- FILE_SHARE_NONE, FILE_OVERWRITE, 0);
-
- if (fnum1 == -1) {
- for (l = 0; l < sizeof(attr_results)/sizeof(struct trunc_open_results); l++) {
- if (attr_results[l].num == k) {
- printf("[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(0x%x:%s)\n",
- k, open_attrs_table[i],
- open_attrs_table[j],
- fname, NT_STATUS_V(cli_nt_error(&cli1)), cli_errstr(&cli1));
- correct = False;
- }
- }
- if (NT_STATUS_V(cli_nt_error(&cli1)) != NT_STATUS_V(NT_STATUS_ACCESS_DENIED)) {
- printf("[%d] trunc open 0x%x -> 0x%x failed with wrong error code %s\n",
- k, open_attrs_table[i], open_attrs_table[j],
- cli_errstr(&cli1));
- correct = False;
- }
-#if 0
- printf("[%d] trunc open 0x%x -> 0x%x failed\n", k, open_attrs_table[i], open_attrs_table[j]);
-#endif
- k++;
- continue;
- }
+ printf("Attribute open test #8 %s.\n", correct ? "passed" : "failed");
- if (!cli_close(&cli1, fnum1)) {
- printf("close %d (2) of %s failed (%s)\n", j, fname, cli_errstr(&cli1));
- return False;
- }
+ cli_unlink(&cli1, fname);
- if (!cli_getatr(&cli1, fname, &attr, NULL, NULL)) {
- printf("getatr(2) failed (%s)\n", cli_errstr(&cli1));
- return False;
- }
+ /*
+ * Test #9. Open with NORMAL, close, then re-open with attribute
+ * HIDDEN and request to truncate.
+ */
-#if 0
- printf("[%d] getatr check [0x%x] trunc [0x%x] got attr 0x%x\n",
- k, open_attrs_table[i], open_attrs_table[j], attr );
-#endif
+ fnum1 = cli_nt_create_full(&cli1, fname,FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL,
+ FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0);
- for (l = 0; l < sizeof(attr_results)/sizeof(struct trunc_open_results); l++) {
- if (attr_results[l].num == k) {
- if (attr != attr_results[l].result_attr ||
- open_attrs_table[i] != attr_results[l].init_attr ||
- open_attrs_table[j] != attr_results[l].trunc_attr) {
- printf("getatr check failed. [0x%x] trunc [0x%x] got attr 0x%x, should be 0x%x\n",
- open_attrs_table[i],
- open_attrs_table[j],
- (unsigned int)attr,
- attr_results[l].result_attr);
- correct = False;
- }
- break;
- }
- }
- k++;
- }
+ if (fnum1 == -1) {
+ printf("test 9 open 1 of %s failed (%s)\n", fname, cli_errstr(&cli1));
+ return False;
}
- cli_setatr(&cli1, fname, 0, 0);
- cli_unlink(&cli1, fname);
+ if (!cli_close(&cli1, fnum1)) {
+ printf("test 9 close 1 of %s failed (%s)\n", fname, cli_errstr(&cli1));
+ return False;
+ }
- printf("open attr test %s.\n", correct ? "passed" : "failed");
+ fnum1 = cli_nt_create_full(&cli1, fname,FILE_READ_DATA|FILE_WRITE_DATA, FILE_ATTRIBUTE_HIDDEN,
+ FILE_SHARE_NONE, FILE_OVERWRITE, 0);
+
+ if (fnum1 == -1) {
+ printf("test 9 open 2 of %s failed (%s)\n", fname, cli_errstr(&cli1));
+ return False;
+ }
+
+ if (!cli_close(&cli1, fnum1)) {
+ printf("test 9 close 2 of %s failed (%s)\n", fname, cli_errstr(&cli1));
+ return False;
+ }
+
+ /* Ensure we have attr hidden. */
+ if (!cli_getatr(&cli1, fname, &attr, NULL, NULL)) {
+ printf("test 9 getatr(2) failed (%s)\n", cli_errstr(&cli1));
+ return False;
+ }
+
+ if (!(attr & FILE_ATTRIBUTE_HIDDEN)) {
+ printf("test 9 getatr didn't have HIDDEN attribute\n");
+ cli_unlink(&cli1, fname);
+ return False;
+ }
+
+ printf("Attribute open test #9 %s.\n", correct ? "passed" : "failed");
+
+ cli_unlink(&cli1, fname);
if (!torture_close_connection(&cli1)) {
correct = False;
}
+ if (!torture_close_connection(&cli2)) {
+ correct = False;
+ }
+
return correct;
}
@@ -3983,9 +3916,6 @@ static struct {
{"RW2", run_readwritemulti, FLAG_MULTIPROC},
{"RW3", run_readwritelarge, 0},
{"OPEN", run_opentest, 0},
-#if 1
- {"OPENATTR", run_openattrtest, 0},
-#endif
{"XCOPY", run_xcopy, 0},
{"RENAME", run_rename, 0},
{"DELETE", run_deletetest, 0},