2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2008
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "libcli/smb2/smb2.h"
24 #include "libcli/smb2/smb2_calls.h"
25 #include "torture/torture.h"
26 #include "torture/smb2/proto.h"
27 #include "param/param.h"
28 #include "librpc/gen_ndr/ndr_security.h"
30 #define FNAME "test_create.dat"
32 #define CHECK_STATUS(status, correct) do { \
33 if (!NT_STATUS_EQUAL(status, correct)) { \
34 printf("(%s) Incorrect status %s - should be %s\n", \
35 __location__, nt_errstr(status), nt_errstr(correct)); \
40 test some interesting combinations found by gentest
42 bool torture_smb2_create_gentest(struct torture_context *torture, struct smb2_tree *tree)
44 struct smb2_create io;
46 TALLOC_CTX *tmp_ctx = talloc_new(tree);
49 io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
50 io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
51 io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
53 NTCREATEX_SHARE_ACCESS_DELETE|
54 NTCREATEX_SHARE_ACCESS_READ|
55 NTCREATEX_SHARE_ACCESS_WRITE;
56 io.in.create_options = 0;
59 status = smb2_create(tree, tmp_ctx, &io);
60 CHECK_STATUS(status, NT_STATUS_OK);
62 status = smb2_util_close(tree, io.out.file.handle);
63 CHECK_STATUS(status, NT_STATUS_OK);
65 io.in.create_options = 0xF0000000;
66 status = smb2_create(tree, tmp_ctx, &io);
67 CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
69 io.in.create_options = 0x00100000;
70 status = smb2_create(tree, tmp_ctx, &io);
71 CHECK_STATUS(status, NT_STATUS_NOT_SUPPORTED);
73 io.in.create_options = 0xF0100000;
74 status = smb2_create(tree, tmp_ctx, &io);
75 CHECK_STATUS(status, NT_STATUS_NOT_SUPPORTED);
83 basic testing of SMB2 create calls
85 bool torture_smb2_create(struct torture_context *torture)
87 TALLOC_CTX *mem_ctx = talloc_new(NULL);
88 struct smb2_tree *tree;
91 if (!torture_smb2_connection(torture, &tree)) {
95 ret &= torture_smb2_create_gentest(torture, tree);
97 smb2_deltree(tree, FNAME);