[pypy-commit] pypy nedbat-sandbox: Implement from os: getuid, geteuid, getgid, getegid; in an attempt to get 'import site' working, but the problems go deeper.
ned
noreply at buildbot.pypy.org
Sat Dec 10 20:35:08 CET 2011
Author: Ned Batchelder <ned at nedbatchelder.com>
Branch: nedbat-sandbox
Changeset: r50359:7fa920a29974
Date: 2011-12-10 14:33 -0500
http://bitbucket.org/pypy/pypy/changeset/7fa920a29974/
Log: Implement from os: getuid, geteuid, getgid, getegid; in an attempt
to get 'import site' working, but the problems go deeper.
diff --git a/pypy/translator/sandbox/sandlib.py b/pypy/translator/sandbox/sandlib.py
--- a/pypy/translator/sandbox/sandlib.py
+++ b/pypy/translator/sandbox/sandlib.py
@@ -9,6 +9,7 @@
from pypy.tool.ansi_print import AnsiLog
import subprocess
from pypy.tool.killsubprocess import killsubprocess
+from pypy.translator.sandbox.vfs import UID, GID
class MyAnsiLog(AnsiLog):
KW_TO_COLOR = {
@@ -524,6 +525,14 @@
node = self.get_node(vpathname)
return node.keys()
+ def do_ll_os__ll_os_getuid(self):
+ return UID
+ do_ll_os__ll_os_geteuid = do_ll_os__ll_os_getuid
+
+ def do_ll_os__ll_os_getgid(self):
+ return GID
+ do_ll_os__ll_os_getegid = do_ll_os__ll_os_getgid
+
class VirtualizedSocketProc(VirtualizedSandboxedProc):
""" Extends VirtualizedSandboxProc with socket
diff --git a/pypy/translator/sandbox/test/test_sandlib.py b/pypy/translator/sandbox/test/test_sandlib.py
--- a/pypy/translator/sandbox/test/test_sandlib.py
+++ b/pypy/translator/sandbox/test/test_sandlib.py
@@ -247,3 +247,18 @@
output, error = proc.communicate("")
assert output == "All ok!\n"
assert error == ""
+
+def test_getuid():
+ def entry_point(argv):
+ import os
+ print "uid is %s" % os.getuid()
+ print "euid is %s" % os.geteuid()
+ print "gid is %s" % os.getgid()
+ print "egid is %s" % os.getegid()
+ return 0
+ exe = compile(entry_point)
+
+ proc = SandboxedProcWithFiles([exe])
+ output, error = proc.communicate("")
+ assert output == "uid is 1000\neuid is 1000\ngid is 1000\negid is 1000\n"
+ assert error == ""
More information about the pypy-commit
mailing list