diff --git a/rpmlint/checks/FilesCheck.py b/rpmlint/checks/FilesCheck.py index 8ebb01142..60cb3cb85 100644 --- a/rpmlint/checks/FilesCheck.py +++ b/rpmlint/checks/FilesCheck.py @@ -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: diff --git a/test/mockdata/mock_files.py b/test/mockdata/mock_files.py index 3dde36ba3..4c40a4d68 100644 --- a/test/mockdata/mock_files.py +++ b/test/mockdata/mock_files.py @@ -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, + }, + }, + }, +) diff --git a/test/test_files.py b/test/test_files.py index 54716c90e..2ae17332c 100644 --- a/test/test_files.py +++ b/test/test_files.py @@ -12,6 +12,7 @@ ManPagesPackage, ManualPagesPackage, NetmaskDebugsourcePackage, + NonReadableGhostPackage, Python3PowerBrokenPackage, Python3PowerPackage, PythonShebangLinkOkPackage, @@ -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