(self)
| 796 | |
| 797 | @unittest.skipUnless(os.name == "nt", "Only on Windows.") |
| 798 | def test_mode_win32(self): |
| 799 | # Use icacls.exe to extract the users with some level of access |
| 800 | # Main thing we are testing is that the BUILTIN\Users group has |
| 801 | # no access. The exact ACL is going to vary based on which user |
| 802 | # is running the test. |
| 803 | dir = self.do_create() |
| 804 | try: |
| 805 | out = subprocess.check_output(["icacls.exe", dir], encoding="oem").casefold() |
| 806 | finally: |
| 807 | os.rmdir(dir) |
| 808 | |
| 809 | dir = dir.casefold() |
| 810 | users = set() |
| 811 | found_user = False |
| 812 | for line in out.strip().splitlines(): |
| 813 | acl = None |
| 814 | # First line of result includes our directory |
| 815 | if line.startswith(dir): |
| 816 | acl = line.removeprefix(dir).strip() |
| 817 | elif line and line[:1].isspace(): |
| 818 | acl = line.strip() |
| 819 | if acl: |
| 820 | users.add(acl.partition(":")[0]) |
| 821 | |
| 822 | self.assertNotIn(r"BUILTIN\Users".casefold(), users) |
| 823 | |
| 824 | def test_collision_with_existing_file(self): |
| 825 | # mkdtemp tries another name when a file with |
nothing calls this directly
no test coverage detected