Check inside --root when querying for files

(cherry picked from commit bdc2950d58650041cd5e8ef479455303792a43dd)
This commit is contained in:
renxichen 2023-08-29 15:25:32 +08:00 committed by openeuler-sync-bot
parent 05cd7f2b9a
commit ea70233c51
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,38 @@
From 3e820eaa4c8cb94a63338366cbf014dc5264eba2 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Tue, 25 Jul 2023 12:08:42 +0200
Subject: [PATCH] Check inside --root when querying for files
rpm -qf checks if the argument actually exists if it can't be found in
the rpmdb and gives different messages based on that.
This was done without taking the root dir into account leading to wrong
messages if the file only exists in the root dir but not outside.
Resolves: #2576
---
lib/query.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/query.c b/lib/query.c
index e816241b7..dc2dc910b 100644
--- a/lib/query.c
+++ b/lib/query.c
@@ -470,11 +470,13 @@ static rpmdbMatchIterator initQueryIterator(QVA_t qva, rpmts ts, const char * ar
if (mi == NULL) {
struct stat sb;
- if (lstat(fn, &sb) != 0)
+ char * full_fn = rpmGetPath(rpmtsRootDir(ts), fn, NULL);
+ if (lstat(full_fn, &sb) != 0)
rpmlog(RPMLOG_ERR, _("file %s: %s\n"), fn, strerror(errno));
else
rpmlog(RPMLOG_NOTICE,
_("file %s is not owned by any package\n"), fn);
+ free(full_fn);
}
free(fn);
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: rpm
Version: 4.17.0
Release: 27
Release: 28
Summary: RPM Package Manager
License: GPLv2+
URL: http://www.rpm.org/
@ -112,6 +112,7 @@ Patch6073: backport-Remove-obscure-check-for-package-build-time-from-reb.patch
Patch6074: backport-Fix-possible-null-pointer-reference-in-ndb.patch
Patch6075: backport-Fix-rpmDigestBundleFinal-and-Update-return-code-on-i.patch
Patch6076: backport-Actually-return-an-error-in-parseScript-if-parsing-f.patch
Patch6077: backport-Check-inside-root-when-querying-for-files.patch
BuildRequires: gcc autoconf automake libtool make gawk popt-devel openssl-devel readline-devel
BuildRequires: zlib-devel zstd-devel >= 1.3.8 xz-devel bzip2-devel libarchive-devel ima-evm-utils-devel
@ -386,6 +387,9 @@ make check || (cat tests/rpmtests.log; exit 0)
%{_mandir}/man1/gendiff.1*
%changelog
* Tue Aug 29 2023 renhongxun<renhongxun@h-partners.com> - 4.17.0-28
- Check inside --root when querying for files
* Wed Aug 02 2023 renhongxun<renhongxun@h-partners.com> - 4.17.0-27
- backport some patches from upstream