Skip to content

Commit 1946e26

Browse files
committed
pythongh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (pythonGH-119056)
1 parent a30cbb2 commit 1946e26

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
@@ -1496,21 +1496,14 @@ def test_exist_ok_existing_regular_file(self):
14961496
@unittest.skipUnless(os.name == 'nt', "requires Windows")
14971497
def test_win32_mkdir_700(self):
14981498
base = support.TESTFN
1499-
path1 = os.path.join(support.TESTFN, 'dir1')
1500-
path2 = os.path.join(support.TESTFN, 'dir2')
1501-
# mode=0o700 is special-cased to override ACLs on Windows
1502-
# There's no way to know exactly how the ACLs will look, so we'll
1503-
# check that they are different from a regularly created directory.
1504-
os.mkdir(path1, mode=0o700)
1505-
os.mkdir(path2, mode=0o777)
1506-
1507-
out1 = subprocess.check_output(["icacls.exe", path1], encoding="oem")
1508-
out2 = subprocess.check_output(["icacls.exe", path2], encoding="oem")
1509-
os.rmdir(path1)
1510-
os.rmdir(path2)
1511-
out1 = out1.replace(path1, "<PATH>")
1512-
out2 = out2.replace(path2, "<PATH>")
1513-
self.assertNotEqual(out1, out2)
1499+
path = os.path.abspath(os.path.join(support.TESTFN, 'dir'))
1500+
os.mkdir(path, mode=0o700)
1501+
out = subprocess.check_output(["cacls.exe", path, "/s"], encoding="oem")
1502+
os.rmdir(path)
1503+
self.assertEqual(
1504+
out.strip(),
1505+
f'{path} "D:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;FA;;;OW)"',
1506+
)
15141507

15151508
def tearDown(self):
15161509
path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3',

Modules/posixmodule.c

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

0 commit comments

Comments
 (0)