diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-04-05 16:15:27 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-04-05 23:46:04 +0200 |
commit | 663dc94e630910b0b5b61801a03622641b2b83b4 (patch) | |
tree | 3d74a050420ec92dd686f618b3b3ad40b647fc86 /source4/librpc | |
parent | f261266c9d66d7143a867f4719d1549f58915036 (diff) | |
download | samba-663dc94e630910b0b5b61801a03622641b2b83b4.tar.gz samba-663dc94e630910b0b5b61801a03622641b2b83b4.tar.bz2 samba-663dc94e630910b0b5b61801a03622641b2b83b4.zip |
auth: Move auth_session_info into IDL
This changes auth_session_info_transport to just be a wrapper, rather
than a copy that has to be kept in sync.
As auth_session_info was already wrapped in python, this required
changes to the existing pyauth wrapper and it's users.
Andrew Bartlett
Diffstat (limited to 'source4/librpc')
-rw-r--r-- | source4/librpc/ndr/py_auth.c | 74 | ||||
-rwxr-xr-x | source4/librpc/wscript_build | 11 |
2 files changed, 85 insertions, 0 deletions
diff --git a/source4/librpc/ndr/py_auth.c b/source4/librpc/ndr/py_auth.c new file mode 100644 index 0000000000..40164e0981 --- /dev/null +++ b/source4/librpc/ndr/py_auth.c @@ -0,0 +1,74 @@ +/* + Unix SMB/CIFS implementation. + Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008 + Copyright (C) Andrew Bartlett <abartlet@samba.org> 2011 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <Python.h> +#include "includes.h" +#include "libcli/util/pyerrors.h" +#include "pyauth.h" +#include "auth/auth.h" +#include "auth/credentials/pycredentials.h" +#include "librpc/rpc/pyrpc_util.h" + +#ifndef Py_RETURN_NONE +#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None +#endif + +static void PyType_AddGetSet(PyTypeObject *type, PyGetSetDef *getset) +{ + PyObject *dict; + int i; + if (type->tp_dict == NULL) + type->tp_dict = PyDict_New(); + dict = type->tp_dict; + for (i = 0; getset[i].name; i++) { + PyObject *descr; + descr = PyDescr_NewGetSet(type, &getset[i]); + PyDict_SetItemString(dict, getset[i].name, + descr); + } +} + +static PyObject *py_auth_session_get_credentials(PyObject *self, void *closure) +{ + struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info); + PyObject *py_credentials; + /* This is evil, as the credentials are not IDL structures */ + py_credentials = py_return_ndr_struct("samba.credentials", "Credentials", session->credentials, session->credentials); + return py_credentials; +} + +static int py_auth_session_set_credentials(PyObject *self, PyObject *value, void *closure) +{ + struct auth_session_info *session = py_talloc_get_type(self, struct auth_session_info); + session->credentials = talloc_reference(session, PyCredentials_AsCliCredentials(value)); + return 0; +} + +static PyGetSetDef py_auth_session_extra_getset[] = { + { discard_const_p(char, "credentials"), (getter)py_auth_session_get_credentials, (setter)py_auth_session_set_credentials, NULL }, + { NULL } +}; + +static void py_auth_session_info_patch(PyTypeObject *type) +{ + PyType_AddGetSet(type, py_auth_session_extra_getset); +} + +#define PY_SESSION_INFO_PATCH py_auth_session_info_patch + diff --git a/source4/librpc/wscript_build b/source4/librpc/wscript_build index 8d1e9a8220..ce015ccaa5 100755 --- a/source4/librpc/wscript_build +++ b/source4/librpc/wscript_build @@ -199,6 +199,17 @@ bld.SAMBA_PYTHON('python_echo', realname='samba/dcerpc/echo.so' ) +bld.SAMBA_PYTHON('python_auth', + source='../../librpc/gen_ndr/py_auth.c', + deps='NDR_AUTH pytalloc-util pyrpc_util', + realname='samba/dcerpc/auth.so' + ) + +bld.SAMBA_PYTHON('python_krb5pac', + source='../../librpc/gen_ndr/py_krb5pac.c', + deps='ndr-krb5pac pytalloc-util pyrpc_util', + realname='samba/dcerpc/krb5pac.so' + ) bld.SAMBA_PYTHON('python_winreg', source='../../librpc/gen_ndr/py_winreg.c', |