[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue Aug 24 18:23:01 UTC 2021


The branch, master has been updated
       via  2a20c8b2b16 rpcclient: Add unixinfo commands
       via  76b7bc5fc06 winbindd: NULL-initialize a pointer
       via  d244d16ca9d rpc_client: Align cli_api_pipe_send() with tevent_req() conventions
       via  17b6c25bda0 rpc_client: Use tevent_req_nterror() properly in cli_api_pipe
       via  730e2903b2f rpc_client: Make rpc_pipe_open_tcp() static
       via  19482ebb748 torture: Remove rpc_open_tcp test program
       via  965ebcae763 rpc_client: Simplify get_complete_frag_send()
       via  7df7bf44e55 rpc_client: Simplify get_complete_frag_got_header()
       via  39c0e3ea2ea rpc_client: Simplify get_complete_frag_got_header()
       via  68a3e478d1c rpc_client: Simplify get_complete_frag_got_rest()
       via  f8c828b87dd rpc_client: Simplify rpc_api_pipe_auth3_done()
       via  dc4371f7d62 rpc_client: Avoid casts
       via  56328aef8eb rpc_client: Use tevent_req_nterror() properly
       via  d11688059f9 rpc_client: Simplify rpccli_bh_disconnect_recv()
       via  3bfc7802ef5 winbind: Remove an unused include
       via  8c7b41063c9 rpc_client: Adapt rpc_write_send() to tevent_req conventions
       via  398e38400d1 rpc_client: Adapt rpc_api_pipe_send() to recent coding conventions
       via  e8dda8421b3 rpc_client: Use ndr_syntax_id_equal() in check_bind_response()
       via  89a0f256e21 rpc_client: Use struct init/assignment
       via  a3f7f279ff0 rpc_client: Adapt rpc_pipe_bind_send() to talloc_req conventions
       via  c4aea464bb0 rpc_client: Avoid ZERO_STRUCTP in prepare_verification_trailer()
       via  2a4e785040d rpc_client: Adapt rpc_api_pipe_req_send() to talloc_req conventions
       via  106c04689e1 rpc_client: Slightly simplify rpc_api_pipe_req_send()
       via  b0c065773e9 rpc_client: Early TALLOC_FREE() in prepare_verification_trailer()
       via  3e3cc4eae9a rpc_client: Fix a small memleak
       via  dbb1226c7ce libsmb: Fix a typo
       via  3fb8eebfe30 rpc_client: Slightly simplify rpc_transport_np_init_pipe_open()
       via  8b45a42bc8b lib: Improve comment wording
       via  7e810091fcf rpc_server: Fix a comment
       via  12942576b32 rpc_server: Simplify _samr_CreateUser2()
       via  95a2540d0b8 rpc_server: Align integer types
       via  da74089533a rpc_server: Remove an unused function declaration
       via  2154bb50f68 rpc_server: Slightly simplify set_user_info_18()
       via  ebac118da5b rpc_server: Slightly simplify set_user_info_21()
       via  b79ed122e53 rpc_server: Simplify open_np_file()
       via  9857c562568 librpc: Simplify GUID_hexstring()
       via  0cddd3f2d66 librpc: Simplify GUID_string2() by using GUID_buf_string()
       via  5e2ac224b79 librpc: Simplify GUID_zero() with a direct struct return
      from  78942ad7d17 samba-tool domain backup: Use tdbbackup on metadata.tdb

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


- Log -----------------------------------------------------------------
commit 2a20c8b2b1659e055dbedcb074e0f49a88b9b8cc
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jun 12 10:03:16 2021 +0200

    rpcclient: Add unixinfo commands
    
    The unixinfo pipe might go away in the future, but right now we have
    it around. This code is simple and can go away again when unixinfo
    dies.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Aug 24 18:22:56 UTC 2021 on sn-devel-184

commit 76b7bc5fc06cb64ab3e43c3d26c09dc0aa605199
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jun 19 17:05:39 2021 +0200

    winbindd: NULL-initialize a pointer
    
    Patches from the dcerpc patchset will create warnings out of this not
    being initialized.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d244d16ca9d28e69494e68f8f3dd1b9b504269d3
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 14:03:55 2021 +0200

    rpc_client: Align cli_api_pipe_send() with tevent_req() conventions
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 17b6c25bda02dc70dca719e667cc0e285918af6e
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 14:05:30 2021 +0200

    rpc_client: Use tevent_req_nterror() properly in cli_api_pipe
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 730e2903b2f967dbc30f84692c8e3bf83d9453e4
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 3 12:13:13 2021 +0200

    rpc_client: Make rpc_pipe_open_tcp() static
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 19482ebb7480ce10bce33c5c6c683c8bab8b8b35
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 3 09:37:12 2021 +0200

    torture: Remove rpc_open_tcp test program
    
    Its initial commit in 2008 stated that it still needs to be integrated
    into the test suite. As far as I can see, this never happened.
    
    Why remove it? Without this we can make rpc_open_tcp() static for
    easier refactoring.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 965ebcae7636c44ba40af1eda50cb819ce10b4c8
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 12:11:32 2021 +0200

    rpc_client: Simplify get_complete_frag_send()
    
    tevent_req_oom() and tevent_req_nomem() instead of explicit
    NT_STATUS_NO_MEMORY; do an early return if done.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7df7bf44e55d4ca63f3cf22a6d75efe28cf64371
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 12:12:31 2021 +0200

    rpc_client: Simplify get_complete_frag_got_header()
    
    tevent_req_nterror() returns a bool, no separate check required
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 39c0e3ea2ea0644dbe827e243efb0c7350d904bb
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 12:12:58 2021 +0200

    rpc_client: Simplify get_complete_frag_got_header()
    
    Use tevent_req_oom()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 68a3e478d1c09c337c4eb0fe4d18fa775038bb79
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 12:14:23 2021 +0200

    rpc_client: Simplify get_complete_frag_got_rest()
    
    tevent_req_simple_finish_ntstatus() is made precisely for this simple
    case where we just pass on a subreq's NTSTATUS
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f8c828b87ddaf8af245e6671590cfc8ef8ed9ee2
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 14:16:22 2021 +0200

    rpc_client: Simplify rpc_api_pipe_auth3_done()
    
    Use tevent_req_simple_finish_ntstatus()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dc4371f7d6224b045bfcbc4cc78147ed2469868f
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 14:18:26 2021 +0200

    rpc_client: Avoid casts
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 56328aef8eb8777500df4f31a8bfb7ce970087fa
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 14:21:23 2021 +0200

    rpc_client: Use tevent_req_nterror() properly
    
    Signed-off-by: Volker Lendecke <vl at samba.org>

commit d11688059f9920f9a565eac06699d58b7e3e828a
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 6 14:22:47 2021 +0200

    rpc_client: Simplify rpccli_bh_disconnect_recv()
    
    Use tevent_req_simple_recv_ntstatus()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3bfc7802ef5b93c4ba19d3d0a27b706f25ab4b2a
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jul 25 15:55:46 2021 +0200

    winbind: Remove an unused include
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8c7b41063c9509e93df14bffb4d9c142abc60737
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Aug 7 10:26:03 2021 +0200

    rpc_client: Adapt rpc_write_send() to tevent_req conventions
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 398e38400d1a5e35d502e9c9764878a8175f8285
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 10 15:56:57 2021 +0200

    rpc_client: Adapt rpc_api_pipe_send() to recent coding conventions
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e8dda8421b3a4c8ac0e3c49d5787662d6f74fb54
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 10 16:12:19 2021 +0200

    rpc_client: Use ndr_syntax_id_equal() in check_bind_response()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 89a0f256e218a53b0eeafdc3150b889557574d70
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 10 16:13:09 2021 +0200

    rpc_client: Use struct init/assignment
    
    Don't leave structures/unions partially uninitialized
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a3f7f279ff0663eb25c24cfcc2104e98e210a210
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 13 15:51:07 2021 +0200

    rpc_client: Adapt rpc_pipe_bind_send() to talloc_req conventions
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c4aea464bb0eebdf1a7db2564e5d9ca37baf11f5
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 13 16:05:00 2021 +0200

    rpc_client: Avoid ZERO_STRUCTP in prepare_verification_trailer()
    
    Direct struct assignments are easier to read for me, but YMMV.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2a4e785040dbdc687061afa246b56fb07802f0e7
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Aug 13 16:15:16 2021 +0200

    rpc_client: Adapt rpc_api_pipe_req_send() to talloc_req conventions
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 106c04689e1855e5631f0a10e685c55134315a26
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 07:42:48 2021 +0200

    rpc_client: Slightly simplify rpc_api_pipe_req_send()
    
    tevent_req_create() zero-initializes "state"
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b0c065773e9e0d1a55aa794997835ca5a52443a8
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 07:49:27 2021 +0200

    rpc_client: Early TALLOC_FREE() in prepare_verification_trailer()
    
    We don't need "t" from here on anymore
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3e3cc4eae9ab779a61496061da34fc4289785769
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 3 09:09:28 2021 +0200

    rpc_client: Fix a small memleak
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dbb1226c7ce7fa5b6fe5de1fc540e01fbec9b553
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 16:28:31 2021 +0200

    libsmb: Fix a typo
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3fb8eebfe304f715bb63aeefa60b3b76e30288a8
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 16:52:24 2021 +0200

    rpc_client: Slightly simplify rpc_transport_np_init_pipe_open()
    
    Avoid an unnecessary else, use tevent_req_nterror() in if-clause
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8b45a42bc8b9c4efbbc7a4c64dd7fa599c3dccc4
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 17:10:17 2021 +0200

    lib: Improve comment wording
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7e810091fcf49663055f46f6800160ad5972b261
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 17:20:03 2021 +0200

    rpc_server: Fix a comment
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 12942576b326e64017e84d98163470a891df1860
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 17:20:21 2021 +0200

    rpc_server: Simplify _samr_CreateUser2()
    
    Use a variable that we just set a line before, don't duplicate the
    priv name.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 95a2540d0b81e8041b20333be4823a5e03570517
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 17:24:45 2021 +0200

    rpc_server: Align integer types
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit da74089533a52dd92abe7df11f2f5e8be2f6adca
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 17:59:49 2021 +0200

    rpc_server: Remove an unused function declaration
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2154bb50f682fb0e2fe3b6216933ef4f66c62ab9
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 20:18:45 2021 +0200

    rpc_server: Slightly simplify set_user_info_18()
    
    Instead of adding the NULL check to data_blob_talloc_zero() put "out"
    on the stack.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ebac118da5b041862af65bbede2bf3bc39a0b27c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 20:18:45 2021 +0200

    rpc_server: Slightly simplify set_user_info_21()
    
    Instead of adding the NULL check to data_blob_talloc_zero() put "out"
    on the stack.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b79ed122e53545ed6117b790dacb7a70ff897783
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 17 20:37:04 2021 +0200

    rpc_server: Simplify open_np_file()
    
    No need to go via a string to create the SID describing the SMB3
    encryption, we can directly use sid_append_rid().
    
    This by the way fixes a bug: SID_MAX_SIZE is the maximum length of the
    binary SID, not the maximum string length for a SID.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9857c562568a718bb14ba49c644db9181aa7110e
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 18 06:21:52 2021 +0200

    librpc: Simplify GUID_hexstring()
    
    A temporary talloc context seems unnecessary to me.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0cddd3f2d66b3fb3af73d42df6c4d42aff7863d7
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 18 06:25:00 2021 +0200

    librpc: Simplify GUID_string2() by using GUID_buf_string()
    
    Avoid unnecessary talloc
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5e2ac224b79574ee07c82e5e58c8ba17c0299b09
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 18 06:27:52 2021 +0200

    librpc: Simplify GUID_zero() with a direct struct return
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 librpc/ndr/uuid.c                     |  32 +--
 source3/lib/util_sec.c                |   2 +-
 source3/libsmb/clientgen.c            |   2 +-
 source3/rpc_client/cli_pipe.c         | 358 +++++++++++++---------------------
 source3/rpc_client/cli_pipe.h         |   6 -
 source3/rpc_client/rpc_transport_np.c |   8 +-
 source3/rpc_server/rpc_pipes.h        |   1 -
 source3/rpc_server/samr/srv_samr_nt.c |  53 +++--
 source3/rpcclient/cmd_unixinfo.c      | 141 +++++++++++++
 source3/rpcclient/rpcclient.c         |   2 +
 source3/rpcclient/wscript_build       |   2 +
 source3/smbd/pipes.c                  |  27 +--
 source3/torture/rpc_open_tcp.c        | 110 -----------
 source3/torture/wscript_build         |   9 -
 source3/winbindd/idmap_ad.c           |   1 -
 source3/winbindd/winbindd_cm.c        |   2 +-
 16 files changed, 329 insertions(+), 427 deletions(-)
 create mode 100644 source3/rpcclient/cmd_unixinfo.c
 delete mode 100644 source3/torture/rpc_open_tcp.c


Changeset truncated at 500 lines:

diff --git a/librpc/ndr/uuid.c b/librpc/ndr/uuid.c
index 2c16f5ad81c..6a8d31e065f 100644
--- a/librpc/ndr/uuid.c
+++ b/librpc/ndr/uuid.c
@@ -143,11 +143,7 @@ _PUBLIC_ struct GUID GUID_random(void)
  */
 _PUBLIC_ struct GUID GUID_zero(void)
 {
-	struct GUID guid;
-
-	ZERO_STRUCT(guid);
-
-	return guid;
+	return (struct GUID) { .time_low = 0 };
 }
 
 _PUBLIC_ bool GUID_all_zero(const struct GUID *u)
@@ -226,31 +222,23 @@ _PUBLIC_ char* GUID_buf_string(const struct GUID *guid,
 
 _PUBLIC_ char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid)
 {
-	char *ret, *s = GUID_string(mem_ctx, guid);
-	ret = talloc_asprintf(mem_ctx, "{%s}", s);
-	talloc_free(s);
+	struct GUID_txt_buf buf;
+	char *ret = talloc_asprintf(
+		mem_ctx, "{%s}", GUID_buf_string(guid, &buf));
 	return ret;
 }
 
 _PUBLIC_ char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid)
 {
-	char *ret;
-	DATA_BLOB guid_blob;
-	TALLOC_CTX *tmp_mem;
+	char *ret = NULL;
+	DATA_BLOB guid_blob = { .data = NULL };
 	NTSTATUS status;
 
-	tmp_mem = talloc_new(mem_ctx);
-	if (!tmp_mem) {
-		return NULL;
+	status = GUID_to_ndr_blob(guid, mem_ctx, &guid_blob);
+	if (NT_STATUS_IS_OK(status)) {
+		ret = data_blob_hex_string_upper(mem_ctx, &guid_blob);
 	}
-	status = GUID_to_ndr_blob(guid, tmp_mem, &guid_blob);
-	if (!NT_STATUS_IS_OK(status)) {
-		talloc_free(tmp_mem);
-		return NULL;
-	}
-
-	ret = data_blob_hex_string_upper(mem_ctx, &guid_blob);
-	talloc_free(tmp_mem);
+	TALLOC_FREE(guid_blob.data);
 	return ret;
 }
 
diff --git a/source3/lib/util_sec.c b/source3/lib/util_sec.c
index 4c3d3dc7881..30a29f535b1 100644
--- a/source3/lib/util_sec.c
+++ b/source3/lib/util_sec.c
@@ -99,7 +99,7 @@ gid_t sec_initial_gid(void)
 /**
  * @brief Check if we are running in root mode.
  *
- * @return If we samba root privileges it returns true, false otehrwise.
+ * @return Return whether Samba has root privileges
  */
 bool root_mode(void)
 {
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index b9b2bacaa76..a5929ecc7df 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -231,7 +231,7 @@ static void _cli_shutdown(struct cli_state *cli)
 	cli_nt_pipes_close(cli);
 
 	/*
-	 * tell our peer to free his resources.  Wihtout this, when an
+	 * tell our peer to free his resources.  Without this, when an
 	 * application attempts to do a graceful shutdown and calls
 	 * smbc_free_context() to clean up all connections, some connections
 	 * can remain active on the peer end, until some (long) timeout period
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 66c24e0dbd8..2ceef482c64 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -123,8 +123,7 @@ static void rpc_read_done(struct tevent_req *subreq)
 
 	status = state->transport->read_recv(subreq, &received);
 	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
-		tevent_req_nterror(req, status);
+	if (tevent_req_nterror(req, status)) {
 		return;
 	}
 
@@ -180,14 +179,11 @@ static struct tevent_req *rpc_write_send(TALLOC_CTX *mem_ctx,
 	DBG_INFO("data_to_write: %zu\n", size);
 
 	subreq = transport->write_send(state, ev, data, size, transport->priv);
-	if (subreq == NULL) {
-		goto fail;
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
 	}
 	tevent_req_set_callback(subreq, rpc_write_done, req);
 	return req;
- fail:
-	TALLOC_FREE(req);
-	return NULL;
 }
 
 static void rpc_write_done(struct tevent_req *subreq)
@@ -201,8 +197,7 @@ static void rpc_write_done(struct tevent_req *subreq)
 
 	status = state->transport->write_recv(subreq, &written);
 	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
-		tevent_req_nterror(req, status);
+	if (tevent_req_nterror(req, status)) {
 		return;
 	}
 
@@ -252,7 +247,6 @@ static struct tevent_req *get_complete_frag_send(TALLOC_CTX *mem_ctx,
 	struct tevent_req *req, *subreq;
 	struct get_complete_frag_state *state;
 	size_t received;
-	NTSTATUS status;
 
 	req = tevent_req_create(mem_ctx, &state,
 				struct get_complete_frag_state);
@@ -267,16 +261,15 @@ static struct tevent_req *get_complete_frag_send(TALLOC_CTX *mem_ctx,
 	received = pdu->length;
 	if (received < RPC_HEADER_LEN) {
 		if (!data_blob_realloc(mem_ctx, pdu, RPC_HEADER_LEN)) {
-			status = NT_STATUS_NO_MEMORY;
-			goto post_status;
+			tevent_req_oom(req);
+			return tevent_req_post(req, ev);
 		}
 		subreq = rpc_read_send(state, state->ev,
 					state->cli->transport,
 					pdu->data + received,
 					RPC_HEADER_LEN - received);
-		if (subreq == NULL) {
-			status = NT_STATUS_NO_MEMORY;
-			goto post_status;
+		if (tevent_req_nomem(subreq, req)) {
+			return tevent_req_post(req, ev);
 		}
 		tevent_req_set_callback(subreq, get_complete_frag_got_header,
 					req);
@@ -289,35 +282,30 @@ static struct tevent_req *get_complete_frag_send(TALLOC_CTX *mem_ctx,
 		return tevent_req_post(req, ev);
 	}
 
-	/*
-	 * Ensure we have frag_len bytes of data.
-	 */
-	if (received < state->frag_len) {
-		if (!data_blob_realloc(NULL, pdu, state->frag_len)) {
-			status = NT_STATUS_NO_MEMORY;
-			goto post_status;
-		}
-		subreq = rpc_read_send(state, state->ev,
-					state->cli->transport,
-					pdu->data + received,
-					state->frag_len - received);
-		if (subreq == NULL) {
-			status = NT_STATUS_NO_MEMORY;
-			goto post_status;
-		}
-		tevent_req_set_callback(subreq, get_complete_frag_got_rest,
-					req);
-		return req;
+	if (received >= state->frag_len) {
+		/*
+		 * Got the whole fragment
+		 */
+		tevent_req_done(req);
+		return tevent_req_post(req, ev);
 	}
 
-	status = NT_STATUS_OK;
- post_status:
-	if (NT_STATUS_IS_OK(status)) {
-		tevent_req_done(req);
-	} else {
-		tevent_req_nterror(req, status);
+	if (!data_blob_realloc(NULL, pdu, state->frag_len)) {
+		tevent_req_oom(req);
+		return tevent_req_post(req, ev);
 	}
-	return tevent_req_post(req, ev);
+
+	subreq = rpc_read_send(
+		state,
+		state->ev,
+		state->cli->transport,
+		pdu->data + received,
+		state->frag_len - received);
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
+	}
+	tevent_req_set_callback(subreq, get_complete_frag_got_rest, req);
+	return req;
 }
 
 static void get_complete_frag_got_header(struct tevent_req *subreq)
@@ -330,8 +318,7 @@ static void get_complete_frag_got_header(struct tevent_req *subreq)
 
 	status = rpc_read_recv(subreq);
 	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
-		tevent_req_nterror(req, status);
+	if (tevent_req_nterror(req, status)) {
 		return;
 	}
 
@@ -342,7 +329,7 @@ static void get_complete_frag_got_header(struct tevent_req *subreq)
 	}
 
 	if (!data_blob_realloc(NULL, state->pdu, state->frag_len)) {
-		tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+		tevent_req_oom(req);
 		return;
 	}
 
@@ -362,17 +349,8 @@ static void get_complete_frag_got_header(struct tevent_req *subreq)
 
 static void get_complete_frag_got_rest(struct tevent_req *subreq)
 {
-	struct tevent_req *req = tevent_req_callback_data(
-		subreq, struct tevent_req);
-	NTSTATUS status;
-
-	status = rpc_read_recv(subreq);
-	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
-		tevent_req_nterror(req, status);
-		return;
-	}
-	tevent_req_done(req);
+	NTSTATUS status = rpc_read_recv(subreq);
+	return tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 static NTSTATUS get_complete_frag_recv(struct tevent_req *req)
@@ -614,7 +592,6 @@ static struct tevent_req *cli_api_pipe_send(TALLOC_CTX *mem_ctx,
 {
 	struct tevent_req *req, *subreq;
 	struct cli_api_pipe_state *state;
-	NTSTATUS status;
 
 	req = tevent_req_create(mem_ctx, &state, struct cli_api_pipe_state);
 	if (req == NULL) {
@@ -629,15 +606,15 @@ static struct tevent_req *cli_api_pipe_send(TALLOC_CTX *mem_ctx,
 		 * bytes. We check this here because we will receive
 		 * RPC_HEADER_LEN bytes in cli_trans_sock_send_done.
 		 */
-		status = NT_STATUS_INVALID_PARAMETER;
-		goto post_status;
+		tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+		return tevent_req_post(req, ev);
 	}
 
 	if (transport->trans_send != NULL) {
 		subreq = transport->trans_send(state, ev, data, data_len,
 					       max_rdata_len, transport->priv);
-		if (subreq == NULL) {
-			goto fail;
+		if (tevent_req_nomem(subreq, req)) {
+			return tevent_req_post(req, ev);
 		}
 		tevent_req_set_callback(subreq, cli_api_pipe_trans_done, req);
 		return req;
@@ -649,18 +626,11 @@ static struct tevent_req *cli_api_pipe_send(TALLOC_CTX *mem_ctx,
 	 */
 
 	subreq = rpc_write_send(state, ev, transport, data, data_len);
-	if (subreq == NULL) {
-		goto fail;
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
 	}
 	tevent_req_set_callback(subreq, cli_api_pipe_write_done, req);
 	return req;
-
- post_status:
-	tevent_req_nterror(req, status);
-	return tevent_req_post(req, ev);
- fail:
-	TALLOC_FREE(req);
-	return NULL;
 }
 
 static void cli_api_pipe_trans_done(struct tevent_req *subreq)
@@ -674,8 +644,7 @@ static void cli_api_pipe_trans_done(struct tevent_req *subreq)
 	status = state->transport->trans_recv(subreq, state, &state->rdata,
 					      &state->rdata_len);
 	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
-		tevent_req_nterror(req, status);
+	if (tevent_req_nterror(req, status)) {
 		return;
 	}
 	tevent_req_done(req);
@@ -691,8 +660,7 @@ static void cli_api_pipe_write_done(struct tevent_req *subreq)
 
 	status = rpc_write_recv(subreq);
 	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
-		tevent_req_nterror(req, status);
+	if (tevent_req_nterror(req, status)) {
 		return;
 	}
 
@@ -726,8 +694,7 @@ static void cli_api_pipe_read_done(struct tevent_req *subreq)
 
 	status = state->transport->read_recv(subreq, &received);
 	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
-		tevent_req_nterror(req, status);
+	if (tevent_req_nterror(req, status)) {
 		return;
 	}
 	state->rdata_len = received;
@@ -805,7 +772,6 @@ static struct tevent_req *rpc_api_pipe_send(TALLOC_CTX *mem_ctx,
 	struct tevent_req *req, *subreq;
 	struct rpc_api_pipe_state *state;
 	uint16_t max_recv_frag;
-	NTSTATUS status;
 
 	req = tevent_req_create(mem_ctx, &state, struct rpc_api_pipe_state);
 	if (req == NULL) {
@@ -821,8 +787,8 @@ static struct tevent_req *rpc_api_pipe_send(TALLOC_CTX *mem_ctx,
 	 * Ensure we're not sending too much.
 	 */
 	if (data->length > cli->max_xmit_frag) {
-		status = NT_STATUS_INVALID_PARAMETER;
-		goto post_status;
+		tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+		return tevent_req_post(req, ev);
 	}
 
 	DEBUG(5,("rpc_api_pipe: %s\n", rpccli_pipe_txt(talloc_tos(), cli)));
@@ -830,8 +796,8 @@ static struct tevent_req *rpc_api_pipe_send(TALLOC_CTX *mem_ctx,
 	if (state->expected_pkt_type == DCERPC_PKT_AUTH3) {
 		subreq = rpc_write_send(state, ev, cli->transport,
 					data->data, data->length);
-		if (subreq == NULL) {
-			goto fail;
+		if (tevent_req_nomem(subreq, req)) {
+			return tevent_req_post(req, ev);
 		}
 		tevent_req_set_callback(subreq, rpc_api_pipe_auth3_done, req);
 		return req;
@@ -843,35 +809,17 @@ static struct tevent_req *rpc_api_pipe_send(TALLOC_CTX *mem_ctx,
 
 	subreq = cli_api_pipe_send(state, ev, cli->transport,
 				   data->data, data->length, max_recv_frag);
-	if (subreq == NULL) {
-		goto fail;
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
 	}
 	tevent_req_set_callback(subreq, rpc_api_pipe_trans_done, req);
 	return req;
-
- post_status:
-	tevent_req_nterror(req, status);
-	return tevent_req_post(req, ev);
- fail:
-	TALLOC_FREE(req);
-	return NULL;
 }
 
 static void rpc_api_pipe_auth3_done(struct tevent_req *subreq)
 {
-	struct tevent_req *req =
-		tevent_req_callback_data(subreq,
-		struct tevent_req);
-	NTSTATUS status;
-
-	status = rpc_write_recv(subreq);
-	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
-		tevent_req_nterror(req, status);
-		return;
-	}
-
-	tevent_req_done(req);
+	NTSTATUS status = rpc_write_recv(subreq);
+	return tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
 static void rpc_api_pipe_trans_done(struct tevent_req *subreq)
@@ -886,9 +834,8 @@ static void rpc_api_pipe_trans_done(struct tevent_req *subreq)
 
 	status = cli_api_pipe_recv(subreq, state, &rdata, &rdata_len);
 	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
+	if (tevent_req_nterror(req, status)) {;
 		DEBUG(5, ("cli_api_pipe failed: %s\n", nt_errstr(status)));
-		tevent_req_nterror(req, status);
 		return;
 	}
 
@@ -929,10 +876,9 @@ static void rpc_api_pipe_got_pdu(struct tevent_req *subreq)
 
 	status = get_complete_frag_recv(subreq);
 	TALLOC_FREE(subreq);
-	if (!NT_STATUS_IS_OK(status)) {
+	if (tevent_req_nterror(req, status)) {
 		DEBUG(5, ("get_complete_frag failed: %s\n",
 			  nt_errstr(status)));
-		tevent_req_nterror(req, status);
 		return;
 	}
 
@@ -944,21 +890,20 @@ static void rpc_api_pipe_got_pdu(struct tevent_req *subreq)
 		 * For now do it sync...
 		 */
 		TALLOC_FREE(state->cli->transport);
-		tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+		tevent_req_oom(req);
 		return;
 	}
 
 	status = dcerpc_pull_ncacn_packet(state->pkt,
 					  &state->incoming_frag,
 					  state->pkt);
-	if (!NT_STATUS_IS_OK(status)) {
+	if (tevent_req_nterror(req, status)) {
 		/*
 		 * TODO: do a real async disconnect ...
 		 *
 		 * For now do it sync...
 		 */
 		TALLOC_FREE(state->cli->transport);
-		tevent_req_nterror(req, status);
 		return;
 	}
 
@@ -974,10 +919,10 @@ static void rpc_api_pipe_got_pdu(struct tevent_req *subreq)
 						&rdata,
 						&state->reply_pdu);
 
-	DEBUG(10,("rpc_api_pipe: got frag len of %u at offset %u: %s\n",
-		  (unsigned)state->incoming_frag.length,
-		  (unsigned)state->reply_pdu_offset,
-		  nt_errstr(status)));
+	DBG_DEBUG("got frag len of %zu at offset %zu: %s\n",
+		  state->incoming_frag.length,
+		  state->reply_pdu_offset,
+		  nt_errstr(status));
 
 	if (state->pkt->ptype != DCERPC_PKT_FAULT && !NT_STATUS_IS_OK(status)) {
 		/*
@@ -1001,8 +946,7 @@ static void rpc_api_pipe_got_pdu(struct tevent_req *subreq)
 		 */
 		TALLOC_FREE(state->cli->transport);
 	}
-	if (!NT_STATUS_IS_OK(status)) {
-		tevent_req_nterror(req, status);
+	if (tevent_req_nterror(req, status)) {
 		return;
 	}
 
@@ -1056,7 +1000,7 @@ static void rpc_api_pipe_got_pdu(struct tevent_req *subreq)
 			 * For now do it sync...
 			 */
 			TALLOC_FREE(state->cli->transport);
-			tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
+			tevent_req_oom(req);
 			return;
 		}
 	}
@@ -1180,8 +1124,19 @@ static NTSTATUS create_bind_or_alt_ctx_internal(TALLOC_CTX *mem_ctx,
 {
 	uint16_t auth_len = auth_info->length;
 	NTSTATUS status;
-	union dcerpc_payload u;
-	struct dcerpc_ctx_list ctx_list;
+	struct dcerpc_ctx_list ctx_list = {
+		.context_id = 0,
+		.num_transfer_syntaxes = 1,
+		.abstract_syntax = *abstract,
+		.transfer_syntaxes = (struct ndr_syntax_id *)discard_const(transfer),
+	};
+	union dcerpc_payload u = {
+		.bind.max_xmit_frag	= RPC_MAX_PDU_FRAG_LEN,
+		.bind.max_recv_frag	= RPC_MAX_PDU_FRAG_LEN,
+		.bind.num_contexts	= 1,
+		.bind.ctx_list		= &ctx_list,
+		.bind.auth_info		= *auth_info,
+	};
 	uint8_t pfc_flags = DCERPC_PFC_FLAG_FIRST | DCERPC_PFC_FLAG_LAST;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list