From 4c1f0641d395e095d46cd0eb9a09055dd07f850b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 May 2008 00:04:11 +0200 Subject: Check for fault codes when connecting. (This used to be commit 42537b1d5282784550120358f3641f299351fba7) --- source4/librpc/rpc/pyrpc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source4/librpc') diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c index 70875168c5..1fc6e4e3c7 100644 --- a/source4/librpc/rpc/pyrpc.c +++ b/source4/librpc/rpc/pyrpc.c @@ -54,7 +54,7 @@ static PyGetSetDef dcerpc_interface_getsetters[] = { void PyErr_SetDCERPCStatus(struct dcerpc_pipe *p, NTSTATUS status) { - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { + if (p != NULL && 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, @@ -206,10 +206,12 @@ static PyObject *dcerpc_interface_new(PyTypeObject *self, PyObject *args, PyObje return NULL; } + ret->pipe = NULL; + status = dcerpc_pipe_connect(NULL, &ret->pipe, binding_string, table, credentials, event_ctx, lp_ctx); if (NT_STATUS_IS_ERR(status)) { - PyErr_SetString(PyExc_RuntimeError, nt_errstr(status)); + PyErr_SetDCERPCStatus(ret->pipe, status); talloc_free(mem_ctx); return NULL; } -- cgit