ref: refs/heads/SuSE-Code-11-Branch
commit fabff5f1b4977b2b9db89ea042a32f762fb087ac
Author: Michael Andres
Date: Thu Feb 26 01:15:31 2009 +0100
Prevent ResStatus from overriding user locks. (bnc #475230)
---
zypp/ResStatus.h | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/zypp/ResStatus.h b/zypp/ResStatus.h
index c0ff1ba..9b7465d 100644
--- a/zypp/ResStatus.h
+++ b/zypp/ResStatus.h
@@ -300,7 +300,7 @@ namespace zypp
return false;
}
}
-
+
bool isToBeUninstalledDueToObsolete () const
{ return isToBeUninstalled() && fieldValueIs<TransactDetailField>( DUE_TO_OBSOLETE ); }
@@ -370,9 +370,9 @@ namespace zypp
}
/** Apply a lock (prevent transaction).
- * Currently by USER only, but who knows... Set LOCKED
- * from KEEP_STATE to be shure all transaction details
- * were reset properly.
+ * Currently by USER or APPL_HIGH only, but who knows...
+ * Set LOCKED from KEEP_STATE to be shure all transaction
+ * details were reset properly.
*/
bool setLock( bool toLock_r, TransactByValue causer_r )
{
@@ -385,19 +385,23 @@ namespace zypp
return true;
}
// Here: Lock status is to be changed:
- if ( causer_r != USER && causer_r != APPL_HIGH)
- return false;
- // Setting no transact removes an existing lock,
- // or brings this into KEEP_STATE, and we apply the lock.
- if ( ! setTransact( false, causer_r ) )
+ if ( causer_r != USER && causer_r != APPL_HIGH )
return false;
if ( toLock_r ) {
- fieldValueAssign<TransactField>( LOCKED );
- fieldValueAssign<TransactByField>( causer_r );
+ // We're in unlocked state, which includes TRANSACT.
+ // Causer must be allowed to reset this. But from
+ // KEEP_STATE every causer is allowed to set the lock.
+ if ( ! setTransact( false, causer_r ) )
+ return false;
+ fieldValueAssign<TransactField>( LOCKED );
+ fieldValueAssign<TransactByField>( causer_r );
} else {
- fieldValueAssign<TransactField>( KEEP_STATE );
- fieldValueAssign<TransactByField>( SOLVER ); // reset to lowest causer
- // in order to distinguish from keep_state_by_user
+ // To leave Locked state it needs a superior causer.
+ if ( isGreaterThan<TransactByField>( causer_r ) )
+ return false;
+ fieldValueAssign<TransactField>( KEEP_STATE );
+ fieldValueAssign<TransactByField>( SOLVER ); // reset to lowest causer
+ // in order to distinguish from keep_state_by_user
}
return true;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org