Skip to content

Commit c4b3f7a

Browse files
committed
pythongh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (pythonGH-119056)
1 parent 0069b38 commit c4b3f7a

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
@@ -1383,21 +1383,14 @@ def test_exist_ok_existing_regular_file(self):
13831383
@unittest.skipUnless(os.name == 'nt', "requires Windows")
13841384
def test_win32_mkdir_700(self):
13851385
base = support.TESTFN
1386-
path1 = os.path.join(support.TESTFN, 'dir1')
1387-
path2 = os.path.join(support.TESTFN, 'dir2')
1388-
# mode=0o700 is special-cased to override ACLs on Windows
1389-
# There's no way to know exactly how the ACLs will look, so we'll
1390-
# check that they are different from a regularly created directory.
1391-
os.mkdir(path1, mode=0o700)
1392-
os.mkdir(path2, mode=0o777)
1393-
1394-
out1 = subprocess.check_output(["icacls.exe", path1], encoding="oem")
1395-
out2 = subprocess.check_output(["icacls.exe", path2], encoding="oem")
1396-
os.rmdir(path1)
1397-
os.rmdir(path2)
1398-
out1 = out1.replace(path1, "<PATH>")
1399-
out2 = out2.replace(path2, "<PATH>")
1400-
self.assertNotEqual(out1, out2)
1386+
path = os.path.abspath(os.path.join(support.TESTFN, 'dir'))
1387+
os.mkdir(path, mode=0o700)
1388+
out = subprocess.check_output(["cacls.exe", path, "/s"], encoding="oem")
1389+
os.rmdir(path)
1390+
self.assertEqual(
1391+
out.strip(),
1392+
f'{path} "D:P(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;FA;;;OW)"',
1393+
)
14011394

14021395
def tearDown(self):
14031396
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
@@ -4173,7 +4173,7 @@ os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd)
41734173
if (mode == 0700 /* 0o700 */) {
41744174
ULONG sdSize;
41754175
pSecAttr = &secAttr;
4176-
// Set a discreationary ACL (D) that is protected (P) and includes
4176+
// Set a discretionary ACL (D) that is protected (P) and includes
41774177
// inheritable (OICI) entries that allow (A) full control (FA) to
41784178
// SYSTEM (SY), Administrators (BA), and the owner (OW).
41794179
if (!ConvertStringSecurityDescriptorToSecurityDescriptorW(

0 commit comments

Comments
 (0)