From: Stefan Metzmacher Date: Fri, 9 Aug 2024 07:07:40 +0000 (+0200) Subject: s4:libcli/smb2: add smb2_tree_channel() helper X-Git-Tag: tdb-1.4.13~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6cb46e5cb60ce753cac55a8ba19f5cffb697d545;p=thirdparty%2Fsamba.git s4:libcli/smb2: add smb2_tree_channel() helper This can be used after smb2_session_channel() in order to have a smb2_tree structure representing the same logic tree connect but uses a different channel/connection. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14430 Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/source4/libcli/smb2/tcon.c b/source4/libcli/smb2/tcon.c index 702e308aa63..e66f00790fd 100644 --- a/source4/libcli/smb2/tcon.c +++ b/source4/libcli/smb2/tcon.c @@ -50,3 +50,28 @@ struct smb2_tree *smb2_tree_init(struct smb2_session *session, return tree; } + +struct smb2_tree *smb2_tree_channel(struct smb2_tree *base_tree, + TALLOC_CTX *parent_ctx, bool primary, + struct smb2_session *session) +{ + struct smb2_tree *tree; + + tree = talloc_zero(parent_ctx, struct smb2_tree); + if (!session) { + return NULL; + } + if (primary) { + tree->session = talloc_steal(tree, session); + } else { + tree->session = talloc_reference(tree, session); + } + + tree->smbXcli = smbXcli_tcon_copy(tree, base_tree->smbXcli); + if (tree->smbXcli == NULL) { + talloc_free(tree); + return NULL; + } + + return tree; +}