]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:libcli/smb2: add smb2_tree_channel() helper
authorStefan Metzmacher <metze@samba.org>
Fri, 9 Aug 2024 07:07:40 +0000 (09:07 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 29 Jan 2025 11:20:33 +0000 (11:20 +0000)
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 <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/libcli/smb2/tcon.c

index 702e308aa63f2d71831c72cab489a16f50837257..e66f00790fd72814ec02e9fe11276885b50a67a2 100644 (file)
@@ -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;
+}