summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/rpc/pyrpc.c17
-rw-r--r--source4/librpc/rpc/pyrpc.h1
2 files changed, 16 insertions, 2 deletions
diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c
index 1662140bbc..70875168c5 100644
--- a/source4/librpc/rpc/pyrpc.c
+++ b/source4/librpc/rpc/pyrpc.c
@@ -47,10 +47,23 @@ static PyObject *py_iface_server_name(PyObject *obj, void *closure)
}
static PyGetSetDef dcerpc_interface_getsetters[] = {
- { discard_const_p(char, "server_name"), py_iface_server_name, NULL },
+ { discard_const_p(char, "server_name"), py_iface_server_name,
+ "name of the server, if connected over SMB"},
{ NULL }
};
+void PyErr_SetDCERPCStatus(struct dcerpc_pipe *p, NTSTATUS status)
+{
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
+ const char *errstr = dcerpc_errstr(NULL, p->last_fault_code);
+ PyErr_SetObject(PyExc_RuntimeError,
+ Py_BuildValue("(i,s)", p->last_fault_code,
+ errstr));
+ } else {
+ PyErr_SetNTSTATUS(status);
+ }
+}
+
static PyObject *py_iface_request(PyObject *self, PyObject *args, PyObject *kwargs)
{
dcerpc_InterfaceObject *iface = (dcerpc_InterfaceObject *)self;
@@ -83,7 +96,7 @@ static PyObject *py_iface_request(PyObject *self, PyObject *args, PyObject *kwar
opnum, false, mem_ctx, &data_in, &data_out);
if (NT_STATUS_IS_ERR(status)) {
- PyErr_SetNTSTATUS(status);
+ PyErr_SetDCERPCStatus(iface->pipe, status);
talloc_free(mem_ctx);
return NULL;
}
diff --git a/source4/librpc/rpc/pyrpc.h b/source4/librpc/rpc/pyrpc.h
index 65501b6b83..209d7d3f1f 100644
--- a/source4/librpc/rpc/pyrpc.h
+++ b/source4/librpc/rpc/pyrpc.h
@@ -50,5 +50,6 @@ PyAPI_DATA(PyTypeObject) dcerpc_InterfaceType;
#define PyErr_SetNdrError(err) \
PyErr_SetObject(PyExc_RuntimeError, PyErr_FromNdrError(err))
+void PyErr_SetDCERPCStatus(struct dcerpc_pipe *pipe, NTSTATUS status);
#endif /* _PYRPC_H_ */