From 96d48126ff3fb4c52e78177dc4bf30b0e2f66971 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Oct 01 2014 07:16:37 +0000 Subject: - Dont wait for transaction lock within scriptlets (RhBug:1135596) --- diff --git a/rpm-4.12.0-tslock-nowait.patch b/rpm-4.12.0-tslock-nowait.patch new file mode 100644 index 0000000..28c7d69 --- /dev/null +++ b/rpm-4.12.0-tslock-nowait.patch @@ -0,0 +1,32 @@ +commit 6ce2d43e2533505aa252159bfa8cc799965655bb +Author: Panu Matilainen +Date: Wed Oct 1 09:59:21 2014 +0300 + + Dont wait for transaction lock within scriptlets (RhBug:1135596) + + - Packages doing stupid things like rpm -U/-i/-e from their scriptlets + can and will get hung waiting on the transaction lock, which can + prompt users to kill the entire transaction, possibly with severe + consequences. Starting with rpm >= 4.12 we also take the transaction + lock for importing public keys, which seems to have caught one of + the bigger fishes in the pond (Google Chrome packages). + - Only wait when stdin is a tty, this affects more than scriptlets but + most likely we dont want to wait for locks in those situations either. + +diff --git a/lib/rpmlock.c b/lib/rpmlock.c +index 7696cbe..9c07654 100644 +--- a/lib/rpmlock.c ++++ b/lib/rpmlock.c +@@ -124,10 +124,11 @@ rpmlock rpmlockNew(const char *lock_path, const char *descr) + int rpmlockAcquire(rpmlock lock) + { + int locked = 0; /* assume failure */ ++ int maywait = isatty(STDIN_FILENO); /* dont wait within scriptlets */ + + if (lock) { + locked = rpmlock_acquire(lock, RPMLOCK_WRITE); +- if (!locked && (lock->openmode & RPMLOCK_WRITE)) { ++ if (!locked && (lock->openmode & RPMLOCK_WRITE) && maywait) { + rpmlog(RPMLOG_WARNING, _("waiting for %s lock on %s\n"), + lock->descr, lock->path); + locked = rpmlock_acquire(lock, (RPMLOCK_WRITE|RPMLOCK_WAIT)); diff --git a/rpm.spec b/rpm.spec index 1002f7d..36a80f2 100644 --- a/rpm.spec +++ b/rpm.spec @@ -27,7 +27,7 @@ Summary: The RPM package management system Name: rpm Version: %{rpmver} -Release: %{?snapver:0.%{snapver}.}1%{?dist} +Release: %{?snapver:0.%{snapver}.}2%{?dist} Group: System Environment/Base Url: http://www.rpm.org/ Source0: http://rpm.org/releases/rpm-4.12.x/%{name}-%{srcver}.tar.bz2 @@ -50,6 +50,8 @@ Patch4: rpm-4.8.1-use-gpg2.patch Patch5: rpm-4.12.0-rpm2cpio-hack.patch # Patches already upstream: +# Dont wait for transaction lock inside scriptlets (#1135596) +Patch100: rpm-4.12.0-tslock-nowait.patch # These are not yet upstream Patch302: rpm-4.7.1-geode-i686.patch @@ -528,6 +530,9 @@ exit 0 %doc doc/librpm/html/* %changelog +* Wed Oct 01 2014 Panu Matilainen - 4.12.0.1-2 +- Dont wait for transaction lock inside scriptlets (#1135596) + * Thu Sep 18 2014 Panu Matilainen - 4.12.0.1-1 - Update to rpm-4.12.0.1 final (http://rpm.org/wiki/Releases/4.12.0.1) - Temporary workaround payload size mismatch issue in rpm2cpio (#1142949)