Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e1dfa97

Browse filesBrowse files
gh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (GH-119056)
(cherry picked from commit 94591dc) Co-authored-by: Steve Dower <steve.dower@python.org>
1 parent dd8a61f commit e1dfa97
Copy full SHA for e1dfa97

File tree

2 files changed

+9
-16
lines changed
Filter options

2 files changed

+9
-16
lines changed

‎Lib/test/test_os.py

Copy file name to clipboardExpand all lines: Lib/test/test_os.py
+8-15Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,21 +1814,14 @@ def test_exist_ok_existing_regular_file(self):
18141814
@unittest.skipUnless(os.name == 'nt', "requires Windows")
18151815
def test_win32_mkdir_700(self):
18161816
base = os_helper.TESTFN
1817-
path1 = os.path.join(os_helper.TESTFN, 'dir1')
1818-
path2 = os.path.join(os_helper.TESTFN, 'dir2')
1819-
# mode=0o700 is special-cased to override ACLs on Windows
1820-
# There's no way to know exactly how the ACLs will look, so we'll
1821-
# check that they are different from a regularly created directory.
1822-
os.mkdir(path1, mode=0o700)
1823-
os.mkdir(path2, mode=0o777)
1824-
1825-
out1 = subprocess.check_output(["icacls.exe", path1], encoding="oem")
1826-
out2 = subprocess.check_output(["icacls.exe", path2], encoding="oem")
1827-
os.rmdir(path1)
1828-
os.rmdir(path2)
1829-
out1 = out1.replace(path1, "<PATH>")
1830-
out2 = out2.replace(path2, "<PATH>")
1831-
self.assertNotEqual(out1, out2)
1817+
path = os.path.abspath(os.path.join(os_helper.TESTFN, 'dir'))
1818+
os.mkdir(path, mode=0o700)
1819+
out = subprocess.check_output(["cacls.exe", path, "/s"], encoding="oem")
1820+
os.rmdir(path)
1821+
self.assertEqual(
1822+
out.strip(),
1823+
f'{path} "D:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;FA;;;OW)"',
1824+
)
18321825

18331826
def tearDown(self):
18341827
path = os.path.join(os_helper.TESTFN, 'dir1', 'dir2', 'dir3',

‎Modules/posixmodule.c

Copy file name to clipboardExpand all lines: Modules/posixmodule.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5590,7 +5590,7 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd)
55905590
if (mode == 0700 /* 0o700 */) {
55915591
ULONG sdSize;
55925592
pSecAttr = &secAttr;
5593-
// Set a discreationary ACL (D) that is protected (P) and includes
5593+
// Set a discretionary ACL (D) that is protected (P) and includes
55945594
// inheritable (OICI) entries that allow (A) full control (FA) to
55955595
// SYSTEM (SY), Administrators (BA), and the owner (OW).
55965596
if (!ConvertStringSecurityDescriptorToSecurityDescriptorW(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.