pysmbd: add "session_info" arg to py_smbd_unlink()
authorRalph Boehme <slow@samba.org>
Tue, 17 Dec 2019 13:14:45 +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/tests/ntacls_backup.py
python/samba/tests/posixacl.py
source3/smbd/pysmbd.c

index d92299187f391c31e9848fe3dbed4825e554abe8..271fdfc2f2f2c4499857795d4e305e00879665ac 100644 (file)
@@ -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):
index b25a4ee8217296906f636064262693e95ab44b5c..a2c14edc2397bf761e5dee4435bb0c802b2b3ef2 100644 (file)
@@ -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()
 
index 098c6e37903bf639a1d39e8a7566a16a0e7074f9..a00c11f3fe948296b2978fa685f242fa6adaa319 100644 (file)
@@ -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;