diff options
| author | Michał Górny <mgorny@gentoo.org> | 2022-09-17 18:48:09 +0200 |
|---|---|---|
| committer | Michał Górny <mgorny@gentoo.org> | 2022-09-17 18:48:09 +0200 |
| commit | a0b1c3cbd4e824f806ac1ddb04ec94fc27d32c17 (patch) | |
| tree | dcecd7268753e94af9ee3ddc6606ecb829f78351 | |
| parent | 0828357e19e55e5090b6d6e13d3ff568dc6cfa29 (diff) | |
| download | gemato-a0b1c3cbd4e824f806ac1ddb04ec94fc27d32c17.tar.gz | |
Print a realpath warning when dealing with symlinks
Closes: https://github.com/projg2/gemato/issues/22
Signed-off-by: Michał Górny <mgorny@gentoo.org>
| -rw-r--r-- | gemato/cli.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gemato/cli.py b/gemato/cli.py index 5b2370d..44ea423 100644 --- a/gemato/cli.py +++ b/gemato/cli.py @@ -15,7 +15,7 @@ import subprocess import sys import timeit -from gemato.exceptions import GematoException +from gemato.exceptions import GematoException, ManifestMismatch from gemato.find_top_level import find_top_level_manifest from gemato.hash import hash_file, hash_path from gemato.manifest import ( @@ -276,10 +276,19 @@ class VerifyCommand(BaseManifestLoaderMixin, VerifyingOpenPGPMixin, logging.info(f'Verifying {p}...') - relpath = os.path.relpath(p, os.path.dirname(tlm)) + tlmdir = os.path.dirname(tlm) + relpath = os.path.relpath(p, tlmdir) if relpath == '.': relpath = '' - ret &= m.assert_directory_verifies(relpath, **self.kwargs) + try: + ret &= m.assert_directory_verifies(relpath, **self.kwargs) + except ManifestMismatch as e: + apparent_path = os.path.join(tlmdir, e.path) + real_path = os.path.realpath(apparent_path) + if apparent_path != real_path: + logging.warning( + f"Path contains symlinks. Real file path: {real_path}") + raise stop = timeit.default_timer() logging.info(f'{p} verified in {stop - start:.2f} seconds') |
