mirror of
https://github.com/samba-team/samba.git
synced 2025-01-04 05:18:06 +03:00
Sync with HEAD.
This commit is contained in:
parent
373f8bcd29
commit
0310e539bb
@ -17,12 +17,11 @@ string, with one character per field."""
|
|||||||
__author__ = 'Martin Pool <mbp@sourcefrog.net>'
|
__author__ = 'Martin Pool <mbp@sourcefrog.net>'
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
# import tdbutil
|
import oldtdbutil
|
||||||
import samba.tdbpack
|
import samba.tdbpack
|
||||||
|
|
||||||
packer = samba.tdbpack.pack
|
both_unpackers = (samba.tdbpack.unpack, oldtdbutil.unpack)
|
||||||
unpacker = samba.tdbpack.unpack
|
both_packers = (samba.tdbpack.pack, oldtdbutil.pack)
|
||||||
|
|
||||||
|
|
||||||
class PackTests(unittest.TestCase):
|
class PackTests(unittest.TestCase):
|
||||||
symm_cases = [('B', ['hello' * 51], '\xff\0\0\0' + 'hello' * 51),
|
symm_cases = [('B', ['hello' * 51], '\xff\0\0\0' + 'hello' * 51),
|
||||||
@ -78,6 +77,8 @@ class PackTests(unittest.TestCase):
|
|||||||
def test_symmetric(self):
|
def test_symmetric(self):
|
||||||
"""Cookbook of symmetric pack/unpack tests
|
"""Cookbook of symmetric pack/unpack tests
|
||||||
"""
|
"""
|
||||||
|
for packer in both_packers:
|
||||||
|
for unpacker in both_unpackers:
|
||||||
for format, values, expected in self.symm_cases:
|
for format, values, expected in self.symm_cases:
|
||||||
self.assertEquals(packer(format, values), expected)
|
self.assertEquals(packer(format, values), expected)
|
||||||
out, rest = unpacker(format, expected)
|
out, rest = unpacker(format, expected)
|
||||||
@ -100,11 +101,13 @@ class PackTests(unittest.TestCase):
|
|||||||
# as if you called list()
|
# as if you called list()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
for packer in both_packers:
|
||||||
for format, values, expected in cases:
|
for format, values, expected in cases:
|
||||||
self.assertEquals(packer(format, values), expected)
|
self.assertEquals(packer(format, values), expected)
|
||||||
|
|
||||||
def test_unpack_extra(self):
|
def test_unpack_extra(self):
|
||||||
# Test leftover data
|
# Test leftover data
|
||||||
|
for unpacker in both_unpackers:
|
||||||
for format, values, packed in self.symm_cases:
|
for format, values, packed in self.symm_cases:
|
||||||
out, rest = unpacker(format, packed + 'hello sailor!')
|
out, rest = unpacker(format, packed + 'hello sailor!')
|
||||||
self.assertEquals(rest, 'hello sailor!')
|
self.assertEquals(rest, 'hello sailor!')
|
||||||
@ -114,7 +117,10 @@ class PackTests(unittest.TestCase):
|
|||||||
def test_unpack(self):
|
def test_unpack(self):
|
||||||
"""Cookbook of tricky unpack tests"""
|
"""Cookbook of tricky unpack tests"""
|
||||||
cases = [
|
cases = [
|
||||||
|
# Apparently I couldn't think of any tests that weren't
|
||||||
|
# symmetric :-/
|
||||||
]
|
]
|
||||||
|
for unpacker in both_unpackers:
|
||||||
for format, values, expected in cases:
|
for format, values, expected in cases:
|
||||||
out, rest = unpacker(format, expected)
|
out, rest = unpacker(format, expected)
|
||||||
self.assertEquals(rest, '')
|
self.assertEquals(rest, '')
|
||||||
@ -141,7 +147,7 @@ class PackTests(unittest.TestCase):
|
|||||||
('f', [2], TypeError),
|
('f', [2], TypeError),
|
||||||
('P', [None], TypeError),
|
('P', [None], TypeError),
|
||||||
('P', (), IndexError),
|
('P', (), IndexError),
|
||||||
('f', [packer], TypeError),
|
('f', [hex], TypeError),
|
||||||
('fw', ['hello'], IndexError),
|
('fw', ['hello'], IndexError),
|
||||||
('f', [u'hello'], TypeError),
|
('f', [u'hello'], TypeError),
|
||||||
('B', [2], TypeError),
|
('B', [2], TypeError),
|
||||||
@ -153,6 +159,7 @@ class PackTests(unittest.TestCase):
|
|||||||
('fQ', ['2'], IndexError),
|
('fQ', ['2'], IndexError),
|
||||||
(2, [2], TypeError),
|
(2, [2], TypeError),
|
||||||
({}, {}, TypeError)]
|
({}, {}, TypeError)]
|
||||||
|
for packer in both_packers:
|
||||||
for format, values, throwable_class in cases:
|
for format, values, throwable_class in cases:
|
||||||
def do_pack():
|
def do_pack():
|
||||||
packer(format, values)
|
packer(format, values)
|
||||||
@ -183,6 +190,7 @@ class PackTests(unittest.TestCase):
|
|||||||
('BB', '\x01\0\0\0a\x01', IndexError),
|
('BB', '\x01\0\0\0a\x01', IndexError),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
for unpacker in both_unpackers:
|
||||||
for format, values, throwable_class in cases:
|
for format, values, throwable_class in cases:
|
||||||
def do_unpack():
|
def do_unpack():
|
||||||
unpacker(format, values)
|
unpacker(format, values)
|
||||||
|
@ -218,7 +218,7 @@ BOOL py_parse_creds(PyObject *creds, char **username, char **domain,
|
|||||||
be freed by calling free(). */
|
be freed by calling free(). */
|
||||||
|
|
||||||
struct cli_state *open_pipe_creds(char *server, PyObject *creds,
|
struct cli_state *open_pipe_creds(char *server, PyObject *creds,
|
||||||
char *pipe_name, char **errstr)
|
int pipe_idx, char **errstr)
|
||||||
{
|
{
|
||||||
char *username, *password, *domain;
|
char *username, *password, *domain;
|
||||||
struct cli_state *cli;
|
struct cli_state *cli;
|
||||||
@ -240,10 +240,9 @@ struct cli_state *open_pipe_creds(char *server, PyObject *creds,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cli_nt_session_open(cli, pipe_name)) {
|
if (!cli_nt_session_open(cli, pipe_idx)) {
|
||||||
cli_shutdown(cli);
|
cli_shutdown(cli);
|
||||||
free(cli);
|
asprintf(errstr, "error opening pipe index %d", pipe_idx);
|
||||||
asprintf(errstr, "error opening %s", pipe_name);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ PyObject *py_setup_logging(PyObject *self, PyObject *args, PyObject *kw);
|
|||||||
BOOL py_parse_creds(PyObject *creds, char **username, char **domain,
|
BOOL py_parse_creds(PyObject *creds, char **username, char **domain,
|
||||||
char **password, char **errstr);
|
char **password, char **errstr);
|
||||||
struct cli_state *open_pipe_creds(char *server, PyObject *creds,
|
struct cli_state *open_pipe_creds(char *server, PyObject *creds,
|
||||||
char *pipe_name, char **errstr);
|
int pipe_idx, char **errstr);
|
||||||
BOOL get_level_value(PyObject *dict, uint32 *level);
|
BOOL get_level_value(PyObject *dict, uint32 *level);
|
||||||
|
|
||||||
/* The following definitions come from python/py_ntsec.c */
|
/* The following definitions come from python/py_ntsec.c */
|
||||||
|
@ -78,7 +78,7 @@ static PyObject *lsa_open_policy(PyObject *self, PyObject *args,
|
|||||||
|
|
||||||
server += 2;
|
server += 2;
|
||||||
|
|
||||||
if (!(cli = open_pipe_creds(server, creds, PIPE_LSARPC, &errstr))) {
|
if (!(cli = open_pipe_creds(server, creds, PI_LSARPC, &errstr))) {
|
||||||
PyErr_SetString(lsa_error, errstr);
|
PyErr_SetString(lsa_error, errstr);
|
||||||
free(errstr);
|
free(errstr);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -393,7 +393,7 @@ static PyObject *samr_connect(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cli = open_pipe_creds(server, creds, PIPE_SAMR, &errstr))) {
|
if (!(cli = open_pipe_creds(server, creds, PI_SAMR, &errstr))) {
|
||||||
PyErr_SetString(samr_error, errstr);
|
PyErr_SetString(samr_error, errstr);
|
||||||
free(errstr);
|
free(errstr);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -409,7 +409,6 @@ static PyObject *samr_connect(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
|
|
||||||
if (!NT_STATUS_IS_OK(ntstatus)) {
|
if (!NT_STATUS_IS_OK(ntstatus)) {
|
||||||
cli_shutdown(cli);
|
cli_shutdown(cli);
|
||||||
SAFE_FREE(cli);
|
|
||||||
PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus));
|
PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -97,12 +97,12 @@ static PyObject *py_smb_session_setup(PyObject *self, PyObject *args,
|
|||||||
PyObject *kw)
|
PyObject *kw)
|
||||||
{
|
{
|
||||||
cli_state_object *cli = (cli_state_object *)self;
|
cli_state_object *cli = (cli_state_object *)self;
|
||||||
static char *kwlist[] = { "creds" };
|
static char *kwlist[] = { "creds", NULL };
|
||||||
PyObject *creds;
|
PyObject *creds;
|
||||||
char *username, *domain, *password, *errstr;
|
char *username, *domain, *password, *errstr;
|
||||||
BOOL result;
|
BOOL result;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "O", kwlist, &creds))
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "|O", kwlist, &creds))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!py_parse_creds(creds, &username, &domain, &password, &errstr)) {
|
if (!py_parse_creds(creds, &username, &domain, &password, &errstr)) {
|
||||||
@ -114,35 +114,192 @@ static PyObject *py_smb_session_setup(PyObject *self, PyObject *args,
|
|||||||
cli->cli, username, password, strlen(password) + 1,
|
cli->cli, username, password, strlen(password) + 1,
|
||||||
password, strlen(password) + 1, domain);
|
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);
|
return Py_BuildValue("i", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *py_smb_tconx(PyObject *self, PyObject *args, PyObject *kw)
|
static PyObject *py_smb_tconx(PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
cli_state_object *cli = (cli_state_object *)self;
|
cli_state_object *cli = (cli_state_object *)self;
|
||||||
static char *kwlist[] = { "service", "creds" };
|
static char *kwlist[] = { "service", NULL };
|
||||||
PyObject *creds;
|
char *service;
|
||||||
char *service, *username, *domain, *password, *errstr;
|
|
||||||
BOOL result;
|
BOOL result;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kw, "sO", kwlist, &service,
|
if (!PyArg_ParseTupleAndKeywords(args, kw, "s", kwlist, &service))
|
||||||
&creds))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!py_parse_creds(creds, &username, &domain, &password, &errstr)) {
|
|
||||||
free(errstr);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = cli_send_tconX(
|
result = cli_send_tconX(
|
||||||
cli->cli, service, strequal(service, "IPC$") ? "IPC" : "?????",
|
cli->cli, service, strequal(service, "IPC$") ? "IPC" :
|
||||||
password, strlen(password) + 1);
|
"?????", "", 1);
|
||||||
|
|
||||||
|
if (cli_is_error(cli->cli)) {
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, "tconx failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return Py_BuildValue("i", result);
|
return Py_BuildValue("i", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *py_smb_nt_create_andx(PyObject *self, PyObject *args,
|
||||||
|
PyObject *kw)
|
||||||
|
{
|
||||||
|
cli_state_object *cli = (cli_state_object *)self;
|
||||||
|
static char *kwlist[] = { "filename", "desired_access",
|
||||||
|
"file_attributes", "share_access",
|
||||||
|
"create_disposition", NULL };
|
||||||
|
char *filename;
|
||||||
|
uint32 desired_access, file_attributes = 0,
|
||||||
|
share_access = FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
create_disposition = FILE_EXISTS_OPEN, create_options = 0;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
/* Parse parameters */
|
||||||
|
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
|
args, kw, "si|iii", kwlist, &filename, &desired_access,
|
||||||
|
&file_attributes, &share_access, &create_disposition,
|
||||||
|
&create_options))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
result = cli_nt_create_full(
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *py_smb_close(PyObject *self, PyObject *args,
|
||||||
|
PyObject *kw)
|
||||||
|
{
|
||||||
|
cli_state_object *cli = (cli_state_object *)self;
|
||||||
|
static char *kwlist[] = { "fnum", NULL };
|
||||||
|
BOOL result;
|
||||||
|
int fnum;
|
||||||
|
|
||||||
|
/* Parse parameters */
|
||||||
|
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
|
args, kw, "i", kwlist, &fnum))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
result = cli_close(cli->cli, fnum);
|
||||||
|
|
||||||
|
return PyInt_FromLong(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *py_smb_unlink(PyObject *self, PyObject *args,
|
||||||
|
PyObject *kw)
|
||||||
|
{
|
||||||
|
cli_state_object *cli = (cli_state_object *)self;
|
||||||
|
static char *kwlist[] = { "filename", NULL };
|
||||||
|
char *filename;
|
||||||
|
BOOL result;
|
||||||
|
|
||||||
|
/* Parse parameters */
|
||||||
|
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
|
args, kw, "s", kwlist, &filename))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
result = cli_unlink(cli->cli, filename);
|
||||||
|
|
||||||
|
return PyInt_FromLong(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
|
||||||
|
PyObject *kw)
|
||||||
|
{
|
||||||
|
cli_state_object *cli = (cli_state_object *)self;
|
||||||
|
static char *kwlist[] = { "fnum", NULL };
|
||||||
|
PyObject *result;
|
||||||
|
SEC_DESC *secdesc = NULL;
|
||||||
|
int fnum;
|
||||||
|
TALLOC_CTX *mem_ctx;
|
||||||
|
|
||||||
|
/* Parse parameters */
|
||||||
|
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
|
args, kw, "i", kwlist, &fnum))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
mem_ctx = talloc_init();
|
||||||
|
|
||||||
|
secdesc = cli_query_secdesc(cli->cli, fnum, mem_ctx);
|
||||||
|
|
||||||
|
if (cli_is_error(cli->cli)) {
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, "query_secdesc failed");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!secdesc) {
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
result = Py_None;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!py_from_SECDESC(&result, secdesc)) {
|
||||||
|
PyErr_SetString(
|
||||||
|
PyExc_TypeError,
|
||||||
|
"Invalid security descriptor returned");
|
||||||
|
result = NULL;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
talloc_destroy(mem_ctx);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *py_smb_set_secdesc(PyObject *self, PyObject *args,
|
||||||
|
PyObject *kw)
|
||||||
|
{
|
||||||
|
cli_state_object *cli = (cli_state_object *)self;
|
||||||
|
static char *kwlist[] = { "fnum", "security_descriptor", NULL };
|
||||||
|
PyObject *py_secdesc;
|
||||||
|
SEC_DESC *secdesc;
|
||||||
|
TALLOC_CTX *mem_ctx = talloc_init();
|
||||||
|
int fnum;
|
||||||
|
BOOL result;
|
||||||
|
|
||||||
|
/* Parse parameters */
|
||||||
|
|
||||||
|
if (!PyArg_ParseTupleAndKeywords(
|
||||||
|
args, kw, "iO", kwlist, &fnum, &py_secdesc))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!py_to_SECDESC(&secdesc, py_secdesc, mem_ctx)) {
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"Invalid security descriptor");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
static PyMethodDef smb_hnd_methods[] = {
|
static PyMethodDef smb_hnd_methods[] = {
|
||||||
|
|
||||||
|
/* Session and connection handling */
|
||||||
|
|
||||||
{ "session_request", (PyCFunction)py_smb_session_request,
|
{ "session_request", (PyCFunction)py_smb_session_request,
|
||||||
METH_VARARGS | METH_KEYWORDS, "Request a session" },
|
METH_VARARGS | METH_KEYWORDS, "Request a session" },
|
||||||
|
|
||||||
@ -155,6 +312,25 @@ static PyMethodDef smb_hnd_methods[] = {
|
|||||||
{ "tconx", (PyCFunction)py_smb_tconx,
|
{ "tconx", (PyCFunction)py_smb_tconx,
|
||||||
METH_VARARGS | METH_KEYWORDS, "Tree connect" },
|
METH_VARARGS | METH_KEYWORDS, "Tree connect" },
|
||||||
|
|
||||||
|
/* File operations */
|
||||||
|
|
||||||
|
{ "nt_create_andx", (PyCFunction)py_smb_nt_create_andx,
|
||||||
|
METH_VARARGS | METH_KEYWORDS, "NT Create&X" },
|
||||||
|
|
||||||
|
{ "close", (PyCFunction)py_smb_close,
|
||||||
|
METH_VARARGS | METH_KEYWORDS, "Close" },
|
||||||
|
|
||||||
|
{ "unlink", (PyCFunction)py_smb_unlink,
|
||||||
|
METH_VARARGS | METH_KEYWORDS, "Unlink" },
|
||||||
|
|
||||||
|
/* Security descriptors */
|
||||||
|
|
||||||
|
{ "query_secdesc", (PyCFunction)py_smb_query_secdesc,
|
||||||
|
METH_VARARGS | METH_KEYWORDS, "Query security descriptor" },
|
||||||
|
|
||||||
|
{ "set_secdesc", (PyCFunction)py_smb_set_secdesc,
|
||||||
|
METH_VARARGS | METH_KEYWORDS, "Set security descriptor" },
|
||||||
|
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ PyObject *spoolss_enumprinterdrivers(PyObject *self, PyObject *args,
|
|||||||
|
|
||||||
/* Call rpc function */
|
/* Call rpc function */
|
||||||
|
|
||||||
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
|
if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
|
||||||
PyErr_SetString(spoolss_error, errstr);
|
PyErr_SetString(spoolss_error, errstr);
|
||||||
free(errstr);
|
free(errstr);
|
||||||
goto done;
|
goto done;
|
||||||
@ -261,7 +261,7 @@ PyObject *spoolss_getprinterdriverdir(PyObject *self, PyObject *args,
|
|||||||
|
|
||||||
/* Call rpc function */
|
/* Call rpc function */
|
||||||
|
|
||||||
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
|
if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
|
||||||
PyErr_SetString(spoolss_error, errstr);
|
PyErr_SetString(spoolss_error, errstr);
|
||||||
free(errstr);
|
free(errstr);
|
||||||
goto done;
|
goto done;
|
||||||
@ -341,7 +341,7 @@ PyObject *spoolss_addprinterdriver(PyObject *self, PyObject *args,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
|
if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
|
||||||
PyErr_SetString(spoolss_error, errstr);
|
PyErr_SetString(spoolss_error, errstr);
|
||||||
free(errstr);
|
free(errstr);
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -53,7 +53,7 @@ PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
|
if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
|
||||||
PyErr_SetString(spoolss_error, errstr);
|
PyErr_SetString(spoolss_error, errstr);
|
||||||
free(errstr);
|
free(errstr);
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -56,7 +56,7 @@ PyObject *spoolss_openprinter(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
|
if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
|
||||||
PyErr_SetString(spoolss_error, errstr);
|
PyErr_SetString(spoolss_error, errstr);
|
||||||
free(errstr);
|
free(errstr);
|
||||||
goto done;
|
goto done;
|
||||||
@ -304,7 +304,7 @@ PyObject *spoolss_enumprinters(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
|
if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
|
||||||
PyErr_SetString(spoolss_error, errstr);
|
PyErr_SetString(spoolss_error, errstr);
|
||||||
free(errstr);
|
free(errstr);
|
||||||
goto done;
|
goto done;
|
||||||
@ -439,7 +439,7 @@ PyObject *spoolss_addprinterex(PyObject *self, PyObject *args, PyObject *kw)
|
|||||||
&PyDict_Type, &info, &PyDict_Type, &creds))
|
&PyDict_Type, &info, &PyDict_Type, &creds))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
|
if (!(cli = open_pipe_creds(server, creds, PI_SPOOLSS, &errstr))) {
|
||||||
PyErr_SetString(spoolss_error, errstr);
|
PyErr_SetString(spoolss_error, errstr);
|
||||||
free(errstr);
|
free(errstr);
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -329,18 +329,35 @@ pytdbpack_calc_reqd_len(char *format_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static PyObject *pytdbpack_bad_type(char ch,
|
||||||
|
const char *expected,
|
||||||
|
PyObject *val_obj)
|
||||||
|
{
|
||||||
|
PyObject *r = PyObject_Repr(val_obj);
|
||||||
|
if (!r)
|
||||||
|
return NULL;
|
||||||
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
"tdbpack: format '%c' requires %s, not %s",
|
||||||
|
ch, expected, PyString_AS_STRING(r));
|
||||||
|
Py_DECREF(r);
|
||||||
|
return val_obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Calculate the number of bytes required to pack a single value.
|
* Calculate the number of bytes required to pack a single value. While doing
|
||||||
*/
|
* this, also conduct some initial checks that the argument types are
|
||||||
|
* reasonable.
|
||||||
|
*
|
||||||
|
* Returns -1 on exception.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
pytdbpack_calc_item_len(char ch,
|
pytdbpack_calc_item_len(char ch,
|
||||||
PyObject *val_obj)
|
PyObject *val_obj)
|
||||||
{
|
{
|
||||||
if (ch == 'd' || ch == 'w') {
|
if (ch == 'd' || ch == 'w') {
|
||||||
if (!PyInt_Check(val_obj)) {
|
if (!PyInt_Check(val_obj)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
pytdbpack_bad_type(ch, "Int", val_obj);
|
||||||
"tdbpack: format '%c' requires an Int",
|
|
||||||
ch);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ch == 'w')
|
if (ch == 'w')
|
||||||
@ -353,10 +370,7 @@ pytdbpack_calc_item_len(char ch,
|
|||||||
else if (ch == 'f' || ch == 'P' || ch == 'B') {
|
else if (ch == 'f' || ch == 'P' || ch == 'B') {
|
||||||
/* nul-terminated 8-bit string */
|
/* nul-terminated 8-bit string */
|
||||||
if (!PyString_Check(val_obj)) {
|
if (!PyString_Check(val_obj)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
pytdbpack_bad_type(ch, "String", val_obj);
|
||||||
"tdbpack: format '%c' requires a String",
|
|
||||||
ch);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch == 'B') {
|
if (ch == 'B') {
|
||||||
@ -371,7 +385,7 @@ pytdbpack_calc_item_len(char ch,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyErr_Format(PyExc_ValueError,
|
PyErr_Format(PyExc_ValueError,
|
||||||
__FUNCTION__ ": format character '%c' is not supported",
|
"tdbpack: format character '%c' is not supported",
|
||||||
ch);
|
ch);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -157,7 +157,8 @@ setup(
|
|||||||
|
|
||||||
Extension(name = "smb",
|
Extension(name = "smb",
|
||||||
sources = [samba_srcdir + "python/py_smb.c",
|
sources = [samba_srcdir + "python/py_smb.c",
|
||||||
samba_srcdir + "python/py_common.c"],
|
samba_srcdir + "python/py_common.c",
|
||||||
|
samba_srcdir + "python/py_ntsec.c"],
|
||||||
libraries = lib_list,
|
libraries = lib_list,
|
||||||
library_dirs = ["/usr/kerberos/lib"],
|
library_dirs = ["/usr/kerberos/lib"],
|
||||||
extra_compile_args = flags_list,
|
extra_compile_args = flags_list,
|
||||||
|
Loading…
Reference in New Issue
Block a user