summaryrefslogtreecommitdiff
path: root/source4/lib/dcom
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-02-21 14:30:49 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:10:50 -0500
commit80d3047333fceb3805ccd10a08cdf95021f57ff4 (patch)
tree16ccb10ace9efe6b52d80e8bfd3f0fd483762f23 /source4/lib/dcom
parent6b4cac2c00bd77c34bfe47f35729a60782b8c9c2 (diff)
downloadsamba-80d3047333fceb3805ccd10a08cdf95021f57ff4.tar.gz
samba-80d3047333fceb3805ccd10a08cdf95021f57ff4.tar.bz2
samba-80d3047333fceb3805ccd10a08cdf95021f57ff4.zip
r5490: The big (D)COM commit! :-) Contains most of the changes described in the
DCOM paper in lorikeet. This is the result of 1.5 months work (mainly figuring out how things *really* work) at the end of 2004. In general: - Clearer distinction between COM and DCOM. DCOM is now merely the glue between DCE/RPC+ORPC and COM. COM can also work without DCOM now. This makes the code a lot clearer. - Clearer distinction between NDR and DCOM. Before, NDR had a couple of "if"s to cope with DCOM, which are now gone. - Use "real" arguments rather then structures for function arguments in COM, mainly because most of these calls are local so packing/unpacking data for every call is too much overhead (both speed- and code-wise) - Support several mechanisms to load class objects: - from memory (e.g. part of the current executable, registered at start-up) - from shared object files - remotely - Most things are now also named COM rather then DCOM because that's what it really is. After an object is created, it no longer matters whether it was created locally or remotely. There is a very simple example class that contains both a class factory and a class that implements the IStream interface. It can be tested (locally only, remotely is broken at the moment) by running the COM-SIMPLE smbtorture test. Still to-do: - Autogenerate parts of the class implementation code (using the coclass definitions in IDL) - Test server-side - Implement some of the common classes, add definitions for common interfaces. (This used to be commit 71fd3e5c3aac5f0002001ab29d2248e6c6842d6f)
Diffstat (limited to 'source4/lib/dcom')
-rw-r--r--source4/lib/dcom/classes/simple.c66
-rw-r--r--source4/lib/dcom/common/dcom.h33
-rw-r--r--source4/lib/dcom/common/main.c120
-rw-r--r--source4/lib/dcom/common/rot.c34
-rw-r--r--source4/lib/dcom/common/tables.c107
-rw-r--r--source4/lib/dcom/config.mk26
6 files changed, 29 insertions, 357 deletions
diff --git a/source4/lib/dcom/classes/simple.c b/source4/lib/dcom/classes/simple.c
deleted file mode 100644
index 13cf4616b2..0000000000
--- a/source4/lib/dcom/classes/simple.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Simple class
- Copyright (C) 2004 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 "lib/dcom/common/dcom.h"
-
-NTSTATUS simple_QueryInterface (struct dcom_interface_p *d, TALLOC_CTX *mem_ctx, struct QueryInterface *r)
-{
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-static NTSTATUS simple_CreateInstance (struct dcom_interface_p *d, TALLOC_CTX *mem_ctx, struct CreateInstance *r)
-{
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-/* Everything below this line should be autogenerated later on */
-
-static struct dcom_IClassFactory_vtable simple_classobject = {
- { simple_QueryInterface, NULL, NULL },
- simple_CreateInstance,
- NULL,
- NULL,
- NULL
-};
-
-NTSTATUS dcom_simple_init(void)
-{
- struct GUID iid;
- struct dcom_class simple_class = {
- "Samba.Simple",
- };
-
- GUID_from_string(DCERPC_IUNKNOWN_UUID, &iid);
-
- simple_class.class_object = dcom_new_local_ifacep(
- talloc_autofree_context(),
- &iid,
- &simple_classobject, NULL);
-
- if (!simple_class.class_object) {
- DEBUG(1, ("Unable to create class object for simple class\n"));
- return NT_STATUS_OK;
- }
-
- GUID_from_string("5e9ddec7-5767-11cf-beab-00aa006c3606", &simple_class.clsid);
-
- return dcom_register_class(&simple_class);
-}
diff --git a/source4/lib/dcom/common/dcom.h b/source4/lib/dcom/common/dcom.h
index 0bc4a256f1..dd21bb9d29 100644
--- a/source4/lib/dcom/common/dcom.h
+++ b/source4/lib/dcom/common/dcom.h
@@ -1,7 +1,7 @@
/*
Unix SMB/CIFS implementation.
DCOM standard objects
- Copyright (C) Jelmer Vernooij 2004.
+ 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
@@ -23,11 +23,6 @@
#include "librpc/ndr/ndr_dcom.h"
-struct IUnknown_AddRef;
-struct IUnknown_Release;
-struct IUnknown_QueryInterface;
-struct dcom_interface_p;
-
struct dcom_context
{
struct dcom_object_exporter {
@@ -49,34 +44,16 @@ struct dcom_context
uint32_t dcerpc_flags;
};
-/* Specific implementation of one or more interfaces */
-struct dcom_class
-{
- const char *prog_id;
- struct GUID clsid;
-
- /* IUnknown */
- struct dcom_interface_p *class_object;
-};
-
-struct dcom_interface
-{
- struct GUID iid;
- int num_methods;
- struct GUID base_iid;
- const void *proxy_vtable;
-};
-
struct dcom_interface_p
{
- struct dcom_context *ctx;
- const struct dcom_interface *interface;
+ struct com_context *ctx;
+ const struct com_interface *interface;
const void *vtable; /* Points to one of the available implementations */
struct GUID ipid;
- struct dcom_object *object;
+ struct com_object *object;
int objref_flags;
int orpc_flags;
- struct dcom_object_exporter *ox;
+ struct com_object_exporter *ox;
uint32_t private_references;
};
diff --git a/source4/lib/dcom/common/main.c b/source4/lib/dcom/common/main.c
index a8324606f1..315912ba3c 100644
--- a/source4/lib/dcom/common/main.c
+++ b/source4/lib/dcom/common/main.c
@@ -117,7 +117,7 @@ WERROR dcom_init(struct dcom_context **ctx, const char *domain, const char *user
return WERR_OK;
}
-static struct dcom_object_exporter *oxid_mapping_by_oxid (struct dcom_context *ctx, uint64_t oxid)
+struct dcom_object_exporter *oxid_mapping_by_oxid (struct dcom_context *ctx, uint64_t oxid)
{
struct dcom_object_exporter *m;
@@ -144,7 +144,7 @@ WERROR dcom_ping(struct dcom_context *ctx)
return WERR_OK;
}
-static WERROR dcom_create_object_remote(struct dcom_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct dcom_interface_p ***ip, WERROR *results)
+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)
{
uint16_t protseq[] = DCOM_NEGOTIATED_PROTOCOLS;
struct dcerpc_pipe *p;
@@ -154,6 +154,10 @@ static WERROR dcom_create_object_remote(struct dcom_context *ctx, struct GUID *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)));
@@ -208,60 +212,7 @@ static WERROR dcom_create_object_remote(struct dcom_context *ctx, struct GUID *c
return WERR_OK;
}
-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)
-{
- struct dcom_interface_p *factory, *iunk = NULL;
- struct QueryInterface qr;
- struct Release rr;
- struct CreateInstance cr;
- WERROR error;
- int i;
- NTSTATUS status;
-
- if (server != NULL) {
- return dcom_create_object_remote(ctx, clsid, server, num_ifaces, iid, ip, results);
- }
-
- /* Obtain class object */
- error = dcom_get_class_object(ctx, clsid, server, iid, &factory);
- if (!W_ERROR_IS_OK(error)) {
- DEBUG(3, ("Unable to obtain class object for %s\n", GUID_string(NULL, clsid)));
- return error;
- }
-
- dcom_OBJREF_from_ifacep(ctx, &cr.in.pUnknown->obj, factory);
-
- GUID_from_string(DCERPC_ICLASSFACTORY_UUID, cr.in.iid);
-
- /* Run IClassFactory::CreateInstance() */
- status = dcom_IClassFactory_CreateInstance(factory, ctx, &cr);
- if (NT_STATUS_IS_ERR(status)) {
- DEBUG(3, ("Error while calling IClassFactory::CreateInstance : %s\n", nt_errstr(status)));
- return ntstatus_to_werror(status);
- }
-
- /* Release class object */
- status = dcom_IUnknown_Release(factory, ctx, &rr);
- if (NT_STATUS_IS_ERR(status)) {
- DEBUG(3, ("Error freeing class factory: %s\n", nt_errstr(status)));
- return ntstatus_to_werror(status);
- }
-
- /* Do one or more QueryInterface calls */
- for (i = 0; i < num_ifaces; i++) {
- qr.in.iid = &iid[i];
- status = dcom_IUnknown_QueryInterface(iunk, ctx, &qr);
- if (NT_STATUS_IS_ERR(status)) {
- DEBUG(4, ("Error obtaining interface %s : %s\n", GUID_string(NULL, &iid[i]), nt_errstr(status)));
- return ntstatus_to_werror(status);
- }
- results[i] = qr.out.result;
- }
-
- return WERR_OK;
-}
-
-WERROR dcom_get_class_object_remote(struct dcom_context *ctx, struct GUID *clsid, const char *server, struct GUID *iid, struct dcom_interface_p **ip)
+WERROR dcom_get_class_object(struct dcom_context *ctx, struct GUID *clsid, const char *server, struct GUID *iid, struct dcom_interface_p **ip)
{
struct dcom_object_exporter *m;
struct RemoteActivation r;
@@ -271,6 +222,10 @@ WERROR dcom_get_class_object_remote(struct dcom_context *ctx, struct GUID *clsid
struct pMInterfacePointer pm;
uint16_t protseq[] = DCOM_NEGOTIATED_PROTOCOLS;
+ if (!server) {
+ return com_get_class_object(ctx, clsid, iid, ip);
+ }
+
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)));
@@ -312,36 +267,6 @@ WERROR dcom_get_class_object_remote(struct dcom_context *ctx, struct GUID *clsid
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)
-{
- const struct dcom_class *c;
- struct QueryInterface qi;
- NTSTATUS status;
-
- if (server != NULL) {
- return dcom_get_class_object_remote(ctx, clsid, server, iid, ip);
- }
-
- c = dcom_class_by_clsid(clsid);
- if (!c) {
- /* FIXME: Better error code.. */
- return WERR_DEST_NOT_FOUND;
- }
-
- qi.in.iid = iid;
-
- status = dcom_IUnknown_QueryInterface(c->class_object, ctx, &qi );
- if (NT_STATUS_IS_ERR(status)) {
- return ntstatus_to_werror(status);
- }
-
- if (!W_ERROR_IS_OK(qi.out.result)) { return qi.out.result; }
-
- dcom_ifacep_from_OBJREF(ctx, ip, &qi.out.data->obj);
-
- return WERR_OK;
-}
-
NTSTATUS dcom_get_pipe (struct dcom_interface_p *iface, struct dcerpc_pipe **pp)
{
struct dcerpc_binding binding;
@@ -549,26 +474,3 @@ uint64_t dcom_get_current_oxid(void)
{
return getpid();
}
-
-struct dcom_interface_p *dcom_new_local_ifacep(struct dcom_context *ctx, const struct GUID *iid, void *vtable, struct dcom_object *object)
-{
- struct dcom_interface_p *ip = talloc(ctx, struct dcom_interface_p);
- const struct dcom_interface *iface = dcom_interface_by_iid(iid);
-
- if (!iface) {
- DEBUG (1, ("Unable to find interface with IID %s\n", GUID_string(ctx, iid)));
- return NULL;
- }
-
- ip->ctx = ctx;
- ip->interface = iface;
- ip->vtable = vtable;
- ip->ipid = GUID_random();
- ip->object = object;
- ip->objref_flags = 0;
- ip->orpc_flags = 0;
- ip->ox = NULL;
- ip->private_references = 1;
-
- return ip;
-}
diff --git a/source4/lib/dcom/common/rot.c b/source4/lib/dcom/common/rot.c
deleted file mode 100644
index 7acdbe066e..0000000000
--- a/source4/lib/dcom/common/rot.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- Running object table functions
-
- Copyright (C) Jelmer Vernooij 2004
-
- 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"
-
-struct dcom_interface_p *dcom_get_local_iface_p(struct GUID *ipid)
-{
- /* FIXME: Call the local ROT and do a
- * rot_get_interface_pointer call */
-
- /* FIXME: Perhaps have a local (thread-local) table with
- * local DCOM objects so that not every DCOM call requires a lookup
- * to the ROT? */
- return NULL;
-}
diff --git a/source4/lib/dcom/common/tables.c b/source4/lib/dcom/common/tables.c
deleted file mode 100644
index cd7e0867ee..0000000000
--- a/source4/lib/dcom/common/tables.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- DCOM interface and class tables
- Copyright (C) 2004 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 "dlinklist.h"
-
-static struct class_list {
- struct class_list *prev, *next;
- struct dcom_class class;
-} *classes = NULL;
-
-static struct interface_list {
- struct interface_list *prev, *next;
- struct dcom_interface interface;
-} *interfaces = NULL;
-
-const struct dcom_interface *dcom_interface_by_iid(const struct GUID *iid)
-{
- struct interface_list *l = interfaces;
-
- while(l) {
-
- if (GUID_equal(iid, &l->interface.iid))
- return &l->interface;
-
- l = l->next;
- }
-
- return NULL;
-}
-
-const struct dcom_class *dcom_class_by_clsid(const struct GUID *clsid)
-{
- struct class_list *c = classes;
-
- while(c) {
-
- if (GUID_equal(clsid, &c->class.clsid)) {
- return &c->class;
- }
-
- c = c->next;
- }
-
- return NULL;
-}
-
-const void *dcom_proxy_vtable_by_iid(const struct GUID *iid)
-{
- const struct dcom_interface *iface = dcom_interface_by_iid(iid);
-
- if (!iface) {
- return NULL;
- }
-
- return iface->proxy_vtable;
-}
-
-NTSTATUS dcom_register_interface(const void *_iface)
-{
- const struct dcom_interface *iface = _iface;
- struct interface_list *l;
- TALLOC_CTX *lcl_ctx = talloc_init("dcom_register_interface");
-
- DEBUG(5, ("Adding DCOM interface %s\n", GUID_string(lcl_ctx, &iface->iid)));
-
- talloc_free(lcl_ctx);
-
- l = talloc_zero(interfaces?interfaces:talloc_autofree_context(),
- struct interface_list);
-
- l->interface = *iface;
-
- DLIST_ADD(interfaces, l);
-
- return NT_STATUS_OK;
-}
-
-NTSTATUS dcom_register_class(const void *_class)
-{
- const struct dcom_class *class = _class;
- struct class_list *l = talloc_zero(classes?classes:talloc_autofree_context(),
- struct class_list);
-
- l->class = *class;
-
- DLIST_ADD(classes, l);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/dcom/config.mk b/source4/lib/dcom/config.mk
index ca280884ea..ae8fe9c4b0 100644
--- a/source4/lib/dcom/config.mk
+++ b/source4/lib/dcom/config.mk
@@ -1,19 +1,19 @@
################################################
# Start SUBSYSTEM LIBDCOM
-[SUBSYSTEM::LIBDCOM]
-INIT_OBJ_FILES = \
- lib/dcom/common/main.o \
- lib/dcom/common/tables.o \
- lib/dcom/common/rot.o
-REQUIRED_SUBSYSTEMS = DCOM_PROXY_DCOM RPC_NDR_REMACT \
- RPC_NDR_OXIDRESOLVER
+#[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]
-SUBSYSTEM = LIBDCOM
-REQUIRED_SUBSYSTEMS = DCOM_PROXY_DCOM
-INIT_FUNCTION = dcom_simple_init
-INIT_OBJ_FILES = \
- lib/dcom/classes/simple.o
+#[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
################################################