From b2ee6d69a5c14dbfc0aa85e7f3fd1499daa7f583 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 26 Jun 2023 21:53:33 +0200 Subject: [PATCH 1/2] gh-106118: Add O_CLOEXEC preprocessor guard --- .../Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst | 2 ++ Python/sysmodule.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst diff --git a/Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst b/Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst new file mode 100644 index 00000000000000..163bdfc9951d35 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst @@ -0,0 +1,2 @@ +Fix compilation for platforms without :c:const:`!O_CLOEXEC`. The issue was +introduced with Python 3.12b1 in :gh:`103295`. Patch by Erlend Aasland. diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 3284e14e7742db..0cd8974d197133 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -2277,7 +2277,10 @@ PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void) { char filename[100]; pid_t pid = getpid(); // Use nofollow flag to prevent symlink attacks. - int flags = O_WRONLY | O_CREAT | O_APPEND | O_NOFOLLOW | O_CLOEXEC; + int flags = O_WRONLY | O_CREAT | O_APPEND | O_NOFOLLOW; +#ifdef O_CLOEXEC + flags |= O_CLOEXEC; +#endif snprintf(filename, sizeof(filename) - 1, "/tmp/perf-%jd.map", (intmax_t)pid); int fd = open(filename, flags, 0600); From 35fbc2b8075565c80f3ec9c675757a0fb3df354a Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 26 Jun 2023 22:02:37 +0200 Subject: [PATCH 2/2] Sphinx fix --- .../next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst b/Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst index 163bdfc9951d35..f93cae5d03b539 100644 --- a/Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst +++ b/Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst @@ -1,2 +1,2 @@ -Fix compilation for platforms without :c:const:`!O_CLOEXEC`. The issue was +Fix compilation for platforms without :data:`!O_CLOEXEC`. The issue was introduced with Python 3.12b1 in :gh:`103295`. Patch by Erlend Aasland.