- add 'print' to the DCERPC binding strings
[samba.git] / source4 / librpc / rpc / dcerpc_util.c
index bc10f4e92d494b71db6ca64b7c8e990cae78ce71..96f0b959e74fb253874652ef51cc3773a3affb97 100644 (file)
@@ -223,8 +223,7 @@ const struct dcerpc_interface_table *idl_iface_by_uuid(const char *uuid)
 */
 NTSTATUS dcerpc_push_auth(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, 
                          struct dcerpc_packet *pkt,
-                         struct dcerpc_auth *auth_info,
-                         unsigned flags)
+                         struct dcerpc_auth *auth_info)
 {
        NTSTATUS status;
        struct ndr_push *ndr;
@@ -234,7 +233,7 @@ NTSTATUS dcerpc_push_auth(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (flags & DCERPC_PUSH_BIGENDIAN) {
+       if (!(pkt->drep[0] & DCERPC_DREP_LE)) {
                ndr->flags |= LIBNDR_FLAG_BIGENDIAN;
        }
 
@@ -277,6 +276,7 @@ static const struct {
        {"sign", DCERPC_SIGN},
        {"seal", DCERPC_SEAL},
        {"validate", DCERPC_DEBUG_VALIDATE_BOTH},
+       {"print", DCERPC_DEBUG_PRINT_BOTH},
        {"bigendian", DCERPC_PUSH_BIGENDIAN}
 };
 
@@ -304,7 +304,7 @@ const char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_bindi
        /* this is a *really* inefficent way of dealing with strings,
           but this is rarely called and the strings are always short,
           so I don't care */
-       for (i=0;b->options[i];i++) {
+       for (i=0;b->options && b->options[i];i++) {
                s = talloc_asprintf(mem_ctx, "%s%s,", s, b->options[i]);
                if (!s) return NULL;
        }
@@ -413,6 +413,7 @@ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_
                                for (k=i;b->options[k];k++) {
                                        b->options[k] = b->options[k+1];
                                }
+                               i--;
                                break;
                        }
                }
@@ -422,7 +423,7 @@ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_
 }
 
 
-/* open a rpc connection to a rpc pipe on SMP using the binding
+/* open a rpc connection to a rpc pipe on SMB using the binding
    structure to determine the endpoint and options */
 static NTSTATUS dcerpc_pipe_connect_ncacn_np(struct dcerpc_pipe **p, 
                                             struct dcerpc_binding *binding,
@@ -578,6 +579,11 @@ NTSTATUS dcerpc_pipe_connect_b(struct dcerpc_pipe **p,
                break;
        }
 
+       /* remember the binding string for possible secondary connections */
+       if (NT_STATUS_IS_OK(status)) {
+               (*p)->binding_string = dcerpc_binding_string((*p)->mem_ctx, binding);
+       }
+
        return status;
 }
 
@@ -613,3 +619,37 @@ NTSTATUS dcerpc_pipe_connect(struct dcerpc_pipe **p,
        talloc_destroy(mem_ctx);
        return status;
 }
+
+
+/*
+  create a secondary dcerpc connection on SMB
+  the secondary connection will be on the same SMB connection, but
+  use a new fnum
+*/
+NTSTATUS dcerpc_secondary_smb(struct dcerpc_pipe *p, struct dcerpc_pipe **p2,
+                             const char *pipe_name,
+                             const char *pipe_uuid,
+                             uint32 pipe_version)
+{
+       NTSTATUS status;
+       struct cli_tree *tree;
+
+       tree = dcerpc_smb_tree(p);
+       if (!tree) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }
+
+       status = dcerpc_pipe_open_smb(p2, tree, pipe_name);
+       if (!NT_STATUS_IS_OK(status)) {
+                return status;
+        }
+       
+       (*p2)->flags = p->flags;
+
+       status = dcerpc_bind_auth_none(*p2, pipe_uuid, pipe_version);
+       if (!NT_STATUS_IS_OK(status)) {
+                return status;
+        }
+
+       return NT_STATUS_OK;
+}