]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli: smb: Add smbXcli_tcon_copy().
authorJeremy Allison <jra@samba.org>
Tue, 13 Jun 2017 23:06:22 +0000 (16:06 -0700)
committerKarolin Seeger <kseeger@samba.org>
Fri, 30 Jun 2017 08:46:22 +0000 (10:46 +0200)
Makes a deep copy of a struct smbXcli_tcon *, will
be used later.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12831

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
(cherry picked from commit 655e10685840fd5ebfde24396853b74020a1dc85)

libcli/smb/smbXcli_base.c
libcli/smb/smbXcli_base.h

index aca5363a66f7395f5485976359d3fa6b8687bfe0..d8c604520abef50727625981d8288a50511f0c85 100644 (file)
@@ -5989,6 +5989,38 @@ struct smbXcli_tcon *smbXcli_tcon_create(TALLOC_CTX *mem_ctx)
        return tcon;
 }
 
+/*
+ * Return a deep structure copy of a struct smbXcli_tcon *
+ */
+
+struct smbXcli_tcon *smbXcli_tcon_copy(TALLOC_CTX *mem_ctx,
+                               const struct smbXcli_tcon *tcon_in)
+{
+       struct smbXcli_tcon *tcon;
+
+       tcon = talloc_memdup(mem_ctx, tcon_in, sizeof(struct smbXcli_tcon));
+       if (tcon == NULL) {
+               return NULL;
+       }
+
+       /* Deal with the SMB1 strings. */
+       if (tcon_in->smb1.service != NULL) {
+               tcon->smb1.service = talloc_strdup(tcon, tcon_in->smb1.service);
+               if (tcon->smb1.service == NULL) {
+                       TALLOC_FREE(tcon);
+                       return NULL;
+               }
+       }
+       if (tcon->smb1.fs_type != NULL) {
+               tcon->smb1.fs_type = talloc_strdup(tcon, tcon_in->smb1.fs_type);
+               if (tcon->smb1.fs_type == NULL) {
+                       TALLOC_FREE(tcon);
+                       return NULL;
+               }
+       }
+       return tcon;
+}
+
 void smbXcli_tcon_set_fs_attributes(struct smbXcli_tcon *tcon,
                                    uint32_t fs_attributes)
 {
index 16c8848dd1271695782c1a17c6251c804117d59b..e9607e577bd63ef212e474972fb8687e8175334a 100644 (file)
@@ -431,6 +431,8 @@ NTSTATUS smb2cli_session_set_channel_key(struct smbXcli_session *session,
 NTSTATUS smb2cli_session_encryption_on(struct smbXcli_session *session);
 
 struct smbXcli_tcon *smbXcli_tcon_create(TALLOC_CTX *mem_ctx);
+struct smbXcli_tcon *smbXcli_tcon_copy(TALLOC_CTX *mem_ctx,
+                               const struct smbXcli_tcon *tcon_in);
 void smbXcli_tcon_set_fs_attributes(struct smbXcli_tcon *tcon,
                                    uint32_t fs_attributes);
 uint32_t smbXcli_tcon_get_fs_attributes(struct smbXcli_tcon *tcon);