[Python-checkins] r52438 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/sandbox.py
phillip.eby
python-checkins at python.org
Tue Oct 24 20:37:04 CEST 2006
Author: phillip.eby
Date: Tue Oct 24 20:37:04 2006
New Revision: 52438
Modified:
sandbox/branches/setuptools-0.6/EasyInstall.txt
sandbox/branches/setuptools-0.6/setuptools/sandbox.py
Log:
Fixed not allowing ``os.open()`` of paths outside the sandbox, even if they
are opened read-only (e.g. reading ``/dev/urandom`` for random numbers, as
is done by ``os.urandom()`` on some platforms).
(backport from trunk)
Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt
==============================================================================
--- sandbox/branches/setuptools-0.6/EasyInstall.txt (original)
+++ sandbox/branches/setuptools-0.6/EasyInstall.txt Tue Oct 24 20:37:04 2006
@@ -1265,6 +1265,10 @@
* Allow explicit selection of Sourceforge mirror(s) with ``--sf-mirror``, and
further refine download/retry algorithm.
+ * Fixed not allowing ``os.open()`` of paths outside the sandbox, even if they
+ are opened read-only (e.g. reading ``/dev/urandom`` for random numbers, as
+ is done by ``os.urandom()`` on some platforms).
+
0.6c3
* You once again use "python -m easy_install" with Python 2.4 and above.
Modified: sandbox/branches/setuptools-0.6/setuptools/sandbox.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/sandbox.py (original)
+++ sandbox/branches/setuptools-0.6/setuptools/sandbox.py Tue Oct 24 20:37:04 2006
@@ -1,4 +1,4 @@
-import os, sys, __builtin__, tempfile
+import os, sys, __builtin__, tempfile, operator
_os = sys.modules[os.name]
_open = open
from distutils.errors import DistutilsError
@@ -187,6 +187,21 @@
self._violation(operation, src, dst, *args, **kw)
return (src,dst)
+ def open(self, file, flags, mode=0777):
+ """Called for low-level os.open()"""
+ if flags & WRITE_FLAGS:
+ self._violation("open", file, flags, mode)
+ return _os.open(file,flags,mode)
+
+
+WRITE_FLAGS = reduce(
+ operator.or_,
+ [getattr(_os, a, 0) for a in
+ "O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARY".split()]
+)
+
+
+
class SandboxViolation(DistutilsError):
"""A setup script attempted to modify the filesystem outside the sandbox"""
@@ -203,3 +218,29 @@
maintainers to find out if a fix or workaround is available.""" % self.args
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
More information about the Python-checkins
mailing list