Commits

Ned Batchelder  committed 8d953e0

Implement from os: getuid, geteuid, getgid, getegid; in an attempt to get 'import site' working, but the problems go deeper.

  • Participants
  • Parent commits d027e73
  • Branches nedbat-sandbox

Comments (0)

Files changed (2)

File pypy/translator/sandbox/sandlib.py

 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 = {
         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

File pypy/translator/sandbox/test/test_sandlib.py

     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 == ""