s4-rpc: added NDR64 support
authorAndrew Tridgell <tridge@samba.org>
Thu, 17 Sep 2009 16:09:48 +0000 (09:09 -0700)
committerAndrew Tridgell <tridge@samba.org>
Thu, 17 Sep 2009 22:19:27 +0000 (15:19 -0700)
This adds support for the nd464 binding string option

librpc/rpc/binding.c
source4/librpc/rpc/dcerpc.c
source4/librpc/rpc/dcerpc.h
source4/librpc/rpc/dcerpc_auth.c
source4/librpc/rpc/dcerpc_smb.c
source4/librpc/rpc/dcerpc_util.c

index 652927b2c5a04c326173ffa5ebd3dbb4ceb94d33..d773b8b59134ee6692eb05f9722355059e7a3531 100644 (file)
@@ -84,7 +84,8 @@ static const struct {
        {"padcheck", DCERPC_DEBUG_PAD_CHECK},
        {"bigendian", DCERPC_PUSH_BIGENDIAN},
        {"smb2", DCERPC_SMB2},
-       {"hdrsign", DCERPC_HEADER_SIGNING}
+       {"hdrsign", DCERPC_HEADER_SIGNING},
+       {"ndr64", DCERPC_NDR64}
 };
 
 const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
index 819edc8eaaf790f1421797a44ba8229ce9e3411a..87d44384ce5541465162eb5a4f6ba2eb9544f550 100644 (file)
@@ -182,6 +182,10 @@ static struct ndr_pull *ndr_pull_init_flags(struct dcerpc_connection *c,
                ndr->flags |= LIBNDR_FLAG_REF_ALLOC;
        }
 
+       if (c->flags & DCERPC_NDR64) {
+               ndr->flags |= LIBNDR_FLAG_NDR64;
+       }
+
        return ndr;
 }
 
@@ -368,6 +372,10 @@ static NTSTATUS ncacn_push_request_sign(struct dcerpc_connection *c,
                ndr->flags |= LIBNDR_FLAG_BIGENDIAN;
        }
 
+       if (c->flags & DCERPC_NDR64) {
+               ndr->flags |= LIBNDR_FLAG_NDR64;
+       }
+
        if (pkt->pfc_flags & DCERPC_PFC_FLAG_OBJECT_UUID) {
                ndr->flags |= LIBNDR_FLAG_OBJECT_PRESENT;
                hdr_size += 16;
@@ -1378,6 +1386,10 @@ struct rpc_request *dcerpc_ndr_request_send(struct dcerpc_pipe *p,
                push->flags |= LIBNDR_FLAG_BIGENDIAN;
        }
 
+       if (p->conn->flags & DCERPC_NDR64) {
+               push->flags |= LIBNDR_FLAG_NDR64;
+       }
+
        /* push the structure into a blob */
        ndr_err = call->ndr_push(push, NDR_IN, r);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
index ea92bcc93a4f1233f9d77598ad01ecc6268bd02b..b539fc2620e30858fd64dc48cbf775fb28886112 100644 (file)
@@ -172,6 +172,9 @@ struct dcerpc_pipe {
 /* this triggers the DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN flag in the bind request */
 #define DCERPC_HEADER_SIGNING          (1<<20)
 
+/* use NDR64 transport */
+#define DCERPC_NDR64                   (1<<21)
+
 /* this describes a binding to a particular transport/pipe */
 struct dcerpc_binding {
        enum dcerpc_transport_t transport;
index 14f0f9deb4b2dd22b8ebf75b4b2044da4812810b..bca7a8d186044ebf4b808902e80b183dd6e3f172 100644 (file)
   return the rpc syntax and transfer syntax given the pipe uuid and version
 */
 static NTSTATUS dcerpc_init_syntaxes(const struct ndr_interface_table *table,
-                             struct ndr_syntax_id *syntax,
-                             struct ndr_syntax_id *transfer_syntax)
+                                    uint32_t pipe_flags,
+                                    struct ndr_syntax_id *syntax,
+                                    struct ndr_syntax_id *transfer_syntax)
 {
        syntax->uuid = table->syntax_id.uuid;
        syntax->if_version = table->syntax_id.if_version;
 
-       *transfer_syntax = ndr_transfer_syntax;
+       if (pipe_flags & DCERPC_NDR64) {
+               *transfer_syntax = ndr64_transfer_syntax;
+       } else {
+               *transfer_syntax = ndr_transfer_syntax;
+       }
 
        return NT_STATUS_OK;
 }
@@ -59,7 +64,7 @@ struct composite_context *dcerpc_bind_auth_none_send(TALLOC_CTX *mem_ctx,
        c = composite_create(mem_ctx, p->conn->event_ctx);
        if (c == NULL) return NULL;
 
-       c->status = dcerpc_init_syntaxes(table,
+       c->status = dcerpc_init_syntaxes(table, p->conn->flags,
                                         &syntax, &transfer_syntax);
        if (!NT_STATUS_IS_OK(c->status)) {
                DEBUG(2,("Invalid uuid string in "
@@ -242,7 +247,7 @@ struct composite_context *dcerpc_bind_auth_send(TALLOC_CTX *mem_ctx,
 
        state->pipe = p;
 
-       c->status = dcerpc_init_syntaxes(table,
+       c->status = dcerpc_init_syntaxes(table, p->conn->flags,
                                         &syntax,
                                         &transfer_syntax);
        if (!composite_is_ok(c)) return c;
index 8b221747aca1532daf92c64a0cc9863a11f06794..f4e6b8c3dd3bb697a8c8ba7165c1008614c0f15c 100644 (file)
@@ -325,7 +325,7 @@ static NTSTATUS smb_send_request(struct dcerpc_connection *c, DATA_BLOB *blob,
        union smb_write io;
        struct smbcli_request *req;
 
-       if (smb->dead) {
+       if (!smb || smb->dead) {
                return NT_STATUS_CONNECTION_DISCONNECTED;
        }
 
@@ -388,6 +388,7 @@ static NTSTATUS smb_shutdown_pipe(struct dcerpc_connection *c, NTSTATUS status)
        }
 
        talloc_free(smb);
+       c->transport.private_data = NULL;
 
        return status;
 }
@@ -398,6 +399,7 @@ static NTSTATUS smb_shutdown_pipe(struct dcerpc_connection *c, NTSTATUS status)
 static const char *smb_peer_name(struct dcerpc_connection *c)
 {
        struct smb_private *smb = (struct smb_private *)c->transport.private_data;
+       if (smb == NULL) return "";
        return smb->server_name;
 }
 
@@ -407,6 +409,7 @@ static const char *smb_peer_name(struct dcerpc_connection *c)
 static const char *smb_target_hostname(struct dcerpc_connection *c)
 {
        struct smb_private *smb = talloc_get_type(c->transport.private_data, struct smb_private);
+       if (smb == NULL) return "";
        return smb->tree->session->transport->socket->hostname;
 }
 
@@ -417,6 +420,7 @@ static NTSTATUS smb_session_key(struct dcerpc_connection *c, DATA_BLOB *session_
 {
        struct smb_private *smb = (struct smb_private *)c->transport.private_data;
 
+       if (smb == NULL) return NT_STATUS_CONNECTION_DISCONNECTED;
        if (smb->tree->session->user_session_key.data) {
                *session_key = smb->tree->session->user_session_key;
                return NT_STATUS_OK;
index 4524673449a83e71fcb1b7d1f112305ab0c86253..86c91535e7a96458dc35fec2c1748c94c98e1945 100644 (file)
@@ -736,7 +736,7 @@ _PUBLIC_ NTSTATUS dcerpc_secondary_context(struct dcerpc_pipe *p,
 
        p2->syntax = table->syntax_id;
 
-       p2->transfer_syntax = ndr_transfer_syntax;
+       p2->transfer_syntax = p->transfer_syntax;
 
        p2->binding = talloc_reference(p2, p->binding);