Skip to content

Commit

Permalink
FilesCheck: Do not error about non-readable %ghost
Browse files Browse the repository at this point in the history
Fix #1287
  • Loading branch information
danigm committed Oct 30, 2024
1 parent 25c5792 commit 2e5ec2c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rpmlint/checks/FilesCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,11 @@ def _check_file_normal_file_devel(self, pkg, fname, pkgfile):
self.output.add_info('W', pkg, 'devel-file-in-non-devel-package', fname)

def _check_file_normal_file_non_readable(self, pkg, fname, pkgfile):
# Do not check permissions for ghosts files
# https://github.com/rpm-software-management/rpmlint/issues/1287
if pkgfile.is_ghost:
return

mode = pkgfile.mode
perm = mode & 0o7777
if mode & 0o444 != 0o444 and perm & 0o7000 == 0:
Expand Down
16 changes: 16 additions & 0 deletions test/mockdata/mock_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,19 @@
},
},
)


# Package with just a ghost file that doesn't exists in rpmroot during build so
# it has no permissions
NonReadableGhostPackage = get_tested_mock_package(
lazyload=True,
header={'requires': []},
files={
'/boohoo': {
'metadata': {
'mode': 0o000 | stat.S_IFREG,
'flags': rpm.RPMFILE_GHOST,
},
},
},
)
9 changes: 9 additions & 0 deletions test/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ManPagesPackage,
ManualPagesPackage,
NetmaskDebugsourcePackage,
NonReadableGhostPackage,
Python3PowerBrokenPackage,
Python3PowerPackage,
PythonShebangLinkOkPackage,
Expand Down Expand Up @@ -324,3 +325,11 @@ def test_files_without_perms_tmpfiles(package, output, test):
assert re.findall(r'W: zero-perms-ghost .*"%ghost %attr\(0644,root,root\) .*resolv.conf"', out)
assert re.findall(r'W: zero-perms-ghost .*"%ghost %attr\(0755,root,group\) /run/netconfig"', out)
assert not re.findall('W: zero-perms.*yp.conf ', out)


# https://github.com/rpm-software-management/rpmlint/issues/1287
@pytest.mark.parametrize('package', [NonReadableGhostPackage])
def test_non_readable_ghost_files(package, output, test):
test.check(package)
out = output.print_results(output.results)
assert 'E: non-readable /boohoo 0' not in out

0 comments on commit 2e5ec2c

Please sign in to comment.