mirror of
https://github.com/samba-team/samba.git
synced 2025-12-12 12:23:50 +03:00
Fixed bug in session setup kwlist.
Added some basic error handling. Just throw a RuntimeError exception on error.
This commit is contained in:
@@ -97,7 +97,7 @@ static PyObject *py_smb_session_setup(PyObject *self, PyObject *args,
|
||||
PyObject *kw)
|
||||
{
|
||||
cli_state_object *cli = (cli_state_object *)self;
|
||||
static char *kwlist[] = { "creds" };
|
||||
static char *kwlist[] = { "creds", NULL };
|
||||
PyObject *creds;
|
||||
char *username, *domain, *password, *errstr;
|
||||
BOOL result;
|
||||
@@ -114,6 +114,11 @@ static PyObject *py_smb_session_setup(PyObject *self, PyObject *args,
|
||||
cli->cli, username, password, strlen(password) + 1,
|
||||
password, strlen(password) + 1, domain);
|
||||
|
||||
if (cli_is_error(cli->cli)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "session setup failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Py_BuildValue("i", result);
|
||||
}
|
||||
|
||||
@@ -131,6 +136,11 @@ static PyObject *py_smb_tconx(PyObject *self, PyObject *args, PyObject *kw)
|
||||
cli->cli, service, strequal(service, "IPC$") ? "IPC" :
|
||||
"?????", "", 1);
|
||||
|
||||
if (cli_is_error(cli->cli)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "tconx failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Py_BuildValue("i", result);
|
||||
}
|
||||
|
||||
@@ -159,6 +169,11 @@ static PyObject *py_smb_nt_create_andx(PyObject *self, PyObject *args,
|
||||
cli->cli, filename, desired_access, file_attributes,
|
||||
share_access, create_disposition, create_options);
|
||||
|
||||
if (cli_is_error(cli->cli)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "nt_create_andx failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return FID */
|
||||
|
||||
return PyInt_FromLong(result);
|
||||
@@ -184,7 +199,10 @@ static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
|
||||
|
||||
secdesc = cli_query_secdesc(cli->cli, fnum, mem_ctx);
|
||||
|
||||
/* FIXME: we should raise an exception here */
|
||||
if (cli_is_error(cli->cli)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "query_secdesc failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!secdesc) {
|
||||
Py_INCREF(Py_None);
|
||||
@@ -232,6 +250,11 @@ static PyObject *py_smb_set_secdesc(PyObject *self, PyObject *args,
|
||||
|
||||
result = cli_set_secdesc(cli->cli, fnum, secdesc);
|
||||
|
||||
if (cli_is_error(cli->cli)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "set_secdesc failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PyInt_FromLong(result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user