summaryrefslogtreecommitdiff
path: root/source4/auth
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2018-07-11 16:48:40 +1200
committerAndrew Bartlett <abartlet@samba.org>2018-07-12 04:32:06 +0200
commiteb6cb6e673e430cb8bb0be326f61c547ae42dfa1 (patch)
tree512b62d0fb045a0051739c8a8fac16babaade5b4 /source4/auth
parent77ffadd3a04d442c19549611dc8cdf253db3863b (diff)
downloadsamba-eb6cb6e673e430cb8bb0be326f61c547ae42dfa1.tar.gz
python: Add samba.auth.session_info_fill_unix()
This fills in the unix portions of the token needed by smbd and the pysmbd bindings Signed-off-by: Andrew Bartlett <abartlet@samba.org> Pair-programmed-with: Joe Guo <joeg@catalyst.net.nz> Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'source4/auth')
-rw-r--r--source4/auth/pyauth.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/source4/auth/pyauth.c b/source4/auth/pyauth.c
index fc22637564d..ada89ef0c8f 100644
--- a/source4/auth/pyauth.c
+++ b/source4/auth/pyauth.c
@@ -164,6 +164,63 @@ static PyObject *py_user_session(PyObject *module, PyObject *args, PyObject *kwa
return PyAuthSession_FromSession(session);
}
+static PyObject *py_session_info_fill_unix(PyObject *module,
+ PyObject *args,
+ PyObject *kwargs)
+{
+ NTSTATUS nt_status;
+ char *user_name = NULL;
+ struct loadparm_context *lp_ctx = NULL;
+ struct auth_session_info *session_info;
+ PyObject *py_lp_ctx = Py_None;
+ PyObject *py_session = Py_None;
+ TALLOC_CTX *frame;
+
+ const char * const kwnames[] = { "session_info",
+ "user_name",
+ "lp_ctx",
+ NULL };
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oz|O",
+ discard_const_p(char *, kwnames),
+ &py_session,
+ &user_name,
+ &py_lp_ctx)) {
+ return NULL;
+ }
+
+ if (!py_check_dcerpc_type(py_session,
+ "samba.dcerpc.auth",
+ "session_info")) {
+ return NULL;
+ }
+ session_info = pytalloc_get_type(py_session,
+ struct auth_session_info);
+ if (!session_info) {
+ PyErr_Format(PyExc_TypeError,
+ "Expected auth_session_info for session_info argument got %s",
+ talloc_get_name(pytalloc_get_ptr(py_session)));
+ return NULL;
+ }
+
+ frame = talloc_stackframe();
+
+ lp_ctx = lpcfg_from_py_object(frame, py_lp_ctx);
+ if (lp_ctx == NULL) {
+ TALLOC_FREE(frame);
+ return NULL;
+ }
+
+ nt_status = auth_session_info_fill_unix(lp_ctx,
+ user_name,
+ session_info);
+ TALLOC_FREE(frame);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ PyErr_NTSTATUS_IS_ERR_RAISE(nt_status);
+ }
+
+ Py_RETURN_NONE;
+}
+
static const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
const char *paramname)
@@ -304,6 +361,10 @@ static PyMethodDef py_auth_methods[] = {
{ "system_session", (PyCFunction)py_system_session, METH_VARARGS, NULL },
{ "admin_session", (PyCFunction)py_admin_session, METH_VARARGS, NULL },
{ "user_session", (PyCFunction)py_user_session, METH_VARARGS|METH_KEYWORDS, NULL },
+ { "session_info_fill_unix",
+ (PyCFunction)py_session_info_fill_unix,
+ METH_VARARGS|METH_KEYWORDS,
+ NULL },
{ NULL },
};