mirror of https://github.com/python/cpython
[3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) (GH-94006)
Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
parent
15c8838273
commit
1073184918
|
@ -600,6 +600,16 @@ class Regrtest:
|
|||
for s in ET.tostringlist(root):
|
||||
f.write(s)
|
||||
|
||||
def fix_umask(self):
|
||||
if support.is_emscripten:
|
||||
# Emscripten has default umask 0o777, which breaks some tests.
|
||||
# see https://github.com/emscripten-core/emscripten/issues/17269
|
||||
old_mask = os.umask(0)
|
||||
if old_mask == 0o777:
|
||||
os.umask(0o027)
|
||||
else:
|
||||
os.umask(old_mask)
|
||||
|
||||
def set_temp_dir(self):
|
||||
if self.ns.tempdir:
|
||||
self.tmp_dir = self.ns.tempdir
|
||||
|
@ -660,6 +670,8 @@ class Regrtest:
|
|||
|
||||
self.set_temp_dir()
|
||||
|
||||
self.fix_umask()
|
||||
|
||||
if self.ns.cleanup:
|
||||
self.cleanup()
|
||||
sys.exit(0)
|
||||
|
|
|
@ -787,6 +787,7 @@ class PosixTester(unittest.TestCase):
|
|||
check_stat(uid, gid)
|
||||
|
||||
@os_helper.skip_unless_working_chmod
|
||||
@unittest.skipIf(support.is_emscripten, "getgid() is a stub")
|
||||
def test_chown(self):
|
||||
# raise an OSError if the file does not exist
|
||||
os.unlink(os_helper.TESTFN)
|
||||
|
@ -798,6 +799,7 @@ class PosixTester(unittest.TestCase):
|
|||
|
||||
@os_helper.skip_unless_working_chmod
|
||||
@unittest.skipUnless(hasattr(posix, 'fchown'), "test needs os.fchown()")
|
||||
@unittest.skipIf(support.is_emscripten, "getgid() is a stub")
|
||||
def test_fchown(self):
|
||||
os.unlink(os_helper.TESTFN)
|
||||
|
||||
|
@ -1356,6 +1358,7 @@ class TestPosixDirFd(unittest.TestCase):
|
|||
|
||||
@unittest.skipUnless(hasattr(os, 'chown') and (os.chown in os.supports_dir_fd),
|
||||
"test needs dir_fd support in os.chown()")
|
||||
@unittest.skipIf(support.is_emscripten, "getgid() is a stub")
|
||||
def test_chown_dir_fd(self):
|
||||
with self.prepare_file() as (dir_fd, name, fullname):
|
||||
posix.chown(name, os.getuid(), os.getgid(), dir_fd=dir_fd)
|
||||
|
|
|
@ -934,6 +934,7 @@ class PydocImportTest(PydocBaseTest):
|
|||
self.assertEqual(err.getvalue(), '')
|
||||
|
||||
@os_helper.skip_unless_working_chmod
|
||||
@unittest.skipIf(is_emscripten, "cannot remove x bit")
|
||||
def test_apropos_empty_doc(self):
|
||||
pkgdir = os.path.join(TESTFN, 'walkpkg')
|
||||
os.mkdir(pkgdir)
|
||||
|
|
|
@ -43,6 +43,13 @@ ac_cv_func_symlinkat=no
|
|||
ac_cv_func_lchmod=no
|
||||
ac_cv_func_lchown=no
|
||||
|
||||
# geteuid / getegid are stubs and always return 0 (root). The stub breaks
|
||||
# code that assume effective user root has special permissions.
|
||||
ac_cv_func_geteuid=no
|
||||
ac_cv_func_getegid=no
|
||||
ac_cv_func_seteuid=no
|
||||
ac_cv_func_setegid=no
|
||||
|
||||
# Syscalls not implemented in emscripten
|
||||
# [Errno 52] Function not implemented
|
||||
ac_cv_func_preadv2=no
|
||||
|
|
Loading…
Reference in New Issue