From 42ddc3a9dab78a647c5b742485a9484637952dfd Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Fri, 10 Aug 2018 10:37:57 -0700 Subject: [PATCH] Backport fix that prevented anaconda running dnf in a subprocess --- ...crash-after-using-dnf.comps.CompsQue.patch | 51 +++++++++++++++++++ libdnf.spec | 10 +++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 0001-transaction-Fix-crash-after-using-dnf.comps.CompsQue.patch diff --git a/0001-transaction-Fix-crash-after-using-dnf.comps.CompsQue.patch b/0001-transaction-Fix-crash-after-using-dnf.comps.CompsQue.patch new file mode 100644 index 0000000..a2da244 --- /dev/null +++ b/0001-transaction-Fix-crash-after-using-dnf.comps.CompsQue.patch @@ -0,0 +1,51 @@ +From bc3b61f81a691eee19aa4da04bf8279f35a7c031 Mon Sep 17 00:00:00 2001 +From: Daniel Mach +Date: Fri, 10 Aug 2018 17:55:33 +0200 +Subject: [PATCH] [transaction] Fix crash after using dnf.comps.CompsQuery and + forking the process in Anaconda. + +dnf.base.Base.install_specs() uses CompsQuery. +CompsQuery opens a connection to the history database. +Anaconda runs do_transaction() as a background (forked) process. +The fork leads to undefined behavior and crash after an attempt +to work with the history database. +--- + libdnf/transaction/CompsEnvironmentItem.cpp | 5 ++++- + libdnf/transaction/CompsGroupItem.cpp | 5 ++++- + 2 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/libdnf/transaction/CompsEnvironmentItem.cpp b/libdnf/transaction/CompsEnvironmentItem.cpp +index d1c0fb40..9b399161 100644 +--- a/libdnf/transaction/CompsEnvironmentItem.cpp ++++ b/libdnf/transaction/CompsEnvironmentItem.cpp +@@ -185,7 +185,10 @@ CompsEnvironmentItem::getTransactionItemsByPattern(SQLite3Ptr conn, const std::s + + std::vector< TransactionItemPtr > result; + +- SQLite3::Query query(*conn, sql); ++ // HACK: create a private connection to avoid undefined behavior ++ // after forking process in Anaconda ++ SQLite3 privateConn(conn->getPath()); ++ SQLite3::Query query(privateConn, sql); + std::string pattern_sql = pattern; + std::replace(pattern_sql.begin(), pattern_sql.end(), '*', '%'); + query.bindv(pattern, pattern, pattern); +diff --git a/libdnf/transaction/CompsGroupItem.cpp b/libdnf/transaction/CompsGroupItem.cpp +index ce7b9146..1eb162e1 100644 +--- a/libdnf/transaction/CompsGroupItem.cpp ++++ b/libdnf/transaction/CompsGroupItem.cpp +@@ -181,7 +181,10 @@ CompsGroupItem::getTransactionItemsByPattern(SQLite3Ptr conn, const std::string + + std::vector< TransactionItemPtr > result; + +- SQLite3::Query query(*conn, sql); ++ // HACK: create a private connection to avoid undefined behavior ++ // after forking process in Anaconda ++ SQLite3 privateConn(conn->getPath()); ++ SQLite3::Query query(privateConn, sql); + std::string pattern_sql = pattern; + std::replace(pattern_sql.begin(), pattern_sql.end(), '*', '%'); + query.bindv(pattern, pattern, pattern); +-- +2.18.0 + diff --git a/libdnf.spec b/libdnf.spec index ee8219f..aa92aec 100644 --- a/libdnf.spec +++ b/libdnf.spec @@ -24,11 +24,16 @@ Name: libdnf Version: 0.17.0 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Library providing simplified C and Python API to libsolv License: LGPLv2+ URL: https://github.com/rpm-software-management/libdnf Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz +# Backported from upstream: fixes an issue that prevented anaconda +# running dnf as a subprocess, which caused anaconda crash +# https://bugzilla.redhat.com/show_bug.cgi?id=1614511 +# https://github.com/rpm-software-management/libdnf/pull/546 +Patch0: 0001-transaction-Fix-crash-after-using-dnf.comps.CompsQue.patch BuildRequires: cmake BuildRequires: gcc @@ -214,6 +219,9 @@ popd %endif %changelog +* Fri Aug 10 2018 Adam Williamson - 0.17.0-2 +- Backport fix that prevented anaconda running dnf in a subprocess (#546) + * Tue Aug 07 2018 Daniel Mach - 0.17.0-1 - [conf] Add module_platform_id option. - [module] Add ModulePackageContainer class.