mirror of
https://github.com/python/cpython.git
synced 2026-06-28 03:41:13 +00:00
[3.15] gh-150368: Change Windows user group to secure identifier in test_tempfile (GH-150369) (#150701)
gh-150368: Change Windows user group to secure identifier in test_tempfile (GH-150369)
(cherry picked from commit 9d64c355b5)
Co-authored-by: Dawid Konrad Kohnke <51542233+anytokin@users.noreply.github.com>
This commit is contained in:
parent
4ce8de3550
commit
58335eebef
1 changed files with 6 additions and 2 deletions
|
|
@ -332,7 +332,9 @@ def test_read_only_directory(self):
|
|||
with _inside_empty_temp_dir():
|
||||
probe = os.path.join(tempfile.tempdir, 'probe')
|
||||
if os.name == 'nt':
|
||||
cmd = ['icacls', tempfile.tempdir, '/deny', 'Everyone:(W)']
|
||||
# Use security identifier *S-1-1-0 instead
|
||||
# of localized "Everyone" to not depend on the locale.
|
||||
cmd = ['icacls', tempfile.tempdir, '/deny', '*S-1-1-0:(W)']
|
||||
stdout = None if support.verbose > 1 else subprocess.DEVNULL
|
||||
subprocess.run(cmd, check=True, stdout=stdout)
|
||||
else:
|
||||
|
|
@ -355,7 +357,9 @@ def test_read_only_directory(self):
|
|||
self.make_temp()
|
||||
finally:
|
||||
if os.name == 'nt':
|
||||
cmd = ['icacls', tempfile.tempdir, '/grant:r', 'Everyone:(M)']
|
||||
# Use security identifier *S-1-1-0 instead
|
||||
# of localized "Everyone" to not depend on the locale.
|
||||
cmd = ['icacls', tempfile.tempdir, '/grant:r', '*S-1-1-0:(M)']
|
||||
subprocess.run(cmd, check=True, stdout=stdout)
|
||||
else:
|
||||
os.chmod(tempfile.tempdir, oldmode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue