summaryrefslogtreecommitdiff
path: root/source4/librpc/rpc
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-05-24 23:02:09 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-05-24 23:02:09 +0200
commit2a6c4da9d10893f56915bfc19333ca776c6dab13 (patch)
tree2c11c4b5918d989db31e2f9459891751b80745dc /source4/librpc/rpc
parent21ce0ff00688c560e60efd6c392c71f85229c9d4 (diff)
downloadsamba-2a6c4da9d10893f56915bfc19333ca776c6dab13.tar.gz
samba-2a6c4da9d10893f56915bfc19333ca776c6dab13.tar.bz2
samba-2a6c4da9d10893f56915bfc19333ca776c6dab13.zip
Support optional object argument when sending DCE/RPC requests.
(This used to be commit 75ba01a0fad87a9a4788f4c2277d8db0513cef4a)
Diffstat (limited to 'source4/librpc/rpc')
-rw-r--r--source4/librpc/rpc/pyrpc.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c
index b87628f345..0f03fe851e 100644
--- a/source4/librpc/rpc/pyrpc.c
+++ b/source4/librpc/rpc/pyrpc.c
@@ -23,6 +23,17 @@
#include "librpc/rpc/dcerpc.h"
#include "lib/events/events.h"
+static bool PyString_AsGUID(PyObject *object, struct GUID *uuid)
+{
+ NTSTATUS status;
+ status = GUID_from_string(PyString_AsString(object), uuid);
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetNTSTATUS(status);
+ return false;
+ }
+ return true;
+}
+
static PyObject *py_iface_server_name(PyObject *obj, void *closure)
{
const char *server_name;
@@ -49,11 +60,12 @@ static PyObject *py_iface_request(PyObject *self, PyObject *args, PyObject *kwar
char *in_data;
int in_length;
PyObject *ret;
- char *object;
+ PyObject *object = NULL;
+ struct GUID object_guid;
TALLOC_CTX *mem_ctx = talloc_new(NULL);
const char *kwnames[] = { "opnum", "data", "object", NULL };
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "is#|s:request",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "is#|O:request",
discard_const_p(char *, kwnames), &opnum, &in_data, &in_length, &object)) {
return NULL;
}
@@ -63,7 +75,11 @@ static PyObject *py_iface_request(PyObject *self, PyObject *args, PyObject *kwar
ZERO_STRUCT(data_out);
- status = dcerpc_request(iface->pipe, NULL /* FIXME: object GUID */,
+ if (object != NULL && !PyString_AsGUID(object, &object_guid)) {
+ return NULL;
+ }
+
+ status = dcerpc_request(iface->pipe, object?&object_guid:NULL,
opnum, false, mem_ctx, &data_in, &data_out);
if (NT_STATUS_IS_ERR(status)) {
@@ -79,7 +95,7 @@ static PyObject *py_iface_request(PyObject *self, PyObject *args, PyObject *kwar
}
static PyMethodDef dcerpc_interface_methods[] = {
- { "request", (PyCFunction)py_iface_request, METH_VARARGS|METH_KEYWORDS, "S.request(opnum, data) -> data\nMake a raw request" },
+ { "request", (PyCFunction)py_iface_request, METH_VARARGS|METH_KEYWORDS, "S.request(opnum, data, object=None) -> data\nMake a raw request" },
{ NULL, NULL, 0, NULL },
};
@@ -91,17 +107,6 @@ static void dcerpc_interface_dealloc(PyObject* self)
PyObject_Del(self);
}
-static bool PyString_AsGUID(PyObject *object, struct GUID *uuid)
-{
- NTSTATUS status;
- status = GUID_from_string(PyString_AsString(object), uuid);
- if (NT_STATUS_IS_ERR(status)) {
- PyErr_SetNTSTATUS(status);
- return false;
- }
- return true;
-}
-
static bool ndr_syntax_from_py_object(PyObject *object, struct ndr_syntax_id *syntax_id)
{
ZERO_STRUCTP(syntax_id);