From: Ralph Boehme Date: Tue, 17 Dec 2019 13:14:45 +0000 (+0100) Subject: pysmbd: add "session_info" arg to py_smbd_unlink() X-Git-Tag: ldb-2.1.0~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4f3860da31a42c3905cdd8f7ff7103bf901394d;p=thirdparty%2Fsamba.git pysmbd: add "session_info" arg to py_smbd_unlink() Signed-off-by: Ralph Boehme Reviewed-by: Stefan Metzmacher --- diff --git a/python/samba/tests/ntacls_backup.py b/python/samba/tests/ntacls_backup.py index d92299187f3..271fdfc2f2f 100644 --- a/python/samba/tests/ntacls_backup.py +++ b/python/samba/tests/ntacls_backup.py @@ -25,6 +25,7 @@ from samba import samdb from samba import ntacls from samba.auth import system_session +from samba.auth_util import system_session_unix from samba.dcerpc import security from samba.tests import env_loadparm from samba.tests.smbd_base import SmbdBaseTests @@ -137,7 +138,7 @@ class NtaclsBackupRestoreTests(SmbdBaseTests): # As well as checking that unlink works, this removes the # fake xattrs from the dev/inode based DB - smbd.unlink(filepath, self.service) + smbd.unlink(filepath, system_session_unix(), self.service) self.assertFalse(os.path.isfile(filepath)) def test_compare_getntacl(self): diff --git a/python/samba/tests/posixacl.py b/python/samba/tests/posixacl.py index b25a4ee8217..a2c14edc239 100644 --- a/python/samba/tests/posixacl.py +++ b/python/samba/tests/posixacl.py @@ -46,7 +46,7 @@ class PosixAclMappingTests(SmbdBaseTests): self.samdb = SamDB(lp=self.lp, session_info=auth.system_session()) def tearDown(self): - smbd.unlink(self.tempf) + smbd.unlink(self.tempf, self.get_session_info()) os.unlink(os.path.join(self.tempdir, "xattr.tdb")) super(PosixAclMappingTests, self).tearDown() diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index 098c6e37903..a00c11f3fe9 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -596,26 +596,46 @@ static PyObject *py_smbd_unlink(PyObject *self, PyObject *args, PyObject *kwargs { const char * const kwnames[] = { "fname", + "session_info", "service", NULL }; connection_struct *conn; int ret; struct smb_filename *smb_fname = NULL; + PyObject *py_session = Py_None; + struct auth_session_info *session_info = NULL; char *fname, *service = NULL; TALLOC_CTX *frame; frame = talloc_stackframe(); - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z", + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO|z", discard_const_p(char *, kwnames), &fname, + &py_session , &service)) { TALLOC_FREE(frame); return NULL; } - conn = get_conn_tos(service, NULL); + 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 == NULL) { + PyErr_Format(PyExc_TypeError, + "Expected auth_session_info for session_info argument got %s", + pytalloc_get_name(py_session)); + TALLOC_FREE(frame); + return NULL; + } + + conn = get_conn_tos(service, session_info); if (!conn) { TALLOC_FREE(frame); return NULL;