[Python-checkins] r50551 - in python/branches/bcannon-sandboxing: Include/sandbox.h Python/pythonrun.c
brett.cannon
python-checkins at python.org
Mon Jul 10 23:54:47 CEST 2006
Author: brett.cannon
Date: Mon Jul 10 23:54:47 2006
New Revision: 50551
Modified:
python/branches/bcannon-sandboxing/Include/sandbox.h
python/branches/bcannon-sandboxing/Python/pythonrun.c
Log:
Initialize PyInterpreterState->sandbox_state to NULL in Py_NewInterpreter(). Also add _PySandbox_Protected() macro to check if the current interpreter is sandboxed or not.
Modified: python/branches/bcannon-sandboxing/Include/sandbox.h
==============================================================================
--- python/branches/bcannon-sandboxing/Include/sandbox.h (original)
+++ python/branches/bcannon-sandboxing/Include/sandbox.h Mon Jul 10 23:54:47 2006
@@ -9,9 +9,16 @@
struct _sandbox_state; /* Forward */
typedef struct _sandbox_state {
+ PY_LONG_LONG mem_cap;
} PySandboxState;
-#endif /* Py_SANDBOX_H */
+/* Return true if sandboxing is turn on for the current interpreter. */
+#define _PySandbox_Protected() (PyThreadState_GET()->interp->sandbox_state != NULL)
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* Py_SANDBOX_H */
#endif /* PySandbox_SUPPORTED */
Modified: python/branches/bcannon-sandboxing/Python/pythonrun.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/pythonrun.c (original)
+++ python/branches/bcannon-sandboxing/Python/pythonrun.c Mon Jul 10 23:54:47 2006
@@ -512,6 +512,13 @@
if (interp == NULL)
return NULL;
+#ifdef PySandbox_SUPPORTED
+ /* Must set sandbox_state to NULL to flag that the interpreter is
+ unprotected. It if is to be protected, the field is set by
+ PySandbox_NewInterpreter(). */
+ interp->sandbox_state = NULL;
+#endif
+
tstate = PyThreadState_New(interp);
if (tstate == NULL) {
PyInterpreterState_Delete(interp);
More information about the Python-checkins
mailing list