diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-09-22 08:18:17 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-09-22 08:18:17 +0400 |
commit | 8fcac6820af048a5c03f41e8f5f40cecf6a67684 (patch) | |
tree | 766fa053b9a3ade87ae202acfaa9390ec417ab69 /source/gameengine | |
parent | 338a5c7bbf3880227911ec09a95f07aee8cac48a (diff) |
KX_PythonInit.cpp - workaround for current sandbox and possible fix. no real change for now but others may want to look into it.
blendef.h - removed some unused defines.
editipo_mods.c - deselect all was selecting instead.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 09c49a15f76..6b2f3c68d55 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1047,6 +1047,21 @@ PyObject *KXpy_import(PyObject *self, PyObject *args) } +/* override python file type functions */ +#if 0 +static int +file_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + KXpy_file(NULL, NULL); + return -1; +} + +static PyObject * +file_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + return KXpy_file(NULL, NULL); +} +#endif static PyMethodDef meth_open[] = {{ "open", KXpy_open, METH_VARARGS, "(disabled)"}}; static PyMethodDef meth_reload[] = {{ "reload", KXpy_reload, METH_VARARGS, "(disabled)"}}; @@ -1060,7 +1075,6 @@ static PyMethodDef meth_import[] = {{ "import", KXpy_import, METH_VARARGS, "our //static PyObject *g_oldimport = 0; //static int g_security = 0; - void setSandbox(TPythonSecurityLevel level) { PyObject *m = PyImport_AddModule("__builtin__"); @@ -1081,6 +1095,19 @@ void setSandbox(TPythonSecurityLevel level) // our own import PyDict_SetItemString(d, "__import__", PyCFunction_New(meth_import, NULL)); //g_security = level; + + // Overiding file dosnt stop it being accessed if your sneaky + // f = [ t for t in (1).__class__.__mro__[-1].__subclasses__() if t.__name__ == 'file'][0]('/some_file.txt', 'w') + // f.write('...') + // so overwrite the file types functions. be very careful here still, since python uses python. + // ps - python devs frown deeply upon this. + + /* this could mess up pythons internals, if we are serious about sandboxing + * issues like the one above need to be solved, possibly modify __subclasses__ is safer? */ +#if 0 + PyFile_Type.tp_init = file_init; + PyFile_Type.tp_new = file_new; +#endif //} break; /* |