From df829170c1d60abfa6f4bf1f76ac3482d843e28d Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Sun, 19 Jun 2022 18:28:55 +0200 Subject: [PATCH] [3.11] gh-84461: Fix Emscripten umask and permission issues (GH-94002) - Emscripten's default umask is too strict, see https://github.com/emscripten-core/emscripten/issues/17269 - getuid/getgid and geteuid/getegid are stubs that always return 0 (root). Disable effective uid/gid syscalls and fix tests that use chmod() current user. - Cannot drop X bit from directory. (cherry picked from commit 2702e408fd0e0dd7aec396b4cf8c7ce9caae81d8) Co-authored-by: Christian Heimes --- Lib/test/libregrtest/main.py | 12 ++++++++++++ Lib/test/test_posix.py | 3 +++ Lib/test/test_pydoc.py | 1 + Tools/wasm/config.site-wasm32-emscripten | 7 +++++++ 4 files changed, 23 insertions(+) diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py index 85bf6e1d48e3a7..cc8ba05d39ca7d 100644 --- a/Lib/test/libregrtest/main.py +++ b/Lib/test/libregrtest/main.py @@ -600,6 +600,16 @@ def save_xml_result(self): 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 @@ def main(self, tests=None, **kwargs): self.set_temp_dir() + self.fix_umask() + if self.ns.cleanup: self.cleanup() sys.exit(0) diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 4130cdd0c022ad..ae25ef55885dd6 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -787,6 +787,7 @@ def check_stat(uid, gid): 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 @@ def test_chown(self): @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 @@ def test_chmod_dir_fd(self): @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) diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index b705b7aee8136d..89faf0d9141f9d 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -934,6 +934,7 @@ def test_apropos_with_unreadable_dir(self): 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) diff --git a/Tools/wasm/config.site-wasm32-emscripten b/Tools/wasm/config.site-wasm32-emscripten index 6420edcf541683..a31d60d05dd770 100644 --- a/Tools/wasm/config.site-wasm32-emscripten +++ b/Tools/wasm/config.site-wasm32-emscripten @@ -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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy