[SCM] Samba Shared Repository - branch master updated
Günther Deschner
gd at samba.org
Tue Jul 13 06:58:44 MDT 2010
The branch, master has been updated
via 0c93b7d... s3-dcerpc: Remove unused functions and headers
via bc6a3e0... s3-dcerpc: Use dcerpc_push_ncacn_packet() in api_pipe_alter_context()
via 3ba93a9... s3-dcerpc: Use dcerpc_push_dcerpc_auth() for spnego auth continuations.
via 7050073... s3-dceprc: Use dcerpc_push_ncacn_packet() in api_pipe_bind_req()
via f6648c5... s3-dcerpc: Use a DATA_BLOB in bind processing and avoid one mem copy
via 8213bba... s3-dcerpc: Rearrange api_pipe_bind_req() to do checks before allocating memory
via 87605e2... s3-dcerpc: fix dcerpc_push_ncacn_packet, pass arg by address
via fe9036c... s3-dcerpc: pass the packet to setup_bind_nack()
via 272704e... s3-dceprc: Add debug messages
via 4ba8923... s3-dcerpc: Remove unused members
via 29a3142... s3-dcerpc: Remove unused functions
via 8e235df... s3-dcerpc: Use dcerpc_pull_ncacn_packet() to unmarshall dceprc requests
via e340aa4... dcerpc: move dcerpc_pull_auth_trailer into a the common dcerpc_util.c file
via 77fb364... s3-dceprc: Store opnum in its own variable
via a138b3d... s3-dceprc use a DATA_BLOB to hold the curren pdu in pipes_struct
via d078b54... s3-dcerpc: use dceprc_push_ncacn_packet_header in create_next_pdu_noauth()
via 53e9c26... s3-dcerpc: Use dcerpc_push_ncacn_packet_header() in create_next_pdu_schannel()
via 98913d8... s3-dcerpc: use dcerpc_push_ncacn_packet_header() in create_next_pdu_ntlmssp()
via 77699c7... sr-dcerpc: add dcerpc_push_ncacn_packet_header()
via aca330a... s3-dcerpc delay rpc header unmarshalling
via 43064a7... s3-dcerpc: Remove unused headers
via cf664b7... s3-dcerpc: Use dcerpc_set_frag_length()
via ea66d8e... s3-dcerpc: link against ../librpc/rpc/dcerpc_util.c
via 716f9d6... s4-dcerpc: move some util functions up to main librpc directory.
via 2297913... s3-dcerpc: Remove unused prototype
from 25d487b... s3-dcerpc: Fix ntlmssp sign/seal.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0c93b7dff7600074977bb4504169488b090f1d46
Author: Simo Sorce <idra at samba.org>
Date: Sun Jul 11 17:49:06 2010 -0400
s3-dcerpc: Remove unused functions and headers
Signed-off-by: Günther Deschner <gd at samba.org>
commit bc6a3e0030f262d9182b241d09df403483c1bf03
Author: Simo Sorce <idra at samba.org>
Date: Sun Jul 11 17:35:02 2010 -0400
s3-dcerpc: Use dcerpc_push_ncacn_packet() in api_pipe_alter_context()
Signed-off-by: Günther Deschner <gd at samba.org>
commit 3ba93a986faa8cc3c7d6deaa753573ae6c654cea
Author: Simo Sorce <idra at samba.org>
Date: Sun Jul 11 17:07:19 2010 -0400
s3-dcerpc: Use dcerpc_push_dcerpc_auth() for spnego auth continuations.
Signed-off-by: Günther Deschner <gd at samba.org>
commit 70500734f9840eaf77f3077e1e64498692af2323
Author: Simo Sorce <idra at samba.org>
Date: Sun Jul 11 11:48:22 2010 -0400
s3-dceprc: Use dcerpc_push_ncacn_packet() in api_pipe_bind_req()
Signed-off-by: Günther Deschner <gd at samba.org>
commit f6648c500b79b0575ccff7b9057c4006c21acadd
Author: Simo Sorce <idra at samba.org>
Date: Sun Jul 11 11:15:40 2010 -0400
s3-dcerpc: Use a DATA_BLOB in bind processing and avoid one mem copy
Also move dcerpc_push_dcerpc_auth() invocation in api_pipe_bind_req()
to simplify the workflow.
Signed-off-by: Günther Deschner <gd at samba.org>
commit 8213bba892c419022efdb3d800647ef3bcf51388
Author: Simo Sorce <idra at samba.org>
Date: Sun Jul 11 10:47:32 2010 -0400
s3-dcerpc: Rearrange api_pipe_bind_req() to do checks before allocating memory
Signed-off-by: Günther Deschner <gd at samba.org>
commit 87605e2030262bc24b59468fe4b5837e8ff584b0
Author: Simo Sorce <idra at samba.org>
Date: Sun Jul 11 12:18:13 2010 -0400
s3-dcerpc: fix dcerpc_push_ncacn_packet, pass arg by address
There is no need to copy the whole structure twice by passing it in by value.
Signed-off-by: Günther Deschner <gd at samba.org>
commit fe9036cf5bd8aa775a0419be8effae257d6f97f2
Author: Simo Sorce <idra at samba.org>
Date: Sun Jul 11 10:37:07 2010 -0400
s3-dcerpc: pass the packet to setup_bind_nack()
Allows to not rely on p->call_id but use the value directly from the request
packet header.
Signed-off-by: Günther Deschner <gd at samba.org>
commit 272704e8c24cff706c5ce38567f7ab35b335cf92
Author: Simo Sorce <idra at samba.org>
Date: Sat Jul 10 18:53:36 2010 -0400
s3-dceprc: Add debug messages
Signed-off-by: Günther Deschner <gd at samba.org>
commit 4ba89230ae03d00f9c6a0882df1361c5369b77a9
Author: Simo Sorce <idra at samba.org>
Date: Sat Jul 10 17:05:58 2010 -0400
s3-dcerpc: Remove unused members
Signed-off-by: Günther Deschner <gd at samba.org>
commit 29a3142be856b010ccebb153afad0bf6499d5b56
Author: Simo Sorce <idra at samba.org>
Date: Sat Jul 10 17:05:24 2010 -0400
s3-dcerpc: Remove unused functions
Signed-off-by: Günther Deschner <gd at samba.org>
commit 8e235df2de96954af0bd8dc1cc464f6d9d834372
Author: Simo Sorce <idra at samba.org>
Date: Fri Jul 9 19:34:34 2010 -0400
s3-dcerpc: Use dcerpc_pull_ncacn_packet() to unmarshall dceprc requests
Signed-off-by: Günther Deschner <gd at samba.org>
commit e340aa40d19cb03d9c9b5d6e64ac073aeee4b759
Author: Simo Sorce <idra at samba.org>
Date: Fri Jul 9 18:23:49 2010 -0400
dcerpc: move dcerpc_pull_auth_trailer into a the common dcerpc_util.c file
Signed-off-by: Günther Deschner <gd at samba.org>
commit 77fb3649cede61407ba5df008ceaa49d32ef71d7
Author: Simo Sorce <idra at samba.org>
Date: Fri Jul 9 19:35:22 2010 -0400
s3-dceprc: Store opnum in its own variable
Signed-off-by: Günther Deschner <gd at samba.org>
commit a138b3d31ef9952dc59630f478264f74091f613d
Author: Simo Sorce <idra at samba.org>
Date: Fri Jul 9 16:28:52 2010 -0400
s3-dceprc use a DATA_BLOB to hold the curren pdu in pipes_struct
Signed-off-by: Günther Deschner <gd at samba.org>
commit d078b54b22061be808c07a40e0e55dd00591cc69
Author: Simo Sorce <idra at samba.org>
Date: Fri Jul 9 15:46:43 2010 -0400
s3-dcerpc: use dceprc_push_ncacn_packet_header in create_next_pdu_noauth()
Signed-off-by: Günther Deschner <gd at samba.org>
commit 53e9c262712ffe5b1fa60ca53a1e5b407d1ebea8
Author: Simo Sorce <idra at samba.org>
Date: Fri Jul 9 15:38:03 2010 -0400
s3-dcerpc: Use dcerpc_push_ncacn_packet_header() in create_next_pdu_schannel()
Signed-off-by: Günther Deschner <gd at samba.org>
commit 98913d8f44b48da345e115847efdbefbe5536e5f
Author: Simo Sorce <idra at samba.org>
Date: Fri Jul 9 15:33:03 2010 -0400
s3-dcerpc: use dcerpc_push_ncacn_packet_header() in create_next_pdu_ntlmssp()
Signed-off-by: Günther Deschner <gd at samba.org>
commit 77699c777e78a1cd8ed8bc9c92cfeebe46997f70
Author: Simo Sorce <idra at samba.org>
Date: Fri Jul 9 15:32:25 2010 -0400
sr-dcerpc: add dcerpc_push_ncacn_packet_header()
Signed-off-by: Günther Deschner <gd at samba.org>
commit aca330a2c5f4a98a050af1a991f7b4eae1a31b0c
Author: Simo Sorce <idra at samba.org>
Date: Fri Jul 9 14:23:59 2010 -0400
s3-dcerpc delay rpc header unmarshalling
Use dcerpc_get_frag_length() to get the whole pdu first
Signed-off-by: Günther Deschner <gd at samba.org>
commit 43064a74a3ee9f7e4a269ceddb7fffb80dea514f
Author: Simo Sorce <idra at samba.org>
Date: Thu Jul 8 20:25:50 2010 -0400
s3-dcerpc: Remove unused headers
Signed-off-by: Günther Deschner <gd at samba.org>
commit cf664b73a4682a09a8e03b69e65aa5f7b18ff13d
Author: Simo Sorce <idra at samba.org>
Date: Thu Jul 8 19:17:13 2010 -0400
s3-dcerpc: Use dcerpc_set_frag_length()
Automatically calculate the fragment length where possible.
Signed-off-by: Günther Deschner <gd at samba.org>
commit ea66d8e4a5cf44924cc59063a023b7fc158629f9
Author: Günther Deschner <gd at samba.org>
Date: Wed Apr 1 22:37:38 2009 +0200
s3-dcerpc: link against ../librpc/rpc/dcerpc_util.c
Guenther
Signed-off-by: Simo Sorce <idra at samba.org>
Signed-off-by: Günther Deschner <gd at samba.org>
commit 716f9d6847a867744f7456eacf45abacb6eb1963
Author: Günther Deschner <gd at samba.org>
Date: Wed Apr 1 22:37:09 2009 +0200
s4-dcerpc: move some util functions up to main librpc directory.
Guenther
Signed-off-by: Simo Sorce <idra at samba.org>
Signed-off-by: Günther Deschner <gd at samba.org>
commit 229791382989c5005ec8e7c0a6d3b84745d37cbe
Author: Simo Sorce <idra at samba.org>
Date: Sat Jul 10 16:55:37 2010 -0400
s3-dcerpc: Remove unused prototype
Signed-off-by: Günther Deschner <gd at samba.org>
-----------------------------------------------------------------------
Summary of changes:
librpc/rpc/dcerpc_util.c | 117 +++
source3/Makefile.in | 1 +
source3/include/ntdomain.h | 20 +-
source3/include/proto.h | 45 +-
source3/include/rpc_dce.h | 80 --
source3/rpc_client/cli_pipe.c | 68 ++-
source3/rpc_parse/parse_rpc.c | 282 -------
source3/rpc_server/rpc_ncacn_np_internal.c | 4 +-
source3/rpc_server/srv_lsa_nt.c | 4 +-
source3/rpc_server/srv_netlog_nt.c | 6 +-
source3/rpc_server/srv_pipe.c | 1224 +++++++++-------------------
source3/rpc_server/srv_pipe_hnd.c | 725 +++++++++--------
source3/rpc_server/srv_samr_nt.c | 2 +-
source3/rpc_server/srv_spoolss_nt.c | 2 +-
source4/librpc/rpc/dcerpc.c | 30 -
source4/librpc/rpc/dcerpc_util.c | 67 --
source4/librpc/wscript_build | 2 +-
17 files changed, 974 insertions(+), 1705 deletions(-)
create mode 100644 librpc/rpc/dcerpc_util.c
mode change 100644 => 100755 source4/librpc/wscript_build
Changeset truncated at 500 lines:
diff --git a/librpc/rpc/dcerpc_util.c b/librpc/rpc/dcerpc_util.c
new file mode 100644
index 0000000..a4bc096
--- /dev/null
+++ b/librpc/rpc/dcerpc_util.c
@@ -0,0 +1,117 @@
+/*
+ Unix SMB/CIFS implementation.
+ raw dcerpc operations
+
+ Copyright (C) Andrew Tridgell 2003-2005
+ Copyright (C) Jelmer Vernooij 2004-2005
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "librpc/rpc/dcerpc.h"
+#include "librpc/gen_ndr/ndr_dcerpc.h"
+
+/* we need to be able to get/set the fragment length without doing a full
+ decode */
+void dcerpc_set_frag_length(DATA_BLOB *blob, uint16_t v)
+{
+ if (CVAL(blob->data,DCERPC_DREP_OFFSET) & DCERPC_DREP_LE) {
+ SSVAL(blob->data, DCERPC_FRAG_LEN_OFFSET, v);
+ } else {
+ RSSVAL(blob->data, DCERPC_FRAG_LEN_OFFSET, v);
+ }
+}
+
+uint16_t dcerpc_get_frag_length(const DATA_BLOB *blob)
+{
+ if (CVAL(blob->data,DCERPC_DREP_OFFSET) & DCERPC_DREP_LE) {
+ return SVAL(blob->data, DCERPC_FRAG_LEN_OFFSET);
+ } else {
+ return RSVAL(blob->data, DCERPC_FRAG_LEN_OFFSET);
+ }
+}
+
+void dcerpc_set_auth_length(DATA_BLOB *blob, uint16_t v)
+{
+ if (CVAL(blob->data,DCERPC_DREP_OFFSET) & DCERPC_DREP_LE) {
+ SSVAL(blob->data, DCERPC_AUTH_LEN_OFFSET, v);
+ } else {
+ RSSVAL(blob->data, DCERPC_AUTH_LEN_OFFSET, v);
+ }
+}
+
+/*
+ pull an dcerpc_auth structure, taking account of any auth padding in
+ the blob at the end of the structure
+ */
+NTSTATUS dcerpc_pull_auth_trailer(struct ncacn_packet *pkt,
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *pkt_auth_blob,
+ struct dcerpc_auth *auth,
+ uint32_t *auth_length,
+ bool check_pad)
+{
+ struct ndr_pull *ndr;
+ enum ndr_err_code ndr_err;
+ uint32_t pad;
+
+ pad = pkt_auth_blob->length - (DCERPC_AUTH_TRAILER_LENGTH + pkt->auth_length);
+
+ /* paranoia check for pad size. This would be caught anyway by
+ the ndr_pull_advance() a few lines down, but it scared
+ Jeremy enough for him to call me, so we might as well check
+ it now, just to prevent someone posting a bogus YouTube
+ video in the future.
+ */
+ if (pad > pkt_auth_blob->length) {
+ return NT_STATUS_INFO_LENGTH_MISMATCH;
+ }
+
+ *auth_length = pkt_auth_blob->length - pad;
+
+ ndr = ndr_pull_init_blob(pkt_auth_blob, mem_ctx);
+ if (!ndr) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (!(pkt->drep[0] & DCERPC_DREP_LE)) {
+ ndr->flags |= LIBNDR_FLAG_BIGENDIAN;
+ }
+
+ ndr_err = ndr_pull_advance(ndr, pad);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(ndr);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ ndr_err = ndr_pull_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, auth);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(ndr);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ if (check_pad && pad != auth->auth_pad_length) {
+ DEBUG(1,(__location__ ": WARNING: pad length mismatch. Calculated %u got %u\n",
+ (unsigned)pad, (unsigned)auth->auth_pad_length));
+ }
+
+ DEBUG(6,(__location__ ": auth_pad_length %u\n",
+ (unsigned)auth->auth_pad_length));
+
+ talloc_steal(mem_ctx, auth->credentials.data);
+ talloc_free(ndr);
+
+ return NT_STATUS_OK;
+}
diff --git a/source3/Makefile.in b/source3/Makefile.in
index e44e121..b980b7f 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -564,6 +564,7 @@ LIBMSRPC_GEN_OBJ = librpc/gen_ndr/cli_lsa.o \
librpc/gen_ndr/cli_epmapper.o \
librpc/gen_ndr/cli_drsuapi.o \
librpc/gen_ndr/cli_spoolss.o \
+ ../librpc/rpc/dcerpc_util.o \
$(LIBNDR_GEN_OBJ) \
$(RPCCLIENT_NDR_OBJ)
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index 25bef47..d000692 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -88,8 +88,10 @@ typedef struct _input_data {
* is collected via multiple writes until a complete
* pdu is seen, then the data is copied into the in_data
* structure. The maximum size of this is 0x1630 (RPC_MAX_PDU_FRAG_LEN).
+ * If length is zero, then we are at the start of a new
+ * pdu.
*/
- uint8_t *current_in_pdu;
+ DATA_BLOB pdu;
/*
* The amount of data needed to complete the in_pdu.
@@ -99,13 +101,6 @@ typedef struct _input_data {
uint32 pdu_needed_len;
/*
- * The amount of data received so far in the in_pdu.
- * If this is zero, then we are at the start of a new
- * pdu.
- */
- uint32 pdu_received_len;
-
- /*
* This is the collection of input data with all
* the rpc headers and auth footers removed.
* The maximum length of this (1Mb) is strictly enforced.
@@ -173,9 +168,6 @@ typedef struct pipes_struct {
PIPE_RPC_FNS *contexts;
- RPC_HDR hdr; /* Incoming RPC header. */
- RPC_HDR_REQ hdr_req; /* Incoming request header. */
-
struct pipe_auth_data auth;
/*
@@ -227,6 +219,12 @@ typedef struct pipes_struct {
/* handle database to use on this pipe. */
struct handle_list *pipe_handles;
+ /* call id retrieved from the pdu header */
+ uint32_t call_id;
+
+ /* operation number retrieved from the rpc header */
+ uint16_t opnum;
+
/* private data for the interface implementation */
void *private_data;
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c0ff722..d7b70cb 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2931,6 +2931,18 @@ void flush_negative_conn_cache_for_domain(const char *domain);
const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code);
NTSTATUS dcerpc_fault_to_nt_status(uint32_t fault_code);
+/* The following definitions come from ../librpc/rpc/dcerpc_util.c */
+
+void dcerpc_set_frag_length(DATA_BLOB *blob, uint16_t v);
+uint16_t dcerpc_get_frag_length(const DATA_BLOB *blob);
+void dcerpc_set_auth_length(DATA_BLOB *blob, uint16_t v);
+NTSTATUS dcerpc_pull_auth_trailer(struct ncacn_packet *pkt,
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *pkt_auth_blob,
+ struct dcerpc_auth *auth,
+ uint32_t *auth_length,
+ bool check_pad);
+
/* The following definitions come from libsmb/dsgetdcname.c */
void debug_dsdcinfo_flags(int lvl, uint32_t flags);
@@ -4836,11 +4848,17 @@ NTSTATUS rpc_api_pipe_req_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
NTSTATUS dcerpc_push_ncacn_packet(TALLOC_CTX *mem_ctx,
enum dcerpc_pkt_type ptype,
uint8_t pfc_flags,
- uint16_t frag_length,
uint16_t auth_length,
uint32_t call_id,
- union dcerpc_payload u,
+ union dcerpc_payload *u,
DATA_BLOB *blob);
+NTSTATUS dcerpc_push_ncacn_packet_header(TALLOC_CTX *mem_ctx,
+ enum dcerpc_pkt_type ptype,
+ uint8_t pfc_flags,
+ uint16_t frag_length,
+ uint16_t auth_length,
+ uint32_t call_id,
+ DATA_BLOB *blob);
NTSTATUS dcerpc_pull_ncacn_packet(TALLOC_CTX *mem_ctx,
const DATA_BLOB *blob,
struct ncacn_packet *r);
@@ -5084,20 +5102,9 @@ const struct ndr_interface_table *get_iface_from_syntax(
const struct ndr_syntax_id *syntax);
const char *get_pipe_name_from_syntax(TALLOC_CTX *mem_ctx,
const struct ndr_syntax_id *syntax);
-void init_rpc_hdr(RPC_HDR *hdr, enum dcerpc_pkt_type pkt_type, uint8 flags,
- uint32 call_id, int data_len, int auth_len);
-bool smb_io_rpc_hdr(const char *desc, RPC_HDR *rpc, prs_struct *ps, int depth);
NTSTATUS dcerpc_pull_dcerpc_bind(TALLOC_CTX *mem_ctx,
const DATA_BLOB *blob,
struct dcerpc_bind *r);
-void init_rpc_hdr_ba(RPC_HDR_BA *rpc,
- uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
- const char *pipe_addr,
- uint8 num_results, uint16 result, uint16 reason,
- const struct ndr_syntax_id *transfer);
-bool smb_io_rpc_hdr_ba(const char *desc, RPC_HDR_BA *rpc, prs_struct *ps, int depth);
-void init_rpc_hdr_req(RPC_HDR_REQ *hdr, uint32 alloc_hint, uint16 opnum);
-bool smb_io_rpc_hdr_req(const char *desc, RPC_HDR_REQ *rpc, prs_struct *ps, int depth);
bool smb_io_rpc_hdr_resp(const char *desc, RPC_HDR_RESP *rpc, prs_struct *ps, int depth);
void init_rpc_hdr_auth(RPC_HDR_AUTH *rai,
uint8 auth_type, uint8 auth_level,
@@ -5138,9 +5145,8 @@ void *_policy_handle_find(struct pipes_struct *p,
/* The following definitions come from rpc_server/srv_pipe.c */
bool create_next_pdu(pipes_struct *p);
-bool api_pipe_bind_auth3(pipes_struct *p, prs_struct *rpc_in_p);
+bool api_pipe_bind_auth3(pipes_struct *p, struct ncacn_packet *pkt);
bool setup_fault_pdu(pipes_struct *p, NTSTATUS status);
-bool setup_cancel_ack_reply(pipes_struct *p, prs_struct *rpc_in_p);
NTSTATUS rpc_pipe_register_commands(int version, const char *clnt,
const char *srv,
const struct ndr_syntax_id *interface,
@@ -5150,13 +5156,10 @@ NTSTATUS rpc_srv_register(int version, const char *clnt,
const struct ndr_interface_table *iface,
const struct api_struct *cmds, int size);
bool is_known_pipename(const char *cli_filename, struct ndr_syntax_id *syntax);
-bool api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p);
-bool api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p);
-bool api_pipe_ntlmssp_auth_process(pipes_struct *p, prs_struct *rpc_in,
- uint32 *p_ss_padding_len, NTSTATUS *pstatus);
-bool api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss_padding_len);
+bool api_pipe_bind_req(pipes_struct *p, struct ncacn_packet *pkt);
+bool api_pipe_alter_context(pipes_struct *p, struct ncacn_packet *pkt);
void free_pipe_rpc_context( PIPE_RPC_FNS *list );
-bool api_pipe_request(pipes_struct *p);
+bool api_pipe_request(pipes_struct *p, struct ncacn_packet *pkt);
/* The following definitions come from rpc_server/srv_pipe_hnd.c */
diff --git a/source3/include/rpc_dce.h b/source3/include/rpc_dce.h
index ade4728..2023827 100644
--- a/source3/include/rpc_dce.h
+++ b/source3/include/rpc_dce.h
@@ -33,27 +33,8 @@
#define RPC_IFACE_LEN (UUID_SIZE + 4)
-/* RPC_HDR - dce rpc header */
-typedef struct rpc_hdr_info {
- uint8 major; /* 5 - RPC major version */
- uint8 minor; /* 0 - RPC minor version */
- uint8 pkt_type; /* dcerpc_pkt_type - RPC response packet */
- uint8 flags; /* DCE/RPC flags */
- uint8 pack_type[4]; /* 0x1000 0000 - little-endian packed data representation */
- uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */
- uint16 auth_len; /* 0 - authentication length */
- uint32 call_id; /* call identifier. matches 12th uint32 of incoming RPC data. */
-} RPC_HDR;
-
#define RPC_HEADER_LEN 16
-/* RPC_HDR_REQ - ms request rpc header */
-typedef struct rpc_hdr_req_info {
- uint32 alloc_hint; /* allocation hint - data size (bytes) minus header and tail. */
- uint16 context_id; /* presentation context identifier */
- uint16 opnum; /* opnum */
-} RPC_HDR_REQ;
-
#define RPC_HDR_REQ_LEN 8
/* RPC_HDR_RESP - ms response rpc header */
@@ -66,36 +47,6 @@ typedef struct rpc_hdr_resp_info {
#define RPC_HDR_RESP_LEN 8
-/* RPC_HDR_FAULT - fault rpc header */
-typedef struct rpc_hdr_fault_info {
- NTSTATUS status;
- uint32 reserved; /* 0x0000 0000 */
-} RPC_HDR_FAULT;
-
-#define RPC_HDR_FAULT_LEN 8
-
-/* this seems to be the same string name depending on the name of the pipe,
- * but is more likely to be linked to the interface name
- * "srvsvc", "\\PIPE\\ntsvcs"
- * "samr", "\\PIPE\\lsass"
- * "wkssvc", "\\PIPE\\wksvcs"
- * "NETLOGON", "\\PIPE\\NETLOGON"
- */
-/* RPC_ADDR_STR */
-typedef struct rpc_addr_info {
- uint16 len; /* length of the string including null terminator */
- fstring str; /* the string above in single byte, null terminated form */
-} RPC_ADDR_STR;
-
-/* RPC_HDR_BBA - bind acknowledge, and alter context response. */
-typedef struct rpc_hdr_bba_info {
- uint16 max_tsize; /* maximum transmission fragment size (0x1630) */
- uint16 max_rsize; /* max receive fragment size (0x1630) */
- uint32 assoc_gid; /* associated group id (0x0) */
-} RPC_HDR_BBA;
-
-#define RPC_HDR_BBA_LEN 8
-
/* RPC_HDR_AUTH */
typedef struct rpc_hdr_auth_info {
uint8 auth_type; /* See XXX_AUTH_TYPE above. */
@@ -107,35 +58,4 @@ typedef struct rpc_hdr_auth_info {
#define RPC_HDR_AUTH_LEN 8
-/*
- * The following length is 8 bytes RPC_HDR_BBA_LEN +
- * 4 bytes size of context count +
- * (context_count * (4 bytes of context_id, size of transfer syntax count + RPC_IFACE_LEN bytes +
- * (transfer_syntax_count * RPC_IFACE_LEN bytes)))
- */
-
-#define RPC_HDR_RB_LEN(rpc_hdr_rb) (RPC_HDR_BBA_LEN + 4 + \
- ((rpc_hdr_rb)->num_contexts) * (4 + RPC_IFACE_LEN + (((rpc_hdr_rb)->ctx_list->num_transfer_syntaxes)*RPC_IFACE_LEN)))
-
-/* RPC_RESULTS - can only cope with one reason, right now... */
-typedef struct rpc_results_info {
- /* uint8[] # 4-byte alignment padding, against SMB header */
-
- uint8 num_results; /* the number of results (0x01) */
-
- /* uint8[] # 4-byte alignment padding, against SMB header */
-
- uint16 result; /* result (0x00 = accept) */
- uint16 reason; /* reason (0x00 = no reason specified) */
-} RPC_RESULTS;
-
-/* RPC_HDR_BA */
-typedef struct rpc_hdr_ba_info {
- RPC_HDR_BBA bba;
-
- RPC_ADDR_STR addr ; /* the secondary address string, as described earlier */
- RPC_RESULTS res ; /* results and reasons */
- struct ndr_syntax_id transfer; /* the transfer syntax from the request */
-} RPC_HDR_BA;
-
#endif /* _DCE_RPC_H */
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 20f2246..91eb767 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -300,10 +300,9 @@ static bool rpc_grow_buffer(prs_struct *pdu, size_t size)
NTSTATUS dcerpc_push_ncacn_packet(TALLOC_CTX *mem_ctx,
enum dcerpc_pkt_type ptype,
uint8_t pfc_flags,
- uint16_t frag_length,
uint16_t auth_length,
uint32_t call_id,
- union dcerpc_payload u,
+ union dcerpc_payload *u,
DATA_BLOB *blob)
{
struct ncacn_packet r;
@@ -317,10 +316,9 @@ NTSTATUS dcerpc_push_ncacn_packet(TALLOC_CTX *mem_ctx,
r.drep[1] = 0;
r.drep[2] = 0;
r.drep[3] = 0;
- r.frag_length = frag_length;
r.auth_length = auth_length;
r.call_id = call_id;
- r.u = u;
+ r.u = *u;
ndr_err = ndr_push_struct_blob(blob, mem_ctx, &r,
(ndr_push_flags_fn_t)ndr_push_ncacn_packet);
@@ -328,13 +326,54 @@ NTSTATUS dcerpc_push_ncacn_packet(TALLOC_CTX *mem_ctx,
return ndr_map_error2ntstatus(ndr_err);
}
+ dcerpc_set_frag_length(blob, blob->length);
+
+
if (DEBUGLEVEL >= 10) {
+ /* set frag len for print function */
+ r.frag_length = blob->length;
NDR_PRINT_DEBUG(ncacn_packet, &r);
}
return NT_STATUS_OK;
}
+NTSTATUS dcerpc_push_ncacn_packet_header(TALLOC_CTX *mem_ctx,
+ enum dcerpc_pkt_type ptype,
+ uint8_t pfc_flags,
+ uint16_t frag_length,
+ uint16_t auth_length,
+ uint32_t call_id,
+ DATA_BLOB *blob)
+{
+ struct ncacn_packet_header r;
+ enum ndr_err_code ndr_err;
+
+ r.rpc_vers = 5;
+ r.rpc_vers_minor = 0;
+ r.ptype = ptype;
+ r.pfc_flags = pfc_flags;
+ r.drep[0] = DCERPC_DREP_LE;
+ r.drep[1] = 0;
+ r.drep[2] = 0;
+ r.drep[3] = 0;
+ r.frag_length = frag_length;
+ r.auth_length = auth_length;
+ r.call_id = call_id;
+
+ ndr_err = ndr_push_struct_blob(blob, mem_ctx, &r,
+ (ndr_push_flags_fn_t)ndr_push_ncacn_packet_header);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_DEBUG(ncacn_packet_header, &r);
+ }
+
+ return NT_STATUS_OK;
+}
+
/*******************************************************************
*******************************************************************/
@@ -2024,7 +2063,6 @@ static NTSTATUS create_bind_or_alt_ctx_internal(enum dcerpc_pkt_type ptype,
const DATA_BLOB *auth_info)
{
uint16 auth_len = auth_info->length;
- uint16 frag_len = 0;
NTSTATUS status;
union dcerpc_payload u;
DATA_BLOB blob;
@@ -2043,17 +2081,13 @@ static NTSTATUS create_bind_or_alt_ctx_internal(enum dcerpc_pkt_type ptype,
u.bind.ctx_list = ctx_list;
u.bind.auth_info = *auth_info;
- /* Start building the frag length. */
- frag_len = RPC_HEADER_LEN + RPC_HDR_RB_LEN(&u.bind) + auth_len;
-
status = dcerpc_push_ncacn_packet(rpc_out->mem_ctx,
ptype,
DCERPC_PFC_FLAG_FIRST |
DCERPC_PFC_FLAG_LAST,
- frag_len,
auth_len ? auth_len - RPC_HDR_AUTH_LEN : 0,
rpc_call_id,
- u,
+ &u,
&blob);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("create_bind_or_alt_ctx_internal: failed to marshall RPC_HDR_RB.\n"));
@@ -2493,15 +2527,18 @@ static NTSTATUS prepare_next_frag(struct rpc_api_pipe_req_state *state,
status = dcerpc_push_ncacn_packet(prs_get_mem_context(&state->outgoing_frag),
DCERPC_PKT_REQUEST,
flags,
- frag_len,
--
Samba Shared Repository
More information about the samba-cvs
mailing list