summaryrefslogtreecommitdiff
path: root/source3/python
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-09-09 04:07:32 +0000
committerGerald Carter <jerry@samba.org>2003-09-09 04:07:32 +0000
commit4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8 (patch)
treedd0a9f32d9933e1f75d919b5083e007d7453f9c4 /source3/python
parent3d7cb49747a9a7f5cdec0ee05c6270ec3604202f (diff)
downloadsamba-4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8.tar.gz
samba-4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8.tar.bz2
samba-4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8.zip
sync 3.0 into HEAD for the last time
(This used to be commit c17a7dc9a190156a069da3e861c18fd3f81224ad)
Diffstat (limited to 'source3/python')
-rw-r--r--source3/python/py_lsa.c43
-rw-r--r--source3/python/py_smb.c25
-rw-r--r--source3/python/py_spoolss_drivers.c5
-rw-r--r--source3/python/py_winbind.c10
4 files changed, 49 insertions, 34 deletions
diff --git a/source3/python/py_lsa.c b/source3/python/py_lsa.c
index 4204f43f7b..07191be868 100644
--- a/source3/python/py_lsa.c
+++ b/source3/python/py_lsa.c
@@ -104,8 +104,7 @@ done:
if (cli)
cli_shutdown(cli);
- if (mem_ctx)
- talloc_destroy(mem_ctx);
+ talloc_destroy(mem_ctx);
}
return result;
@@ -141,12 +140,13 @@ static PyObject *lsa_close(PyObject *self, PyObject *args, PyObject *kw)
static PyObject *lsa_lookup_names(PyObject *self, PyObject *args)
{
- PyObject *py_names, *result;
+ PyObject *py_names, *result = NULL;
NTSTATUS ntstatus;
lsa_policy_hnd_object *hnd = (lsa_policy_hnd_object *)self;
int num_names, i;
const char **names;
DOM_SID *sids;
+ TALLOC_CTX *mem_ctx = NULL;
uint32 *name_types;
if (!PyArg_ParseTuple(args, "O", &py_names))
@@ -157,18 +157,22 @@ static PyObject *lsa_lookup_names(PyObject *self, PyObject *args)
return NULL;
}
+ if (!(mem_ctx = talloc_init("lsa_lookup_names"))) {
+ PyErr_SetString(lsa_error, "unable to init talloc context\n");
+ goto done;
+ }
+
if (PyList_Check(py_names)) {
/* Convert list to char ** array */
num_names = PyList_Size(py_names);
- names = (const char **)talloc(
- hnd->mem_ctx, num_names * sizeof(char *));
+ names = (const char **)talloc(mem_ctx, num_names * sizeof(char *));
for (i = 0; i < num_names; i++) {
PyObject *obj = PyList_GetItem(py_names, i);
- names[i] = talloc_strdup(hnd->mem_ctx, PyString_AsString(obj));
+ names[i] = talloc_strdup(mem_ctx, PyString_AsString(obj));
}
} else {
@@ -176,17 +180,17 @@ static PyObject *lsa_lookup_names(PyObject *self, PyObject *args)
/* Just a single element */
num_names = 1;
- names = (const char **)talloc(hnd->mem_ctx, sizeof(char *));
+ names = (const char **)talloc(mem_ctx, sizeof(char *));
names[0] = PyString_AsString(py_names);
}
- ntstatus = cli_lsa_lookup_names(hnd->cli, hnd->mem_ctx, &hnd->pol,
+ ntstatus = cli_lsa_lookup_names(hnd->cli, mem_ctx, &hnd->pol,
num_names, names, &sids, &name_types);
if (!NT_STATUS_IS_OK(ntstatus) && NT_STATUS_V(ntstatus) != 0x107) {
PyErr_SetObject(lsa_ntstatus, py_ntstatus_tuple(ntstatus));
- return NULL;
+ goto done;
}
result = PyList_New(num_names);
@@ -196,10 +200,13 @@ static PyObject *lsa_lookup_names(PyObject *self, PyObject *args)
py_from_SID(&sid_obj, &sids[i]);
- obj = Py_BuildValue("(Oi)", sid_obj, name_types[i]);
+ obj = Py_BuildValue("(Ni)", sid_obj, name_types[i]);
PyList_SetItem(result, i, obj);
}
+
+ done:
+ talloc_destroy(mem_ctx);
return result;
}
@@ -207,7 +214,7 @@ static PyObject *lsa_lookup_names(PyObject *self, PyObject *args)
static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
PyObject *kw)
{
- PyObject *py_sids, *result;
+ PyObject *py_sids, *result = NULL;
NTSTATUS ntstatus;
int num_sids, i;
char **domains, **names;
@@ -224,7 +231,7 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
return NULL;
}
- if (!(mem_ctx = talloc_init("lsa_open_policy"))) {
+ if (!(mem_ctx = talloc_init("lsa_lookup_sids"))) {
PyErr_SetString(lsa_error, "unable to init talloc context\n");
goto done;
}
@@ -243,7 +250,6 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
if (!string_to_sid(&sids[i], PyString_AsString(obj))) {
PyErr_SetString(PyExc_ValueError, "string_to_sid failed");
- result = NULL;
goto done;
}
}
@@ -257,7 +263,6 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
if (!string_to_sid(&sids[0], PyString_AsString(py_sids))) {
PyErr_SetString(PyExc_ValueError, "string_to_sid failed");
- result = NULL;
goto done;
}
}
@@ -268,7 +273,6 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
if (!NT_STATUS_IS_OK(ntstatus)) {
PyErr_SetObject(lsa_ntstatus, py_ntstatus_tuple(ntstatus));
- result = NULL;
goto done;
}
@@ -285,8 +289,7 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args,
}
done:
- if (mem_ctx)
- talloc_destroy(mem_ctx);
+ talloc_destroy(mem_ctx);
return result;
}
@@ -404,7 +407,7 @@ static PyMethodDef lsa_methods[] = {
"\n"
"Example:\n"
"\n"
-">>> spoolss.setup_logging(interactive = 1)" },
+">>> lsa.setup_logging(interactive = 1)" },
{ "get_debuglevel", (PyCFunction)get_debuglevel,
METH_VARARGS,
@@ -412,7 +415,7 @@ static PyMethodDef lsa_methods[] = {
"\n"
"Example:\n"
"\n"
-">>> spoolss.get_debuglevel()\n"
+">>> lsa.get_debuglevel()\n"
"0" },
{ "set_debuglevel", (PyCFunction)set_debuglevel,
@@ -421,7 +424,7 @@ static PyMethodDef lsa_methods[] = {
"\n"
"Example:\n"
"\n"
-">>> spoolss.set_debuglevel(10)" },
+">>> lsa.set_debuglevel(10)" },
{ NULL }
};
diff --git a/source3/python/py_smb.c b/source3/python/py_smb.c
index bb84a337c9..e5e6506196 100644
--- a/source3/python/py_smb.c
+++ b/source3/python/py_smb.c
@@ -221,10 +221,10 @@ static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
{
cli_state_object *cli = (cli_state_object *)self;
static char *kwlist[] = { "fnum", NULL };
- PyObject *result;
+ PyObject *result = NULL;
SEC_DESC *secdesc = NULL;
int fnum;
- TALLOC_CTX *mem_ctx;
+ TALLOC_CTX *mem_ctx = NULL;
/* Parse parameters */
@@ -238,7 +238,6 @@ static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
if (cli_is_error(cli->cli)) {
PyErr_SetString(PyExc_RuntimeError, "query_secdesc failed");
- result = NULL;
goto done;
}
@@ -252,7 +251,6 @@ static PyObject *py_smb_query_secdesc(PyObject *self, PyObject *args,
PyErr_SetString(
PyExc_TypeError,
"Invalid security descriptor returned");
- result = NULL;
goto done;
}
@@ -268,11 +266,12 @@ static PyObject *py_smb_set_secdesc(PyObject *self, PyObject *args,
{
cli_state_object *cli = (cli_state_object *)self;
static char *kwlist[] = { "fnum", "security_descriptor", NULL };
+ PyObject *result = NULL;
PyObject *py_secdesc;
SEC_DESC *secdesc;
- TALLOC_CTX *mem_ctx = talloc_init("py_smb_set_secdesc");
+ TALLOC_CTX *mem_ctx = NULL;
int fnum;
- BOOL result;
+ BOOL err;
/* Parse parameters */
@@ -280,20 +279,26 @@ static PyObject *py_smb_set_secdesc(PyObject *self, PyObject *args,
args, kw, "iO", kwlist, &fnum, &py_secdesc))
return NULL;
+ mem_ctx = talloc_init("py_smb_set_secdesc");
+
if (!py_to_SECDESC(&secdesc, py_secdesc, mem_ctx)) {
PyErr_SetString(PyExc_TypeError,
"Invalid security descriptor");
- return NULL;
+ goto done;
}
- result = cli_set_secdesc(cli->cli, fnum, secdesc);
+ err = cli_set_secdesc(cli->cli, fnum, secdesc);
if (cli_is_error(cli->cli)) {
PyErr_SetString(PyExc_RuntimeError, "set_secdesc failed");
- return NULL;
+ goto done;
}
- return PyInt_FromLong(result);
+ result = PyInt_FromLong(err);
+ done:
+ talloc_destroy(mem_ctx);
+
+ return result;
}
static PyMethodDef smb_hnd_methods[] = {
diff --git a/source3/python/py_spoolss_drivers.c b/source3/python/py_spoolss_drivers.c
index a072ac0d5c..12190519ec 100644
--- a/source3/python/py_spoolss_drivers.c
+++ b/source3/python/py_spoolss_drivers.c
@@ -177,6 +177,7 @@ PyObject *spoolss_hnd_getprinterdriver(PyObject *self, PyObject *args,
int level = 1;
uint32 needed;
char *arch = "Windows NT x86";
+ int version = 2;
static char *kwlist[] = {"level", "arch", NULL};
/* Parse parameters */
@@ -189,12 +190,12 @@ PyObject *spoolss_hnd_getprinterdriver(PyObject *self, PyObject *args,
werror = cli_spoolss_getprinterdriver(
hnd->cli, hnd->mem_ctx, 0, &needed, &hnd->pol, level,
- arch, &ctr);
+ version, arch, &ctr);
if (W_ERROR_V(werror) == ERRinsufficientbuffer)
werror = cli_spoolss_getprinterdriver(
hnd->cli, hnd->mem_ctx, needed, NULL, &hnd->pol,
- level, arch, &ctr);
+ level, version, arch, &ctr);
if (!W_ERROR_IS_OK(werror)) {
PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
diff --git a/source3/python/py_winbind.c b/source3/python/py_winbind.c
index ebceb95d71..130f78d7e1 100644
--- a/source3/python/py_winbind.c
+++ b/source3/python/py_winbind.c
@@ -427,7 +427,10 @@ static PyObject *py_auth_crap(PyObject *self, PyObject *args, PyObject *kw)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- fstrcpy(request.data.auth_crap.user, username);
+ if (push_utf8_fstring(request.data.auth_crap.user, username) == -1) {
+ PyErr_SetString(winbind_error, "unable to create utf8 string");
+ return NULL;
+ }
generate_random_buffer(request.data.auth_crap.chal, 8, False);
@@ -473,7 +476,10 @@ static PyObject *py_auth_smbd(PyObject *self, PyObject *args, PyObject *kw)
ZERO_STRUCT(request);
ZERO_STRUCT(response);
- fstrcpy(request.data.smbd_auth_crap.user, username);
+ if (push_utf8_fstring(request.data.auth_crap.user, username) == -1) {
+ PyErr_SetString("unable to create utf8 string");
+ return NULL;
+ }
generate_random_buffer(request.data.smbd_auth_crap.chal, 8, False);