diff options
author | Tristan Maat <tm@tlater.net> | 2019-12-10 13:22:05 +0000 |
---|---|---|
committer | Tristan Maat <tm@tlater.net> | 2019-12-10 13:22:05 +0000 |
commit | 397a8fe5e8d32a8ec6a9ef252cd7a55007ad4f66 (patch) | |
tree | 41343f94e25cb8474e35d0a4b73465d6b440569e | |
parent | 4ad66cd51f36319feef0ed0824e303f3f64c7422 (diff) | |
parent | bb9045a1c1fa7d4d45041af4c0a892df9584a3be (diff) | |
download | buildstream-397a8fe5e8d32a8ec6a9ef252cd7a55007ad4f66.tar.gz |
Merge branch 'tlater/tar-test-security' into 'master'
tests/sources/tar.py: `utils._force_rmtree` instead of giving 777 permissions
See merge request BuildStream/buildstream!1763
-rw-r--r-- | tests/sources/tar.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/tests/sources/tar.py b/tests/sources/tar.py index f5f3dde2d..c3621c152 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -2,7 +2,7 @@ # pylint: disable=redefined-outer-name import os -from shutil import copyfile, rmtree +from shutil import copyfile import subprocess import tarfile import tempfile @@ -10,6 +10,7 @@ import urllib.parse import pytest +from buildstream import utils from buildstream._exceptions import ErrorDomain from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import @@ -303,16 +304,7 @@ def test_read_only_dir(cli, tmpdir, datafiles, tar_name, base_dir): result.assert_success() finally: - - # Make tmpdir deletable no matter what happens - def make_dir_writable(_fn, path, _excinfo): - os.chmod(os.path.dirname(path), 0o777) - if os.path.isdir(path): - os.rmdir(path) - else: - os.remove(path) - - rmtree(str(tmpdir), onerror=make_dir_writable) + utils._force_rmtree(str(tmpdir)) @pytest.mark.parametrize("server_type", ("FTP", "HTTP")) |