mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
[3.12] gh-104522: Fix OSError raised when run a subprocess (GH-114195) (#114219)
gh-104522: Fix OSError raised when run a subprocess (GH-114195)
Only set filename to cwd if it was caused by failed chdir(cwd).
_fork_exec() now returns "noexec:chdir" for failed chdir(cwd).
(cherry picked from commit e2c097ebde
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Robert O'Shea <PurityLake@users.noreply.github.com>
This commit is contained in:
parent
2c9cf64a3f
commit
f8fc8534c4
4 changed files with 29 additions and 18 deletions
|
@ -2032,11 +2032,12 @@ class POSIXProcessTestCase(BaseTestCase):
|
|||
"import os; print(os.getuid())"],
|
||||
user=user,
|
||||
close_fds=close_fds)
|
||||
except PermissionError: # (EACCES, EPERM)
|
||||
pass
|
||||
except PermissionError as e: # (EACCES, EPERM)
|
||||
self.assertIsNone(e.filename)
|
||||
except OSError as e:
|
||||
if e.errno not in (errno.EACCES, errno.EPERM):
|
||||
raise
|
||||
self.assertIsNone(e.filename)
|
||||
else:
|
||||
if isinstance(user, str):
|
||||
user_uid = pwd.getpwnam(user).pw_uid
|
||||
|
@ -2080,8 +2081,8 @@ class POSIXProcessTestCase(BaseTestCase):
|
|||
"import os; print(os.getgid())"],
|
||||
group=group,
|
||||
close_fds=close_fds)
|
||||
except PermissionError: # (EACCES, EPERM)
|
||||
pass
|
||||
except PermissionError as e: # (EACCES, EPERM)
|
||||
self.assertIsNone(e.filename)
|
||||
else:
|
||||
if isinstance(group, str):
|
||||
group_gid = grp.getgrnam(group).gr_gid
|
||||
|
@ -2129,7 +2130,8 @@ class POSIXProcessTestCase(BaseTestCase):
|
|||
[sys.executable, "-c",
|
||||
"import os, sys, json; json.dump(os.getgroups(), sys.stdout)"],
|
||||
extra_groups=group_list)
|
||||
except PermissionError:
|
||||
except PermissionError as e:
|
||||
self.assertIsNone(e.filename)
|
||||
self.skipTest("setgroup() EPERM; this test may require root.")
|
||||
else:
|
||||
parent_groups = os.getgroups()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue