Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-test
authorAndrew Tridgell <tridge@samba.org>
Wed, 28 May 2008 02:07:20 +0000 (12:07 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 28 May 2008 02:07:20 +0000 (12:07 +1000)
(This used to be commit ecb0e5477aa63180daade5c597e7ac2aebfc1e15)

source4/ntvfs/posix/pvfs_qfileinfo.c
source4/ntvfs/posix/pvfs_read.c
source4/ntvfs/posix/pvfs_write.c
source4/smb_server/smb/reply.c
source4/torture/gentest.c
source4/torture/gentest_smb2.c
source4/torture/smb2/lock.c
source4/torture/smb2/read.c

index 6e3092b744fc1aa2d4ceaaad92d3e6be7ba52a61..c6634669852c80572e5bdb79fe55a0bc5a62c288 100644 (file)
@@ -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;
 
index a01a8a57e3b800595ebe434d9aed4a54ba76cab4..8e1a59473f2f08cd5c57deff3ef9c3b0e1cb96c0 100644 (file)
@@ -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;
index dda8c8340738e4b8d16e1f12200ab83934d3a6a7..1f662f13fcdab52618bb4c5f07d8357dc9c57ef2 100644 (file)
@@ -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))) {
index d28f4b6072e5abee0a37aa1b62a78a3195779df8..d7ed052ba0e48661ee85b6befbc21bbfcdd81c64 100644 (file)
@@ -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 */
index cd33074b4f268251ae3a05e3c4870b07de154ff7..068b6bdc2f11dd5da3cc2d6174a60704e0b1521b 100644 (file)
@@ -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
index 3e705dc60d3709f52901a02f14493cf79b5f9565..60bf6264c248e93b3e89dcf116c65a3883352de7 100644 (file)
@@ -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
index 4e21045a33027933a4fc16f99bb06d81f13969b7..5a36ac3eaef2ca8a631842e08a2485e87a39b4c3 100644 (file)
@@ -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;
index 3e1d077b7dd7fdea054072b1512f74dbe0b61c27..62240f35baed78333fcdd882439c3bb668654183 100644 (file)
 
 #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");