2 Unix SMB/CIFS implementation.
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2011
5 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2011
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "libcli/util/pyerrors.h"
25 #include "auth/auth.h"
26 #include "auth/credentials/pycredentials.h"
27 #include "librpc/rpc/pyrpc_util.h"
29 #ifndef Py_RETURN_NONE
30 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
33 static void PyType_AddGetSet(PyTypeObject
*type
, PyGetSetDef
*getset
)
37 if (type
->tp_dict
== NULL
)
38 type
->tp_dict
= PyDict_New();
40 for (i
= 0; getset
[i
].name
; i
++) {
42 descr
= PyDescr_NewGetSet(type
, &getset
[i
]);
43 PyDict_SetItemString(dict
, getset
[i
].name
,
48 static PyObject
*py_auth_session_get_credentials(PyObject
*self
, void *closure
)
50 struct auth_session_info
*session
= pytalloc_get_type(self
, struct auth_session_info
);
51 PyObject
*py_credentials
;
52 /* This is evil, as the credentials are not IDL structures */
53 py_credentials
= py_return_ndr_struct("samba.credentials", "Credentials", session
->credentials
, session
->credentials
);
54 return py_credentials
;
57 static int py_auth_session_set_credentials(PyObject
*self
, PyObject
*value
, void *closure
)
59 struct auth_session_info
*session
= pytalloc_get_type(self
, struct auth_session_info
);
60 session
->credentials
= talloc_reference(session
, PyCredentials_AsCliCredentials(value
));
64 static PyGetSetDef py_auth_session_extra_getset
[] = {
65 { discard_const_p(char, "credentials"), (getter
)py_auth_session_get_credentials
, (setter
)py_auth_session_set_credentials
, NULL
},
69 static void py_auth_session_info_patch(PyTypeObject
*type
)
71 PyType_AddGetSet(type
, py_auth_session_extra_getset
);
74 #define PY_SESSION_INFO_PATCH py_auth_session_info_patch