diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-05-24 21:20:45 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-05-24 21:20:45 +0200 |
commit | fe5be25547b5517ebc2e74d298921ae8c53650e5 (patch) | |
tree | 997e5f5eda69bd4c04701951e6366be3c33e8c71 /source4 | |
parent | 654be49c010949a0420412450971effdbd4ce585 (diff) | |
download | samba-fe5be25547b5517ebc2e74d298921ae8c53650e5.tar.gz samba-fe5be25547b5517ebc2e74d298921ae8c53650e5.tar.bz2 samba-fe5be25547b5517ebc2e74d298921ae8c53650e5.zip |
Allow request() call to do custom calls on DCE/RPC interfaces.
(This used to be commit 9c2eff0289d7c5963da87d5e002f1b80e6e66cdd)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/librpc/rpc/pyrpc.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c index 6796e4beee..cf16c582f4 100644 --- a/source4/librpc/rpc/pyrpc.c +++ b/source4/librpc/rpc/pyrpc.c @@ -25,9 +25,14 @@ static PyObject *py_iface_server_name(PyObject *obj, void *closure) { + const char *server_name; dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)obj; + + server_name = dcerpc_server_name(iface->pipe); + if (server_name == NULL) + return Py_None; - return PyString_FromString(dcerpc_server_name(iface->pipe)); + return PyString_FromString(server_name); } static PyGetSetDef dcerpc_interface_getsetters[] = { @@ -41,24 +46,35 @@ static PyObject *py_iface_request(PyObject *self, PyObject *args, PyObject *kwar int opnum; DATA_BLOB data_in, data_out; NTSTATUS status; + char *in_data; + int in_length; + PyObject *ret; char *object; + TALLOC_CTX *mem_ctx = talloc_new(NULL); const char *kwnames[] = { "opnum", "data", "object", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "is#|s:request", - discard_const_p(char *, kwnames), &opnum, &data_in.data, &data_in.length, &object)) { + discard_const_p(char *, kwnames), &opnum, &in_data, &in_length, &object)) { return NULL; } - status = dcerpc_request(iface->pipe, NULL /* FIXME: object GUID */, opnum, false, NULL, &data_in, - &data_out); + data_in.data = talloc_strndup(mem_ctx, in_data, in_length); + data_in.length = in_length; + + status = dcerpc_request(iface->pipe, NULL /* FIXME: object GUID */, + opnum, false, mem_ctx, &data_in, &data_out); if (NT_STATUS_IS_ERR(status)) { /* FIXME: Set more appropriate error */ PyErr_SetString(PyExc_RuntimeError, "Unable to connect"); + talloc_free(mem_ctx); return NULL; } - return PyString_FromStringAndSize((char *)data_out.data, data_out.length); + ret = PyString_FromStringAndSize((char *)data_out.data, data_out.length); + + talloc_free(mem_ctx); + return ret; } static PyMethodDef dcerpc_interface_methods[] = { |