Line data Source code
1 : /* 2 : Unix SMB/CIFS implementation. 3 : 4 : Copyright (C) Ralph Boehme 2014 5 : 6 : This program is free software; you can redistribute it and/or modify 7 : it under the terms of the GNU General Public License as published by 8 : the Free Software Foundation; either version 3 of the License, or 9 : (at your option) any later version. 10 : 11 : This program is distributed in the hope that it will be useful, 12 : but WITHOUT ANY WARRANTY; without even the implied warranty of 13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 : GNU General Public License for more details. 15 : 16 : You should have received a copy of the GNU General Public License 17 : along with this program. If not, see <http://www.gnu.org/licenses/>. 18 : */ 19 : 20 : #include "includes.h" 21 : #include "system/filesys.h" 22 : #include "libcli/libcli.h" 23 : #include "../lib/util/dlinklist.h" 24 : 25 : #include "libcli/smb2/smb2.h" 26 : #include "libcli/smb2/smb2_calls.h" 27 : #include "lib/cmdline/cmdline.h" 28 : #include "param/param.h" 29 : #include "libcli/resolve/resolve.h" 30 : 31 : #include "torture/util.h" 32 : #include "torture/smbtorture.h" 33 : #include "torture/vfs/proto.h" 34 : #include "torture/smb2/proto.h" 35 : 36 18 : static bool wrap_2ns_smb2_test(struct torture_context *torture_ctx, 37 : struct torture_tcase *tcase, 38 : struct torture_test *test) 39 : { 40 0 : bool (*fn) (struct torture_context *, struct smb2_tree *, struct smb2_tree *); 41 0 : bool ok; 42 : 43 18 : struct smb2_tree *tree1 = NULL; 44 18 : struct smb2_tree *tree2 = NULL; 45 18 : TALLOC_CTX *mem_ctx = talloc_new(torture_ctx); 46 : 47 18 : if (!torture_smb2_connection(torture_ctx, &tree1)) { 48 0 : torture_fail(torture_ctx, 49 : "Establishing SMB2 connection failed\n"); 50 : return false; 51 : } 52 : 53 : /* 54 : * This is a trick: 55 : * The test might close the connection. If we steal the tree context 56 : * before that and free the parent instead of tree directly, we avoid 57 : * a double free error. 58 : */ 59 18 : talloc_steal(mem_ctx, tree1); 60 : 61 18 : ok = torture_smb2_con_sopt(torture_ctx, "share2", &tree2); 62 18 : if (ok) { 63 18 : talloc_steal(mem_ctx, tree2); 64 : } 65 : 66 18 : fn = test->fn; 67 : 68 18 : ok = fn(torture_ctx, tree1, tree2); 69 : 70 : /* the test may already have closed some of the connections */ 71 18 : talloc_free(mem_ctx); 72 : 73 18 : return ok; 74 : } 75 : 76 : /* 77 : * Run a test with 2 connected trees, the default share and another 78 : * taken from option strings "torture:share2" 79 : */ 80 7062 : struct torture_test *torture_suite_add_2ns_smb2_test(struct torture_suite *suite, 81 : const char *name, 82 : bool (*run)(struct torture_context *, 83 : struct smb2_tree *, 84 : struct smb2_tree *)) 85 : { 86 375 : struct torture_test *test; 87 375 : struct torture_tcase *tcase; 88 : 89 7062 : tcase = torture_suite_add_tcase(suite, name); 90 : 91 7062 : test = talloc(tcase, struct torture_test); 92 : 93 7062 : test->name = talloc_strdup(test, name); 94 7062 : test->description = NULL; 95 7062 : test->run = wrap_2ns_smb2_test; 96 7062 : test->fn = run; 97 7062 : test->dangerous = false; 98 : 99 7062 : DLIST_ADD_END(tcase->tests, test); 100 : 101 7062 : return test; 102 : } 103 : 104 2354 : NTSTATUS torture_vfs_init(TALLOC_CTX *ctx) 105 : { 106 2354 : struct torture_suite *suite = torture_suite_create( 107 : ctx, "vfs"); 108 : 109 2354 : suite->description = talloc_strdup(suite, "VFS modules tests"); 110 : 111 2354 : torture_suite_add_suite(suite, torture_vfs_fruit(suite)); 112 2354 : torture_suite_add_suite(suite, torture_vfs_fruit_netatalk(suite)); 113 2354 : torture_suite_add_suite(suite, torture_acl_xattr(suite)); 114 2354 : torture_suite_add_suite(suite, torture_vfs_fruit_file_id(suite)); 115 2354 : torture_suite_add_suite(suite, torture_vfs_fruit_timemachine(suite)); 116 2354 : torture_suite_add_suite(suite, torture_vfs_fruit_conversion(suite)); 117 2354 : torture_suite_add_suite(suite, torture_vfs_fruit_unfruit(suite)); 118 2354 : torture_suite_add_1smb2_test(suite, "fruit_validate_afpinfo", test_fruit_validate_afpinfo); 119 : 120 2354 : torture_register_suite(ctx, suite); 121 : 122 2354 : return NT_STATUS_OK; 123 : }