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));