diff options
author | Michael Adam <obnox@samba.org> | 2012-01-27 17:20:23 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2012-02-03 11:10:30 +0100 |
commit | 7c7e1fd5c7028fa242213bfa13551dbcff181077 (patch) | |
tree | 147280433b9abc393fe94251f57c13111e302e44 /source4 | |
parent | 1d8fbff7ffbea58ae8ed55fd887f4be022f1cc97 (diff) | |
download | samba-7c7e1fd5c7028fa242213bfa13551dbcff181077.tar.gz samba-7c7e1fd5c7028fa242213bfa13551dbcff181077.tar.bz2 samba-7c7e1fd5c7028fa242213bfa13551dbcff181077.zip |
s4:torture: add torture_smb2_tree_connect() utility function
This does a tcon based on an existing session, using the
name an host present in the torture context.
Diffstat (limited to 'source4')
-rw-r--r-- | source4/torture/smb2/util.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 094161e6eb..8ab61c7934 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -259,6 +259,48 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) talloc_free(tmp_ctx); } +/** + * open a smb2 tree connect + */ +bool torture_smb2_tree_connect(struct torture_context *tctx, + struct smb2_session *session, + TALLOC_CTX *mem_ctx, + struct smb2_tree **_tree) +{ + NTSTATUS status; + const char *host = torture_setting_string(tctx, "host", NULL); + const char *share = torture_setting_string(tctx, "share", NULL); + struct smb2_tree_connect tcon; + struct smb2_tree *tree; + + ZERO_STRUCT(tcon); + tcon.in.reserved = 0; + tcon.in.path = talloc_asprintf(tctx, "\\\\%s\\%s", host, share); + if (tcon.in.path == NULL) { + printf("talloc failed\n"); + return false; + } + + status = smb2_tree_connect(session, &tcon); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to tree_connect to SMB2 share \\\\%s\\%s - %s\n", + host, share, nt_errstr(status)); + return false; + } + + tree = smb2_tree_init(session, mem_ctx, true); + if (tree == NULL) { + printf("talloc failed\n"); + return false; + } + + tree->tid = tcon.out.tid; + + *_tree = tree; + + return true; +} + /* open a smb2 connection |