From a0b1c3cbd4e824f806ac1ddb04ec94fc27d32c17 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sat, 17 Sep 2022 18:48:09 +0200 Subject: Print a realpath warning when dealing with symlinks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: https://github.com/projg2/gemato/issues/22 Signed-off-by: Michał Górny --- gemato/cli.py | 15 ++++++++++++--- 1 file 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') -- cgit v1.2.3