commit
1eda310518
@ -0,0 +1 @@
|
|||||||
|
SOURCES/libdnf-0.73.1.tar.gz
|
@ -0,0 +1 @@
|
|||||||
|
317b564ada6b63d238865d657ff00f59ec6672df SOURCES/libdnf-0.73.1.tar.gz
|
@ -0,0 +1,229 @@
|
|||||||
|
From 85432dfd048912083897ab687488087038a9ac96 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
||||||
|
Date: Mon, 8 Apr 2024 07:32:31 +0200
|
||||||
|
Subject: [PATCH] context: use `rpmtsAddReinstallElement()` when doing a
|
||||||
|
reinstall
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
`rpmtsAddInstallElement()` doesn't work for all reinstall cases, such as
|
||||||
|
when a package `Provides` and `Conflicts` with the same capability.
|
||||||
|
|
||||||
|
Fixes: https://github.com/rpm-software-management/microdnf/issues/137
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
libdnf/dnf-rpmts-private.hpp | 6 ++
|
||||||
|
libdnf/dnf-rpmts.cpp | 108 +++++++++++++++++++++++------------
|
||||||
|
libdnf/dnf-transaction.cpp | 8 ++-
|
||||||
|
3 files changed, 85 insertions(+), 37 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libdnf/dnf-rpmts-private.hpp b/libdnf/dnf-rpmts-private.hpp
|
||||||
|
index 94ad6b45..7a8f70fb 100644
|
||||||
|
--- a/libdnf/dnf-rpmts-private.hpp
|
||||||
|
+++ b/libdnf/dnf-rpmts-private.hpp
|
||||||
|
@@ -31,4 +31,10 @@ gboolean dnf_rpmts_add_install_filename2(rpmts ts,
|
||||||
|
DnfPackage *pkg,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
+gboolean dnf_rpmts_add_reinstall_filename(rpmts ts,
|
||||||
|
+ const gchar *filename,
|
||||||
|
+ gboolean allow_untrusted,
|
||||||
|
+ GError **error);
|
||||||
|
+
|
||||||
|
+
|
||||||
|
#endif /* __DNF_RPMTS_PRIVATE_HPP */
|
||||||
|
diff --git a/libdnf/dnf-rpmts.cpp b/libdnf/dnf-rpmts.cpp
|
||||||
|
index ec3d3706..9c0152fc 100644
|
||||||
|
--- a/libdnf/dnf-rpmts.cpp
|
||||||
|
+++ b/libdnf/dnf-rpmts.cpp
|
||||||
|
@@ -88,94 +88,132 @@ test_fail_safe(Header * hdr, DnfPackage * pkg, GError **error)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
-gboolean
|
||||||
|
-dnf_rpmts_add_install_filename2(rpmts ts,
|
||||||
|
- const gchar *filename,
|
||||||
|
- gboolean allow_untrusted,
|
||||||
|
- gboolean is_update,
|
||||||
|
- DnfPackage * pkg,
|
||||||
|
- GError **error) try
|
||||||
|
-{
|
||||||
|
- gboolean ret = TRUE;
|
||||||
|
- gint res;
|
||||||
|
- Header hdr;
|
||||||
|
- FD_t fd;
|
||||||
|
-
|
||||||
|
- /* open this */
|
||||||
|
- fd = Fopen(filename, "r.ufdio");
|
||||||
|
- res = rpmReadPackageFile(ts, fd, filename, &hdr);
|
||||||
|
-
|
||||||
|
+static gboolean
|
||||||
|
+result_is_accepted(gint result, gboolean allow_untrusted, const gchar *filename, GError **error) {
|
||||||
|
/* be less strict when we're allowing untrusted transactions */
|
||||||
|
if (allow_untrusted) {
|
||||||
|
- switch(res) {
|
||||||
|
+ switch(result) {
|
||||||
|
case RPMRC_NOKEY:
|
||||||
|
case RPMRC_NOTFOUND:
|
||||||
|
case RPMRC_NOTTRUSTED:
|
||||||
|
case RPMRC_OK:
|
||||||
|
- break;
|
||||||
|
+ return TRUE;
|
||||||
|
case RPMRC_FAIL:
|
||||||
|
- ret = FALSE;
|
||||||
|
g_set_error(error,
|
||||||
|
DNF_ERROR,
|
||||||
|
DNF_ERROR_INTERNAL_ERROR,
|
||||||
|
_("signature does not verify for %s"),
|
||||||
|
filename);
|
||||||
|
- goto out;
|
||||||
|
+ return FALSE;
|
||||||
|
default:
|
||||||
|
- ret = FALSE;
|
||||||
|
g_set_error(error,
|
||||||
|
DNF_ERROR,
|
||||||
|
DNF_ERROR_INTERNAL_ERROR,
|
||||||
|
_("failed to open(generic error): %s"),
|
||||||
|
filename);
|
||||||
|
- goto out;
|
||||||
|
+ return FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
- switch(res) {
|
||||||
|
+ switch(result) {
|
||||||
|
case RPMRC_OK:
|
||||||
|
- break;
|
||||||
|
+ return TRUE;
|
||||||
|
case RPMRC_NOTTRUSTED:
|
||||||
|
- ret = FALSE;
|
||||||
|
g_set_error(error,
|
||||||
|
DNF_ERROR,
|
||||||
|
DNF_ERROR_INTERNAL_ERROR,
|
||||||
|
_("failed to verify key for %s"),
|
||||||
|
filename);
|
||||||
|
- goto out;
|
||||||
|
+ return FALSE;
|
||||||
|
case RPMRC_NOKEY:
|
||||||
|
- ret = FALSE;
|
||||||
|
g_set_error(error,
|
||||||
|
DNF_ERROR,
|
||||||
|
DNF_ERROR_INTERNAL_ERROR,
|
||||||
|
_("public key unavailable for %s"),
|
||||||
|
filename);
|
||||||
|
- goto out;
|
||||||
|
+ return FALSE;
|
||||||
|
case RPMRC_NOTFOUND:
|
||||||
|
- ret = FALSE;
|
||||||
|
g_set_error(error,
|
||||||
|
DNF_ERROR,
|
||||||
|
DNF_ERROR_INTERNAL_ERROR,
|
||||||
|
_("signature not found for %s"),
|
||||||
|
filename);
|
||||||
|
- goto out;
|
||||||
|
+ return FALSE;
|
||||||
|
case RPMRC_FAIL:
|
||||||
|
- ret = FALSE;
|
||||||
|
g_set_error(error,
|
||||||
|
DNF_ERROR,
|
||||||
|
DNF_ERROR_INTERNAL_ERROR,
|
||||||
|
_("signature does not verify for %s"),
|
||||||
|
filename);
|
||||||
|
- goto out;
|
||||||
|
+ return FALSE;
|
||||||
|
default:
|
||||||
|
- ret = FALSE;
|
||||||
|
g_set_error(error,
|
||||||
|
DNF_ERROR,
|
||||||
|
DNF_ERROR_INTERNAL_ERROR,
|
||||||
|
_("failed to open(generic error): %s"),
|
||||||
|
filename);
|
||||||
|
- goto out;
|
||||||
|
+ return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+gboolean
|
||||||
|
+dnf_rpmts_add_reinstall_filename(rpmts ts,
|
||||||
|
+ const gchar *filename,
|
||||||
|
+ gboolean allow_untrusted,
|
||||||
|
+ GError **error) try
|
||||||
|
+{
|
||||||
|
+ gboolean ret = TRUE;
|
||||||
|
+ gint res;
|
||||||
|
+ Header hdr;
|
||||||
|
+ FD_t fd;
|
||||||
|
+
|
||||||
|
+ /* open this */
|
||||||
|
+ fd = Fopen(filename, "r.ufdio");
|
||||||
|
+ res = rpmReadPackageFile(ts, fd, filename, &hdr);
|
||||||
|
+
|
||||||
|
+ if (!result_is_accepted(res, allow_untrusted, filename, error)) {
|
||||||
|
+ ret = FALSE;
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* add to the transaction */
|
||||||
|
+ res = rpmtsAddReinstallElement(ts, hdr, (fnpyKey) filename);
|
||||||
|
+ if (res != 0) {
|
||||||
|
+ ret = FALSE;
|
||||||
|
+ g_set_error(error,
|
||||||
|
+ DNF_ERROR,
|
||||||
|
+ DNF_ERROR_INTERNAL_ERROR,
|
||||||
|
+ _("failed to add reinstall element: %1$s [%2$i]"),
|
||||||
|
+ filename, res);
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
+out:
|
||||||
|
+ Fclose(fd);
|
||||||
|
+ headerFree(hdr);
|
||||||
|
+ return ret;
|
||||||
|
+} CATCH_TO_GERROR(FALSE)
|
||||||
|
+
|
||||||
|
+gboolean
|
||||||
|
+dnf_rpmts_add_install_filename2(rpmts ts,
|
||||||
|
+ const gchar *filename,
|
||||||
|
+ gboolean allow_untrusted,
|
||||||
|
+ gboolean is_update,
|
||||||
|
+ DnfPackage * pkg,
|
||||||
|
+ GError **error) try
|
||||||
|
+{
|
||||||
|
+ gboolean ret = TRUE;
|
||||||
|
+ gint res;
|
||||||
|
+ Header hdr;
|
||||||
|
+ FD_t fd;
|
||||||
|
+
|
||||||
|
+ /* open this */
|
||||||
|
+ fd = Fopen(filename, "r.ufdio");
|
||||||
|
+ res = rpmReadPackageFile(ts, fd, filename, &hdr);
|
||||||
|
+
|
||||||
|
+ if (!result_is_accepted(res, allow_untrusted, filename, error)) {
|
||||||
|
+ ret = FALSE;
|
||||||
|
+ goto out;
|
||||||
|
+ }
|
||||||
|
if (pkg) {
|
||||||
|
if (!test_fail_safe(&hdr, pkg, error)) {
|
||||||
|
ret = FALSE;
|
||||||
|
diff --git a/libdnf/dnf-transaction.cpp b/libdnf/dnf-transaction.cpp
|
||||||
|
index c4c5e02b..35b2ff95 100644
|
||||||
|
--- a/libdnf/dnf-transaction.cpp
|
||||||
|
+++ b/libdnf/dnf-transaction.cpp
|
||||||
|
@@ -1222,8 +1222,12 @@ dnf_transaction_commit(DnfTransaction *transaction, HyGoal goal, DnfState *state
|
||||||
|
filename = dnf_package_get_filename(pkg);
|
||||||
|
allow_untrusted = (priv->flags & DNF_TRANSACTION_FLAG_ONLY_TRUSTED) == 0;
|
||||||
|
is_update = action == DNF_STATE_ACTION_UPDATE || action == DNF_STATE_ACTION_DOWNGRADE;
|
||||||
|
- ret = dnf_rpmts_add_install_filename2(
|
||||||
|
- priv->ts, filename, allow_untrusted, is_update, pkg, error);
|
||||||
|
+ if (action == DNF_STATE_ACTION_REINSTALL) {
|
||||||
|
+ ret = dnf_rpmts_add_reinstall_filename(priv->ts, filename, allow_untrusted, error);
|
||||||
|
+ } else {
|
||||||
|
+ ret = dnf_rpmts_add_install_filename2(
|
||||||
|
+ priv->ts, filename, allow_untrusted, is_update, pkg, error);
|
||||||
|
+ }
|
||||||
|
if (!ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
@ -0,0 +1,78 @@
|
|||||||
|
From bc371683ab69d51127952b037bde209a56e44105 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
||||||
|
Date: Fri, 3 May 2024 08:55:47 +0200
|
||||||
|
Subject: [PATCH] Since we use rpmtsAddReinstallElement rpm also uninstalls the
|
||||||
|
package
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
It calls callbacks for `RPMCALLBACK_INST_START` and
|
||||||
|
`RPMCALLBACK_INST_PROGRESS` just like before when the reinstall was done
|
||||||
|
through regural install (rpmtsAddInstallElement) but in addition it also
|
||||||
|
calls `RPMCALLBACK_UNINST_START` and `RPMCALLBACK_UNINST_PROGRESS`. To
|
||||||
|
ensure they find the `DnfPackage` add it to `remove_helper` array.
|
||||||
|
|
||||||
|
Unfortunaly this means that the reinstall action is reported twice to
|
||||||
|
the clients (one install and one uninstall). We could try to hide one of
|
||||||
|
the them but I think a better solution is to report what is actually
|
||||||
|
happening and report one install and one uninstall.
|
||||||
|
|
||||||
|
This is for the context part of libdnf (microdnf, packagekit, ...)
|
||||||
|
|
||||||
|
Fixes: https://github.com/rpm-software-management/libdnf/issues/1653
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
libdnf/dnf-transaction.cpp | 15 ++++++++++++---
|
||||||
|
1 file changed, 12 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libdnf/dnf-transaction.cpp b/libdnf/dnf-transaction.cpp
|
||||||
|
index 35b2ff95..fcb1152f 100644
|
||||||
|
--- a/libdnf/dnf-transaction.cpp
|
||||||
|
+++ b/libdnf/dnf-transaction.cpp
|
||||||
|
@@ -602,7 +602,7 @@ dnf_transaction_ts_progress_cb(const void *arg,
|
||||||
|
|
||||||
|
/* map to correct action code */
|
||||||
|
action = dnf_package_get_action(pkg);
|
||||||
|
- if (action == DNF_STATE_ACTION_UNKNOWN)
|
||||||
|
+ if (action == DNF_STATE_ACTION_UNKNOWN || action == DNF_STATE_ACTION_REINSTALL)
|
||||||
|
action = DNF_STATE_ACTION_INSTALL;
|
||||||
|
|
||||||
|
/* set the pkgid if not already set */
|
||||||
|
@@ -641,7 +641,7 @@ dnf_transaction_ts_progress_cb(const void *arg,
|
||||||
|
|
||||||
|
/* map to correct action code */
|
||||||
|
action = dnf_package_get_action(pkg);
|
||||||
|
- if (action == DNF_STATE_ACTION_UNKNOWN)
|
||||||
|
+ if (action == DNF_STATE_ACTION_UNKNOWN || action == DNF_STATE_ACTION_REINSTALL)
|
||||||
|
action = DNF_STATE_ACTION_REMOVE;
|
||||||
|
|
||||||
|
/* remove start */
|
||||||
|
@@ -716,7 +716,7 @@ dnf_transaction_ts_progress_cb(const void *arg,
|
||||||
|
|
||||||
|
/* map to correct action code */
|
||||||
|
action = dnf_package_get_action(pkg);
|
||||||
|
- if (action == DNF_STATE_ACTION_UNKNOWN)
|
||||||
|
+ if (action == DNF_STATE_ACTION_UNKNOWN || action == DNF_STATE_ACTION_REINSTALL)
|
||||||
|
action = DNF_STATE_ACTION_REMOVE;
|
||||||
|
|
||||||
|
dnf_state_set_package_progress(
|
||||||
|
@@ -1354,6 +1354,15 @@ dnf_transaction_commit(DnfTransaction *transaction, HyGoal goal, DnfState *state
|
||||||
|
g_ptr_array_unref(pkglist);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* add reinstalled packages to a helper array which is used to
|
||||||
|
+ * map removed packages auto-added by rpm to actual DnfPackage's */
|
||||||
|
+ pkglist = dnf_goal_get_packages(goal, DNF_PACKAGE_INFO_REINSTALL, -1);
|
||||||
|
+ for (i = 0; i < pkglist->len; i++) {
|
||||||
|
+ pkg_tmp = static_cast< DnfPackage * >(g_ptr_array_index(pkglist, i));
|
||||||
|
+ g_ptr_array_add(priv->remove_helper, g_object_ref(pkg_tmp));
|
||||||
|
+ }
|
||||||
|
+ g_ptr_array_unref(pkglist);
|
||||||
|
+
|
||||||
|
/* this section done */
|
||||||
|
ret = dnf_state_done(state, error);
|
||||||
|
if (!ret)
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
@ -0,0 +1,91 @@
|
|||||||
|
From 90d2ffad964a91a7a798b81e15c16eb1e840f257 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jan Kolarik <jkolarik@redhat.com>
|
||||||
|
Date: Tue, 23 Apr 2024 14:11:19 +0000
|
||||||
|
Subject: [PATCH] MergedTransaction: Fix invalid memory access when dropping
|
||||||
|
items
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
When an item is dropped from the merged transaction, the `ItemPair` reference becomes invalid and should no longer be used.
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
libdnf/transaction/MergedTransaction.cpp | 18 +++++++++++-------
|
||||||
|
libdnf/transaction/MergedTransaction.hpp | 2 +-
|
||||||
|
2 files changed, 12 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libdnf/transaction/MergedTransaction.cpp b/libdnf/transaction/MergedTransaction.cpp
|
||||||
|
index 8f26882f..75d2c1e7 100644
|
||||||
|
--- a/libdnf/transaction/MergedTransaction.cpp
|
||||||
|
+++ b/libdnf/transaction/MergedTransaction.cpp
|
||||||
|
@@ -264,14 +264,15 @@ getItemIdentifier(ItemPtr item)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve the difference between RPMs in the first and second transaction item
|
||||||
|
- * and create a ItemPair of Upgrade, Downgrade or drop the item from the merged
|
||||||
|
- * transaction set in case of both packages are of the same version.
|
||||||
|
- * Method is called when original package is being removed and than installed again.
|
||||||
|
+ * and create a ItemPair of Upgrade, Downgrade or remove the item from the merged
|
||||||
|
+ * transaction set in case of both packages are the same.
|
||||||
|
+ * Method is called when original package is being removed and then installed again.
|
||||||
|
* \param itemPairMap merged transaction set
|
||||||
|
* \param previousItemPair original item pair
|
||||||
|
* \param mTransItem new transaction item
|
||||||
|
+ * \return true if the original and new transaction item differ
|
||||||
|
*/
|
||||||
|
-void
|
||||||
|
+bool
|
||||||
|
MergedTransaction::resolveRPMDifference(ItemPairMap &itemPairMap,
|
||||||
|
ItemPair &previousItemPair,
|
||||||
|
TransactionItemBasePtr mTransItem)
|
||||||
|
@@ -287,7 +288,7 @@ MergedTransaction::resolveRPMDifference(ItemPairMap &itemPairMap,
|
||||||
|
firstRPM->getRelease() == secondRPM->getRelease()) {
|
||||||
|
// Drop the item from merged transaction
|
||||||
|
itemPairMap.erase(getItemIdentifier(firstItem));
|
||||||
|
- return;
|
||||||
|
+ return false;
|
||||||
|
} else if ((*firstRPM) < (*secondRPM)) {
|
||||||
|
// Upgrade to secondRPM
|
||||||
|
previousItemPair.first->setAction(TransactionItemAction::UPGRADED);
|
||||||
|
@@ -298,6 +299,7 @@ MergedTransaction::resolveRPMDifference(ItemPairMap &itemPairMap,
|
||||||
|
mTransItem->setAction(TransactionItemAction::DOWNGRADE);
|
||||||
|
}
|
||||||
|
previousItemPair.second = mTransItem;
|
||||||
|
+ return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -308,12 +310,14 @@ MergedTransaction::resolveErase(ItemPairMap &itemPairMap,
|
||||||
|
/*
|
||||||
|
* The original item has been removed - it has to be installed now unless the rpmdb
|
||||||
|
* has changed. Resolve the difference between packages and mark it as Upgrade,
|
||||||
|
- * Reinstall or Downgrade
|
||||||
|
+ * Downgrade or remove it from the transaction
|
||||||
|
*/
|
||||||
|
if (mTransItem->getAction() == TransactionItemAction::INSTALL) {
|
||||||
|
if (mTransItem->getItem()->getItemType() == ItemType::RPM) {
|
||||||
|
// resolve the difference between RPM packages
|
||||||
|
- resolveRPMDifference(itemPairMap, previousItemPair, mTransItem);
|
||||||
|
+ if (!resolveRPMDifference(itemPairMap, previousItemPair, mTransItem)) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
} else {
|
||||||
|
// difference between comps can't be resolved
|
||||||
|
mTransItem->setAction(TransactionItemAction::REINSTALL);
|
||||||
|
diff --git a/libdnf/transaction/MergedTransaction.hpp b/libdnf/transaction/MergedTransaction.hpp
|
||||||
|
index f85b133a..50212159 100644
|
||||||
|
--- a/libdnf/transaction/MergedTransaction.hpp
|
||||||
|
+++ b/libdnf/transaction/MergedTransaction.hpp
|
||||||
|
@@ -76,7 +76,7 @@ protected:
|
||||||
|
typedef std::map< std::string, ItemPair > ItemPairMap;
|
||||||
|
|
||||||
|
void mergeItem(ItemPairMap &itemPairMap, TransactionItemBasePtr transItem);
|
||||||
|
- void resolveRPMDifference(ItemPairMap &itemPairMap, ItemPair &previousItemPair, TransactionItemBasePtr mTransItem);
|
||||||
|
+ bool resolveRPMDifference(ItemPairMap &itemPairMap, ItemPair &previousItemPair, TransactionItemBasePtr mTransItem);
|
||||||
|
void resolveErase(ItemPairMap &itemPairMap, ItemPair &previousItemPair, TransactionItemBasePtr mTransItem);
|
||||||
|
void resolveAltered(ItemPairMap &itemPairMap, ItemPair &previousItemPair, TransactionItemBasePtr mTransItem);
|
||||||
|
};
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
@ -0,0 +1,40 @@
|
|||||||
|
From a6d89d66698f75c01539cd03c04a87ab52b6db7c Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
||||||
|
Date: Tue, 25 Jun 2024 13:38:14 +0200
|
||||||
|
Subject: [PATCH] Set pool flag to fix pool_addfileprovides_queue() without
|
||||||
|
filelists.xml
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Since dnf4 now also conditionally load filelists it ran into the same
|
||||||
|
problem as dnf5 here: https://github.com/rpm-software-management/dnf5/issues/520
|
||||||
|
|
||||||
|
Additional details in: https://github.com/openSUSE/libsolv/pull/531
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
libdnf/dnf-sack.cpp | 7 +++++++
|
||||||
|
1 file changed, 7 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/libdnf/dnf-sack.cpp b/libdnf/dnf-sack.cpp
|
||||||
|
index 3c3a7657..e95009fb 100644
|
||||||
|
--- a/libdnf/dnf-sack.cpp
|
||||||
|
+++ b/libdnf/dnf-sack.cpp
|
||||||
|
@@ -185,6 +185,13 @@ dnf_sack_init(DnfSack *sack)
|
||||||
|
DnfSackPrivate *priv = GET_PRIVATE(sack);
|
||||||
|
priv->pool = pool_create();
|
||||||
|
pool_set_flag(priv->pool, POOL_FLAG_WHATPROVIDESWITHDISABLED, 1);
|
||||||
|
+
|
||||||
|
+ // Configures the pool_addfileprovides_queue() method to only add files from primary.xml.
|
||||||
|
+ // This ensures the method works correctly even if filelist.xml metadata are not loaded.
|
||||||
|
+ // At the same time when filelist.xml are loaded libsolv is able to search them for required
|
||||||
|
+ // files if needed.
|
||||||
|
+ pool_set_flag(priv->pool, POOL_FLAG_ADDFILEPROVIDESFILTERED, 1);
|
||||||
|
+
|
||||||
|
priv->running_kernel_id = -1;
|
||||||
|
priv->running_kernel_fn = running_kernel;
|
||||||
|
priv->considered_uptodate = TRUE;
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
@ -0,0 +1,128 @@
|
|||||||
|
From 1f6c2479260e2d26a861b871c443a5b960523a71 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Evan Goode <mail@evangoo.de>
|
||||||
|
Date: Tue, 7 May 2024 16:33:03 +0000
|
||||||
|
Subject: [PATCH] ConfigParser: fix use-out-of-scope leaks
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
libdnf/conf/ConfigParser.cpp | 48 ++++++++++++++++++++++++------------
|
||||||
|
1 file changed, 32 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libdnf/conf/ConfigParser.cpp b/libdnf/conf/ConfigParser.cpp
|
||||||
|
index 76e7f9cc..977da757 100644
|
||||||
|
--- a/libdnf/conf/ConfigParser.cpp
|
||||||
|
+++ b/libdnf/conf/ConfigParser.cpp
|
||||||
|
@@ -95,7 +95,9 @@ std::pair<std::string, size_t> ConfigParser::substitute_expression(const std::st
|
||||||
|
const auto & variable_key = res.substr(pos_variable, pos_after_variable - pos_variable);
|
||||||
|
const auto variable_mapping = substitutions.find(variable_key);
|
||||||
|
|
||||||
|
- const std::string * variable_value = nullptr;
|
||||||
|
+ // No std::optional here.
|
||||||
|
+ bool variable_value_has_value{false};
|
||||||
|
+ std::string variable_value{""};
|
||||||
|
|
||||||
|
if (variable_mapping == substitutions.end()) {
|
||||||
|
if (variable_key == "releasever_major" || variable_key == "releasever_minor") {
|
||||||
|
@@ -103,17 +105,22 @@ std::pair<std::string, size_t> ConfigParser::substitute_expression(const std::st
|
||||||
|
if (releasever_mapping != substitutions.end()) {
|
||||||
|
const auto & releasever_split = ConfigParser::split_releasever(releasever_mapping->second);
|
||||||
|
if (variable_key == "releasever_major") {
|
||||||
|
- variable_value = &std::get<0>(releasever_split);
|
||||||
|
+ variable_value = std::get<0>(releasever_split);
|
||||||
|
+ variable_value_has_value = true;
|
||||||
|
} else {
|
||||||
|
- variable_value = &std::get<1>(releasever_split);
|
||||||
|
+ variable_value = std::get<1>(releasever_split);
|
||||||
|
+ variable_value_has_value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
- variable_value = &variable_mapping->second;
|
||||||
|
+ variable_value = variable_mapping->second;
|
||||||
|
+ variable_value_has_value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
- const std::string * subst_str = nullptr;
|
||||||
|
+ // No std::optional here
|
||||||
|
+ std::string subst_str{""};
|
||||||
|
+ bool subst_str_has_value{false};
|
||||||
|
|
||||||
|
size_t pos_after_variable_expression;
|
||||||
|
|
||||||
|
@@ -153,20 +160,23 @@ std::pair<std::string, size_t> ConfigParser::substitute_expression(const std::st
|
||||||
|
// If variable is unset or empty, the expansion of word is
|
||||||
|
// substituted. Otherwise, the value of variable is
|
||||||
|
// substituted.
|
||||||
|
- if (variable_value == nullptr || variable_value->empty()) {
|
||||||
|
- subst_str = &expanded_word;
|
||||||
|
+ if (!variable_value_has_value || variable_value.empty()) {
|
||||||
|
+ subst_str = expanded_word;
|
||||||
|
+ subst_str_has_value = true;
|
||||||
|
} else {
|
||||||
|
subst_str = variable_value;
|
||||||
|
+ subst_str_has_value = true;
|
||||||
|
}
|
||||||
|
} else if (expansion_mode == '+') {
|
||||||
|
// ${variable:+word} (alternate value)
|
||||||
|
// If variable is unset or empty nothing is substituted.
|
||||||
|
// Otherwise, the expansion of word is substituted.
|
||||||
|
- if (variable_value == nullptr || variable_value->empty()) {
|
||||||
|
- const std::string empty{};
|
||||||
|
- subst_str = ∅
|
||||||
|
+ if (!variable_value_has_value || variable_value.empty()) {
|
||||||
|
+ subst_str = "";
|
||||||
|
+ subst_str_has_value = true;
|
||||||
|
} else {
|
||||||
|
- subst_str = &expanded_word;
|
||||||
|
+ subst_str = expanded_word;
|
||||||
|
+ subst_str_has_value = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Unknown expansion mode, continue after the ':'
|
||||||
|
@@ -176,7 +186,10 @@ std::pair<std::string, size_t> ConfigParser::substitute_expression(const std::st
|
||||||
|
pos_after_variable_expression = pos_after_word + 1;
|
||||||
|
} else if (res[pos_after_variable] == '}') {
|
||||||
|
// ${variable}
|
||||||
|
- subst_str = variable_value;
|
||||||
|
+ if (variable_value_has_value) {
|
||||||
|
+ subst_str = variable_value;
|
||||||
|
+ subst_str_has_value = true;
|
||||||
|
+ }
|
||||||
|
// Move past the closing '}'
|
||||||
|
pos_after_variable_expression = pos_after_variable + 1;
|
||||||
|
} else {
|
||||||
|
@@ -186,20 +199,23 @@ std::pair<std::string, size_t> ConfigParser::substitute_expression(const std::st
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// No braces, we have a $variable
|
||||||
|
- subst_str = variable_value;
|
||||||
|
+ if (variable_value_has_value) {
|
||||||
|
+ subst_str = variable_value;
|
||||||
|
+ subst_str_has_value = true;
|
||||||
|
+ }
|
||||||
|
pos_after_variable_expression = pos_after_variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is no substitution to make, move past the variable expression and continue.
|
||||||
|
- if (subst_str == nullptr) {
|
||||||
|
+ if (!subst_str_has_value) {
|
||||||
|
total_scanned += pos_after_variable_expression - pos;
|
||||||
|
pos = pos_after_variable_expression;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
- res.replace(pos, pos_after_variable_expression - pos, *subst_str);
|
||||||
|
+ res.replace(pos, pos_after_variable_expression - pos, subst_str);
|
||||||
|
total_scanned += pos_after_variable_expression - pos;
|
||||||
|
- pos += subst_str->length();
|
||||||
|
+ pos += subst_str.length();
|
||||||
|
} else {
|
||||||
|
total_scanned += 1;
|
||||||
|
pos += 1;
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
@ -0,0 +1,42 @@
|
|||||||
|
From 18f49a49be14f80233613710e84dda47c5958252 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Evan Goode <mail@evangoo.de>
|
||||||
|
Date: Tue, 7 May 2024 16:28:59 +0000
|
||||||
|
Subject: [PATCH] Add tests for shell-style variable expansion
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||||
|
---
|
||||||
|
tests/libdnf/conf/ConfigParserTest.cpp | 17 +++++++++++++++++
|
||||||
|
1 file changed, 17 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/tests/libdnf/conf/ConfigParserTest.cpp b/tests/libdnf/conf/ConfigParserTest.cpp
|
||||||
|
index 70278196..1448d8d3 100644
|
||||||
|
--- a/tests/libdnf/conf/ConfigParserTest.cpp
|
||||||
|
+++ b/tests/libdnf/conf/ConfigParserTest.cpp
|
||||||
|
@@ -30,4 +30,21 @@ void ConfigParserTest::testConfigParserReleasever()
|
||||||
|
libdnf::ConfigParser::substitute(text, substitutions);
|
||||||
|
CPPUNIT_ASSERT(text == "major: , minor: ");
|
||||||
|
}
|
||||||
|
+ {
|
||||||
|
+ std::map<std::string, std::string> substitutions = {
|
||||||
|
+ {"var1", "value123"},
|
||||||
|
+ {"var2", "456"},
|
||||||
|
+ };
|
||||||
|
+ std::string text = "foo$var1-bar";
|
||||||
|
+ libdnf::ConfigParser::substitute(text, substitutions);
|
||||||
|
+ CPPUNIT_ASSERT(text == "foovalue123-bar");
|
||||||
|
+
|
||||||
|
+ text = "${var1:+alternate}-${unset:-default}-${nn:+n${nn:-${nnn:}";
|
||||||
|
+ libdnf::ConfigParser::substitute(text, substitutions);
|
||||||
|
+ CPPUNIT_ASSERT(text == "alternate-default-${nn:+n${nn:-${nnn:}");
|
||||||
|
+
|
||||||
|
+ text = "${unset:-${var1:+${var2:+$var2}}}";
|
||||||
|
+ libdnf::ConfigParser::substitute(text, substitutions);
|
||||||
|
+ CPPUNIT_ASSERT(text == "456");
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue