- Dont wait for transaction lock within scriptlets (RhBug:1135596)

This commit is contained in:
Panu Matilainen 2014-10-01 10:16:37 +03:00
parent 2176e2752d
commit 96d48126ff
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,32 @@
commit 6ce2d43e2533505aa252159bfa8cc799965655bb
Author: Panu Matilainen <pmatilai@redhat.com>
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));

View File

@ -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 <pmatilai@redhat.com> - 4.12.0.1-2
- Dont wait for transaction lock inside scriptlets (#1135596)
* Thu Sep 18 2014 Panu Matilainen <pmatilai@redhat.com> - 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)