Skip to content

Commit

Permalink
FilesCheck: Fix zero perm check with binaries
Browse files Browse the repository at this point in the history
Try to read tmpfiles.d configuration just from .conf files. This patch also
wrap the readline with try/except to make it not crash if there's any special
file there that we try to read.

Fix #1257
  • Loading branch information
danigm committed Aug 2, 2024
1 parent 78f9ad0 commit 2ee228f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rpmlint/checks/FilesCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,18 @@ def find_perm_in_tmpfiles(pkg, fname):
fname = os.path.realpath(fname)

for k, v in pkg.files.items():
if 'tmpfiles.d' not in k:
if 'tmpfiles.d' not in k or not k.endswith('.conf'):
continue
if not os.path.exists(v.path) or os.path.isdir(v.path):
continue

with open(v.path) as f:
tmpd += f.readlines()
try:
tmpd += f.readlines()
except ValueError:
# Can't read this file, so we are not trying to read definition
# from there
pass

for line in tmpd:
if f' {fname} ' not in line:
Expand Down
1 change: 1 addition & 0 deletions test/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def test_files_without_perms(package, output, test):
"""
},
'/etc/tmpfiles.d': {'is_dir': True},
'/etc/tmpfiles.d/binary.zip': {'content': b'\xa0\x1b'},
},
),
])
Expand Down

0 comments on commit 2ee228f

Please sign in to comment.