Visitar URL original
gh-134587: Fix os.mkdir(mode=0o700) under Windows AppContainer by thatnerdyguy · Pull Request #148804 · python/cpython · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix trailing spaces
  • Loading branch information
thatnerdyguy committed Apr 20, 2026
commit e31766a947e64226197f58d4f09bbb3a4efcd5ae
2 changes: 1 addition & 1 deletion Lib/test/test_os/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -2338,7 +2338,7 @@ class PROCESS_INFORMATION(ctypes.Structure):
import os
import shutil
import tempfile

# Test what was reported in gh-134587
target = tempfile.mkdtemp(prefix='_test_ac_inner_')
try:
Expand Down
20 changes: 10 additions & 10 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6143,11 +6143,11 @@ os__path_normpath_impl(PyObject *module, path_t *path)
#if defined(MS_WINDOWS) && \
(defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM))

// If running under an AppContainer, this will append an ACE to the provided
// If running under an AppContainer, this will append an ACE to the provided
// SDDL string that grants full control to the AppContainer SID.
static LPCWSTR
sddl_append_for_appcontainer_if_necessary(LPCWSTR base_sddl) {

// Default to using the "base" SDDL, which is what we want if
// we are not running under an AppContainer
LPCWSTR resolved_sddl = base_sddl;
Expand Down Expand Up @@ -6184,7 +6184,7 @@ sddl_append_for_appcontainer_if_necessary(LPCWSTR base_sddl) {
}

// Get the AppContainer SID
getTokenResult = GetTokenInformation(hToken, TokenAppContainerSid,
getTokenResult = GetTokenInformation(hToken, TokenAppContainerSid,
tokenInfo, returnLength, &returnLength);
if (!getTokenResult) {
goto done;
Expand All @@ -6200,28 +6200,28 @@ sddl_append_for_appcontainer_if_necessary(LPCWSTR base_sddl) {
}

// Now that we know we are running under an AppContainer, and we have
// the AppContainer SID as a string, we can append an ACE to the provided
// the AppContainer SID as a string, we can append an ACE to the provided
// SDDL

// Dynamically allocate the final buffer here. This is expected to be
// called at most once, however in the case it could be called from
// multiple threads, we are dynamically allocating the buffer here rather
// than using a static buffer (which would then require synchronization
// Dynamically allocate the final buffer here. This is expected to be
// called at most once, however in the case it could be called from
// multiple threads, we are dynamically allocating the buffer here rather
// than using a static buffer (which would then require synchronization
// for that static buffer).
LPWSTR sddl_buf = PyMem_RawMalloc(sizeof(WCHAR) * 256);

int sddl_chars = _snwprintf(
sddl_buf,
256,
// Append a string that includes inheritable (OICI) entries
// Append a string that includes inheritable (OICI) entries
// that allow (A) full control (FA) to the AppContainer SID
L"%s(A;OICI;FA;;;%s)",
base_sddl,
sidStr);

if (sddl_chars >= 0 && (size_t)sddl_chars < 256) {
resolved_sddl = sddl_buf;
}
}
else {
PyMem_RawFree(sddl_buf);
}
Expand Down
Loading