1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

passdb: Allocate talloc stackframe before calling in pdb functions.

This commit is contained in:
Amitay Isaacs 2011-08-11 13:59:00 +10:00 committed by Andrew Bartlett
parent ae9a3274bc
commit 65e12c0501

View File

@ -959,10 +959,16 @@ static PyObject *py_pdb_domain_info(pytalloc_Object *self, PyObject *args)
struct pdb_methods *methods;
struct pdb_domain_info *domain_info;
PyObject *py_domain_info;
TALLOC_CTX *tframe;
methods = pytalloc_get_ptr(self);
domain_info = methods->get_domain_info(methods, pytalloc_get_mem_ctx(self));
if ((tframe = talloc_stackframe()) == NULL) {
PyErr_NoMemory();
return NULL;
}
domain_info = methods->get_domain_info(methods, tframe);
if (! domain_info) {
Py_RETURN_NONE;
}
@ -980,7 +986,7 @@ static PyObject *py_pdb_domain_info(pytalloc_Object *self, PyObject *args)
struct GUID guid;
*/
talloc_free(domain_info);
talloc_free(tframe);
return py_domain_info;
}
@ -1432,6 +1438,12 @@ static PyObject *py_passdb_backends(PyObject *self)
{
PyObject *py_blist;
const struct pdb_init_function_entry *entry;
TALLOC_CTX *tframe;
if ((tframe = talloc_stackframe()) == NULL) {
PyErr_NoMemory();
return NULL;
}
entry = pdb_get_backends();
if(! entry) {
@ -1448,6 +1460,8 @@ static PyObject *py_passdb_backends(PyObject *self)
entry = entry->next;
}
talloc_free(tframe);
return py_blist;
}
@ -1455,17 +1469,25 @@ static PyObject *py_passdb_backends(PyObject *self)
static PyObject *py_set_smb_config(PyObject *self, PyObject *args)
{
const char *smb_config;
TALLOC_CTX *tframe;
if (!PyArg_ParseTuple(args, "s", &smb_config)) {
return NULL;
}
if ((tframe = talloc_stackframe()) == NULL) {
PyErr_NoMemory();
return NULL;
}
/* Load smbconf parameters */
if (!lp_load_global(smb_config)) {
PyErr_Format(py_pdb_error, "Cannot open '%s'", smb_config);
return NULL;
}
talloc_free(tframe);
Py_RETURN_NONE;
}
@ -1473,11 +1495,17 @@ static PyObject *py_set_smb_config(PyObject *self, PyObject *args)
static PyObject *py_set_secrets_dir(PyObject *self, PyObject *args)
{
const char *private_dir;
TALLOC_CTX *tframe;
if (!PyArg_ParseTuple(args, "s", &private_dir)) {
return NULL;
}
if ((tframe = talloc_stackframe()) == NULL) {
PyErr_NoMemory();
return NULL;
}
/* Initialize secrets database */
if (!secrets_init_path(private_dir)) {
PyErr_Format(py_pdb_error, "Cannot open secrets file database in '%s'",
@ -1485,6 +1513,8 @@ static PyObject *py_set_secrets_dir(PyObject *self, PyObject *args)
return NULL;
}
talloc_free(tframe);
Py_RETURN_NONE;
}