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 static void PyType_AddGetSet(PyTypeObject
*type
, PyGetSetDef
*getset
)
33 if (type
->tp_dict
== NULL
)
34 type
->tp_dict
= PyDict_New();
36 for (i
= 0; getset
[i
].name
; i
++) {
38 descr
= PyDescr_NewGetSet(type
, &getset
[i
]);
39 PyDict_SetItemString(dict
, getset
[i
].name
,
45 static PyObject
*py_auth_session_get_credentials(PyObject
*self
, void *closure
)
47 struct auth_session_info
*session
= pytalloc_get_type(self
, struct auth_session_info
);
48 PyObject
*py_credentials
;
49 /* This is evil, as the credentials are not IDL structures */
50 py_credentials
= py_return_ndr_struct("samba.credentials", "Credentials", session
->credentials
, session
->credentials
);
51 return py_credentials
;
54 static int py_auth_session_set_credentials(PyObject
*self
, PyObject
*value
, void *closure
)
56 struct auth_session_info
*session
= pytalloc_get_type(self
, struct auth_session_info
);
57 session
->credentials
= talloc_reference(session
, PyCredentials_AsCliCredentials(value
));
61 static PyGetSetDef py_auth_session_extra_getset
[] = {
63 .name
= discard_const_p(char, "credentials"),
64 .get
= (getter
)py_auth_session_get_credentials
,
65 .set
= (setter
)py_auth_session_set_credentials
,
70 static void py_auth_session_info_patch(PyTypeObject
*type
)
72 PyType_AddGetSet(type
, py_auth_session_extra_getset
);
75 #define PY_SESSION_INFO_PATCH py_auth_session_info_patch