8000 [3.9] gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) by zooba · Pull Request #118741 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.9] gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) #118741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 24, 2024
Merged
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
Next Next commit
gh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (GH-1…
  • Loading branch information
zooba committed May 15, 2024
commit 1946e26c3670078185774846459c4b1acb8c3798
23 changes: 8 additions & 15 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,21 +1496,14 @@ def test_exist_ok_existing_regular_file(self):
@unittest.skipUnless(os.name == 'nt', "requires Windows")
def test_win32_mkdir_700(self):
base = support.TESTFN
path1 = os.path.join(support.TESTFN, 'dir1')
path2 = os.path.join(support.TESTFN, 'dir2')
# mode=0o700 is special-cased to override ACLs on Windows
# There's no way to know exactly how the ACLs will look, so we'll
# check that they are different from a regularly created directory.
os.mkdir(path1, mode=0o700)
os.mkdir(path2, mode=0o777)

out1 = subprocess.check_output(["icacls.exe", path1], encoding="oem")
out2 = subprocess.check_output(["icacls.exe", path2], encoding="oem")
os.rmdir(path1)
os.rmdir(path2)
out1 = out1.replace(path1, "<PATH>")
out2 = out2.replace(path2, "<PATH>")
self.assertNotEqual(out1, out2)
path = os.path.abspath(os.path.join(support.TESTFN, 'dir'))
os.mkdir(path, mode=0o700)
out = subprocess.check_output(["cacls.exe", path, "/s"], encoding="oem")
os.rmdir(path)
self.assertEqual(
out.strip(),
f'{path} "D:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;FA;;;OW)"',
)

def tearDown(self):
path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3',
Expand Down
2 changes: 1 addition & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4479,7 +4479,7 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd)
if (mode == 0700 /* 0o700 */) {
ULONG sdSize;
pSecAttr = &secAttr;
// Set a discreationary ACL (D) that is protected (P) and includes
// Set a discretionary ACL (D) that is protected (P) and includes
// inheritable (OICI) entries that allow (A) full control (FA) to
// SYSTEM (SY), Administrators (BA), and the owner (OW).
if (!ConvertStringSecurityDescriptorToSecurityDescriptorW(
Expand Down
0