From: Ralph Boehme Date: Tue, 17 Dec 2019 13:14:07 +0000 (+0100) Subject: pysmbd: add "session_info" arg to py_smbd_chown() X-Git-Url: http://git.samba.org/samba.git/?a=commitdiff_plain;h=da2a9857d0397d75ac45fc62440ad29bbd0388a1;p=gd%2Fsamba-autobuild%2F.git pysmbd: add "session_info" arg to py_smbd_chown() Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py index 152e1923e83..bb9ddd15bc7 100644 --- a/python/samba/provision/__init__.py +++ b/python/samba/provision/__init__.py @@ -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.") diff --git a/python/samba/tests/posixacl.py b/python/samba/tests/posixacl.py index c6030024651..b25a4ee8217 100644 --- a/python/samba/tests/posixacl.py +++ b/python/samba/tests/posixacl.py @@ -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)" diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index ea062a5a7e8..098c6e37903 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -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;