1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

r4624: Several crash fixes for DCOM

More work on the example class implementation
This commit is contained in:
Jelmer Vernooij 2005-01-09 21:35:37 +00:00 committed by Gerald (Jerry) Carter
parent da3c7712d2
commit 1f8f4dd179
6 changed files with 64 additions and 12 deletions

View File

@ -139,7 +139,14 @@ static NTSTATUS dcom_proxy_$interface->{NAME}_$name(struct dcom_interface_p *d,
$res .="
NTSTATUS dcom_$interface->{NAME}_$name (struct dcom_interface_p *d, TALLOC_CTX *mem_ctx, struct $name *r)
{
return ((const struct dcom_$interface->{NAME}_vtable *)d->vtable)->$name (d, mem_ctx, r);
const struct dcom_$interface->{NAME}_vtable *table = d->vtable;
if (table->$name == NULL) {
DEBUG(0, (\"Object does not implement $name of interface $interface->{NAME}\\n\"));
return NT_STATUS_NOT_IMPLEMENTED;
}
return table->$name (d, mem_ctx, r);
}
";
}
@ -151,7 +158,7 @@ sub ParseInterface($)
{
my($interface) = shift;
my($data) = $interface->{DATA};
$res = "/* DCOM stubs generated by pidl */\n\n";
$res = "/* DCOM proxy generated by pidl */\n\n";
foreach my $d (@{$data}) {
($d->{TYPE} eq "FUNCTION") &&
ParseFunction($interface, $d);

View File

@ -21,7 +21,25 @@
#include "includes.h"
#include "lib/dcom/common/dcom.h"
static struct dcom_IClassFactory_vtable simple_classobject;
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)
{
@ -32,10 +50,17 @@ NTSTATUS dcom_simple_init(void)
GUID_from_string(DCERPC_IUNKNOWN_UUID, &iid);
simple_class.class_object = dcom_new_local_ifacep(talloc_autofree_context(),
dcom_interface_by_iid(&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_FOOBAR;
}
GUID_from_string("5e9ddec7-5767-11cf-beab-00aa006c3606", &simple_class.clsid);
return dcom_register_class(&simple_class);
}

View File

@ -549,9 +549,15 @@ HYPER_T dcom_get_current_oxid(void)
return getpid();
}
struct dcom_interface_p *dcom_new_local_ifacep(struct dcom_context *ctx, const struct dcom_interface *iface, void *vtable, struct dcom_object *object)
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_p(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;

View File

@ -77,7 +77,12 @@ 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_destroy(lcl_ctx);
l = talloc_zero_p(interfaces?interfaces:talloc_autofree_context(),
struct interface_list);

View File

@ -10,6 +10,7 @@ REQUIRED_SUBSYSTEMS = DCOM_PROXY_DCOM RPC_NDR_REMACT \
[MODULE::DCOM_SIMPLE]
SUBSYSTEM = LIBDCOM
REQUIRED_SUBSYSTEMS = DCOM_PROXY_DCOM
INIT_FUNCTION = dcom_simple_init
INIT_OBJ_FILES = \
lib/dcom/classes/simple.o

View File

@ -26,11 +26,10 @@
#define CLSID_SIMPLE "5e9ddec7-5767-11cf-beab-00aa006c3606"
#define DEFAULT_TRANS 4096
BOOL torture_dcom_simple(void)
static BOOL test_readwrite(TALLOC_CTX *mem_ctx, const char *host)
{
NTSTATUS status;
struct dcerpc_pipe *p = NULL;
TALLOC_CTX *mem_ctx;
BOOL ret = True;
struct GUID IID[2];
struct GUID clsid;
@ -45,18 +44,15 @@ BOOL torture_dcom_simple(void)
extern NTSTATUS dcom_IUnknown_init(void);
extern NTSTATUS dcom_IStream_init(void);
mem_ctx = talloc_init("torture_dcom_simple");
torture_dcom_init(&ctx);
GUID_from_string(DCERPC_ISTREAM_UUID, &IID[0]);
GUID_from_string(DCERPC_IUNKNOWN_UUID, &IID[1]);
GUID_from_string(CLSID_SIMPLE, &clsid);
error = dcom_create_object(ctx, &clsid,
lp_parm_string(-1, "torture", "dcomhost"), 2, IID,
host, 2, IID,
&interfaces,
results);
if (!W_ERROR_IS_OK(error)) {
printf("dcom_create_object failed - %s\n", win_errstr(error));
@ -102,5 +98,17 @@ BOOL torture_dcom_simple(void)
talloc_destroy(mem_ctx);
torture_rpc_close(p);
return True;
}
BOOL torture_dcom_simple(void)
{
BOOL ret = True;
TALLOC_CTX *mem_ctx = talloc_init("torture_dcom_simple");
ret &= test_readwrite(mem_ctx, NULL);
ret &= test_readwrite(mem_ctx, lp_parm_string(-1, "torture", "dcomhost"));
return ret;
}