Skip to content

Commit e598a53

Browse files
committed
pythongh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (pythonGH-119056)
1 parent 1288fdc commit e598a53

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

Lib/test/test_os.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,21 +1746,14 @@ def test_exist_ok_existing_regular_file(self):
17461746
@unittest.skipUnless(os.name == 'nt', "requires Windows")
17471747
def test_win32_mkdir_700(self):
17481748
base = os_helper.TESTFN
1749-
path1 = os.path.join(os_helper.TESTFN, 'dir1')
1750-
path2 = os.path.join(os_helper.TESTFN, 'dir2')
1751-
# mode=0o700 is special-cased to override ACLs on Windows
1752-
# There's no way to know exactly how the ACLs will look, so we'll
1753-
# check that they are different from a regularly created directory.
1754-
os.mkdir(path1, mode=0o700)
1755-
os.mkdir(path2, mode=0o777)
1756-
1757-
out1 = subprocess.check_output(["icacls.exe", path1], encoding="oem")
1758-
out2 = subprocess.check_output(["icacls.exe", path2], encoding="oem")
1759-
os.rmdir(path1)
1760-
os.rmdir(path2)
1761-
out1 = out1.replace(path1, "<PATH>")
1762-
out2 = out2.replace(path2, "<PATH>")
1763-
self.assertNotEqual(out1, out2)
1749+
path = os.path.abspath(os.path.join(os_helper.TESTFN, 'dir'))
1750+
os.mkdir(path, mode=0o700)
1751+
out = subprocess.check_output(["cacls.exe", path, "/s"], encoding="oem")
1752+
os.rmdir(path)
1753+
self.assertEqual(
1754+
out.strip(),
1755+
f'{path} "D:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;FA;;;OW)"',
1756+
)
17641757

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

Modules/posixmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4636,7 +4636,7 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd)
46364636
if (mode == 0700 /* 0o700 */) {
46374637
ULONG sdSize;
46384638
pSecAttr = &secAttr;
4639-
// Set a discreationary ACL (D) that is protected (P) and includes
4639+
// Set a discretionary ACL (D) that is protected (P) and includes
46404640
// inheritable (OICI) entries that allow (A) full control (FA) to
46414641
// SYSTEM (SY), Administrators (BA), and the owner (OW).
46424642
if (!ConvertStringSecurityDescriptorToSecurityDescriptorW(

0 commit comments

Comments
 (0)