SMB2-CREATE: be more strict in error checking
authorStefan Metzmacher <metze@samba.org>
Thu, 14 Aug 2008 07:54:22 +0000 (09:54 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 14 Aug 2008 11:13:51 +0000 (13:13 +0200)
metze
(This used to be commit d7d4df78c1de19d0cd7a63daaa2fa0863a243a12)

source4/torture/smb2/create.c

index 744c5d2b6c63ff5539fdebfb453c6b9355620729..6edacbfd0799097e09b295ad00894863e701237a 100644 (file)
@@ -54,6 +54,7 @@ static bool test_create_gentest(struct torture_context *torture, struct smb2_tre
        TALLOC_CTX *tmp_ctx = talloc_new(tree);
        uint32_t access_mask, file_attributes, file_attributes_set, denied_mask;
        uint32_t ok_mask, not_supported_mask, invalid_parameter_mask;
        TALLOC_CTX *tmp_ctx = talloc_new(tree);
        uint32_t access_mask, file_attributes, file_attributes_set, denied_mask;
        uint32_t ok_mask, not_supported_mask, invalid_parameter_mask;
+       uint32_t not_a_directory_mask, unexpected_mask;
        union smb_fileinfo q;
 
        ZERO_STRUCT(io);
        union smb_fileinfo q;
 
        ZERO_STRUCT(io);
@@ -104,7 +105,11 @@ static bool test_create_gentest(struct torture_context *torture, struct smb2_tre
        io.in.file_attributes = 0;
        io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
        io.in.desired_access     = SEC_FLAG_MAXIMUM_ALLOWED;
        io.in.file_attributes = 0;
        io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
        io.in.desired_access     = SEC_FLAG_MAXIMUM_ALLOWED;
-       ok_mask = not_supported_mask = invalid_parameter_mask = 0;
+       ok_mask = 0;
+       not_supported_mask = 0;
+       invalid_parameter_mask = 0;
+       not_a_directory_mask = 0;
+       unexpected_mask = 0;
        {
                int i;
                for (i=0;i<32;i++) {
        {
                int i;
                for (i=0;i<32;i++) {
@@ -117,11 +122,14 @@ static bool test_create_gentest(struct torture_context *torture, struct smb2_tre
                                not_supported_mask |= 1<<i;
                        } else if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
                                invalid_parameter_mask |= 1<<i;
                                not_supported_mask |= 1<<i;
                        } else if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
                                invalid_parameter_mask |= 1<<i;
+                       } else if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_A_DIRECTORY)) {
+                               not_a_directory_mask |= 1<<i;
                        } else if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
                                ok_mask |= 1<<i;
                                status = smb2_util_close(tree, io.out.file.handle);
                                CHECK_STATUS(status, NT_STATUS_OK);
                        } else {
                        } else if (NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
                                ok_mask |= 1<<i;
                                status = smb2_util_close(tree, io.out.file.handle);
                                CHECK_STATUS(status, NT_STATUS_OK);
                        } else {
+                               unexpected_mask |= 1<<i;
                                printf("create option 0x%08x returned %s\n", 1<<i, nt_errstr(status));
                        }
                }
                                printf("create option 0x%08x returned %s\n", 1<<i, nt_errstr(status));
                        }
                }
@@ -129,8 +137,10 @@ static bool test_create_gentest(struct torture_context *torture, struct smb2_tre
        io.in.create_options = 0;
 
        CHECK_EQUAL(ok_mask,                0x00efcf7e);
        io.in.create_options = 0;
 
        CHECK_EQUAL(ok_mask,                0x00efcf7e);
+       CHECK_EQUAL(not_a_directory_mask,   0x00000001);
        CHECK_EQUAL(not_supported_mask,     0x00102080);
        CHECK_EQUAL(invalid_parameter_mask, 0xff000000);
        CHECK_EQUAL(not_supported_mask,     0x00102080);
        CHECK_EQUAL(invalid_parameter_mask, 0xff000000);
+       CHECK_EQUAL(unexpected_mask,        0x00000000);
 
        io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
        io.in.file_attributes = 0;
 
        io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
        io.in.file_attributes = 0;