From ba20e36659ee291c28591fe5d212f0d9d926025c Mon Sep 17 00:00:00 2001 From: renxichen Date: Thu, 17 Aug 2023 19:57:09 +0800 Subject: [PATCH] Check inside --root when querying for files --- ...-inside-root-when-querying-for-files.patch | 38 +++++++++++++++++++ rpm.spec | 6 ++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 backport-Check-inside-root-when-querying-for-files.patch diff --git a/backport-Check-inside-root-when-querying-for-files.patch b/backport-Check-inside-root-when-querying-for-files.patch new file mode 100644 index 0000000..3759486 --- /dev/null +++ b/backport-Check-inside-root-when-querying-for-files.patch @@ -0,0 +1,38 @@ +From 3e820eaa4c8cb94a63338366cbf014dc5264eba2 Mon Sep 17 00:00:00 2001 +From: Florian Festi +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 + diff --git a/rpm.spec b/rpm.spec index 04296ea..26fad0a 100644 --- a/rpm.spec +++ b/rpm.spec @@ -1,6 +1,6 @@ Name: rpm Version: 4.18.1 -Release: 3 +Release: 4 Summary: RPM Package Manager License: GPLv2+ URL: http://www.rpm.org/ @@ -26,6 +26,7 @@ Patch6004: backport-Remove-obscure-check-for-package-build-time-from-reb.patch Patch6005: backport-Fix-possible-null-pointer-reference-in-ndb.patch Patch6006: backport-Fix-rpmDigestBundleFinal-and-Update-return-code-on-i.patch Patch6007: backport-Actually-return-an-error-in-parseScript-if-parsing-f.patch +Patch6008: backport-Check-inside-root-when-querying-for-files.patch Patch9000: Add-digest-list-plugin.patch Patch9001: Add-IMA-digest-list-support.patch @@ -308,6 +309,9 @@ make clean %exclude %{_mandir}/man8/rpmspec.8.gz %changelog +* Tue Aug 29 2023 renhongxun - 4.18.1-4 +- Check inside --root when querying for files + * Wed Aug 02 2023 renhongxun - 4.18.1-3 - backport some patches from upstream