pysmbd: add "session_info" arg to py_smbd_chown()
authorRalph Boehme <slow@samba.org>
Tue, 17 Dec 2019 13:14:07 +0000 (14:14 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 20 Dec 2019 11:41:42 +0000 (11:41 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
python/samba/provision/__init__.py
python/samba/tests/posixacl.py
source3/smbd/pysmbd.c

index 152e1923e83c7eab2b87098ce9103335df43cf69..bb9ddd15bc70eb951c2395fbccabcfe4b07ac87c 100644 (file)
@@ -1707,7 +1707,7 @@ def setsysvolacl(samdb, netlogon, sysvol, uid, gid, domainsid, dnsdomain,
                 raise ProvisioningError("Your filesystem or build does not support posix ACLs, which s3fs requires.  "
                                         "Try the mounting the filesystem with the 'acl' option.")
             try:
-                smbd.chown(file.name, uid, gid)
+                smbd.chown(file.name, uid, gid, system_session_unix())
             except OSError:
                 raise ProvisioningError("Unable to chown a file on your filesystem.  "
                                         "You may not be running provision as root.")
index c6030024651116a2c182247d69cdfb46b66394c5..b25a4ee8217296906f636064262693e95ab44b5c 100644 (file)
@@ -224,7 +224,7 @@ class PosixAclMappingTests(SmbdBaseTests):
         SO_sid = security.dom_sid(security.SID_BUILTIN_SERVER_OPERATORS)
         (SO_id, SO_type) = s4_passdb.sid_to_id(SO_sid)
         self.assertEquals(SO_type, idmap.ID_TYPE_BOTH)
-        smbd.chown(self.tempdir, BA_id, SO_id)
+        smbd.chown(self.tempdir, BA_id, SO_id, self.get_session_info())
         smbd.set_simple_acl(self.tempdir, 0o750, self.get_session_info())
         facl = getntacl(self.lp, self.tempdir, direct_db_access=False)
         acl = "O:BAG:SOD:(A;;0x001f01ff;;;BA)(A;;0x001200a9;;;SO)(A;;;;;WD)(A;OICIIO;0x001f01ff;;;CO)(A;OICIIO;0x001200a9;;;CG)(A;OICIIO;0x001200a9;;;WD)"
index ea062a5a7e8c19fe3be0bb6b76f9caaef9947214..098c6e37903bf639a1d39e8a7566a16a0e7074f9 100644 (file)
@@ -500,6 +500,7 @@ static PyObject *py_smbd_chown(PyObject *self, PyObject *args, PyObject *kwargs)
                "fname",
                "uid",
                "gid",
+               "session_info",
                "service",
                NULL
        };
@@ -507,21 +508,38 @@ static PyObject *py_smbd_chown(PyObject *self, PyObject *args, PyObject *kwargs)
        int ret;
        NTSTATUS status;
        char *fname, *service = NULL;
+       PyObject *py_session = Py_None;
+       struct auth_session_info *session_info = NULL;
        int uid, gid;
        TALLOC_CTX *frame;
        struct files_struct *fsp = NULL;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sii|z",
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "siiO|z",
                                         discard_const_p(char *, kwnames),
                                         &fname,
                                         &uid,
                                         &gid,
+                                        &py_session,
                                         &service))
                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 == NULL) {
+               PyErr_Format(PyExc_TypeError,
+                            "Expected auth_session_info for session_info argument got %s",
+                            pytalloc_get_name(py_session));
+               return NULL;
+       }
+
        frame = talloc_stackframe();
 
-       conn = get_conn_tos(service, NULL);
+       conn = get_conn_tos(service, session_info);
        if (!conn) {
                TALLOC_FREE(frame);
                return NULL;