summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-15 04:16:15 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-15 17:40:34 +0200
commit51fbc88fc24c23d17f976217ef907fd7e57fe4ab (patch)
treec327c30df880131028c24d5928cad0bb40575199 /source4
parent82ee6ee5035a6265aa97da0befd8d65358c89c9d (diff)
downloadsamba-51fbc88fc24c23d17f976217ef907fd7e57fe4ab.tar.gz
samba-51fbc88fc24c23d17f976217ef907fd7e57fe4ab.tar.bz2
samba-51fbc88fc24c23d17f976217ef907fd7e57fe4ab.zip
Get code closer to compiling without errors, fix formatting, add docstrings.
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/com/dcom/dcom.h15
-rw-r--r--source4/lib/com/dcom/main.c18
-rw-r--r--source4/lib/wmi/wbemdata.c110
-rw-r--r--source4/librpc/idl/wmi.idl13
4 files changed, 84 insertions, 72 deletions
diff --git a/source4/lib/com/dcom/dcom.h b/source4/lib/com/dcom/dcom.h
index b3f42bc562..69bb7183b2 100644
--- a/source4/lib/com/dcom/dcom.h
+++ b/source4/lib/com/dcom/dcom.h
@@ -28,10 +28,16 @@ struct dcerpc_pipe;
#include "librpc/gen_ndr/orpc.h"
struct dcom_client_context {
- struct cli_credentials *credentials;
+ struct dcom_server_credentials {
+ const char *server;
+ struct cli_credentials *credentials;
+ struct dcom_server_credentials *prev, *next;
+ } *credentials;
struct dcom_object_exporter {
- uint64_t oxid;
- struct DUALSTRINGARRAY bindings;
+ uint64_t oxid;
+ char *host;
+ struct IRemUnknown *rem_unknown;
+ struct DUALSTRINGARRAY *bindings;
struct dcerpc_pipe *pipe;
struct dcom_object_exporter *prev, *next;
} *object_exporters;
@@ -50,7 +56,7 @@ NTSTATUS dcom_get_pipe(struct IUnknown *iface, struct dcerpc_pipe **pp);
NTSTATUS dcom_OBJREF_from_IUnknown(struct OBJREF *o, struct IUnknown *p);
NTSTATUS dcom_IUnknown_from_OBJREF(struct com_context *ctx, struct IUnknown **_p, struct OBJREF *o);
uint64_t dcom_get_current_oxid(void);
-void dcom_set_server_credentials(struct com_context *ctx, const char *server, struct cli_credentials *credentials);
+void dcom_add_server_credentials(struct com_context *ctx, const char *server, struct cli_credentials *credentials);
WERROR dcom_query_interface(struct IUnknown *d, uint32_t cRefs, uint16_t cIids, struct GUID *iids, struct IUnknown **ip, WERROR *results);
#include "librpc/gen_ndr/com_dcom.h"
@@ -61,5 +67,6 @@ NTSTATUS dcom_register_marshal(struct GUID *clsid, marshal_fn marshal, unmarshal
#include "libcli/composite/composite.h"
void dcom_release_continue(struct composite_context *cr);
+#define IUnknown_ipid(d) ((d)->obj.u_objref.u_standard.std.ipid)
#endif /* _DCOM_H */
diff --git a/source4/lib/com/dcom/main.c b/source4/lib/com/dcom/main.c
index 01efb68c05..f3eb2ab608 100644
--- a/source4/lib/com/dcom/main.c
+++ b/source4/lib/com/dcom/main.c
@@ -84,12 +84,23 @@ struct cli_credentials *dcom_get_server_credentials(struct com_context *ctx, con
return d;
}
-void dcom_set_server_credentials(struct com_context *ctx, const char *server, struct cli_credentials *credentials)
+/**
+ * Register credentials for a specific server.
+ *
+ * @param ctx COM context
+ * @param server Name of server, can be NULL
+ * @param credentials Credentials object
+ */
+void dcom_add_server_credentials(struct com_context *ctx, const char *server,
+ struct cli_credentials *credentials)
{
struct dcom_server_credentials *c;
+ /* FIXME: Don't use talloc_find_parent_bytype */
for (c = ctx->dcom->credentials; c; c = c->next) {
- if ((server == NULL && c->server == NULL) ||(server && c->server && !strcmp(c->server, server))) {
+ if ((server == NULL && c->server == NULL) ||
+ (server != NULL && c->server != NULL &&
+ !strcmp(c->server, server))) {
if (c->credentials && c->credentials != credentials) {
talloc_unlink(c, c->credentials);
c->credentials = credentials;
@@ -98,9 +109,11 @@ void dcom_set_server_credentials(struct com_context *ctx, const char *server, st
else
talloc_steal(c, c->credentials);
}
+
return;
}
}
+
c = talloc(ctx->event_ctx, struct dcom_server_credentials);
c->server = talloc_strdup(c, server);
c->credentials = credentials;
@@ -108,6 +121,7 @@ void dcom_set_server_credentials(struct com_context *ctx, const char *server, st
(void)talloc_reference(c, c->credentials);
else
talloc_steal(c, c->credentials);
+
DLIST_ADD(ctx->dcom->credentials, c);
}
diff --git a/source4/lib/wmi/wbemdata.c b/source4/lib/wmi/wbemdata.c
index 6783cb7233..b24499ab5c 100644
--- a/source4/lib/wmi/wbemdata.c
+++ b/source4/lib/wmi/wbemdata.c
@@ -34,24 +34,9 @@
#include "libcli/composite/composite.h"
#include "lib/wmi/wmi.h"
-#define NDR_CHECK_LEN(n) do { if (p + (n) > pend) { \
- DEBUG(0, ("%s(%d): WBEMDATA_ERR(0x%08X): Buffer too small(0x%04X)\n", __FILE__, __LINE__, ndr->offset, p + (n) - pend)); \
- status = NT_STATUS_UNSUCCESSFUL; \
- goto end; \
- } \
- } while(0)
-
-#define NDR_CHECK_EXPR(expr) do { if (!(expr)) {\
- DEBUG(0, ("%s(%d): WBEMDATA_ERR(0x%08X): Error parsing(%s)\n", __FILE__, __LINE__, ndr->offset, #expr)); \
- status = NT_STATUS_UNSUCCESSFUL; \
- goto end; \
- } \
- } while(0)
-
enum {
DATATYPE_CLASSOBJECT = 2,
DATATYPE_OBJECT = 3,
-
COFLAG_IS_CLASS = 4,
};
@@ -61,7 +46,7 @@ static enum ndr_err_code marshal(TALLOC_CTX *mem_ctx, struct IUnknown *pv, struc
struct WbemClassObject *wco;
struct MInterfacePointer *mp;
- mp = (struct MInterfacePointer *)((char *)o - offsetof(struct MInterfacePointer, obj)); // FIXME:high remove this Mumbo Jumbo
+ mp = (struct MInterfacePointer *)((char *)o - offsetof(struct MInterfacePointer, obj)); /* FIXME:high remove this Mumbo Jumbo */
wco = pv->object_data;
ndr = talloc_zero(mem_ctx, struct ndr_push);
ndr->flags = 0;
@@ -169,7 +154,7 @@ void WbemClassObject_CreateInstance(struct WbemClassObject *wco)
wco->instance->data = talloc_array(wco->instance, union CIMVAR, wco->obj_class->__PROPERTY_COUNT);
memset(wco->instance->data, 0, sizeof(union CIMVAR) * wco->obj_class->__PROPERTY_COUNT);
for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) {
- wco->instance->default_flags[i] = 1; // FIXME:high resolve this magic
+ wco->instance->default_flags[i] = 1; /* FIXME:high resolve this magic */
}
wco->instance->__CLASS = wco->obj_class->__CLASS;
wco->instance->u2_4 = 4;
@@ -240,18 +225,16 @@ void duplicate_WbemClass(TALLOC_CTX *mem_ctx, const struct WbemClass *src, struc
dst->__PROPERTY_COUNT = src->__PROPERTY_COUNT;
- dst->properties = talloc_array(mem_ctx, struct WbemProperty, src->__PROPERTY_COUNT);
+ dst->properties = talloc_array(mem_ctx, struct WbemClassProperty, src->__PROPERTY_COUNT);
for (i = 0; i < src->__PROPERTY_COUNT; ++i) {
- dst->properties[i].name = talloc_strdup(dst->properties, src->properties[i].name);
- dst->properties[i].desc = talloc_memdup(dst->properties, src->properties[i].desc, sizeof(*src->properties[i].desc));
- duplicate_WbemQualifiers(dst->properties[i].desc, &src->properties[i].desc->qualifiers, &dst->properties[i].desc->qualifiers);
+ dst->properties[i].property.name = talloc_strdup(dst->properties, src->properties[i].property.name);
+ dst->properties[i].property.desc = talloc_memdup(dst->properties, src->properties[i].property.desc, sizeof(*src->properties[i].property.desc));
+ duplicate_WbemQualifiers(dst->properties[i].property.desc, &src->properties[i].property.desc->qualifiers, &dst->properties[i].property.desc->qualifiers);
}
- dst->default_flags = talloc_array(mem_ctx, uint8_t, src->__PROPERTY_COUNT);
- dst->default_values = talloc_array(mem_ctx, union CIMVAR, src->__PROPERTY_COUNT);
for (i = 0; i < src->__PROPERTY_COUNT; ++i) {
- dst->default_flags[i] = src->default_flags[i];
- duplicate_CIMVAR(dst->default_values, &src->default_values[i], &dst->default_values[i], src->properties[i].desc->cimtype);
+ dst->properties[i].default_flags = src->properties[i].default_flags;
+ duplicate_CIMVAR(dst->properties, &src->properties[i].default_values, &dst->properties[i].default_values, src->properties[i].property.desc->cimtype);
}
}
@@ -302,7 +285,7 @@ void duplicate_WbemInstance(TALLOC_CTX *mem_ctx, const struct WbemInstance *src,
dst->data = talloc_array(mem_ctx, union CIMVAR, cls->__PROPERTY_COUNT);
for (i = 0; i < cls->__PROPERTY_COUNT; ++i) {
dst->default_flags[i] = src->default_flags[i];
- duplicate_CIMVAR(dst->data, &src->data[i], &dst->data[i], cls->properties[i].desc->cimtype);
+ duplicate_CIMVAR(dst->data, &src->data[i], &dst->data[i], cls->properties[i].property.desc->cimtype);
}
dst->u2_4 = src->u2_4;
@@ -404,10 +387,12 @@ WERROR WbemClassObject_Get(struct WbemClassObject *d, TALLOC_CTX *mem_ctx, const
{
uint32_t i;
for (i = 0; i < d->obj_class->__PROPERTY_COUNT; ++i) {
- if (!strcmp(d->obj_class->properties[i].name, name)) {
- duplicate_CIMVAR(mem_ctx, &d->instance->data[i], val, d->obj_class->properties[i].desc->cimtype);
- if (cimtype) *cimtype = d->obj_class->properties[i].desc->cimtype;
- if (flavor) *flavor = 0; // FIXME:avg implement flavor
+ if (!strcmp(d->obj_class->properties[i].property.name, name)) {
+ duplicate_CIMVAR(mem_ctx, &d->instance->data[i], val, d->obj_class->properties[i].property.desc->cimtype);
+ if (cimtype != NULL)
+ *cimtype = d->obj_class->properties[i].property.desc->cimtype;
+ if (flavor != NULL)
+ *flavor = 0; /* FIXME:avg implement flavor */
return WERR_OK;
}
}
@@ -421,10 +406,10 @@ WERROR IWbemClassObject_Put(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, con
wco = (struct WbemClassObject *)d->object_data;
for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) {
- if (!strcmp(wco->obj_class->properties[i].name, name)) {
- if (cimtype && cimtype != wco->obj_class->properties[i].desc->cimtype) return WERR_INVALID_PARAM;
+ if (!strcmp(wco->obj_class->properties[i].property.name, name)) {
+ if (cimtype && cimtype != wco->obj_class->properties[i].property.desc->cimtype) return WERR_INVALID_PARAM;
wco->instance->default_flags[i] = 0;
- duplicate_CIMVAR(wco->instance, val, &wco->instance->data[i], wco->obj_class->properties[i].desc->cimtype);
+ duplicate_CIMVAR(wco->instance, val, &wco->instance->data[i], wco->obj_class->properties[i].property.desc->cimtype);
return WERR_OK;
}
}
@@ -432,11 +417,11 @@ WERROR IWbemClassObject_Put(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, con
}
#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \
- DEBUG(1, ("ERROR: %s - %s\n", msg, wmi_errstr(result))); \
- goto end; \
- } else { \
- DEBUG(1, ("OK : %s\n", msg)); \
- }
+ DEBUG(1, ("ERROR: %s - %s\n", msg, wmi_errstr(result))); \
+ return result; \
+ } else { \
+ DEBUG(1, ("OK : %s\n", msg)); \
+ }
struct pair_guid_ptr {
struct GUID guid;
@@ -448,7 +433,7 @@ static void *get_ptr_by_guid(struct pair_guid_ptr *list, struct GUID *uuid)
{
for (; list; list = list->next) {
if (GUID_equal(&list->guid, uuid))
- return list->ptr;
+ return list->ptr;
}
return NULL;
}
@@ -470,8 +455,13 @@ struct IEnumWbemClassObject_data {
struct IWbemWCOSmartEnum *pSE;
struct pair_guid_ptr *cache;
};
+#define NDR_CHECK_EXPR(expr) do { if (!(expr)) {\
+ DEBUG(0, ("%s(%d): WBEMDATA_ERR(0x%08X): Error parsing(%s)\n", __FILE__, __LINE__, ndr->offset, #expr)); \
+ return NDR_ERR_VALIDATE; \
+ } \
+ } while(0)
+
#define NDR_CHECK_CONST(val, exp) NDR_CHECK_EXPR((val) == (exp))
-#define NDR_CHECK_RSTRING(rstring) NDR_CHECK_EXPR((rstring) >= 0)
static enum ndr_err_code WBEMDATA_Parse(TALLOC_CTX *mem_ctx, uint8_t *data, uint32_t size, struct IEnumWbemClassObject *d, uint32_t uCount, struct WbemClassObject **apObjects)
@@ -479,11 +469,11 @@ static enum ndr_err_code WBEMDATA_Parse(TALLOC_CTX *mem_ctx, uint8_t *data, uint
struct ndr_pull *ndr;
uint32_t u, i, ofs_next;
uint8_t u8, datatype;
- NTSTATUS status;
struct GUID guid;
struct IEnumWbemClassObject_data *ecod;
- if (!uCount) return NDR_ERR_BAD_SWITCH;
+ if (!uCount)
+ return NDR_ERR_BAD_SWITCH;
ecod = d->object_data;
@@ -493,7 +483,6 @@ static enum ndr_err_code WBEMDATA_Parse(TALLOC_CTX *mem_ctx, uint8_t *data, uint
ndr->data_size = size;
ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
- NDR_CHECK_set_shift(0x18);
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
NDR_CHECK_CONST(u, 0x0);
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u));
@@ -560,8 +549,6 @@ static enum ndr_err_code WBEMDATA_Parse(TALLOC_CTX *mem_ctx, uint8_t *data, uint
return NDR_ERR_SUCCESS;
}
-struct composite_context *dcom_proxy_IEnumWbemClassObject_Release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx);
-
WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount, struct WbemClassObject **apObjects, uint32_t *puReturned)
{
WERROR result;
@@ -574,18 +561,18 @@ WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX
loc_ctx = talloc_new(0);
ecod = d->object_data;
if (!ecod) {
- struct GUID iid;
+ struct GUID iid;
WERROR coresult;
d->object_data = ecod = talloc_zero(d, struct IEnumWbemClassObject_data);
- GUID_from_string(COM_IWBEMFETCHSMARTENUM_UUID, &iid);
- result = dcom_query_interface((struct IUnknown *)d, 5, 1, &iid, (struct IUnknown **)&ecod->pFSE, &coresult);
- WERR_CHECK("dcom_query_interface.");
- result = coresult;
- WERR_CHECK("Retrieve enumerator of result(IWbemFetchSmartEnum).");
+ GUID_from_string(COM_IWBEMFETCHSMARTENUM_UUID, &iid);
+ result = dcom_query_interface((struct IUnknown *)d, 5, 1, &iid, (struct IUnknown **)&ecod->pFSE, &coresult);
+ WERR_CHECK("dcom_query_interface.");
+ result = coresult;
+ WERR_CHECK("Retrieve enumerator of result(IWbemFetchSmartEnum).");
- result = IWbemFetchSmartEnum_Fetch(ecod->pFSE, mem_ctx, &ecod->pSE);
- WERR_CHECK("Retrieve enumerator of result(IWbemWCOSmartEnum).");
+ result = IWbemFetchSmartEnum_Fetch(ecod->pFSE, mem_ctx, &ecod->pSE);
+ WERR_CHECK("Retrieve enumerator of result(IWbemWCOSmartEnum).");
ecod->guid = GUID_random();
d->vtable->Release_send = dcom_proxy_IEnumWbemClassObject_Release_send;
@@ -593,16 +580,15 @@ WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX
result = IWbemWCOSmartEnum_Next(ecod->pSE, loc_ctx, &ecod->guid, lTimeout, uCount, puReturned, &size, &data);
if (!W_ERROR_EQUAL(result, WERR_BADFUNC)) {
- WERR_CHECK("IWbemWCOSmartEnum_Next.");
+ WERR_CHECK("IWbemWCOSmartEnum_Next.");
}
if (data) {
NDR_CHECK(WBEMDATA_Parse(mem_ctx, data, size, d, *puReturned, apObjects));
}
-end:
if (!W_ERROR_IS_OK(result)) {
- status = werror_to_ntstatus(result);
- DEBUG(9, ("dcom_proxy_IEnumWbemClassObject_Next: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status)));
+ status = werror_to_ntstatus(result);
+ DEBUG(9, ("dcom_proxy_IEnumWbemClassObject_Next: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status)));
}
talloc_free(loc_ctx);
return result;
@@ -630,15 +616,15 @@ struct composite_context *dcom_proxy_IEnumWbemClassObject_Release_send(struct IU
if (ecod) {
if (ecod->pFSE) {
talloc_steal(d, ecod->pFSE);
- iref[n].ipid = IUnknown_ipid(ecod->pFSE);
- iref[n].cPublicRefs = 5;
- iref[n].cPrivateRefs = 0;
+ iref[n].ipid = IUnknown_ipid(ecod->pFSE);
+ iref[n].cPublicRefs = 5;
+ iref[n].cPrivateRefs = 0;
++n;
}
if (ecod->pSE) {
talloc_steal(d, ecod->pSE);
- iref[n].ipid = IUnknown_ipid(ecod->pSE);
- iref[n].cPublicRefs = 5;
+ iref[n].ipid = IUnknown_ipid(ecod->pSE);
+ iref[n].cPublicRefs = 5;
iref[n].cPrivateRefs = 0;
++n;
}
diff --git a/source4/librpc/idl/wmi.idl b/source4/librpc/idl/wmi.idl
index 11f6b1beaf..fe16e5e8ef 100644
--- a/source4/librpc/idl/wmi.idl
+++ b/source4/librpc/idl/wmi.idl
@@ -417,6 +417,13 @@ interface IWbemClassObject : IUnknown
DEFAULT_FLAG_INHERITED = 2
} DEFAULT_FLAGS;
+ typedef struct {
+ WbemProperty property;
+ uint8 default_flags;
+ [switch_is(property.desc->cimtype)] CIMVAR default_values;
+ } WbemClassProperty;
+
+
typedef [public,nopush,nopull,noprint,flag(NDR_NOALIGN)] struct
{
uint8 u_0;
@@ -425,9 +432,7 @@ interface IWbemClassObject : IUnknown
CIMSTRINGS __DERIVATION;
WbemQualifiers qualifiers;
uint32 __PROPERTY_COUNT;
- WbemProperty properties[__PROPERTY_COUNT];
- uint8 default_flags[__PROPERTY_COUNT];
- uint32 /*CIMVAR*/ default_values[__PROPERTY_COUNT];
+ WbemClassProperty properties[__PROPERTY_COUNT];
} WbemClass;
typedef [public] struct
@@ -452,7 +457,7 @@ interface IWbemClassObject : IUnknown
uint8 u1_0;
[relative,charset(UTF16)] uint16 *__CLASS;
uint8 *default_flags;
- uint32 /*CIMVAR*/ *data;
+ uint32 *data;
uint32 u2_4;
uint8 u3_1;
} WbemInstance;