pysmbd: add session_info arg to py_smbd_set_nt_acl
authorJoe Guo <joeg@catalyst.net.nz>
Tue, 3 Jul 2018 22:18:30 +0000 (10:18 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Jul 2018 02:31:59 +0000 (04:31 +0200)
Add session_info arg as optional and pass it down to get_conn_tos.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13521

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source3/smbd/pysmbd.c

index faf4565fff9419073e7900b72163ca2856a13aee..1431925efd03844daf926e3e8fadf77ef0bdb203 100644 (file)
@@ -556,20 +556,26 @@ static PyObject *py_smbd_have_posix_acls(PyObject *self)
  */
 static PyObject *py_smbd_set_nt_acl(PyObject *self, PyObject *args, PyObject *kwargs)
 {
-       const char * const kwnames[] = { "fname", "security_info_sent", "sd", "service", NULL };
+       const char * const kwnames[] = {
+               "fname", "security_info_sent", "sd",
+               "service", "session_info", NULL };
+
        NTSTATUS status;
        char *fname, *service = NULL;
        int security_info_sent;
        PyObject *py_sd;
        struct security_descriptor *sd;
+       PyObject *py_session = Py_None;
+       struct auth_session_info *session_info = NULL;
        connection_struct *conn;
        TALLOC_CTX *frame;
 
        frame = talloc_stackframe();
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs,
-                                        "siO|z", discard_const_p(char *, kwnames),
-                                        &fname, &security_info_sent, &py_sd, &service)) {
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siO|zO",
+                                        discard_const_p(char *, kwnames),
+                                        &fname, &security_info_sent, &py_sd,
+                                        &service, &py_session)) {
                TALLOC_FREE(frame);
                return NULL;
        }
@@ -579,7 +585,24 @@ static PyObject *py_smbd_set_nt_acl(PyObject *self, PyObject *args, PyObject *kw
                return NULL;
        }
 
-       conn = get_conn_tos(service, NULL);
+       if (py_session != Py_None) {
+               if (!py_check_dcerpc_type(py_session,
+                                         "samba.dcerpc.auth",
+                                         "session_info")) {
+                       TALLOC_FREE(frame);
+                       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;
+               }
+       }
+
+       conn = get_conn_tos(service, session_info);
        if (!conn) {
                TALLOC_FREE(frame);
                return NULL;