diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/ntvfs/posix/pvfs_qfileinfo.c | 9 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_read.c | 2 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_write.c | 2 | ||||
-rw-r--r-- | source4/smb_server/smb/reply.c | 3 | ||||
-rw-r--r-- | source4/torture/gentest.c | 7 | ||||
-rw-r--r-- | source4/torture/gentest_smb2.c | 37 | ||||
-rw-r--r-- | source4/torture/smb2/lock.c | 12 | ||||
-rw-r--r-- | source4/torture/smb2/read.c | 55 |
8 files changed, 108 insertions, 19 deletions
diff --git a/source4/ntvfs/posix/pvfs_qfileinfo.c b/source4/ntvfs/posix/pvfs_qfileinfo.c index 6e3092b744..c663466985 100644 --- a/source4/ntvfs/posix/pvfs_qfileinfo.c +++ b/source4/ntvfs/posix/pvfs_qfileinfo.c @@ -178,6 +178,15 @@ static NTSTATUS pvfs_map_fileinfo(struct pvfs_state *pvfs, case RAW_FILEINFO_ALL_EAS: return pvfs_query_all_eas(pvfs, req, name, fd, &info->all_eas.out); + case RAW_FILEINFO_SMB2_ALL_EAS: { + NTSTATUS status = pvfs_query_all_eas(pvfs, req, name, fd, &info->all_eas.out); + if (NT_STATUS_IS_OK(status) && + info->all_eas.out.num_eas == 0) { + return NT_STATUS_NO_EAS_ON_FILE; + } + return status; + } + case RAW_FILEINFO_IS_NAME_VALID: return NT_STATUS_OK; diff --git a/source4/ntvfs/posix/pvfs_read.c b/source4/ntvfs/posix/pvfs_read.c index a01a8a57e3..8e1a59473f 100644 --- a/source4/ntvfs/posix/pvfs_read.c +++ b/source4/ntvfs/posix/pvfs_read.c @@ -46,7 +46,7 @@ NTSTATUS pvfs_read(struct ntvfs_module_context *ntvfs, } if (f->handle->fd == -1) { - return NT_STATUS_FILE_IS_A_DIRECTORY; + return NT_STATUS_INVALID_DEVICE_REQUEST; } mask = SEC_FILE_READ_DATA; diff --git a/source4/ntvfs/posix/pvfs_write.c b/source4/ntvfs/posix/pvfs_write.c index dda8c83407..1f662f13fc 100644 --- a/source4/ntvfs/posix/pvfs_write.c +++ b/source4/ntvfs/posix/pvfs_write.c @@ -45,7 +45,7 @@ NTSTATUS pvfs_write(struct ntvfs_module_context *ntvfs, } if (f->handle->fd == -1) { - return NT_STATUS_FILE_IS_A_DIRECTORY; + return NT_STATUS_INVALID_DEVICE_REQUEST; } if (!(f->access_mask & (SEC_FILE_WRITE_DATA | SEC_FILE_APPEND_DATA))) { diff --git a/source4/smb_server/smb/reply.c b/source4/smb_server/smb/reply.c index d28f4b6072..d7ed052ba0 100644 --- a/source4/smb_server/smb/reply.c +++ b/source4/smb_server/smb/reply.c @@ -2195,7 +2195,8 @@ void smbsrv_reply_ntcreate_and_X(struct smbsrv_request *req) /* we use a couple of bits of the create options internally */ if (io->ntcreatex.in.create_options & NTCREATEX_OPTIONS_PRIVATE_MASK) { - return NT_STATUS_INVALID_PARAMETER; + smbsrv_send_error(req, NT_STATUS_INVALID_PARAMETER); + return; } /* we need a neater way to handle this alignment */ diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index cd33074b4f..068b6bdc2f 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -49,6 +49,7 @@ static struct gentest_options { const char *seeds_file; int use_preset_seeds; int fast_reconnect; + int skip_cleanup; } options; /* mapping between open handles on the server and local handles */ @@ -1865,6 +1866,11 @@ static bool handler_notify(int instance) static void wipe_files(void) { int i; + + if (options.skip_cleanup) { + return; + } + for (i=0;i<NSERVERS;i++) { int n = smbcli_deltree(servers[i].cli[0]->tree, "\\gentest"); if (n == -1) { @@ -2196,6 +2202,7 @@ static bool split_unc_name(const char *unc, char **server, char **share) {"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL}, {"seedsfile", 0, POPT_ARG_STRING, &options.seeds_file, 0, "seed file", NULL}, { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" }, + {"skip-cleanup", 0, POPT_ARG_NONE, &options.skip_cleanup, 0, "don't delete files at start", NULL}, POPT_COMMON_SAMBA POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS diff --git a/source4/torture/gentest_smb2.c b/source4/torture/gentest_smb2.c index 3e705dc60d..60bf6264c2 100644 --- a/source4/torture/gentest_smb2.c +++ b/source4/torture/gentest_smb2.c @@ -56,6 +56,7 @@ static struct gentest_options { int mask_indexing; int no_eas; int skip_cleanup; + int valid; } options; /* mapping between open handles on the server and local handles */ @@ -510,7 +511,7 @@ static uint32_t gen_bits_mask(uint_t mask) */ static uint32_t gen_bits_mask2(uint32_t mask1, uint32_t mask2) { - if (gen_chance(10)) return gen_bits_mask(mask2); + if (!options.valid && gen_chance(10)) return gen_bits_mask(mask2); return gen_bits_mask(mask1); } @@ -519,21 +520,25 @@ static uint32_t gen_bits_mask2(uint32_t mask1, uint32_t mask2) */ static uint64_t gen_reserved8(void) { + if (options.valid) return 0; return gen_bits_mask(0xFF); } static uint64_t gen_reserved16(void) { + if (options.valid) return 0; return gen_bits_mask(0xFFFF); } static uint64_t gen_reserved32(void) { + if (options.valid) return 0; return gen_bits_mask(0xFFFFFFFF); } static uint64_t gen_reserved64(void) { + if (options.valid) return 0; return gen_bits_mask(0xFFFFFFFF) | (((uint64_t)gen_bits_mask(0xFFFFFFFF))<<32); } @@ -552,7 +557,7 @@ static bool gen_bool(void) */ static uint16_t gen_lock_flags(void) { - if (gen_chance(5)) return gen_bits_mask(0xFFFF); + if (!options.valid && gen_chance(5)) return gen_bits_mask(0xFFFF); if (gen_chance(20)) return gen_bits_mask(0x1F); if (gen_chance(50)) return SMB2_LOCK_FLAG_UNLOCK; return gen_bits_mask(SMB2_LOCK_FLAG_SHARED | @@ -573,9 +578,12 @@ static off_t gen_lock_count(void) */ static uint32_t gen_access_mask(void) { + uint32_t ret; if (gen_chance(70)) return SEC_FLAG_MAXIMUM_ALLOWED; if (gen_chance(70)) return SEC_FILE_ALL; - return gen_bits_mask(0xFFFFFFFF); + ret = gen_bits_mask(0xFFFFFFFF); + if (options.valid) ret &= ~SEC_MASK_INVALID; + return ret; } /* @@ -583,7 +591,7 @@ static uint32_t gen_access_mask(void) */ static uint32_t gen_create_options(void) { - if (gen_chance(20)) return gen_bits_mask(0xFFFFFFFF); + if (!options.valid && gen_chance(20)) return gen_bits_mask(0xFFFFFFFF); if (gen_chance(50)) return 0; return gen_bits_mask(NTCREATEX_OPTIONS_DELETE_ON_CLOSE | NTCREATEX_OPTIONS_DIRECTORY); } @@ -594,7 +602,7 @@ static uint32_t gen_create_options(void) static uint32_t gen_open_disp(void) { if (gen_chance(50)) return NTCREATEX_DISP_OPEN_IF; - if (gen_chance(10)) return gen_bits_mask(0xFFFFFFFF); + if (!options.valid && gen_chance(10)) return gen_bits_mask(0xFFFFFFFF); return gen_int_range(0, 5); } @@ -603,7 +611,12 @@ static uint32_t gen_open_disp(void) */ static uint32_t gen_attrib(void) { - if (gen_chance(20)) return gen_bits_mask(0xFFFFFFFF); + uint32_t ret; + if (gen_chance(20)) { + ret = gen_bits_mask(0xFFFFFFFF); + if (options.valid) ret &= FILE_ATTRIBUTE_ALL_MASK; + return ret; + } return gen_bits_mask(FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY); } @@ -1097,10 +1110,7 @@ static bool handler_create(int instance) parm[0].in.security_flags = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFF); parm[0].in.oplock_level = gen_bits_levels(3, 90, 0x0, 70, 0x9, 100, 0xFF); parm[0].in.impersonation_level = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFFFFFFFF); - parm[0].in.create_flags = gen_bits_levels(2, 90, 0x0, 100, 0xFFFFFFFF); - if (gen_chance(2)) { - parm[0].in.create_flags |= gen_bits_mask(0xFFFFFFFF); - } + parm[0].in.create_flags = gen_reserved64(); parm[0].in.reserved = gen_reserved64(); parm[0].in.desired_access = gen_access_mask(); parm[0].in.file_attributes = gen_attrib(); @@ -1115,6 +1125,12 @@ static bool handler_create(int instance) parm[0].in.oplock_level = 0; } + if (options.valid) { + parm[0].in.security_flags &= 3; + parm[0].in.oplock_level &= 9; + parm[0].in.impersonation_level &= 3; + } + GEN_COPY_PARM; GEN_CALL(smb2_create(tree, current_op.mem_ctx, &parm[i])); @@ -1926,6 +1942,7 @@ static bool split_unc_name(const char *unc, char **server, char **share) {"maskindexing", 0, POPT_ARG_NONE, &options.mask_indexing, 0, "mask out the indexed file attrib", NULL}, {"noeas", 0, POPT_ARG_NONE, &options.no_eas, 0, "don't use extended attributes", NULL}, {"skip-cleanup", 0, POPT_ARG_NONE, &options.skip_cleanup, 0, "don't delete files at start", NULL}, + {"valid", 0, POPT_ARG_NONE, &options.valid, 0, "generate only valid fields", NULL}, POPT_COMMON_SAMBA POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c index 4e21045a33..5a36ac3eae 100644 --- a/source4/torture/smb2/lock.c +++ b/source4/torture/smb2/lock.c @@ -252,12 +252,20 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree lck.in.lock_count = 1; el[0].flags = SMB2_LOCK_FLAG_UNLOCK; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + if (torture_setting_bool(torture, "windows", false)) { + CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); + } else { + CHECK_STATUS(status, NT_STATUS_OK); + } lck.in.lock_count = 1; el[0].flags = SMB2_LOCK_FLAG_UNLOCK; status = smb2_lock(tree, &lck); - CHECK_STATUS(status, NT_STATUS_OK); + if (torture_setting_bool(torture, "windows", false)) { + CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); + } else { + CHECK_STATUS(status, NT_STATUS_OK); + } lck.in.lock_count = 1; el[0].flags = SMB2_LOCK_FLAG_UNLOCK; diff --git a/source4/torture/smb2/read.c b/source4/torture/smb2/read.c index 3e1d077b7d..62240f35ba 100644 --- a/source4/torture/smb2/read.c +++ b/source4/torture/smb2/read.c @@ -38,13 +38,13 @@ #define CHECK_VALUE(v, correct) do { \ if ((v) != (correct)) { \ - printf("(%s) Incorrect value %s=%d - should be %d\n", \ - __location__, #v, v, correct); \ + printf("(%s) Incorrect value %s=%u - should be %u\n", \ + __location__, #v, (unsigned)v, (unsigned)correct); \ ret = false; \ goto done; \ }} while (0) -static bool test_read(struct torture_context *torture, struct smb2_tree *tree) +static bool test_read_eof(struct torture_context *torture, struct smb2_tree *tree) { bool ret = true; NTSTATUS status; @@ -126,13 +126,60 @@ done: return ret; } + +static bool test_read_position(struct torture_context *torture, struct smb2_tree *tree) +{ + bool ret = true; + NTSTATUS status; + struct smb2_handle h; + uint8_t buf[70000]; + struct smb2_read rd; + TALLOC_CTX *tmp_ctx = talloc_new(tree); + union smb_fileinfo info; + + ZERO_STRUCT(buf); + + status = torture_smb2_testfile(tree, "lock1.txt", &h); + CHECK_STATUS(status, NT_STATUS_OK); + + status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf)); + CHECK_STATUS(status, NT_STATUS_OK); + + ZERO_STRUCT(rd); + rd.in.file.handle = h; + rd.in.length = 10; + rd.in.offset = 0; + rd.in.min_count = 1; + + status = smb2_read(tree, tmp_ctx, &rd); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(rd.out.data.length, 10); + + info.generic.level = RAW_FILEINFO_SMB2_ALL_INFORMATION; + info.generic.in.file.handle = h; + + status = smb2_getinfo_file(tree, tmp_ctx, &info); + CHECK_STATUS(status, NT_STATUS_OK); + if (torture_setting_bool(torture, "windows", false)) { + CHECK_VALUE(info.all_info2.out.position, 0); + } else { + CHECK_VALUE(info.all_info2.out.position, 10); + } + + +done: + talloc_free(tmp_ctx); + return ret; +} + /* basic testing of SMB2 read */ struct torture_suite *torture_smb2_read_init(void) { struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "READ"); - torture_suite_add_1smb2_test(suite, "READ", test_read); + torture_suite_add_1smb2_test(suite, "EOF", test_read_eof); + torture_suite_add_1smb2_test(suite, "POSITION", test_read_position); suite->description = talloc_strdup(suite, "SMB2-READ tests"); |