mirror of
https://github.com/python/cpython.git
synced 2025-10-22 22:53:06 +00:00
gh-95675: fix uid and gid at test_add_dir_getmember (gh-102207)
Co-authored-by: Seonkyo Ok <seonkyo.ok@linecorp.com>
This commit is contained in:
parent
54dfa14c5a
commit
56e93c8020
2 changed files with 8 additions and 6 deletions
|
@ -225,18 +225,19 @@ class UstarReadTest(ReadTest, unittest.TestCase):
|
||||||
self.add_dir_and_getmember('bar')
|
self.add_dir_and_getmember('bar')
|
||||||
self.add_dir_and_getmember('a'*101)
|
self.add_dir_and_getmember('a'*101)
|
||||||
|
|
||||||
@unittest.skipIf(
|
@unittest.skipUnless(hasattr(os, "getuid") and hasattr(os, "getgid"),
|
||||||
(hasattr(os, 'getuid') and os.getuid() > 0o777_7777) or
|
"Missing getuid or getgid implementation")
|
||||||
(hasattr(os, 'getgid') and os.getgid() > 0o777_7777),
|
|
||||||
"uid or gid too high for USTAR format."
|
|
||||||
)
|
|
||||||
def add_dir_and_getmember(self, name):
|
def add_dir_and_getmember(self, name):
|
||||||
|
def filter(tarinfo):
|
||||||
|
tarinfo.uid = tarinfo.gid = 100
|
||||||
|
return tarinfo
|
||||||
|
|
||||||
with os_helper.temp_cwd():
|
with os_helper.temp_cwd():
|
||||||
with tarfile.open(tmpname, 'w') as tar:
|
with tarfile.open(tmpname, 'w') as tar:
|
||||||
tar.format = tarfile.USTAR_FORMAT
|
tar.format = tarfile.USTAR_FORMAT
|
||||||
try:
|
try:
|
||||||
os.mkdir(name)
|
os.mkdir(name)
|
||||||
tar.add(name)
|
tar.add(name, filter=filter)
|
||||||
finally:
|
finally:
|
||||||
os.rmdir(name)
|
os.rmdir(name)
|
||||||
with tarfile.open(tmpname) as tar:
|
with tarfile.open(tmpname) as tar:
|
||||||
|
|
|
@ -1308,6 +1308,7 @@ Jon Oberheide
|
||||||
Milan Oberkirch
|
Milan Oberkirch
|
||||||
Pascal Oberndoerfer
|
Pascal Oberndoerfer
|
||||||
Géry Ogam
|
Géry Ogam
|
||||||
|
Seonkyo Ok
|
||||||
Jeffrey Ollie
|
Jeffrey Ollie
|
||||||
Adam Olsen
|
Adam Olsen
|
||||||
Bryan Olson
|
Bryan Olson
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue