52 lines
2.2 KiB
Diff
52 lines
2.2 KiB
Diff
|
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
|
||
|
|