From 078f6911c253d46b7b5b9904b4c81623e18339b4 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Wed, 7 May 2025 10:55:21 +0200 Subject: [PATCH 1/7] disable security descriptor handling on unsupported WinAPI partitions --- Modules/posixmodule.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 922694fa367ac3..b30e77e9fe83c2 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5726,6 +5726,7 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd) #ifdef MS_WINDOWS Py_BEGIN_ALLOW_THREADS +#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) if (mode == 0700 /* 0o700 */) { ULONG sdSize; pSecAttr = &secAttr; @@ -5741,6 +5742,7 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd) error = GetLastError(); } } +#endif if (!error) { result = CreateDirectoryW(path->wide, pSecAttr); if (secAttr.lpSecurityDescriptor && From 243f3771cb2920fe0582f156626f715d2330fa16 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 7 May 2025 09:02:20 +0000 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst diff --git a/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst b/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst new file mode 100644 index 00000000000000..a2bb0bcc32b849 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst @@ -0,0 +1 @@ +Disable handling of security descriptors by :func:`os.mkdir` with mode `0o700` on WinAPI partitions that do not support it. From 24aeedf0324952d30236449f3e6cc1d735f313fb Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Wed, 7 May 2025 11:04:01 +0200 Subject: [PATCH 3/7] fix linter error --- .../next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst b/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst index a2bb0bcc32b849..88e216b9a22c47 100644 --- a/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst +++ b/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst @@ -1 +1 @@ -Disable handling of security descriptors by :func:`os.mkdir` with mode `0o700` on WinAPI partitions that do not support it. +Disable handling of security descriptors by :func:`os.mkdir` with mode ``0o700`` on WinAPI partitions that do not support it. From 4c98d03943db71959f03b89ac91d339b46ebe945 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Wed, 7 May 2025 12:46:56 +0200 Subject: [PATCH 4/7] fix guard --- Modules/posixmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index b30e77e9fe83c2..2197e79f9a6597 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5726,7 +5726,7 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd) #ifdef MS_WINDOWS Py_BEGIN_ALLOW_THREADS -#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_SYSTEM) +#if defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM) if (mode == 0700 /* 0o700 */) { ULONG sdSize; pSecAttr = &secAttr; From e2ee3d030f7f3e7470eefa7128af22bf1eed963b Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Wed, 7 May 2025 21:48:49 +0200 Subject: [PATCH 5/7] Update Modules/posixmodule.c Co-authored-by: Steve Dower --- Modules/posixmodule.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 2197e79f9a6597..d374116da42dce 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5726,6 +5726,8 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd) #ifdef MS_WINDOWS Py_BEGIN_ALLOW_THREADS + // For API sets that don't support these APIs, we have no choice + // but to silently create a directory with default ACL. #if defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM) if (mode == 0700 /* 0o700 */) { ULONG sdSize; From 8c37fa1c96f11dc4051d632ed9b3e95e23e1ab15 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Wed, 7 May 2025 21:48:56 +0200 Subject: [PATCH 6/7] Update Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst Co-authored-by: Steve Dower --- .../next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst b/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst index 88e216b9a22c47..884425b839a264 100644 --- a/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst +++ b/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst @@ -1 +1 @@ -Disable handling of security descriptors by :func:`os.mkdir` with mode ``0o700`` on WinAPI partitions that do not support it. +Disable handling of security descriptors by :func:`os.mkdir` with mode ``0o700`` on WinAPI partitions that do not support it. This only affects custom builds for specialized targets. From 2575d66950010c63231d752b1e0674233825c737 Mon Sep 17 00:00:00 2001 From: Max Bachmann Date: Wed, 7 May 2025 21:51:36 +0200 Subject: [PATCH 7/7] move news entry --- .../2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/{Library => Windows}/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst (100%) diff --git a/Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst b/Misc/NEWS.d/next/Windows/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst similarity index 100% rename from Misc/NEWS.d/next/Library/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst rename to Misc/NEWS.d/next/Windows/2025-05-07-09-02-19.gh-issue-133562.lqqNW1.rst