summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-10-06 19:14:16 (GMT)
committerGitHub <noreply@github.com>2022-10-06 19:14:16 (GMT)
commit3d89ac2f4c573f5facde11579db0791832f5b392 (patch)
tree89c32530996894126e5518630b56beff5b7c8607 /Lib
parent537c93ea3b822b4dc039c35ea1375046a9e95c7a (diff)
downloadcpython-3d89ac2f4c573f5facde11579db0791832f5b392.zip
cpython-3d89ac2f4c573f5facde11579db0791832f5b392.tar.gz
cpython-3d89ac2f4c573f5facde11579db0791832f5b392.tar.bz2
[3.10] gh-97897: Prevent os.mkfifo and os.mknod segfaults with macOS 13 SDK (GH-97944) (#97967)
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. (cherry picked from commit 6d0a0191a4e5477bd843e62c24d7f3bcad4fd5fc) Co-authored-by: Ned Deily <nad@python.org>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_posix.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 701543b..19bc885 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -2066,6 +2066,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):