mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
gh-97897: Prevent os.mkfifo and os.mknod segfaults with macOS 13 SDK (GH-97944)
The macOS 13 SDK includes support for the `mkfifoat` and `mknodat` system calls.
Using the `dir_fd` option with either `os.mkfifo` or `os.mknod` could result in a
segfault if cpython is built with the macOS 13 SDK but run on an earlier
version of macOS. Prevent this by adding runtime support for detection of
these system calls ("weaklinking") as is done for other newer syscalls on
macOS.
This commit is contained in:
parent
e63d7dae90
commit
6d0a0191a4
3 changed files with 80 additions and 8 deletions
|
|
@ -2090,6 +2090,28 @@ class TestPosixWeaklinking(unittest.TestCase):
|
|||
with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
|
||||
os.mkdir("dir", dir_fd=0)
|
||||
|
||||
def test_mkfifo(self):
|
||||
self._verify_available("HAVE_MKFIFOAT")
|
||||
if self.mac_ver >= (13, 0):
|
||||
self.assertIn("HAVE_MKFIFOAT", posix._have_functions)
|
||||
|
||||
else:
|
||||
self.assertNotIn("HAVE_MKFIFOAT", posix._have_functions)
|
||||
|
||||
with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
|
||||
os.mkfifo("path", dir_fd=0)
|
||||
|
||||
def test_mknod(self):
|
||||
self._verify_available("HAVE_MKNODAT")
|
||||
if self.mac_ver >= (13, 0):
|
||||
self.assertIn("HAVE_MKNODAT", posix._have_functions)
|
||||
|
||||
else:
|
||||
self.assertNotIn("HAVE_MKNODAT", posix._have_functions)
|
||||
|
||||
with self.assertRaisesRegex(NotImplementedError, "dir_fd unavailable"):
|
||||
os.mknod("path", dir_fd=0)
|
||||
|
||||
def test_rename_replace(self):
|
||||
self._verify_available("HAVE_RENAMEAT")
|
||||
if self.mac_ver >= (10, 10):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue