summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/rpc/pyrpc.c17
-rw-r--r--source4/librpc/rpc/pyrpc.h1
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm9
3 files changed, 24 insertions, 3 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_ */
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 26197365ee..2795d987f7 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -409,7 +409,14 @@ sub PythonFunctionBody($$$)
}
}
$self->pidl("status = dcerpc_$fn->{NAME}(iface->pipe, mem_ctx, r);");
- $self->handle_ntstatus("status", "NULL", "mem_ctx");
+ $self->pidl("if (NT_STATUS_IS_ERR(status)) {");
+ $self->indent;
+ $self->pidl("PyErr_SetDCERPCStatus(iface->pipe, status);");
+ $self->pidl("talloc_free(mem_ctx);");
+ $self->pidl("return NULL;");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
$env = GenerateFunctionOutEnv($fn, "r->");
my $i = 0;