Backport fix that prevented anaconda running dnf in a subprocess

This commit is contained in:
Adam Williamson 2018-08-10 10:37:57 -07:00
parent b1be46c5c3
commit 42ddc3a9da
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,51 @@
From bc3b61f81a691eee19aa4da04bf8279f35a7c031 Mon Sep 17 00:00:00 2001
From: Daniel Mach <dmach@redhat.com>
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

View File

@ -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 <awilliam@redhat.com> - 0.17.0-2
- Backport fix that prevented anaconda running dnf in a subprocess (#546)
* Tue Aug 07 2018 Daniel Mach <dmach@redhat.com> - 0.17.0-1
- [conf] Add module_platform_id option.
- [module] Add ModulePackageContainer class.