The branch, master has been updated
       via  bb92c70f0ee libcli/auth: let netlogon_creds_copy() make use of 
ndr_deepcopy_struct()
       via  63a5269a77a librpc/ndr: add ndr_deepcopy_struct() helper
      from  6d71edab5a7 smbd: use fsctl_get_reparse_point() in 
smb3_file_posix_information_init()

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit bb92c70f0ee126981a4ffeea28bf7059ab0b08d0
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Jul 19 21:04:53 2023 +0200

    libcli/auth: let netlogon_creds_copy() make use of ndr_deepcopy_struct()
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>
    
    Autobuild-User(master): Volker Lendecke <[email protected]>
    Autobuild-Date(master): Thu Nov 28 13:53:25 UTC 2024 on atb-devel-224

commit 63a5269a77aae1b157fe3c7ac31b2980f6ba71ff
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Jul 19 20:55:55 2023 +0200

    librpc/ndr: add ndr_deepcopy_struct() helper
    
    Keep libndr at 6.0.0, this has not been released yet.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15425
    
    Signed-off-by: Stefan Metzmacher <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 libcli/auth/credentials.c | 26 ++++++--------------------
 librpc/ABI/ndr-6.0.0.sigs |  1 +
 librpc/ndr/libndr.h       | 10 ++++++++++
 librpc/ndr/ndr.c          | 26 ++++++++++++++++++++++++++
 librpc/wscript_build      |  2 +-
 5 files changed, 44 insertions(+), 21 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/auth/credentials.c b/libcli/auth/credentials.c
index 7a1f6038ef2..53a089bd5b7 100644
--- a/libcli/auth/credentials.c
+++ b/libcli/auth/credentials.c
@@ -22,6 +22,7 @@
 
 #include "includes.h"
 #include "system/time.h"
+#include "librpc/gen_ndr/ndr_schannel.h"
 #include "libcli/auth/libcli_auth.h"
 #include "../libcli/security/dom_sid.h"
 #include "lib/util/util_str_escape.h"
@@ -1408,33 +1409,18 @@ struct netlogon_creds_CredentialState 
*netlogon_creds_copy(
        const struct netlogon_creds_CredentialState *creds_in)
 {
        struct netlogon_creds_CredentialState *creds = talloc_zero(mem_ctx, 
struct netlogon_creds_CredentialState);
+       enum ndr_err_code ndr_err;
 
        if (!creds) {
                return NULL;
        }
 
-       *creds = *creds_in;
-
-       creds->computer_name = talloc_strdup(creds, creds_in->computer_name);
-       if (!creds->computer_name) {
-               talloc_free(creds);
-               return NULL;
-       }
-       creds->account_name = talloc_strdup(creds, creds_in->account_name);
-       if (!creds->account_name) {
-               talloc_free(creds);
+       ndr_err = ndr_deepcopy_struct(netlogon_creds_CredentialState,
+                                     creds_in, creds, creds);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               TALLOC_FREE(creds);
                return NULL;
        }
 
-       if (creds_in->ex != NULL) {
-               creds->ex = talloc_zero(creds,
-                       struct netlogon_creds_CredentialState_extra_info);
-               if (creds->ex == NULL) {
-                       talloc_free(creds);
-                       return NULL;
-               }
-               *creds->ex = *creds_in->ex;
-       }
-
        return creds;
 }
diff --git a/librpc/ABI/ndr-6.0.0.sigs b/librpc/ABI/ndr-6.0.0.sigs
index 3244948abcc..7c672a1bf51 100644
--- a/librpc/ABI/ndr-6.0.0.sigs
+++ b/librpc/ABI/ndr-6.0.0.sigs
@@ -12,6 +12,7 @@ GUID_string2: char *(TALLOC_CTX *, const struct GUID *)
 GUID_to_ndr_blob: NTSTATUS (const struct GUID *, TALLOC_CTX *, DATA_BLOB *)
 GUID_to_ndr_buf: void (const struct GUID *, struct GUID_ndr_buf *)
 GUID_zero: struct GUID (void)
+_ndr_deepcopy_struct: enum ndr_err_code (ndr_push_flags_fn_t, const void *, 
ndr_pull_flags_fn_t, TALLOC_CTX *, void *)
 _ndr_pull_error: enum ndr_err_code (struct ndr_pull *, enum ndr_err_code, 
const char *, const char *, const char *, ...)
 _ndr_push_error: enum ndr_err_code (struct ndr_push *, enum ndr_err_code, 
const char *, const char *, const char *, ...)
 ndr_align_size: size_t (uint32_t, size_t)
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 21c71f1a022..c8cf6ee1d45 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -759,6 +759,16 @@ enum ndr_err_code ndr_pull_struct_blob_all_noalloc(const 
DATA_BLOB *blob,
 enum ndr_err_code ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX 
*mem_ctx, void *p, uint32_t level, ndr_pull_flags_fn_t fn);
 enum ndr_err_code ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC_CTX 
*mem_ctx, void *p, uint32_t level, ndr_pull_flags_fn_t fn);
 
+enum ndr_err_code _ndr_deepcopy_struct(ndr_push_flags_fn_t push_fn,
+                                      const void *src,
+                                      ndr_pull_flags_fn_t pull_fn,
+                                      TALLOC_CTX *dst_mem, void *dst);
+#define ndr_deepcopy_struct(type, src, dst_mem, dst) \
+       _ndr_deepcopy_struct((ndr_push_flags_fn_t)ndr_push_ ## type, \
+                            src, \
+                            (ndr_pull_flags_fn_t)ndr_pull_ ## type, \
+                            dst_mem, dst)
+
 /* from libndr_basic.h */
 #define NDR_SCALAR_PROTO(name, type) \
 enum ndr_err_code ndr_push_ ## name(struct ndr_push *ndr, ndr_flags_type 
ndr_flags, type v); \
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index b48c798cd75..c07bd233a93 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -1393,6 +1393,32 @@ _PUBLIC_ enum ndr_err_code 
ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLO
        return NDR_ERR_SUCCESS;
 }
 
+_PUBLIC_ enum ndr_err_code
+_ndr_deepcopy_struct(ndr_push_flags_fn_t push_fn,
+                    const void *src,
+                    ndr_pull_flags_fn_t pull_fn,
+                    TALLOC_CTX *dst_mem, void *dst)
+{
+       TALLOC_CTX *frame = talloc_stackframe();
+       DATA_BLOB blob = { .length = 0, };
+       enum ndr_err_code ndr_err;
+
+       ndr_err = ndr_push_struct_blob(&blob, frame, src, push_fn);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               TALLOC_FREE(frame);
+               return ndr_err;
+       }
+
+       ndr_err = ndr_pull_struct_blob_all(&blob, dst_mem, dst, pull_fn);
+       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+               TALLOC_FREE(frame);
+               return ndr_err;
+       }
+
+       TALLOC_FREE(frame);
+       return NDR_ERR_SUCCESS;
+}
+
 /*
  * pull a struct from a blob using NDR
  *
diff --git a/librpc/wscript_build b/librpc/wscript_build
index 6cb4e1cff2b..a4cdfd9f508 100644
--- a/librpc/wscript_build
+++ b/librpc/wscript_build
@@ -676,7 +676,7 @@ bld.SAMBA_LIBRARY('ndr',
     header_path= [('*gen_ndr*', 'gen_ndr')],
     vnum='6.0.0',
     abi_directory='ABI',
-    abi_match='!ndr_table_* ndr_* GUID_* _ndr_pull_error* _ndr_push_error*',
+    abi_match='!ndr_table_* ndr_* GUID_* _ndr_pull_error* _ndr_push_error* 
_ndr_deepcopy_*',
     )
 
 bld.SAMBA_LIBRARY('dcerpc-binding',


-- 
Samba Shared Repository

Reply via email to