summaryrefslogtreecommitdiff
path: root/libgpo
diff options
context:
space:
mode:
authorKristján Valur <kristjan@rvx.is>2019-02-27 16:36:32 +0000
committerNoel Power <npower@samba.org>2019-03-07 14:08:22 +0000
commitd2a75489477a6628662e7bb5dd94b3e769e8c3b1 (patch)
tree49201c3cb9cf9a781114117df698137a9be33ac8 /libgpo
parent1ff252e398c6dc140570821394a7cda262af6dd9 (diff)
downloadsamba-d2a75489477a6628662e7bb5dd94b3e769e8c3b1.tar.gz
pygpo: keep a reference to python credentials in the ADS struct to keep the internal pointer valid.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13822 Signed-off-by: Kristján Valur Jónsson <kristjan@rvx.is> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org>
Diffstat (limited to 'libgpo')
-rw-r--r--libgpo/pygpo.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c
index 5e012dfc972..36e5f1052d0 100644
--- a/libgpo/pygpo.c
+++ b/libgpo/pygpo.c
@@ -132,12 +132,14 @@ static PyTypeObject GPOType = {
typedef struct {
PyObject_HEAD
ADS_STRUCT *ads_ptr;
+ PyObject *py_creds;
struct cli_credentials *cli_creds;
} ADS;
static void py_ads_dealloc(ADS* self)
{
ads_destroy(&(self->ads_ptr));
+ Py_CLEAR(self->py_creds);
Py_TYPE(self)->tp_free((PyObject*)self);
}
@@ -154,7 +156,6 @@ static int py_ads_init(ADS *self, PyObject *args, PyObject *kwds)
const char *realm = NULL;
const char *workgroup = NULL;
const char *ldap_server = NULL;
- PyObject *py_creds = NULL;
PyObject *lp_obj = NULL;
struct loadparm_context *lp_ctx = NULL;
bool ok = false;
@@ -164,18 +165,20 @@ static int py_ads_init(ADS *self, PyObject *args, PyObject *kwds)
};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO|O",
discard_const_p(char *, kwlist),
- &ldap_server, &lp_obj, &py_creds)) {
+ &ldap_server, &lp_obj, &self->py_creds)) {
return -1;
}
+ /* keep reference to the credentials */
+ Py_XINCREF(self->py_creds);
- if (py_creds) {
- ok = py_check_dcerpc_type(py_creds, "samba.credentials",
+ if (self->py_creds) {
+ ok = py_check_dcerpc_type(self->py_creds, "samba.credentials",
"Credentials");
if (!ok) {
return -1;
}
self->cli_creds
- = PyCredentials_AsCliCredentials(py_creds);
+ = PyCredentials_AsCliCredentials(self->py_creds);
}
ok = py_check_dcerpc_type(lp_obj, "samba.param", "LoadParm");