diff options
author | David Mulder <dmulder@suse.com> | 2017-11-07 10:41:05 -0700 |
---|---|---|
committer | Garming Sam <garming@samba.org> | 2017-11-20 21:41:15 +0100 |
commit | d65f6dd46aabf0b432c9d8ee01d901af61e13272 (patch) | |
tree | fe9d13b4832a4c384e08ba2d6fd7fa0fd717decd /libgpo/pygpo.c | |
parent | f0e3c2daf901fa4413d3178d6c7a18fba13ccf91 (diff) | |
download | samba-d65f6dd46aabf0b432c9d8ee01d901af61e13272.tar.gz |
libgpo: Setup the stack frame in ads_connect
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'libgpo/pygpo.c')
-rw-r--r-- | libgpo/pygpo.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c index 28f41f754b8..aaa74296cb8 100644 --- a/libgpo/pygpo.c +++ b/libgpo/pygpo.c @@ -241,6 +241,7 @@ static int py_ads_init(ADS *self, PyObject *args, PyObject *kwds) static PyObject* py_ads_connect(ADS *self) { ADS_STATUS status; + TALLOC_CTX *frame = talloc_stackframe(); if (self->cli_creds) { self->ads_ptr->auth.user_name = SMB_STRDUP(cli_credentials_get_username(self->cli_creds)); self->ads_ptr->auth.flags |= ADS_AUTH_USER_CREDS; @@ -250,6 +251,7 @@ self->ads_ptr->auth.flags |= ADS_AUTH_USER_CREDS; status = ads_connect_user_creds(self->ads_ptr); if (!ADS_ERR_OK(status)) { PyErr_SetString(PyExc_SystemError, "ads_connect() failed"); + TALLOC_FREE(frame); Py_RETURN_FALSE; } } else { @@ -257,31 +259,38 @@ self->ads_ptr->auth.flags |= ADS_AUTH_USER_CREDS; if (asprintf(&(self->ads_ptr->auth.user_name), "%s$", lp_netbios_name()) == -1) { PyErr_SetString(PyExc_SystemError, "Failed to asprintf"); + TALLOC_FREE(frame); Py_RETURN_FALSE; } else self->ads_ptr->auth.flags |= ADS_AUTH_USER_CREDS; if (!secrets_init()) { PyErr_SetString(PyExc_SystemError, "secrets_init() failed"); + TALLOC_FREE(frame); Py_RETURN_FALSE; } + if (!(passwd = secrets_fetch_machine_password(self->ads_ptr->server.workgroup, NULL, NULL))) { PyErr_SetString(PyExc_SystemError, "Failed to fetch the machine account password"); + TALLOC_FREE(frame); Py_RETURN_FALSE; } self->ads_ptr->auth.password = smb_xstrdup(passwd); self->ads_ptr->auth.realm = smb_xstrdup(self->ads_ptr->server.realm); if (!strupper_m(self->ads_ptr->auth.realm)) { PyErr_SetString(PyExc_SystemError, "Failed to strdup"); + TALLOC_FREE(frame); Py_RETURN_FALSE; } status = ads_connect(self->ads_ptr); if (!ADS_ERR_OK(status)) { PyErr_SetString(PyExc_SystemError, "ads_connect() failed"); + TALLOC_FREE(frame); Py_RETURN_FALSE; } } + TALLOC_FREE(frame); Py_RETURN_TRUE; } |