summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-03-06 21:43:54 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:10:59 -0500
commit77ec3f684dc8563965ae5118ef5549925ea81d0f (patch)
tree6069494061404ddf873fdfcdfe82d86267c2e1b3 /source4
parentffae01d432c715961c44e499258ee2a9f7e3d5f1 (diff)
downloadsamba-77ec3f684dc8563965ae5118ef5549925ea81d0f.tar.gz
samba-77ec3f684dc8563965ae5118ef5549925ea81d0f.tar.bz2
samba-77ec3f684dc8563965ae5118ef5549925ea81d0f.zip
r5674: - Re-enable DCOM support.
- Always put IID in vtables (useful for asserts) - Add table to keep track of DCOM proxy classes - Bunch of smaller bug fixes (This used to be commit 26d5a0b92c66bc86d0c26f687f83fa712342ac32)
Diffstat (limited to 'source4')
-rw-r--r--source4/build/pidl/com_header.pm1
-rw-r--r--source4/build/pidl/dcom_proxy.pm30
-rw-r--r--source4/build/smb_build/main.pm1
-rw-r--r--source4/include/includes.h3
-rw-r--r--source4/lib/com/com.h13
-rw-r--r--source4/lib/com/config.mk11
-rw-r--r--source4/lib/com/dcom/main.c (renamed from source4/lib/dcom/common/main.c)250
-rw-r--r--source4/lib/com/dcom/tables.c50
-rw-r--r--source4/lib/dcom/common/dcom.h60
-rw-r--r--source4/lib/dcom/config.mk19
-rw-r--r--source4/librpc/idl/dcom.idl2
-rw-r--r--source4/librpc/idl/orpc.idl4
-rw-r--r--source4/librpc/ndr/ndr_orpc.h (renamed from source4/librpc/ndr/ndr_dcom.h)5
-rw-r--r--source4/torture/com/simple.c15
-rw-r--r--source4/torture/config.mk6
15 files changed, 190 insertions, 280 deletions
diff --git a/source4/build/pidl/com_header.pm b/source4/build/pidl/com_header.pm
index 18df78f90d..1c7194d85c 100644
--- a/source4/build/pidl/com_header.pm
+++ b/source4/build/pidl/com_header.pm
@@ -65,6 +65,7 @@ sub HeaderVTable($)
}
$res .= "\n";
$res .= "struct $interface->{NAME}_vtable {\n";
+ $res .= "\tstruct GUID iid;\n";
$res .= "\t" . uc($interface->{NAME}) . "_METHODS\n";
$res .= "};\n\n";
diff --git a/source4/build/pidl/dcom_proxy.pm b/source4/build/pidl/dcom_proxy.pm
index 1a1b8de064..8cc5547680 100644
--- a/source4/build/pidl/dcom_proxy.pm
+++ b/source4/build/pidl/dcom_proxy.pm
@@ -43,8 +43,8 @@ sub ParseRegFunc($)
$res .= "static NTSTATUS dcom_proxy_$interface->{NAME}_init(void)
{
struct GUID base_iid;
- struct GUID iid;
- struct $interface->{NAME}_vtable proxy_vtable;";
+ struct $interface->{NAME}_vtable *proxy_vtable = talloc(talloc_autofree_context(), struct $interface->{NAME}_vtable);
+";
if (defined($interface->{BASE})) {
$res.= "
@@ -54,7 +54,7 @@ sub ParseRegFunc($)
base_vtable = dcom_proxy_vtable_by_iid(&base_iid);
if (base_vtable == NULL) {
- DEBUG(0, (\"No proxy registered for base interface\n\"));
+ DEBUG(0, (\"No proxy registered for base interface '$interface->{BASE}'\\n\"));
return NT_STATUS_FOOBAR;
}
@@ -69,9 +69,9 @@ sub ParseRegFunc($)
}
$res.= "
- GUID_from_string(DCERPC_" . (uc $interface->{NAME}) . "_UUID, &iid);
+ GUID_from_string(DCERPC_" . (uc $interface->{NAME}) . "_UUID, &proxy_vtable.iid);
- return dcom_register_proxy(&iid, &proxy_vtable);
+ return dcom_register_proxy(&proxy_vtable);
}\n\n";
}
@@ -102,10 +102,13 @@ static $fn->{RETURN_TYPE} dcom_proxy_$interface->{NAME}_$name(struct $interface-
";
# Put arguments into r
- foreach my $a (@{$fn->{DATA}}) {
- next if ($a->{NAME} eq "ORPCthis");
+ foreach my $a (@{$fn->{ELEMENTS}}) {
next unless (util::has_property($a, "in"));
- $res .= "\tr.in.$a->{NAME} = $a->{NAME};\n";
+ if (typelist::typeIs($a->{TYPE}, "INTERFACE")) {
+ $res .="\tNDR_CHECK(dcom_OBJREF_from_IUnknown(&r.in.$a->{NAME}.obj, $a->{NAME}));\n";
+ } else {
+ $res .= "\tr.in.$a->{NAME} = $a->{NAME};\n";
+ }
}
$res .="
@@ -122,10 +125,15 @@ static $fn->{RETURN_TYPE} dcom_proxy_$interface->{NAME}_$name(struct $interface-
";
# Put r info back into arguments
- foreach my $a (@{$fn->{DATA}}) {
- next if ($a->{NAME} eq "ORPCthat");
+ foreach my $a (@{$fn->{ELEMENTS}}) {
next unless (util::has_property($a, "out"));
- $res .= "\t*$a->{NAME} = r.out.$a->{NAME};\n";
+
+ if (typelist::typeIs($a->{TYPE}, "INTERFACE")) {
+ $res .="\tNDR_CHECK(dcom_IUnknown_from_OBJREF(d->ctx, &$a->{NAME}, r.out.$a->{NAME}.obj));\n";
+ } else {
+ $res .= "\t*$a->{NAME} = r.out.$a->{NAME};\n";
+ }
+
}
if ($fn->{RETURN_TYPE} eq "NTSTATUS") {
diff --git a/source4/build/smb_build/main.pm b/source4/build/smb_build/main.pm
index c401bc8de6..b6e29a7ace 100644
--- a/source4/build/smb_build/main.pm
+++ b/source4/build/smb_build/main.pm
@@ -57,7 +57,6 @@ sub smb_build_main($)
"libcli/libsmb.mk",
"libcli/config.mk",
"libcli/security/config.mk",
- "lib/dcom/config.mk",
"lib/com/config.mk",
"scripting/swig/config.mk",
);
diff --git a/source4/include/includes.h b/source4/include/includes.h
index be100c6390..9a802aebd0 100644
--- a/source4/include/includes.h
+++ b/source4/include/includes.h
@@ -126,12 +126,13 @@ extern int errno;
#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/ndr_dcerpc.h"
+#include "librpc/ndr/ndr_orpc.h"
+#include "librpc/gen_ndr/ndr_orpc.h"
#include "librpc/rpc/dcerpc.h"
#include "smb_interfaces.h"
#include "ntvfs/ntvfs.h"
#include "cli_context.h"
#include "lib/com/com.h"
-#include "lib/dcom/common/dcom.h"
#define malloc_p(type) (type *)malloc(sizeof(type))
#define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
diff --git a/source4/lib/com/com.h b/source4/lib/com/com.h
index be7dcde5b5..a056d1d9ee 100644
--- a/source4/lib/com/com.h
+++ b/source4/lib/com/com.h
@@ -21,8 +21,21 @@
#ifndef _COM_H /* _COM_H */
#define _COM_H
+struct IUnknown_vtable;
+
struct com_context
{
+ struct {
+ const char *domain;
+ const char *user;
+ const char *password;
+ struct dcom_object_exporter {
+ uint64_t oxid;
+ struct DUALSTRINGARRAY bindings;
+ struct dcerpc_pipe *pipe;
+ struct dcom_object_exporter *prev, *next;
+ } *object_exporters;
+ } dcom;
};
typedef struct IUnknown *(*get_class_object_function) (const struct GUID *clsid);
diff --git a/source4/lib/com/config.mk b/source4/lib/com/config.mk
index 006ea212c1..a4fe891864 100644
--- a/source4/lib/com/config.mk
+++ b/source4/lib/com/config.mk
@@ -4,6 +4,17 @@ INIT_OBJ_FILES = \
lib/com/rot.o \
lib/com/main.o
+################################################
+# Start SUBSYSTEM LIBDCOM
+[SUBSYSTEM::LIBDCOM]
+INIT_OBJ_FILES = \
+ lib/com/dcom/main.o \
+ lib/com/dcom/tables.o
+REQUIRED_SUBSYSTEMS = LIBCOM DCOM_PROXY_DCOM RPC_NDR_REMACT \
+ RPC_NDR_OXIDRESOLVER
+# End SUBSYSTEM LIBDCOM
+################################################
+
[MODULE::com_simple]
SUBSYSTEM = LIBCOM
INIT_OBJ_FILES = lib/com/classes/simple.o
diff --git a/source4/lib/dcom/common/main.c b/source4/lib/com/dcom/main.c
index 315912ba3c..b8c2eef82c 100644
--- a/source4/lib/dcom/common/main.c
+++ b/source4/lib/com/dcom/main.c
@@ -25,6 +25,7 @@
#include "librpc/gen_ndr/ndr_remact.h"
#include "librpc/gen_ndr/ndr_oxidresolver.h"
#include "librpc/gen_ndr/ndr_dcom.h"
+#include "librpc/gen_ndr/com_dcom.h"
#define DCOM_NEGOTIATED_PROTOCOLS { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NCALRPC }
@@ -57,7 +58,7 @@ static NTSTATUS dcerpc_binding_from_STRINGBINDING(TALLOC_CTX *mem_ctx, struct dc
return NT_STATUS_OK;
}
-static NTSTATUS dcom_connect_host(struct dcom_context *ctx, struct dcerpc_pipe **p, const char *server)
+static NTSTATUS dcom_connect_host(struct com_context *ctx, struct dcerpc_pipe **p, const char *server)
{
struct dcerpc_binding bd;
enum dcerpc_transport_t available_transports[] = { NCACN_IP_TCP, NCACN_NP };
@@ -65,12 +66,20 @@ static NTSTATUS dcom_connect_host(struct dcom_context *ctx, struct dcerpc_pipe *
NTSTATUS status;
TALLOC_CTX *mem_ctx = talloc_init("dcom_connect");
+ if (server == NULL) {
+ bd.transport = NCALRPC;
+ return dcerpc_pipe_connect_b(p, &bd,
+ DCERPC_IREMOTEACTIVATION_UUID,
+ DCERPC_IREMOTEACTIVATION_VERSION,
+ ctx->dcom.domain, ctx->dcom.user, ctx->dcom.password);
+ }
+
/* Allow server name to contain a binding string */
if (NT_STATUS_IS_OK(dcerpc_parse_binding(mem_ctx, server, &bd))) {
status = dcerpc_pipe_connect_b(p, &bd,
DCERPC_IREMOTEACTIVATION_UUID,
DCERPC_IREMOTEACTIVATION_VERSION,
- ctx->domain, ctx->user, ctx->password);
+ ctx->dcom.domain, ctx->dcom.user, ctx->dcom.password);
talloc_free(mem_ctx);
return status;
@@ -80,14 +89,6 @@ static NTSTATUS dcom_connect_host(struct dcom_context *ctx, struct dcerpc_pipe *
ZERO_STRUCT(bd);
bd.host = server;
- if (server == NULL) {
- bd.transport = NCALRPC;
- return dcerpc_pipe_connect_b(p, &bd,
- DCERPC_IREMOTEACTIVATION_UUID,
- DCERPC_IREMOTEACTIVATION_VERSION,
- ctx->domain, ctx->user, ctx->password);
- }
-
for (i = 0; i < ARRAY_SIZE(available_transports); i++)
{
bd.transport = available_transports[i];
@@ -95,7 +96,7 @@ static NTSTATUS dcom_connect_host(struct dcom_context *ctx, struct dcerpc_pipe *
status = dcerpc_pipe_connect_b(p, &bd,
DCERPC_IREMOTEACTIVATION_UUID,
DCERPC_IREMOTEACTIVATION_VERSION,
- ctx->domain, ctx->user, ctx->password);
+ ctx->dcom.domain, ctx->dcom.user, ctx->dcom.password);
if (NT_STATUS_IS_OK(status)) {
return status;
@@ -105,46 +106,17 @@ static NTSTATUS dcom_connect_host(struct dcom_context *ctx, struct dcerpc_pipe *
return status;
}
-WERROR dcom_init(struct dcom_context **ctx, const char *domain, const char *user, const char *pass)
-{
- *ctx = talloc(NULL, struct dcom_context);
- (*ctx)->oxids = NULL;
- (*ctx)->domain = talloc_strdup(*ctx, domain);
- (*ctx)->user = talloc_strdup(*ctx, user);
- (*ctx)->password = talloc_strdup(*ctx, pass);
- (*ctx)->dcerpc_flags = 0;
-
- return WERR_OK;
-}
-
-struct dcom_object_exporter *oxid_mapping_by_oxid (struct dcom_context *ctx, uint64_t oxid)
+struct dcom_object_exporter *object_exporter_by_oxid(struct com_context *ctx, uint64_t oxid)
{
- struct dcom_object_exporter *m;
-
- for (m = ctx->oxids;m;m = m->next) {
- if (m->oxid == oxid) {
- break;
- }
- }
-
- /* Add oxid mapping if we couldn't find one */
- if (!m) {
- m = talloc_zero(ctx, struct dcom_object_exporter);
- m->oxid = oxid;
- DLIST_ADD(ctx->oxids, m);
- }
-
- return m;
+ return NULL; /* FIXME */
}
-WERROR dcom_ping(struct dcom_context *ctx)
+struct dcom_object_exporter *object_exporter_by_ip(struct com_context *ctx, struct IUnknown *ip)
{
- /* FIXME: If OID's waiting in queue, do a ComplexPing call */
- /* FIXME: otherwise, do a SimplePing call */
- return WERR_OK;
+ return NULL; /* FIXME */
}
-static WERROR dcom_create_object(struct dcom_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct dcom_interface_p ***ip, WERROR *results)
+WERROR dcom_create_object(struct com_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct IUnknown ***ip, WERROR *results)
{
uint16_t protseq[] = DCOM_NEGOTIATED_PROTOCOLS;
struct dcerpc_pipe *p;
@@ -154,10 +126,6 @@ static WERROR dcom_create_object(struct dcom_context *ctx, struct GUID *clsid, c
struct DUALSTRINGARRAY dualstring;
int i;
- if (!server) {
- return com_create_object(ctx, clsid, num_ifaces, iid, ip, results);
- }
-
status = dcom_connect_host(ctx, &p, server);
if (NT_STATUS_IS_ERR(status)) {
DEBUG(1, ("Unable to connect to %s - %s\n", server, nt_errstr(status)));
@@ -174,7 +142,7 @@ static WERROR dcom_create_object(struct dcom_context *ctx, struct GUID *clsid, c
r.in.protseq = protseq;
r.in.Interfaces = num_ifaces;
r.in.pIIDs = iid;
- r.out.ifaces = talloc_array(ctx, struct pMInterfacePointer, num_ifaces);
+ r.out.ifaces = talloc_array(ctx, struct MInterfacePointer, num_ifaces);
r.out.pdsaOxidBindings = &dualstring;
status = dcerpc_RemoteActivation(p, ctx, &r);
@@ -191,35 +159,33 @@ static WERROR dcom_create_object(struct dcom_context *ctx, struct GUID *clsid, c
return r.out.hr;
}
- *ip = talloc_array(ctx, struct dcom_interface_p *, num_ifaces);
+ *ip = talloc_array(ctx, struct IUnknown *, num_ifaces);
for (i = 0; i < num_ifaces; i++) {
results[i] = r.out.results[i];
(*ip)[i] = NULL;
if (W_ERROR_IS_OK(results[i])) {
- status = dcom_ifacep_from_OBJREF(ctx, &(*ip)[i], &r.out.ifaces[i].p->obj);
- if (NT_STATUS_IS_OK(status)) {
- (*ip)[i]->private_references = 1;
- } else {
+ status = dcom_IUnknown_from_OBJREF(ctx, &(*ip)[i], &r.out.ifaces[i].obj);
+ if (!NT_STATUS_IS_OK(status)) {
results[i] = ntstatus_to_werror(status);
}
}
}
/* Add the OXID data for the returned oxid */
- m = oxid_mapping_by_oxid(ctx, r.out.pOxid);
+ m = object_exporter_by_oxid(ctx, r.out.pOxid);
m->bindings = *r.out.pdsaOxidBindings;
return WERR_OK;
}
-WERROR dcom_get_class_object(struct dcom_context *ctx, struct GUID *clsid, const char *server, struct GUID *iid, struct dcom_interface_p **ip)
+WERROR dcom_get_class_object(struct com_context *ctx, struct GUID *clsid, const char *server, struct GUID *iid, struct IUnknown **ip)
{
struct dcom_object_exporter *m;
struct RemoteActivation r;
struct dcerpc_pipe *p;
struct DUALSTRINGARRAY dualstring;
NTSTATUS status;
- struct pMInterfacePointer pm;
+ struct MInterfacePointer pm;
uint16_t protseq[] = DCOM_NEGOTIATED_PROTOCOLS;
if (!server) {
@@ -257,17 +223,16 @@ WERROR dcom_get_class_object(struct dcom_context *ctx, struct GUID *clsid, const
if(!W_ERROR_IS_OK(r.out.results[0])) { return r.out.results[0]; }
/* Set up the interface data */
- dcom_ifacep_from_OBJREF(ctx, ip, &pm.p->obj);
- (*ip)->private_references = 1;
+ dcom_IUnknown_from_OBJREF(ctx, ip, &pm.obj);
/* Add the OXID data for the returned oxid */
- m = oxid_mapping_by_oxid(ctx, r.out.pOxid);
+ m = object_exporter_by_oxid(ctx, r.out.pOxid);
m->bindings = *r.out.pdsaOxidBindings;
return WERR_OK;
}
-NTSTATUS dcom_get_pipe (struct dcom_interface_p *iface, struct dcerpc_pipe **pp)
+NTSTATUS dcom_get_pipe (struct IUnknown *iface, struct dcerpc_pipe **pp)
{
struct dcerpc_binding binding;
struct GUID iid;
@@ -277,20 +242,22 @@ NTSTATUS dcom_get_pipe (struct dcom_interface_p *iface, struct dcerpc_pipe **pp)
struct dcerpc_pipe *p;
TALLOC_CTX *tmp_ctx;
const char *uuid;
+ struct dcom_object_exporter *ox;
+
+ ox = object_exporter_by_ip(iface->ctx, iface);
tmp_ctx = talloc_new(NULL);
- p = iface->ox->pipe;
+ p = ox->pipe;
- oxid = iface->ox->oxid;
- iid = iface->interface->iid;
+ iid = iface->vtable->iid;
uuid = GUID_string(tmp_ctx, &iid);
if (p) {
if (!GUID_equal(&p->syntax.uuid, &iid)) {
struct dcerpc_pipe *p2;
- iface->ox->pipe->syntax.uuid = iid;
+ ox->pipe->syntax.uuid = iid;
status = dcerpc_secondary_context(p, &p2, uuid, 0);
if (NT_STATUS_IS_OK(status)) {
p = p2;
@@ -306,19 +273,18 @@ NTSTATUS dcom_get_pipe (struct dcom_interface_p *iface, struct dcerpc_pipe **pp)
i = 0;
do {
status = dcerpc_binding_from_STRINGBINDING(iface->ctx, &binding,
- iface->ox->bindings.stringbindings[i]);
+ ox->bindings.stringbindings[i]);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("Error parsing string binding"));
} else {
- binding.flags = iface->ctx->dcerpc_flags;
status = dcerpc_pipe_connect_b(&p, &binding,
uuid, 0.0,
- iface->ctx->domain, iface->ctx->user,
- iface->ctx->password);
+ iface->ctx->dcom.domain, iface->ctx->dcom.user,
+ iface->ctx->dcom.password);
}
i++;
- } while (NT_STATUS_IS_ERR(status) && iface->ox->bindings.stringbindings[i]);
+ } while (NT_STATUS_IS_ERR(status) && ox->bindings.stringbindings[i]);
if (NT_STATUS_IS_ERR(status)) {
DEBUG(0, ("Unable to connect to remote host - %s\n", nt_errstr(status)));
@@ -334,68 +300,56 @@ NTSTATUS dcom_get_pipe (struct dcom_interface_p *iface, struct dcerpc_pipe **pp)
return NT_STATUS_OK;
}
-struct dcom_object *dcom_object_by_oid(struct dcom_object_exporter *ox, uint64_t oid)
+NTSTATUS dcom_OBJREF_from_IUnknown(struct OBJREF *o, struct IUnknown *p)
{
- struct dcom_object *o;
-
- for (o = ox->objects; o; o = o->next) {
- if (o->oid == oid) {
- break;
- }
- }
-
- if (o == NULL) {
- o = talloc_zero(ox, struct dcom_object);
- o->oid = oid;
- DLIST_ADD(ox->objects, o);
- }
+ /* FIXME: Cache generated objref objects? */
+ ZERO_STRUCTP(o);
- return o;
-}
-
+ o->signature = OBJREF_SIGNATURE;
+
+ if (!p) {
+ o->flags = OBJREF_NULL;
+ } else {
+ o->iid = p->vtable->iid;
+ /*
+ OBJREF_STANDARD
+ OBJREF_CUSTOM
+ OBJREF_HANDLER
+ */
+ }
-NTSTATUS dcom_OBJREF_from_ifacep(struct dcom_context *ctx, struct OBJREF *o, struct dcom_interface_p *_p)
-{
return NT_STATUS_NOT_IMPLEMENTED;
}
-NTSTATUS dcom_ifacep_from_OBJREF(struct dcom_context *ctx, struct dcom_interface_p **_p, struct OBJREF *o)
+NTSTATUS dcom_IUnknown_from_OBJREF(struct com_context *ctx, struct IUnknown **_p, struct OBJREF *o)
{
- struct dcom_interface_p *p = talloc(ctx, struct dcom_interface_p);
-
- p->ctx = ctx;
- p->interface = dcom_interface_by_iid(&o->iid);
- if (!p->interface) {
- DEBUG(0, ("Unable to find interface with IID %s\n", GUID_string(ctx, &o->iid)));
- return NT_STATUS_NOT_SUPPORTED;
- }
+ struct IUnknown *p;
+ struct dcom_object_exporter *ox;
- p->private_references = 0;
- p->objref_flags = o->flags;
-
- switch(p->objref_flags) {
+ switch(o->flags) {
case OBJREF_NULL:
- p->object = NULL;
- p->ox = NULL;
- p->vtable = dcom_proxy_vtable_by_iid(&p->interface->iid);
- ZERO_STRUCT(p->ipid);
- *_p = p;
+ *_p = NULL;
return NT_STATUS_OK;
case OBJREF_STANDARD:
- p->ox = oxid_mapping_by_oxid(ctx, o->u_objref.u_standard.std.oxid);
- p->ipid = o->u_objref.u_standard.std.ipid;
- p->object = dcom_object_by_oid(p->ox, o->u_objref.u_standard.std.oid);
- p->ox->resolver_address = o->u_objref.u_standard.saResAddr;
- p->vtable = dcom_proxy_vtable_by_iid(&p->interface->iid);
+ p = talloc(ctx, struct IUnknown);
+ p->ctx = ctx;
+ p->vtable = dcom_proxy_vtable_by_iid(&o->iid);
+ if (!p->vtable) {
+ DEBUG(0, ("Unable to find proxy class for interface with IID %s\n", GUID_string(ctx, &o->iid)));
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ ox = object_exporter_by_oxid(ctx, o->u_objref.u_standard.std.oxid);
+ /* FIXME: Add object to list of objects to ping */
*_p = p;
return NT_STATUS_OK;
case OBJREF_HANDLER:
- p->ox = oxid_mapping_by_oxid(ctx, o->u_objref.u_handler.std.oxid );
- p->ipid = o->u_objref.u_handler.std.ipid;
- p->object = dcom_object_by_oid(p->ox, o->u_objref.u_standard.std.oid);
- p->ox->resolver_address = o->u_objref.u_handler.saResAddr;
+ p = talloc(ctx, struct IUnknown);
+ p->ctx = ctx;
+ ox = object_exporter_by_oxid(ctx, o->u_objref.u_handler.std.oxid );
+ /* FIXME: Add object to list of objects to ping */
/*FIXME p->vtable = dcom_vtable_by_clsid(&o->u_objref.u_handler.clsid);*/
/* FIXME: Do the custom unmarshaling call */
@@ -403,71 +357,15 @@ NTSTATUS dcom_ifacep_from_OBJREF(struct dcom_context *ctx, struct dcom_interface
return NT_STATUS_OK;
case OBJREF_CUSTOM:
- {
- p->vtable = NULL;
-
+ p = talloc(ctx, struct IUnknown);
+ p->ctx = ctx;
+ p->vtable = NULL;
/* FIXME: Do the actual custom unmarshaling call */
- p->ox = NULL;
- p->object = NULL;
- ZERO_STRUCT(p->ipid);
*_p = p;
return NT_STATUS_NOT_SUPPORTED;
- }
}
return NT_STATUS_NOT_SUPPORTED;
-
-
-#if 0
- struct dcom_oxid_mapping *m;
- /* Add OXID mapping if none present yet */
- if (!m) {
- struct dcerpc_pipe *po;
- struct ResolveOxid r;
- uint16_t protseq[] = DCOM_NEGOTIATED_PROTOCOLS;
-
- DEBUG(3, ("No binding data present yet, resolving OXID %llu\n", p->ox->oxid));
-
- m = talloc_zero(p->ctx, struct dcom_oxid_mapping);
- m->oxid = oxid;
-
- i = 0;
- do {
- status = dcerpc_binding_from_STRINGBINDING(p->ctx, &binding, p->client.objref->u_objref.u_standard.saResAddr.stringbindings[i]);
-
- if (NT_STATUS_IS_OK(status)) {
- binding.flags = iface->ctx->dcerpc_flags;
- status = dcerpc_pipe_connect_b(&po, &binding, DCERPC_IOXIDRESOLVER_UUID, DCERPC_IOXIDRESOLVER_VERSION, iface->ctx->domain, iface->ctx->user, iface->ctx->password);
- } else {
- DEBUG(1, ("Error parsing string binding - %s", nt_errstr(status)));
- }
-
- i++;
- } while (!NT_STATUS_IS_OK(status) && iface->client.objref->u_objref.u_standard.saResAddr.stringbindings[i]);
-
- if (NT_STATUS_IS_ERR(status)) {
- DEBUG(1, ("Error while connecting to OXID Resolver : %s\n", nt_errstr(status)));
- return status;
- }
-
- r.in.pOxid = oxid;
- r.in.cRequestedProtseqs = ARRAY_SIZE(protseq);
- r.in.arRequestedProtseqs = protseq;
- r.out.ppdsaOxidBindings = &m->bindings;
-
- status = dcerpc_ResolveOxid(po, iface->ctx, &r);
- if (NT_STATUS_IS_ERR(status)) {
- DEBUG(1, ("Error while resolving OXID: %s\n", nt_errstr(status)));
- return status;
- }
-
- dcerpc_pipe_close(po);
-
- DLIST_ADD(iface->ctx->oxids, m);
- }
-#endif
-
- return NT_STATUS_NOT_SUPPORTED;
}
uint64_t dcom_get_current_oxid(void)
diff --git a/source4/lib/com/dcom/tables.c b/source4/lib/com/dcom/tables.c
new file mode 100644
index 0000000000..a824413b34
--- /dev/null
+++ b/source4/lib/com/dcom/tables.c
@@ -0,0 +1,50 @@
+/*
+ Unix SMB/CIFS implementation.
+ DCOM proxy tables functionality
+ Copyright (C) 2005 Jelmer Vernooij <jelmer@samba.org>
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "system/filesys.h"
+#include "dlinklist.h"
+#include "librpc/gen_ndr/com_dcom.h"
+
+static struct dcom_proxy {
+ struct IUnknown_vtable *vtable;
+ struct dcom_proxy *prev, *next;
+} *proxies = NULL;
+
+NTSTATUS dcom_register_proxy(struct IUnknown_vtable *proxy_vtable)
+{
+ struct dcom_proxy *proxy = talloc(talloc_autofree_context(), struct dcom_proxy);
+
+ proxy->vtable = proxy_vtable;
+ DLIST_ADD(proxies, proxy);
+
+ return NT_STATUS_OK;
+}
+
+struct IUnknown_vtable *dcom_proxy_vtable_by_iid(struct GUID *iid)
+{
+ struct dcom_proxy *p;
+ for (p = proxies; p; p = p->next) {
+ if (GUID_equal(&p->vtable->iid, iid)) {
+ return p->vtable;
+ }
+ }
+ return NULL;
+}
diff --git a/source4/lib/dcom/common/dcom.h b/source4/lib/dcom/common/dcom.h
deleted file mode 100644
index dd21bb9d29..0000000000
--- a/source4/lib/dcom/common/dcom.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- DCOM standard objects
- 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 2 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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _DCOM_H /* _DCOM_H */
-#define _DCOM_H
-
-#include "librpc/ndr/ndr_dcom.h"
-
-struct dcom_context
-{
- struct dcom_object_exporter {
- struct dcom_object_exporter *prev, *next;
- struct STRINGARRAY resolver_address;
- struct DUALSTRINGARRAY bindings;
- uint64_t oxid;
- struct dcerpc_pipe *pipe;
- struct dcom_object
- {
- struct dcom_object *prev, *next;
- uint64_t oid;
- void *private_data;
- } *objects;
- } *oxids;
- const char *domain;
- const char *user;
- const char *password;
- uint32_t dcerpc_flags;
-};
-
-struct dcom_interface_p
-{
- struct com_context *ctx;
- const struct com_interface *interface;
- const void *vtable; /* Points to one of the available implementations */
- struct GUID ipid;
- struct com_object *object;
- int objref_flags;
- int orpc_flags;
- struct com_object_exporter *ox;
- uint32_t private_references;
-};
-
-#endif /* _DCOM_H */
diff --git a/source4/lib/dcom/config.mk b/source4/lib/dcom/config.mk
deleted file mode 100644
index ae8fe9c4b0..0000000000
--- a/source4/lib/dcom/config.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-################################################
-# Start SUBSYSTEM LIBDCOM
-#[SUBSYSTEM::LIBDCOM]
-#ENABLE = NO
-#INIT_OBJ_FILES = \
-# lib/dcom/common/main.o
-#REQUIRED_SUBSYSTEMS = LIBCOM DCOM_PROXY_DCOM RPC_NDR_REMACT \
-# RPC_NDR_OXIDRESOLVER
-
-#[MODULE::DCOM_SIMPLE]
-#ENABLE = NO
-#SUBSYSTEM = LIBDCOM
-#REQUIRED_SUBSYSTEMS = DCOM_PROXY_DCOM
-#INIT_FUNCTION = dcom_simple_init
-#INIT_OBJ_FILES = \
-# lib/dcom/classes/simple.o
-#
-# End SUBSYSTEM LIBDCOM
-################################################
diff --git a/source4/librpc/idl/dcom.idl b/source4/librpc/idl/dcom.idl
index 70a56c2ec5..3e4d9d0c2c 100644
--- a/source4/librpc/idl/dcom.idl
+++ b/source4/librpc/idl/dcom.idl
@@ -270,7 +270,7 @@ object,
object
] interface ICoffeeMachine : IUnknown
{
- [helpstring("method MakeCoffee")] WERROR MakeCoffee(unistr *flavor);
+ [helpstring("method MakeCoffee")] WERROR MakeCoffee([in] unistr *flavor);
}
[
diff --git a/source4/librpc/idl/orpc.idl b/source4/librpc/idl/orpc.idl
index 8b94059e89..34ef41377b 100644
--- a/source4/librpc/idl/orpc.idl
+++ b/source4/librpc/idl/orpc.idl
@@ -45,7 +45,7 @@ interface ObjectRpcBaseTypes
} COMVERSION;
/* enumeration of additional information present in the call packet. */
- typedef enum {
+ typedef bitmap {
ORPCF_NULL = 0x00, /* no additional info in packet */
ORPCF_LOCAL = 0x01, /* call is local to this machine */
ORPCF_RESERVED1 = 0x02, /* reserved for local use */
@@ -130,7 +130,7 @@ interface ObjectRpcBaseTypes
/* Flag values for a STDOBJREF (standard part of an OBJREF). */
/* SORF_OXRES1 - SORF_OXRES8 are reserved for the object exporters */
/* use only, object importers must ignore them and must not enforce MBZ. */
- typedef enum {
+ typedef bitmap {
SORF_NULL = 0x0000, /* convenient for initializing SORF */
SORF_OXRES1 = 0x0001, /* reserved for exporter */
SORF_OXRES2 = 0x0020, /* reserved for exporter */
diff --git a/source4/librpc/ndr/ndr_dcom.h b/source4/librpc/ndr/ndr_orpc.h
index 06c2681621..d1817969a4 100644
--- a/source4/librpc/ndr/ndr_dcom.h
+++ b/source4/librpc/ndr/ndr_orpc.h
@@ -20,6 +20,9 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#ifndef __NDR_ORPC_H__
+#define __NDR_ORPC_H__
+
struct STRINGARRAY
{
struct STRINGBINDING **stringbindings;
@@ -30,3 +33,5 @@ struct DUALSTRINGARRAY
struct STRINGBINDING **stringbindings;
struct SECURITYBINDING **securitybindings;
};
+
+#endif /* __NDR_ORPC_H__ */
diff --git a/source4/torture/com/simple.c b/source4/torture/com/simple.c
index 369b03f151..32b269f475 100644
--- a/source4/torture/com/simple.c
+++ b/source4/torture/com/simple.c
@@ -44,12 +44,15 @@ static BOOL test_readwrite(TALLOC_CTX *mem_ctx, const char *host)
GUID_from_string(COM_ISTREAM_UUID, &IID[0]);
GUID_from_string(COM_IUNKNOWN_UUID, &IID[1]);
GUID_from_string(CLSID_SIMPLE, &clsid);
-/* error = dcom_create_object(ctx, &clsid,
+
+ if (host) {
+ error = dcom_create_object(ctx, &clsid,
host, 2, IID,
&interfaces,
- results);*/
-
- error = com_create_object(ctx, &clsid, 2, IID, interfaces, results);
+ results);
+ } else {
+ error = com_create_object(ctx, &clsid, 2, IID, interfaces, results);
+ }
if (!W_ERROR_IS_OK(error)) {
printf("(d)com_create_object failed - %s\n", win_errstr(error));
@@ -83,9 +86,9 @@ BOOL torture_com_simple(void)
{
BOOL ret = True;
TALLOC_CTX *mem_ctx = talloc_init("torture_dcom_simple");
+ const char *host = lp_parm_string(-1, "dcom", "host");
- ret &= test_readwrite(mem_ctx, NULL);
- ret &= test_readwrite(mem_ctx, lp_parm_string(-1, "torture", "dcomhost"));
+ ret &= test_readwrite(mem_ctx, host);
talloc_free(mem_ctx);
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 7519a03ac3..f46d964777 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -58,13 +58,13 @@ REQUIRED_SUBSYSTEMS = \
#################################
#################################
-# Start SUBSYSTEM TORTURE_DCOM
+# Start SUBSYSTEM TORTURE_COM
[SUBSYSTEM::TORTURE_COM]
ADD_OBJ_FILES = \
torture/com/simple.o
REQUIRED_SUBSYSTEMS = \
- LIBCOM
-# End SUBSYSTEM TORTURE_DCOM
+ LIBCOM LIBDCOM
+# End SUBSYSTEM TORTURE_COM
#################################
#################################