Fixes relative paths handling issues

master
Eugene Zamriy 1 year ago
parent 93273a8b28
commit 1018b394a9
Signed by: ezamriy
GPG Key ID: 7EBF95C7DCFA496C

@ -220,10 +220,23 @@ class TapProducer:
counter = staticmethod(counter)
def normalize_path(path: str) -> str:
"""
Returns an absolute path with all variables expanded.
Args:
path: path to be normalized.
Returns:
Normalized path.
"""
return os.path.abspath(os.path.expanduser(os.path.expandvars(path)))
def main():
arg_parser = init_arg_parser()
args = arg_parser.parse_args()
rpm_file = args.rpm_file
rpm_file = normalize_path(args.rpm_file)
tap = TapProducer()
#
step = 'load public IMA certificate'
@ -247,7 +260,7 @@ def main():
failed = False
with unpack_rpm_to_tmp(rpm_file) as rpm_dir:
for rel_path, sig_hdr in ima_sigs:
file_path = os.path.join(rpm_dir, rel_path)
file_path = os.path.join(rpm_dir, os.path.relpath(rel_path, '/'))
if not os.path.isfile(file_path) or os.path.islink(file_path):
tap.skipped(f'{rel_path} is not a regular file')
continue

Loading…
Cancel
Save